Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,17 @@ export const ResourceDataView = <
const basicFilters: React.ReactNode[] = [];

if (!hideNameLabelFilters) {
basicFilters.push(<DataViewTextFilter key="name" filterId="name" title={t('public~Name')} />);
basicFilters.push(
<DataViewTextFilter
key="name"
filterId="name"
title={t('public~Name')}
placeholder={t('public~Filter by name')}
/>,
);
}

if (!hideNameLabelFilters && !hideLabelFilter) {
if (!hideNameLabelFilters && !hideLabelFilter && loaded) {
basicFilters.push(
<DataViewLabelFilter key="label" filterId="label" title={t('public~Label')} data={data} />,
);
Expand All @@ -149,7 +156,7 @@ export const ResourceDataView = <

// Can't use data in the deps array as it will recompute the filters and will cause the selected category to reset
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [additionalFilterNodes, t]);
}, [additionalFilterNodes, t, loaded]);

return mock ? (
<EmptyBox label={label} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,42 +76,35 @@ export const useResourceDataViewData = <

const dataViewColumns = React.useMemo<ResourceDataViewColumn<TData>[]>(
() =>
activeColumns.map(
(
{ id, title, sort, props: { classes, isStickyColumn, stickyMinWidth, modifier } },
index,
) => {
const headerProps: ThProps = {
className: classes,
isStickyColumn,
stickyMinWidth,
modifier,
activeColumns.map(({ id, title, sort, props }, index) => {
const headerProps: ThProps = {
...props,
dataLabel: title,
};

if (sort) {
headerProps.sort = {
columnIndex: index,
sortBy: {
index: 0,
direction: SortByDirection.asc,
defaultDirection: SortByDirection.asc,
},
};

if (sort) {
headerProps.sort = {
columnIndex: index,
sortBy: {
index: 0,
direction: SortByDirection.asc,
defaultDirection: SortByDirection.asc,
},
};
}

return {
id,
title,
sortFunction: sort,
props: headerProps,
cell: title ? (
<span>{title}</span>
) : (
<span className="pf-v6-u-screen-reader">{t('public~Actions')}</span>
),
};
},
),
}

return {
id,
title,
sortFunction: sort,
props: headerProps,
cell: title ? (
<span>{title}</span>
) : (
<span className="pf-v6-u-screen-reader">{t('public~Actions')}</span>
),
};
}),
[activeColumns, t],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ import {
K8sModel,
} from '@console/internal/module/k8s';

export const useCRDAdditionalPrinterColumns = (model: K8sModel): CRDAdditionalPrinterColumn[] => {
export const useCRDAdditionalPrinterColumns = (
model: K8sModel,
): [CRDAdditionalPrinterColumn[], boolean] => {
const [CRDAPC, setCRDAPC] = useState<CRDAdditionalPrinterColumns>({});
const [loading, setLoading] = useState(true);
const [loaded, setLoaded] = useState(false);

useEffect(() => {
coFetchJSON(`/api/console/crd-columns/${model.plural}.${model.apiGroup}`)
.then((response) => {
setCRDAPC(response);
setLoading(false);
setLoaded(true);
})
.catch((e) => {
setLoading(false);
setLoaded(false);
// eslint-disable-next-line no-console
console.log(e.message);
});
}, [model.plural, model.apiGroup]);

return !loading ? CRDAPC?.[model.apiVersion] ?? [] : [];
return [CRDAPC?.[model.apiVersion] ?? [], loaded];
};
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('Debug pod', () => {

it('Opens debug terminal page from Logs subsection', () => {
cy.visit(`/k8s/ns/${testName}/pods`);
listPage.rows.shouldExist(POD_NAME);
listPage.dvRows.shouldExist(POD_NAME);
cy.visit(`/k8s/ns/${testName}/pods/${POD_NAME}`);
detailsPage.isLoaded();
detailsPage.selectTab('Logs');
Expand All @@ -63,7 +63,7 @@ describe('Debug pod', () => {
listPage.titleShouldHaveText(`Debug ${CONTAINER_NAME}`);
cy.get(XTERM_CLASS).should('exist');
cy.get('[data-test-id="breadcrumb-link-0"]').click();
listPage.rows.shouldExist(POD_NAME);
listPage.dvRows.shouldExist(POD_NAME);
});

it('Opens debug terminal page from Pod Details - Status tool tip', () => {
Expand All @@ -74,13 +74,13 @@ describe('Debug pod', () => {
listPage.titleShouldHaveText(`Debug ${CONTAINER_NAME}`);
cy.get(XTERM_CLASS).should('exist');
cy.get('[data-test-id="breadcrumb-link-0"]').click();
listPage.rows.shouldExist(POD_NAME);
listPage.dvRows.shouldExist(POD_NAME);
});

it('Opens debug terminal page from Pods Page - Status tool tip', () => {
cy.visit(`/k8s/ns/${testName}/pods`);
listPage.rows.shouldExist(POD_NAME);
listPage.rows.clickStatusButton(POD_NAME);
listPage.dvRows.shouldExist(POD_NAME);
listPage.dvRows.clickStatusButton(POD_NAME);
// Click on first debug link
cy.byTestID(`popup-debug-container-link-${CONTAINER_NAME}`).click();
listPage.titleShouldHaveText(`Debug ${CONTAINER_NAME}`);
Expand All @@ -94,18 +94,18 @@ describe('Debug pod', () => {
expect(`${ipAddressOne}`).to.not.equal(`${ipAddressTwo}`);
});
cy.get('[data-test-id="breadcrumb-link-0"]').click();
listPage.rows.shouldExist(POD_NAME);
listPage.dvRows.shouldExist(POD_NAME);
});

it('Debug pod should be terminated after leaving debug container page', () => {
cy.visit(`/k8s/ns/${testName}/pods`);
listPage.rows.shouldExist(POD_NAME);
listPage.filter.by('Running');
listPage.dvRows.shouldExist(POD_NAME);
listPage.dvFilter.by('Running');
cy.exec(
`oc get pods -n ${testName} -o jsonpath='{.items[0].metadata.name}{"#"}{.items[1].metadata.name}'`,
).then((result) => {
const debugPodName = result.stdout.split('#')[1];
listPage.rows.shouldNotExist(debugPodName);
listPage.dvRows.shouldNotExist(debugPodName);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ describe('Filtering and Searching', () => {
cy.deleteProjectWithCLI(testName);
});

it('filters Pod from object detail', () => {
// disabled as listPage.rows.shouldExist isn't a valid test
xit('filters Pod from object detail', () => {
cy.visit(`/k8s/ns/${testName}/deployments`);
listPage.rows.shouldExist(WORKLOAD_NAME);
cy.visit(`/k8s/ns/${testName}/deployments/${WORKLOAD_NAME}/pods`);
Expand All @@ -63,12 +64,15 @@ describe('Filtering and Searching', () => {

it('filters invalid Pod from object detail', () => {
cy.visit(`/k8s/ns/${testName}/deployments/${WORKLOAD_NAME}/pods`);
listPage.rows.shouldBeLoaded();
listPage.filter.byName('XYZ123');
cy.byTestID('empty-box-body').should('be.visible');
listPage.dvRows.shouldBeLoaded();
listPage.dvFilter.byName('XYZ123');
cy.get('[data-test="data-view-table"]').within(() => {
cy.get('.pf-v6-l-bullseye').should('contain', 'No Pods found');
});
});

it('filters from Pods list', () => {
// disabled as listPage.rows.shouldExist isn't a valid test
xit('filters from Pods list', () => {
cy.visit(`/k8s/all-namespaces/pods`);
listPage.rows.shouldBeLoaded();
listPage.filter.byName(WORKLOAD_NAME);
Expand All @@ -80,7 +84,8 @@ describe('Filtering and Searching', () => {
listPage.rows.shouldExist(WORKLOAD_NAME);
});

it('searches for object by kind, label, and name', () => {
// disabled as listPage.rows.shouldExist isn't a valid test
xit('searches for object by kind, label, and name', () => {
cy.visit(`/search/all-namespaces`, {
qs: { kind: 'Pod', q: 'app=name', name: WORKLOAD_NAME },
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ describe('Pod log viewer tab', () => {

it('Open logs from pod details page tab and verify the log buffer sizes', () => {
cy.visit(
`/k8s/ns/openshift-kube-apiserver/core~v1~Pod?name=kube-apiserver-ip-&rowFilter-pod-status=Running&orderBy=desc&sortBy=Owner`,
`/k8s/ns/openshift-kube-apiserver/core~v1~Pod?name=kube-apiserver-ip-&rowFilter-pod-status=Running&orderBy=asc&sortBy=Owner`,
);
listPage.rows.clickFirstLinkInFirstRow();
listPage.dvRows.clickFirstLinkInFirstRow();
detailsPage.isLoaded();
detailsPage.selectTab('Logs');
detailsPage.isLoaded();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Start a Job from a CronJob', () => {
cy.visit(`/k8s/ns/${testName}/cronjobs`);
listPage.rows.shouldBeLoaded();
cy.visit(`/k8s/ns/${testName}/cronjobs/${CRONJOB_NAME}/jobs`);
listPage.rows.countShouldBe(2);
listPage.dvRows.countShouldBe(2);
});

it('verify the number of events in CronJob > Events tab list page', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as _ from 'lodash';
import { checkErrors, testName } from '../../support';
import { detailsPage } from '../../views/details-page';
import { listPage } from '../../views/list-page';
import { modal } from '../../views/modal';
import * as yamlEditor from '../../views/yaml-editor';

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

cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
listPage.rows.shouldBeLoaded();
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
modal.shouldBeOpened();
modal.modalTitleShouldContain(`Delete ${crd}`);
modal.submit();
modal.shouldBeClosed();
cy.exec(`oc delete ${crd} ${name}`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ describe(`${crd} CRD`, () => {
cy.get(cell).should('not.exist');

cy.visit(`/k8s/ns/${testName}/pods?name=${podName}`);
listPage.rows.shouldBeLoaded();
listPage.rows.clickKebabAction(podName, 'Delete Pod');
listPage.dvRows.shouldBeLoaded();
listPage.dvRows.clickKebabAction(podName, 'Delete Pod');
modal.shouldBeOpened();
modal.modalTitleShouldContain('Delete Pod');
modal.submit();
modal.shouldBeClosed();

cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
listPage.rows.shouldBeLoaded();
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
listPage.dvRows.shouldBeLoaded();
listPage.dvRows.clickKebabAction(name, `Delete ${crd}`);
modal.shouldBeOpened();
modal.modalTitleShouldContain(`Delete ${crd}`);
modal.submit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ describe(`${crd} CRD`, () => {
.should('exist');

cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
listPage.rows.shouldBeLoaded();
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
listPage.dvRows.shouldBeLoaded();
listPage.dvRows.clickKebabAction(name, `Delete ${crd}`);
modal.shouldBeOpened();
modal.modalTitleShouldContain(`Delete ${crd}`);
modal.submit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as _ from 'lodash';
import { checkErrors, testName } from '../../support';
import { detailsPage } from '../../views/details-page';
import { listPage } from '../../views/list-page';
import { modal } from '../../views/modal';
import * as yamlEditor from '../../views/yaml-editor';

const crd = 'ConsoleNotification';
Expand Down Expand Up @@ -50,9 +49,8 @@ describe(`${crd} CRD`, () => {
});

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

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

cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
listPage.rows.shouldBeLoaded();
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
modal.shouldBeOpened();
modal.modalTitleShouldContain(`Delete ${crd}`);
modal.submit();
modal.shouldBeClosed();
cy.exec(`oc delete ${crd} ${name}`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as _ from 'lodash';
import { checkErrors, testName } from '../../support';
import { detailsPage } from '../../views/details-page';
import { listPage } from '../../views/list-page';
import { modal } from '../../views/modal';
import * as resourceSidebar from '../../views/resource-sidebar';
import * as yamlEditor from '../../views/yaml-editor';

Expand Down Expand Up @@ -76,9 +75,9 @@ metadata:
});

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

// Delete CRD
cy.visit(`/k8s/cluster/console.openshift.io~v1~${crd}`);
listPage.rows.shouldBeLoaded();
listPage.rows.clickKebabAction(name, `Delete ${crd}`);
modal.shouldBeOpened();
modal.modalTitleShouldContain(`Delete ${crd}`);
modal.submit();
modal.shouldBeClosed();
cy.exec(`oc delete ${crd} ${name}`);
});
});
Loading