Skip to content

Commit 125860f

Browse files
committed
CONSOLE-4615: Update DefaultList to use ResourceDataView
1 parent 55db5c8 commit 125860f

File tree

5 files changed

+201
-154
lines changed

5 files changed

+201
-154
lines changed

frontend/packages/console-shared/src/hooks/useCRDAdditionalPrinterColumns.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,24 @@ import {
66
K8sModel,
77
} from '@console/internal/module/k8s';
88

9-
export const useCRDAdditionalPrinterColumns = (model: K8sModel): CRDAdditionalPrinterColumn[] => {
9+
export const useCRDAdditionalPrinterColumns = (
10+
model: K8sModel,
11+
): [CRDAdditionalPrinterColumn[], boolean] => {
1012
const [CRDAPC, setCRDAPC] = useState<CRDAdditionalPrinterColumns>({});
11-
const [loading, setLoading] = useState(true);
13+
const [loaded, setLoaded] = useState(false);
1214

1315
useEffect(() => {
1416
coFetchJSON(`/api/console/crd-columns/${model.plural}.${model.apiGroup}`)
1517
.then((response) => {
1618
setCRDAPC(response);
17-
setLoading(false);
19+
setLoaded(true);
1820
})
1921
.catch((e) => {
20-
setLoading(false);
22+
setLoaded(false);
2123
// eslint-disable-next-line no-console
2224
console.log(e.message);
2325
});
2426
}, [model.plural, model.apiGroup]);
2527

26-
return !loading ? CRDAPC?.[model.apiVersion] ?? [] : [];
28+
return [CRDAPC?.[model.apiVersion] ?? [], loaded];
2729
};

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as _ from 'lodash';
33
import { checkErrors, testName } from '../../support';
44
import { detailsPage } from '../../views/details-page';
55
import { listPage } from '../../views/list-page';
6-
import { modal } from '../../views/modal';
76
import * as yamlEditor from '../../views/yaml-editor';
87

98
const crd = 'ConsoleCLIDownload';
@@ -60,12 +59,6 @@ describe(`${crd} CRD`, () => {
6059
cy.visit(`/command-line-tools`);
6160
cy.get(`[data-test-id=${name}]`).should('contain', name);
6261

63-
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
64-
listPage.rows.shouldBeLoaded();
65-
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
66-
modal.shouldBeOpened();
67-
modal.modalTitleShouldContain(`Delete ${crd}`);
68-
modal.submit();
69-
modal.shouldBeClosed();
62+
cy.exec(`oc delete ${crd} ${name}`);
7063
});
7164
});

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as _ from 'lodash';
33
import { checkErrors, testName } from '../../support';
44
import { detailsPage } from '../../views/details-page';
55
import { listPage } from '../../views/list-page';
6-
import { modal } from '../../views/modal';
76
import * as yamlEditor from '../../views/yaml-editor';
87

98
const crd = 'ConsoleNotification';
@@ -50,9 +49,8 @@ describe(`${crd} CRD`, () => {
5049
});
5150

5251
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
53-
listPage.rows.shouldBeLoaded();
52+
listPage.dvRows.shouldBeLoaded();
5453
cy.log('Additional printer columns should exist.');
55-
cy.byTestID('has-additional-printer-columns').should('exist');
5654
cy.byTestID('additional-printer-column-header-Text').should('have.text', 'Text');
5755
cy.byTestID('additional-printer-column-data-Text').should('have.text', text);
5856
cy.byTestID('additional-printer-column-header-Location').should('have.text', 'Location');
@@ -99,12 +97,6 @@ describe(`${crd} CRD`, () => {
9997

10098
cy.get(altNotification).contains(altText).should('exist').and('be.visible');
10199

102-
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
103-
listPage.rows.shouldBeLoaded();
104-
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
105-
modal.shouldBeOpened();
106-
modal.modalTitleShouldContain(`Delete ${crd}`);
107-
modal.submit();
108-
modal.shouldBeClosed();
100+
cy.exec(`oc delete ${crd} ${name}`);
109101
});
110102
});

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as _ from 'lodash';
33
import { checkErrors, testName } from '../../support';
44
import { detailsPage } from '../../views/details-page';
55
import { listPage } from '../../views/list-page';
6-
import { modal } from '../../views/modal';
76
import * as resourceSidebar from '../../views/resource-sidebar';
87
import * as yamlEditor from '../../views/yaml-editor';
98

@@ -76,9 +75,9 @@ metadata:
7675
});
7776

7877
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
79-
listPage.rows.shouldBeLoaded();
78+
listPage.dvRows.shouldBeLoaded();
8079
cy.log('Additional printer columns should not exist.');
81-
cy.byTestID('has-additional-printer-columns').should('not.exist');
80+
cy.get('[data-test^="additional-printer-column-header-"]').should('not.exist');
8281
cy.log('Created date should exist since Age does not.');
8382
cy.byTestID('column-header-Created').should('exist');
8483
cy.byTestID('column-data-Created').should('exist');
@@ -105,12 +104,6 @@ metadata:
105104
detailsPage.titleShouldContain(testJobName);
106105

107106
// Delete CRD
108-
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
109-
listPage.rows.shouldBeLoaded();
110-
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
111-
modal.shouldBeOpened();
112-
modal.modalTitleShouldContain(`Delete ${crd}`);
113-
modal.submit();
114-
modal.shouldBeClosed();
107+
cy.exec(`oc delete ${crd} ${name}`);
115108
});
116109
});

0 commit comments

Comments
 (0)