Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(*): ktabledata adoption [KHCP-13280] #1660

Merged
merged 31 commits into from
Oct 16, 2024

Conversation

portikM
Copy link
Member

@portikM portikM commented Sep 25, 2024

Summary

Jira: https://konghq.atlassian.net/browse/KHCP-13280

Changes:

  • adopting KTableData in EntityBaseTable component (replacing KTable)
    • related type changes in EntityBaseTable types
  • adding InitialLoad and NoRecords fetcher states in useFetcher composable
  • utilizing new fetcher states for hiding toolbar in entities tables components in certain states

Resources

@portikM portikM self-assigned this Sep 25, 2024
@@ -390,6 +392,7 @@ const modalContent = computed(() => {
const toggleEnableStatus = (row: EntityRow) => {
enablementModalVisible.value = true
switchEnablementTarget.value = row
delete switchEnablementTarget.value.selected
Copy link
Contributor

@Justineo Justineo Sep 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to discuss the API design for this. There may be similar cases throughout the codebase that we've overlooked. Ideally, IMO, there should be a selectedRowKeys: string[] prop for <KTableView> so that we don't have to write into userland row data and then fix potential issues in an ad-hoc manner. And before that we should have a proper row key first as we have discussed.

/cc @adamdehaven @portikM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little context: I added this line because there was an issue when toggling the enabled status of a gateway service:

Kapture 2024-09-29 at 16 21 29

selected is included in the request payload, resulting in a 400 error. This is caused by how the bulk actions functionality is implemented in KTableView: it adds selected to the original data.

We feel instead of deleting the selected field every time we see an issue, it may be better to re-think the implementation of bulk actions as @Justineo suggested.

Copy link
Member

@adamdehaven adamdehaven Sep 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this aligns with some of the concerns I brought up on the original KTableView PR on reserved keys

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change the selected key to something more specific like bulkActionsSelected so it doesn't collide with plugins enabled status. Would that be sufficient?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change the selected key to something more specific like bulkActionsSelected so it doesn't collide with plugins enabled status. Would that be sufficient?

To be honest I think this is the issue with “reserved keys” - the component shouldn’t have a requirement limiting the keys utilized in the data object in the first place. Yes, something named this specifically will likely prevent a collision; however, I’m still not convinced this is the desired pattern.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we implement the mini refactor we discussed above as a fix-forward patch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. There's an existing issue in KTableView with using indexes as keys that presents an issue when a row is deleted
  2. The bulk actions key and selected keys need to be refactored into separate props based on this PR discussion

There's no reason to release a new Kongponents component that utilizes KTableView under the hood with these substantial issues/changes in flight

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't I attempt to fix the issue like I suggested? Once we confirm the fix is sufficient, the changes in flight will be the minor under-the-hood implementation change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: we decided to implement the refactor in KTableView and proceed with merging KTableData and deprecating KTable afterwards to avoid having to test it twice. I will add a sction in the original KTableView component brief discussion the need for new rowKey prop. After the refactor is implemented we shouldn't need the fix deleting an unexpected property from the row object.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refactor has been implemented, this is ready a final review.

:disable-sorting="disableSorting"
:empty-state-options="emptyStateOptions"
enable-entity-actions
:error-message="errorMessage"
:fetcher="fetcher"
:fetcher-cache-key="fetcherCacheKey"
:hide-toolbar="hideTableToolbar"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what criteria should be used to determine when the toolbar should be hidden?

Copy link
Member Author

@portikM portikM Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The toolbar is hidden when fetcher returns no records and there is no search query or filters. Something like a "true" empty state. In that case none of the toolbar items (search, column visibility menu) are actionable.

@portikM portikM marked this pull request as ready for review October 16, 2024 15:10
@portikM portikM requested review from kongponents-bot and a team as code owners October 16, 2024 15:10
@portikM portikM enabled auto-merge (squash) October 16, 2024 15:18
Copy link
Contributor

@kaiarrowood kaiarrowood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@adamdehaven adamdehaven merged commit 31ca10e into main Oct 16, 2024
36 checks passed
@adamdehaven adamdehaven deleted the fix/khcp-13280-ktabledata-adoption-1 branch October 16, 2024 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants