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

feat(entities): add resizable + show hide columns for all GM entity tables [KHCP-11568] #1382

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/core/core/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { UserTablePreferences } from './useTablePreferences/types'
import type { TablePreferences } from '@kong/kongponents'

/** The localStorage key to store user table preferences */
export const USER_TABLE_PREFERENCES_LOCAL_STORAGE_KEY = 'khcp-user-table-preferences'

export const DEFAULT_USER_TABLE_PREFERENCES: UserTablePreferences = {
export const DEFAULT_USER_TABLE_PREFERENCES: TablePreferences = {
pageSize: 30,
sortColumnKey: undefined,
sortColumnOrder: undefined,
columnWidths: {},
columnVisibility: {},
}
1 change: 0 additions & 1 deletion packages/core/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export { default as useWindow } from './useWindow'

// Export explicit type interfaces as needed
export * from './usePackage/types'
export * from './useTablePreferences/types'
export * from './useWindow/types'

// Constants
Expand Down
10 changes: 5 additions & 5 deletions packages/core/core/src/useTablePreferences/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { USER_TABLE_PREFERENCES_LOCAL_STORAGE_KEY, DEFAULT_USER_TABLE_PREFERENCES } from '../constants'
import type { UserTablePreferences } from './types'
import type { TablePreferences } from '@kong/kongponents'

export default function useTablePreferences() {
/**
Expand Down Expand Up @@ -41,9 +41,9 @@ export default function useTablePreferences() {
/**
* Store the preferences for a table, by unique id string, to localStorage for persistence
* @param {string} tableKey The table identifier
* @param {UserTablePreferences} newPreferences The table preferences object to store
* @param {TablePreferences} newPreferences The table preferences object to store
*/
const setTablePreferences = (tableKey: string, newPreferences: UserTablePreferences): void => {
const setTablePreferences = (tableKey: string, newPreferences: TablePreferences): void => {
// Wrap in a try/catch in case localStorage is full
try {
const existingPreferencesMap = getAllTablePreferences()
Expand All @@ -60,9 +60,9 @@ export default function useTablePreferences() {
/**
* Retrieve the stored table preferences for a table, by unique id string. Fallback to the default table preferences
* @param {string} tableKey The table identifier
* @returns {UserTablePreferences} The stored preferences for the given tableKey
* @returns {TablePreferences} The stored preferences for the given tableKey
*/
const getTablePreferences = (tableKey: string): UserTablePreferences => {
const getTablePreferences = (tableKey: string): TablePreferences => {
const existingPreferences = getAllTablePreferences()

const tablePreferences = existingPreferences?.get(tableKey) || undefined
Expand Down
8 changes: 0 additions & 8 deletions packages/core/core/src/useTablePreferences/types/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('<CACertificateList />', () => {
},
})

cy.getTestId('dropdown-trigger').eq(0).click()
cy.getTestId('overflow-actions-button').eq(0).click()
cy.getTestId('action-entity-copy-id').should('be.visible')
})

Expand Down Expand Up @@ -354,13 +354,15 @@ describe('<CACertificateList />', () => {
})

it('should allow picking different page sizes and persist the preference', () => {
const cacheIdentifier = `ca-certificate-list-${uuidv4()}`

interceptKMMultiPage({
mockData: caCertificate100,
})

cy.mount(CACertificateList, {
props: {
cacheIdentifier: `ca-certificate-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKM,
canCreate: () => {},
canEdit: () => {},
Expand Down Expand Up @@ -400,7 +402,7 @@ describe('<CACertificateList />', () => {
cy.get('@vueWrapper').then((wrapper: any) => wrapper.unmount())
cy.mount(CACertificateList, {
props: {
cacheIdentifier: `ca-certificate-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKM,
canCreate: () => {},
canEdit: () => {},
Expand Down Expand Up @@ -652,13 +654,15 @@ describe('<CACertificateList />', () => {
})

it('should allow picking different page sizes and persist the preference', () => {
const cacheIdentifier = `ca-certificate-list-${uuidv4()}`

interceptKonnectMultiPage({
mockData: caCertificate100,
})

cy.mount(CACertificateList, {
props: {
cacheIdentifier: `ca-certificate-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKonnect,
canCreate: () => {},
canEdit: () => {},
Expand Down Expand Up @@ -698,7 +702,7 @@ describe('<CACertificateList />', () => {
cy.get('@vueWrapper').then((wrapper: any) => wrapper.unmount())
cy.mount(CACertificateList, {
props: {
cacheIdentifier: `ca-certificate-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKonnect,
canCreate: () => {},
canEdit: () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('<CertificateList />', () => {
},
})

cy.getTestId('dropdown-trigger').eq(0).click()
cy.getTestId('overflow-actions-button').eq(0).click()
cy.getTestId('action-entity-copy-id').should('be.visible')
})

Expand Down Expand Up @@ -394,13 +394,15 @@ describe('<CertificateList />', () => {
})

it('should allow picking different page sizes and persist the preference', () => {
const cacheIdentifier = `certificate-list-${uuidv4()}`

interceptKMMultiPage({
mockData: certificate100,
})

cy.mount(CertificateList, {
props: {
cacheIdentifier: `certificate-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKM,
canCreate: () => {},
canEdit: () => {},
Expand Down Expand Up @@ -440,7 +442,7 @@ describe('<CertificateList />', () => {
cy.get('@vueWrapper').then((wrapper: any) => wrapper.unmount())
cy.mount(CertificateList, {
props: {
cacheIdentifier: `certificate-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKM,
canCreate: () => {},
canEdit: () => {},
Expand Down Expand Up @@ -699,13 +701,15 @@ describe('<CertificateList />', () => {
})

it('should allow picking different page sizes and persist the preference', () => {
const cacheIdentifier = `certificate-list-${uuidv4()}`

interceptKonnectMultiPage({
mockData: certificate100,
})

cy.mount(CertificateList, {
props: {
cacheIdentifier: `certificate-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKonnect,
canCreate: () => {},
canEdit: () => {},
Expand Down Expand Up @@ -745,7 +749,7 @@ describe('<CertificateList />', () => {
cy.get('@vueWrapper').then((wrapper: any) => wrapper.unmount())
cy.mount(CertificateList, {
props: {
cacheIdentifier: `certificate-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKonnect,
canCreate: () => {},
canEdit: () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('<ConsumerCredentialList />', () => {
},
})

cy.getTestId('dropdown-trigger').eq(0).click()
cy.getTestId('overflow-actions-button').eq(0).click()
cy.getTestId('action-entity-copy-id').should('be.visible')
})

Expand All @@ -91,7 +91,7 @@ describe('<ConsumerCredentialList />', () => {
},
})

cy.getTestId('dropdown-trigger').eq(0).click()
cy.getTestId('overflow-actions-button').eq(0).click()
cy.getTestId('action-entity-copy-credential').should('be.visible')
})

Expand All @@ -111,7 +111,7 @@ describe('<ConsumerCredentialList />', () => {
},
})

cy.getTestId('dropdown-trigger').eq(0).click()
cy.getTestId('overflow-actions-button').eq(0).click()
cy.getTestId('action-entity-copy-key').should('be.visible')
})

Expand All @@ -131,7 +131,7 @@ describe('<ConsumerCredentialList />', () => {
},
})

cy.getTestId('dropdown-trigger').eq(0).click()
cy.getTestId('overflow-actions-button').eq(0).click()
cy.getTestId('action-entity-copy-key').should('be.visible')
})

Expand All @@ -151,7 +151,7 @@ describe('<ConsumerCredentialList />', () => {
},
})

cy.getTestId('dropdown-trigger').eq(0).click()
cy.getTestId('overflow-actions-button').eq(0).click()
cy.getTestId('action-entity-copy-key').should('be.visible')
})

Expand All @@ -171,7 +171,7 @@ describe('<ConsumerCredentialList />', () => {
},
})

cy.getTestId('dropdown-trigger').eq(0).click()
cy.getTestId('overflow-actions-button').eq(0).click()
cy.getTestId('action-entity-copy-secret').should('be.visible')
})

Expand All @@ -191,7 +191,7 @@ describe('<ConsumerCredentialList />', () => {
},
})

cy.getTestId('dropdown-trigger').eq(0).click()
cy.getTestId('overflow-actions-button').eq(0).click()
cy.getTestId('action-entity-copy-secret').should('be.visible')
})

Expand All @@ -210,7 +210,7 @@ describe('<ConsumerCredentialList />', () => {
},
})

cy.getTestId('dropdown-trigger').eq(0).click()
cy.getTestId('overflow-actions-button').eq(0).click()
cy.getTestId('action-entity-edit').should(`${expected ? '' : 'not.'}exist`)
})

Expand All @@ -227,7 +227,7 @@ describe('<ConsumerCredentialList />', () => {
},
})

cy.getTestId('dropdown-trigger').eq(0).click()
cy.getTestId('overflow-actions-button').eq(0).click()
cy.getTestId('action-entity-delete').should(`${expected ? '' : 'not.'}exist`)
})
})
Expand Down Expand Up @@ -450,13 +450,15 @@ describe('<ConsumerCredentialList />', () => {
})

it('should allow picking different page sizes and persist the preference', () => {
const cacheIdentifier = `consumer-credential-list-${uuidv4()}`

interceptKMMultiPage({
mockData: basicAuthCredentials100,
})

cy.mount(ConsumerCredentialList, {
props: {
cacheIdentifier: `consumer-credential-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKM,
canCreate: () => {},
canEdit: () => {},
Expand Down Expand Up @@ -496,7 +498,7 @@ describe('<ConsumerCredentialList />', () => {
cy.get('@vueWrapper').then((wrapper: any) => wrapper.unmount())
cy.mount(ConsumerCredentialList, {
props: {
cacheIdentifier: `consumer-credential-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKM,
canCreate: () => {},
canEdit: () => {},
Expand Down Expand Up @@ -743,13 +745,15 @@ describe('<ConsumerCredentialList />', () => {
})

it('should allow picking different page sizes and persist the preference', () => {
const cacheIdentifier = `consumer-credential-list-${uuidv4()}`

interceptKonnectMultiPage({
mockData: basicAuthCredentials100,
})

cy.mount(ConsumerCredentialList, {
props: {
cacheIdentifier: `consumer-credential-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKonnect,
canCreate: () => {},
canEdit: () => {},
Expand Down Expand Up @@ -788,7 +792,7 @@ describe('<ConsumerCredentialList />', () => {
cy.get('@vueWrapper').then((wrapper: any) => wrapper.unmount())
cy.mount(ConsumerCredentialList, {
props: {
cacheIdentifier: `consumer-credential-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKonnect,
canCreate: () => {},
canEdit: () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,15 @@ describe('<ConsumerGroupList />', () => {
})

it('should allow picking different page sizes and persist the preference', () => {
const cacheIdentifier = `consumer-group-list-${uuidv4()}`

interceptKMMultiPage({
mockData: consumerGroups100,
})

cy.mount(ConsumerGroupList, {
props: {
cacheIdentifier: `consumer-group-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKM,
canCreate: () => {},
canEdit: () => {},
Expand Down Expand Up @@ -346,7 +348,7 @@ describe('<ConsumerGroupList />', () => {
cy.get('@vueWrapper').then((wrapper: any) => wrapper.unmount())
cy.mount(ConsumerGroupList, {
props: {
cacheIdentifier: `consumer-group-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKM,
canCreate: () => {},
canEdit: () => {},
Expand Down Expand Up @@ -916,13 +918,15 @@ describe('<ConsumerGroupList />', () => {
})

it('should allow picking different page sizes and persist the preference', () => {
const cacheIdentifier = `consumer-group-list-${uuidv4()}`

interceptKonnectMultiPage({
mockData: consumerGroups100,
})

cy.mount(ConsumerGroupList, {
props: {
cacheIdentifier: `consumer-group-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKonnect,
canCreate: () => {},
canEdit: () => {},
Expand Down Expand Up @@ -962,7 +966,7 @@ describe('<ConsumerGroupList />', () => {
cy.get('@vueWrapper').then((wrapper: any) => wrapper.unmount())
cy.mount(ConsumerGroupList, {
props: {
cacheIdentifier: `consumer-group-list-${uuidv4()}`,
cacheIdentifier,
config: baseConfigKonnect,
canCreate: () => {},
canEdit: () => {},
Expand Down
Loading
Loading