Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -75,10 +75,10 @@ describe('Alertmanager', () => {
cy.byTestID('label-0').type(label);
alertmanager.save();
alertmanager.validateCreation(receiverName, receiverType, label);
listPage.rows.clickKebabAction(receiverName, 'Delete Receiver');
listPage.dvRows.clickKebabAction(receiverName, 'Delete Receiver');
warningModal.confirm('AlertmanagerDeleteReceiverConfirmation');
warningModal.shouldBeClosed('AlertmanagerDeleteReceiverConfirmation');
listPage.rows.shouldNotExist(receiverName);
listPage.dvRows.shouldNotExist(receiverName);
});

it('prevents deletion and form edit of a receiver with sub-route', () => {
Expand All @@ -100,7 +100,7 @@ receivers:
yamlEditor.clickSaveCreateButton();
cy.byTestID('alert-success').should('exist');
detailsPage.selectTab('Details');
cy.get('[data-test-rows="resource-row"]')
cy.get('[data-test="data-view-table"]')
.contains('team-X-pager')
.parents('tr')
.within(() => {
Expand Down Expand Up @@ -180,7 +180,7 @@ route:
yamlEditor.clickSaveCreateButton();
cy.get('.yaml-editor__buttons .pf-m-success').should('exist');
detailsPage.selectTab('Details');
listPage.rows.shouldExist(receiverName);
listPage.dvRows.shouldExist(receiverName);
alertmanager.visitEditPage(receiverName);
cy.byTestID('label-0').should('have.value', matcher1);
cy.byTestID('label-1').should('have.value', matcher2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Alertmanager: PagerDuty Receiver Form', () => {
alertmanager.validateCreation(receiverName, receiverType, label);

cy.log('update pagerduty_url');
listPage.rows.clickKebabAction(receiverName, 'Edit Receiver');
listPage.dvRows.clickKebabAction(receiverName, 'Edit Receiver');
// Save as default checkbox disabled when url equals global url
cy.byTestID('save-as-default').should('be.disabled');
// changing url enables Save as default checkbox, should save pagerduty_url with Receiver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Visiting other routes', () => {
},
{
path: '/api-explorer',
waitFor: () => cy.get('[data-ouia-component-type$="TableRow"]').should('be.visible'),
waitFor: () => cy.get('[data-test="data-view-table"]').should('be.visible'),
},
{
path: '/api-resource/ns/default/core~v1~Pod',
Expand All @@ -59,7 +59,7 @@ describe('Visiting other routes', () => {
? [
{
path: '/api-resource/ns/default/core~v1~Pod/access',
waitFor: () => cy.get('[data-ouia-component-type$="TableRow"]').should('be.visible'),
waitFor: () => cy.get('[data-test="data-view-table"]').should('be.visible'),
},
{
path: '/k8s/cluster/user.openshift.io~v1~User',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export const alertmanager = {
validateCreation: (receiverName: string, type: string, label: string) => {
cy.byLegacyTestID('item-filter').clear();
cy.byLegacyTestID('item-filter').type(receiverName);
listPage.rows.shouldExist(receiverName);
listPage.rows.shouldExist(type);
listPage.rows.shouldExist(label);
listPage.dvRows.shouldExist(receiverName);
listPage.dvRows.shouldExist(type);
listPage.dvRows.shouldExist(label);
},
visitAlertmanagerPage: () => {
cy.visit('/settings/cluster/alertmanagerconfig');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ export const listPage = {
shouldBeLoaded: () => {
cy.get(`[data-test="data-view-table"]`).should('be.visible');
},
shouldExist: (resourceName: string) =>
cy.get(`[data-test="data-view-cell-${resourceName}-name"]`).contains(resourceName),
shouldNotExist: (resourceName: string) =>
cy
.get(`[data-test="data-view-cell-${resourceName}-name"]`, { timeout: 90000 })
.should('not.exist'),
clickKebabAction: (resourceName: string, actionName: string) => {
cy.get(`[data-test="data-view-cell-${resourceName}-name"]`)
.contains(resourceName)
Expand Down
Loading