Skip to content

Commit 08f29af

Browse files
migrate Secrets list page from VirtualizedTable to ResourceDataView
1 parent fd95953 commit 08f29af

File tree

10 files changed

+327
-239
lines changed

10 files changed

+327
-239
lines changed

frontend/packages/console-app/src/components/data-view/ResourceDataView.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ import { ResourceFilters, GetDataViewRows } from './types';
2929
import { useResourceDataViewData } from './useResourceDataViewData';
3030
import { useResourceDataViewFilters } from './useResourceDataViewFilters';
3131

32+
// Utility functions for cell properties
33+
export const getNameCellProps = (name: string) => ({
34+
'data-test': `data-view-cell-${name}-name`,
35+
});
36+
37+
export const actionsCellProps = {
38+
'data-test': 'actions',
39+
};
40+
41+
export const cellIsStickyProps = {
42+
isStickyColumn: true,
43+
stickyMinWidth: 200,
44+
};
45+
46+
export const initialFiltersDefault = {
47+
name: '',
48+
label: '',
49+
};
50+
3251
export type ResourceDataViewProps<TData, TCustomRowData, TFilters> = {
3352
label?: string;
3453
data: TData[];

frontend/packages/integration-tests-cypress/tests/crd-extensions/console-cli-download.cy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ describe(`${crd} CRD`, () => {
4141
it(`creates, displays, and deletes a new ${crd} instance`, () => {
4242
cy.visit(`/k8s/cluster/customresourcedefinitions?custom-resource-definition-name=${crd}`);
4343
listPage.isCreateButtonVisible();
44-
listPage.rows.shouldBeLoaded();
45-
listPage.rows.clickKebabAction(crd, 'View instances');
44+
listPage.dvRows.shouldBeLoaded();
45+
listPage.dvRows.clickKebabAction(crd, 'View instances');
4646
listPage.titleShouldHaveText(crd);
4747
listPage.clickCreateYAMLbutton();
4848
yamlEditor.isLoaded();
@@ -61,8 +61,8 @@ describe(`${crd} CRD`, () => {
6161
cy.get(`[data-test-id=${name}]`).should('contain', name);
6262

6363
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
64-
listPage.rows.shouldBeLoaded();
65-
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
64+
listPage.dvRows.shouldBeLoaded();
65+
listPage.dvRows.clickKebabAction(name, `Delete ${crd}`);
6666
modal.shouldBeOpened();
6767
modal.modalTitleShouldContain(`Delete ${crd}`);
6868
modal.submit();

frontend/packages/integration-tests-cypress/tests/crd-extensions/console-external-log-link.cy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe(`${crd} CRD`, () => {
3232

3333
it(`creates, displays, modifies, and deletes a new ${crd} instance`, () => {
3434
cy.visit(`/k8s/cluster/customresourcedefinitions?custom-resource-definition-name=${crd}`);
35-
listPage.rows.shouldBeLoaded();
35+
listPage.dvRows.shouldBeLoaded();
3636
listPage.rows.clickRowByName(crd);
3737
detailsPage.titleShouldContain('consoleexternalloglinks.console.openshift.io');
3838
detailsPage.selectTab('Instances');
@@ -94,8 +94,8 @@ describe(`${crd} CRD`, () => {
9494
modal.shouldBeClosed();
9595

9696
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
97-
listPage.rows.shouldBeLoaded();
98-
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
97+
listPage.dvRows.shouldBeLoaded();
98+
listPage.dvRows.clickKebabAction(name, `Delete ${crd}`);
9999
modal.shouldBeOpened();
100100
modal.modalTitleShouldContain(`Delete ${crd}`);
101101
modal.submit();

frontend/packages/integration-tests-cypress/tests/crd-extensions/console-link.cy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ describe(`${crd} CRD`, () => {
5757
it(`creates, displays, and deletes a new ${crd} ${dropdownMenuName} instance`, () => {
5858
cy.visit(`/k8s/cluster/customresourcedefinitions?custom-resource-definition-name=${crd}`);
5959
listPage.isCreateButtonVisible();
60-
listPage.rows.shouldBeLoaded();
61-
listPage.rows.clickKebabAction(crd, 'View instances');
60+
listPage.dvRows.shouldBeLoaded();
61+
listPage.dvRows.clickKebabAction(crd, 'View instances');
6262
listPage.titleShouldHaveText(crd);
6363
listPage.clickCreateYAMLbutton();
6464
yamlEditor.isLoaded();
@@ -88,8 +88,8 @@ describe(`${crd} CRD`, () => {
8888
.should('exist');
8989

9090
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
91-
listPage.rows.shouldBeLoaded();
92-
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
91+
listPage.dvRows.shouldBeLoaded();
92+
listPage.dvRows.clickKebabAction(name, `Delete ${crd}`);
9393
modal.shouldBeOpened();
9494
modal.modalTitleShouldContain(`Delete ${crd}`);
9595
modal.submit();

frontend/packages/integration-tests-cypress/tests/crd-extensions/console-notification.cy.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ describe(`${crd} CRD`, () => {
3232
it(`creates, displays, modifies, and deletes a new ${crd} instance`, () => {
3333
cy.visit(`/k8s/cluster/customresourcedefinitions?custom-resource-definition-name=${crd}`);
3434
listPage.isCreateButtonVisible();
35-
listPage.rows.shouldBeLoaded();
36-
listPage.rows.clickKebabAction(crd, 'View instances');
35+
listPage.dvRows.shouldBeLoaded();
36+
listPage.dvRows.clickKebabAction(crd, 'View instances');
3737
listPage.titleShouldHaveText(crd);
3838
listPage.clickCreateYAMLbutton();
3939
yamlEditor.isLoaded();
@@ -50,7 +50,7 @@ describe(`${crd} CRD`, () => {
5050
});
5151

5252
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
53-
listPage.rows.shouldBeLoaded();
53+
listPage.dvRows.shouldBeLoaded();
5454
cy.log('Additional printer columns should exist.');
5555
cy.byTestID('has-additional-printer-columns').should('exist');
5656
cy.byTestID('additional-printer-column-header-Text').should('have.text', 'Text');
@@ -100,8 +100,8 @@ describe(`${crd} CRD`, () => {
100100
cy.get(altNotification).contains(altText).should('exist').and('be.visible');
101101

102102
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
103-
listPage.rows.shouldBeLoaded();
104-
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
103+
listPage.dvRows.shouldBeLoaded();
104+
listPage.dvRows.clickKebabAction(name, `Delete ${crd}`);
105105
modal.shouldBeOpened();
106106
modal.modalTitleShouldContain(`Delete ${crd}`);
107107
modal.submit();

frontend/packages/integration-tests-cypress/tests/crd-extensions/console-yaml-sample.cy.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ metadata:
6262
it(`creates, displays, tests and deletes a new ${crd} instance`, () => {
6363
cy.visit(`/k8s/cluster/customresourcedefinitions?custom-resource-definition-name=${crd}`);
6464
listPage.isCreateButtonVisible();
65-
listPage.rows.shouldBeLoaded();
66-
listPage.rows.clickKebabAction(crd, 'View instances');
65+
listPage.dvRows.shouldBeLoaded();
66+
listPage.dvRows.clickKebabAction(crd, 'View instances');
6767
listPage.titleShouldHaveText(crd);
6868
listPage.clickCreateYAMLbutton();
6969
yamlEditor.isLoaded();
@@ -76,7 +76,7 @@ metadata:
7676
});
7777

7878
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
79-
listPage.rows.shouldBeLoaded();
79+
listPage.dvRows.shouldBeLoaded();
8080
cy.log('Additional printer columns should not exist.');
8181
cy.byTestID('has-additional-printer-columns').should('not.exist');
8282
cy.log('Created date should exist since Age does not.');
@@ -106,8 +106,8 @@ metadata:
106106

107107
// Delete CRD
108108
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
109-
listPage.rows.shouldBeLoaded();
110-
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
109+
listPage.dvRows.shouldBeLoaded();
110+
listPage.dvRows.clickKebabAction(name, `Delete ${crd}`);
111111
modal.shouldBeOpened();
112112
modal.modalTitleShouldContain(`Delete ${crd}`);
113113
modal.submit();

frontend/packages/integration-tests-cypress/views/list-page.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,20 @@ export const listPage = {
100100
shouldNotExist: (resourceName: string) =>
101101
cy.get(`[data-test-id="${resourceName}"]`, { timeout: 90000 }).should('not.exist'),
102102
},
103+
dvRows: {
104+
shouldBeLoaded: () => {
105+
cy.get(`[data-test="data-view-table"]`).should('be.visible');
106+
},
107+
clickKebabAction: (resourceName: string, actionName: string) => {
108+
cy.get(`[data-test="data-view-cell-${resourceName}-name"]`)
109+
.contains(resourceName)
110+
.parents('tr')
111+
.within(() => {
112+
cy.get('[data-test-id="kebab-button"]').click();
113+
});
114+
cy.byTestActionID(actionName).click();
115+
},
116+
},
103117
};
104118

105119
export namespace ListPageSelector {

frontend/public/components/factory/list-page.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ type ListPageWrapperProps<L = any, C = any> = {
105105
customData?: C;
106106
hideColumnManagement?: boolean;
107107
nameFilter?: string;
108+
hideLegacyFilterToolbar?: boolean;
108109
};
109110

110111
export const ListPageWrapper: React.FC<ListPageWrapperProps> = (props) => {
@@ -122,6 +123,7 @@ export const ListPageWrapper: React.FC<ListPageWrapperProps> = (props) => {
122123
name,
123124
resources,
124125
nameFilter,
126+
hideLegacyFilterToolbar,
125127
} = props;
126128
const dispatch = useDispatch();
127129
const memoizedIds = useDeepCompareMemoize(reduxIDs);
@@ -145,6 +147,7 @@ export const ListPageWrapper: React.FC<ListPageWrapperProps> = (props) => {
145147
hideLabelFilter={hideLabelFilter}
146148
columnLayout={columnLayout}
147149
uniqueFilterName={name}
150+
hideLegacyFilterToolbar={hideLegacyFilterToolbar}
148151
{...props}
149152
/>
150153
);
@@ -348,6 +351,7 @@ export type ListPageProps<L = any, C = any> = PageCommonProps<L, C> & {
348351
limit?: number;
349352
nameFilter?: string;
350353
skipAccessReview?: boolean;
354+
hideLegacyFilterToolbar?: boolean;
351355
};
352356

353357
export const ListPage = withFallback<ListPageProps>((props) => {
@@ -380,6 +384,7 @@ export const ListPage = withFallback<ListPageProps>((props) => {
380384
hideNameLabelFilters,
381385
hideColumnManagement,
382386
columnLayout,
387+
hideLegacyFilterToolbar,
383388
flatten = (_resources) => _.get(_resources, name || kind, {} as FirehoseResult).data,
384389
} = props;
385390
const { t } = useTranslation();
@@ -457,6 +462,7 @@ export const ListPage = withFallback<ListPageProps>((props) => {
457462
hideColumnManagement={hideColumnManagement}
458463
columnLayout={columnLayout}
459464
nameFilter={nameFilter}
465+
hideLegacyFilterToolbar={hideLegacyFilterToolbar}
460466
/>
461467
);
462468
}, ErrorBoundaryFallbackPage);
@@ -485,6 +491,7 @@ type PageCommonProps<L = any, C = any> = {
485491
nameFilterPlaceholder?: string;
486492
autoFocus?: boolean;
487493
mock?: boolean;
494+
hideLegacyFilterToolbar?: boolean;
488495
};
489496

490497
export type MultiListPageProps<L = any, C = any> = PageCommonProps<L, C> & {
@@ -499,6 +506,7 @@ export type MultiListPageProps<L = any, C = any> = PageCommonProps<L, C> & {
499506
resources: (Omit<FirehoseResource, 'prop'> & { prop?: FirehoseResource['prop'] })[];
500507
staticFilters?: { key: string; value: string }[];
501508
nameFilter?: string;
509+
hideLegacyFilterToolbar?: boolean;
502510
};
503511

504512
export const MultiListPage: React.FC<MultiListPageProps> = (props) => {
@@ -530,6 +538,7 @@ export const MultiListPage: React.FC<MultiListPageProps> = (props) => {
530538
hideColumnManagement,
531539
columnLayout,
532540
nameFilter,
541+
hideLegacyFilterToolbar,
533542
} = props;
534543

535544
const { t } = useTranslation();
@@ -573,6 +582,7 @@ export const MultiListPage: React.FC<MultiListPageProps> = (props) => {
573582
labelFilterPlaceholder={labelFilterPlaceholder}
574583
nameFilter={nameFilter}
575584
namespace={namespace}
585+
hideLegacyFilterToolbar={hideLegacyFilterToolbar}
576586
/>
577587
</Firehose>
578588
</FireMan>

0 commit comments

Comments
 (0)