Skip to content

Commit 97639ce

Browse files
Addressed PR reviews
modified: frontend/packages/console-app/locales/en/console-app.json modified: frontend/packages/console-app/src/components/pdb/PDBList.tsx modified: frontend/packages/integration-tests-cypress/tests/app/filtering-and-searching.cy.ts modified: frontend/packages/integration-tests-cypress/tests/app/start-job-from-cronjob.cy.ts modified: frontend/packages/integration-tests-cypress/tests/crud/resource-crud.cy.ts modified: frontend/public/components/configmap.tsx modified: frontend/public/components/cron-job.tsx modified: frontend/public/components/factory/list-page.tsx modified: frontend/public/components/secret.tsx
1 parent 53a707b commit 97639ce

File tree

9 files changed

+137
-135
lines changed

9 files changed

+137
-135
lines changed

frontend/packages/console-app/locales/en/console-app.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@
480480
"Edit {{label}}": "Edit {{label}}",
481481
"{helpText}": "{helpText}",
482482
"Disruptions allowed": "Disruptions allowed",
483+
"PodDisruptionBudget": "PodDisruptionBudget",
483484
"Create PodDisruptionBudget": "Create PodDisruptionBudget",
484485
"Disruption not allowed": "Disruption not allowed",
485486
"No PodDisruptionBudget": "No PodDisruptionBudget",

frontend/packages/console-app/src/components/pdb/PDBList.tsx

Lines changed: 64 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,42 @@ import {
77
cellIsStickyProps,
88
getNameCellProps,
99
initialFiltersDefault,
10-
ResourceDataView,
11-
} from '@console/app/src/components/data-view/ResourceDataView';
10+
ConsoleDataView,
11+
} from '@console/app/src/components/data-view/ConsoleDataView';
1212
import { GetDataViewRows } from '@console/app/src/components/data-view/types';
1313
import { YellowExclamationTriangleIcon } from '@console/dynamic-plugin-sdk';
14-
import { TableColumn } from '@console/dynamic-plugin-sdk/src/extensions/console-types';
15-
import { getGroupVersionKindForModel } from '@console/dynamic-plugin-sdk/src/utils/k8s/k8s-ref';
14+
import {
15+
TableColumn,
16+
ColumnLayout,
17+
} from '@console/dynamic-plugin-sdk/src/extensions/console-types';
1618
import { ResourceLink, Selector } from '@console/internal/components/utils';
1719
import { LoadingBox } from '@console/internal/components/utils/status-box';
18-
import { referenceFor } from '@console/internal/module/k8s';
19-
import { LazyActionMenu, DASH } from '@console/shared';
20+
import { referenceForModel } from '@console/internal/module/k8s';
21+
import {
22+
LazyActionMenu,
23+
DASH,
24+
COLUMN_MANAGEMENT_CONFIGMAP_KEY,
25+
COLUMN_MANAGEMENT_LOCAL_STORAGE_KEY,
26+
} from '@console/shared';
2027
import { Timestamp } from '@console/shared/src/components/datetime/Timestamp';
28+
import { useUserSettingsCompatibility } from '@console/shared/src/hooks/useUserSettingsCompatibility';
2129
import { PodDisruptionBudgetModel } from '../../models';
30+
import { getPDBTableColumns, tableColumnInfo } from './pdb-table-columns';
2231
import { PodDisruptionBudgetKind } from './types';
2332
import { isDisruptionViolated } from './utils/get-pdb-resources';
2433

25-
const tableColumnInfo = [
26-
{ id: 'name' },
27-
{ id: 'namespace' },
28-
{ id: 'selector' },
29-
{ id: 'minAvailable' },
30-
{ id: 'disruptionsAllowed' },
31-
{ id: 'creationTimestamp' },
32-
{ id: 'actions' },
33-
];
34+
const pdbColumnManagementID = referenceForModel(PodDisruptionBudgetModel);
3435

3536
const getDataViewRows: GetDataViewRows<PodDisruptionBudgetKind, undefined> = (data, columns) => {
3637
return data.map(({ obj: pdb }) => {
3738
const { name, namespace } = pdb.metadata;
38-
const resourceKind = referenceFor(pdb);
39+
const resourceKind = referenceForModel(PodDisruptionBudgetModel);
3940
const context = { [resourceKind]: pdb };
4041
const isPDBViolated = isDisruptionViolated(pdb);
4142

4243
const rowCells = {
4344
[tableColumnInfo[0].id]: {
44-
cell: (
45-
<ResourceLink
46-
groupVersionKind={getGroupVersionKindForModel(PodDisruptionBudgetModel)}
47-
name={name}
48-
namespace={namespace}
49-
/>
50-
),
45+
cell: <ResourceLink kind={resourceKind} name={name} namespace={namespace} />,
5146
props: getNameCellProps(name),
5247
},
5348
[tableColumnInfo[1].id]: {
@@ -57,15 +52,12 @@ const getDataViewRows: GetDataViewRows<PodDisruptionBudgetKind, undefined> = (da
5752
cell: <Selector selector={pdb.spec.selector} namespace={namespace} />,
5853
},
5954
[tableColumnInfo[3].id]: {
60-
cell: (
61-
<span>
62-
{_.isNil(pdb.spec.maxUnavailable) && _.isNil(pdb.spec.minAvailable)
63-
? DASH
64-
: _.isNil(pdb.spec.maxUnavailable)
65-
? `Min available ${pdb.spec.minAvailable}`
66-
: `Max unavailable ${pdb.spec.maxUnavailable}`}
67-
</span>
68-
),
55+
cell:
56+
_.isNil(pdb.spec.maxUnavailable) && _.isNil(pdb.spec.minAvailable)
57+
? DASH
58+
: _.isNil(pdb.spec.maxUnavailable)
59+
? `Min available ${pdb.spec.minAvailable}`
60+
: `Max unavailable ${pdb.spec.maxUnavailable}`,
6961
},
7062
[tableColumnInfo[4].id]: {
7163
cell: (
@@ -99,89 +91,63 @@ const getDataViewRows: GetDataViewRows<PodDisruptionBudgetKind, undefined> = (da
9991
});
10092
};
10193

102-
const usePDBColumns = (): TableColumn<PodDisruptionBudgetKind>[] => {
103-
const { t } = useTranslation();
104-
const columns = React.useMemo(() => {
105-
return [
106-
{
107-
title: t('console-app~Name'),
108-
id: tableColumnInfo[0].id,
109-
sort: 'metadata.name',
110-
props: {
111-
...cellIsStickyProps,
112-
modifier: 'nowrap',
113-
},
114-
},
115-
{
116-
title: t('console-app~Namespace'),
117-
id: tableColumnInfo[1].id,
118-
sort: 'metadata.namespace',
119-
props: {
120-
modifier: 'nowrap',
121-
},
122-
},
123-
{
124-
title: t('console-app~Selector'),
125-
id: tableColumnInfo[2].id,
126-
sort: 'spec.selector',
127-
props: {
128-
modifier: 'nowrap',
129-
},
130-
},
131-
{
132-
title: t('console-app~Availability'),
133-
id: tableColumnInfo[3].id,
134-
sort: 'spec.minAvailable',
135-
props: {
136-
modifier: 'nowrap',
137-
},
138-
},
139-
{
140-
title: t('console-app~Disruptions allowed'),
141-
id: tableColumnInfo[4].id,
142-
sort: 'status.disruptionsAllowed',
143-
props: {
144-
modifier: 'nowrap',
145-
},
146-
},
147-
{
148-
title: t('console-app~Created'),
149-
id: tableColumnInfo[5].id,
150-
sort: 'metadata.creationTimestamp',
151-
props: {
152-
modifier: 'nowrap',
153-
},
154-
},
155-
{
156-
title: '',
157-
id: tableColumnInfo[6].id,
158-
props: {
159-
...cellIsStickyProps,
160-
},
161-
},
162-
];
163-
}, [t]);
164-
return columns;
94+
const getPDBColumns = (): TableColumn<PodDisruptionBudgetKind>[] => {
95+
const sharedColumns = getPDBTableColumns();
96+
97+
return sharedColumns.map((col, index) => ({
98+
title: col.title,
99+
id: col.id,
100+
sort: col.sort,
101+
props: {
102+
...cellIsStickyProps,
103+
modifier: 'nowrap',
104+
...(index === sharedColumns.length - 1 && { ...cellIsStickyProps }),
105+
},
106+
}));
165107
};
166108

167109
const PodDisruptionBudgetList: React.FCC<PodDisruptionBudgetsListProps> = ({
168110
data,
169111
loaded,
170112
...props
171113
}) => {
172-
const columns = usePDBColumns();
114+
const { t } = useTranslation();
115+
const columns = getPDBColumns();
116+
const [selectedColumns] = useUserSettingsCompatibility(
117+
COLUMN_MANAGEMENT_CONFIGMAP_KEY,
118+
COLUMN_MANAGEMENT_LOCAL_STORAGE_KEY,
119+
undefined,
120+
true,
121+
);
122+
123+
const columnLayout = React.useMemo<ColumnLayout>(
124+
() => ({
125+
columns: columns
126+
.filter((column) => column.title && column.title.trim() !== '')
127+
.map((column) => _.pick(column, ['title', 'additional', 'id'])),
128+
id: pdbColumnManagementID,
129+
selectedColumns:
130+
selectedColumns?.[pdbColumnManagementID]?.length > 0
131+
? new Set(selectedColumns[pdbColumnManagementID])
132+
: null,
133+
type: t('console-app~PodDisruptionBudget'),
134+
showNamespaceOverride: false,
135+
}),
136+
[columns, selectedColumns, t],
137+
);
173138

174139
return (
175140
<React.Suspense fallback={<LoadingBox />}>
176-
<ResourceDataView<PodDisruptionBudgetKind>
141+
<ConsoleDataView<PodDisruptionBudgetKind>
177142
{...props}
178143
label={PodDisruptionBudgetModel.labelPlural}
179144
data={data}
180145
loaded={loaded}
181146
columns={columns}
147+
columnLayout={columnLayout}
148+
columnManagementID={pdbColumnManagementID}
182149
initialFilters={initialFiltersDefault}
183150
getDataViewRows={getDataViewRows}
184-
hideColumnManagement
185151
/>
186152
</React.Suspense>
187153
);

frontend/packages/integration-tests-cypress/tests/app/filtering-and-searching.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('Filtering and Searching', () => {
5252
cy.deleteProjectWithCLI(testName);
5353
});
5454

55-
// disabled as listPage.dvRows.shouldExist isn't a valid test
55+
// disabled as listPage.rows.shouldExist isn't a valid test
5656
xit('filters Pod from object detail', () => {
5757
cy.visit(`/k8s/ns/${testName}/deployments`);
5858
listPage.rows.shouldExist(WORKLOAD_NAME);

frontend/packages/integration-tests-cypress/tests/app/start-job-from-cronjob.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('Start a Job from a CronJob', () => {
6868
cy.visit(`/k8s/ns/${testName}/cronjobs`);
6969
listPage.dvRows.shouldBeLoaded();
7070
cy.visit(`/k8s/ns/${testName}/cronjobs/${CRONJOB_NAME}/jobs`);
71-
listPage.rows.countShouldBe(2);
71+
listPage.dvRows.countShouldBe(2);
7272
});
7373

7474
it('verify the number of events in CronJob > Events tab list page', () => {

frontend/packages/integration-tests-cypress/tests/crud/resource-crud.cy.ts

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,64 @@ describe('Kubernetes resource CRUD operations', () => {
3333
});
3434

3535
const k8sObjs = OrderedMap<string, TestDefinition>()
36+
.set('pods', { kind: 'Pod' })
37+
.set('serviceaccounts', { kind: 'ServiceAccount', humanizeKind: false })
3638
.set('secrets', { kind: 'Secret', skipYamlReloadTest: true })
39+
.set('persistentvolumes', {
40+
kind: 'PersistentVolume',
41+
namespaced: false,
42+
humanizeKind: false,
43+
})
44+
.set('storageclasses', {
45+
kind: 'StorageClass',
46+
namespaced: false,
47+
humanizeKind: false,
48+
})
3749
.set('cronjobs', { kind: 'CronJob', humanizeKind: false })
50+
.set('jobs', { kind: 'Job' })
3851
.set('daemonsets', { kind: 'DaemonSet', humanizeKind: false })
39-
.set('deployments', { kind: 'Deployment', skipYamlReloadTest: true, skipYamlSaveTest: true });
52+
.set('deployments', { kind: 'Deployment', skipYamlReloadTest: true, skipYamlSaveTest: true })
53+
.set('replicasets', { kind: 'ReplicaSet', humanizeKind: false })
54+
.set('replicationcontrollers', { kind: 'ReplicationController', humanizeKind: false })
55+
.set('persistentvolumeclaims', {
56+
kind: 'PersistentVolumeClaim',
57+
humanizeKind: false,
58+
})
59+
.set('statefulsets', { kind: 'StatefulSet', humanizeKind: false })
60+
.set('resourcequotas', { kind: 'ResourceQuota', humanizeKind: false })
61+
.set('limitranges', { kind: 'LimitRange', humanizeKind: false })
62+
.set('horizontalpodautoscalers', { kind: 'HorizontalPodAutoscaler', humanizeKind: false })
63+
.set('roles', { kind: 'Role' })
64+
.set('snapshot.storage.k8s.io~v1~VolumeSnapshot', {
65+
kind: 'snapshot.storage.k8s.io~v1~VolumeSnapshot',
66+
})
67+
.set('snapshot.storage.k8s.io~v1~VolumeSnapshotClass', {
68+
kind: 'snapshot.storage.k8s.io~v1~VolumeSnapshotClass',
69+
namespaced: false,
70+
})
71+
.set('snapshot.storage.k8s.io~v1~VolumeSnapshotContent', {
72+
kind: 'snapshot.storage.k8s.io~v1~VolumeSnapshotContent',
73+
namespaced: false,
74+
});
4075

41-
const openshiftObjs = OrderedMap<string, TestDefinition>().set('deploymentconfigs', {
42-
kind: 'DeploymentConfig',
43-
humanizeKind: false,
44-
skipYamlReloadTest: true,
45-
skipYamlSaveTest: true,
46-
});
47-
// .set('buildconfigs', {
48-
// kind: 'BuildConfig',
49-
// humanizeKind: false,
50-
// skipYamlReloadTest: true,
51-
// skipYamlSaveTest: true,
52-
// })
53-
// .set('imagestreams', { kind: 'ImageStream', humanizeKind: false })
54-
// .set('user.openshift.io~v1~Group', {
55-
// kind: 'user.openshift.io~v1~Group',
56-
// namespaced: false,
57-
// });
76+
const openshiftObjs = OrderedMap<string, TestDefinition>()
77+
.set('deploymentconfigs', {
78+
kind: 'DeploymentConfig',
79+
humanizeKind: false,
80+
skipYamlReloadTest: true,
81+
skipYamlSaveTest: true,
82+
})
83+
.set('buildconfigs', {
84+
kind: 'BuildConfig',
85+
humanizeKind: false,
86+
skipYamlReloadTest: true,
87+
skipYamlSaveTest: true,
88+
})
89+
.set('imagestreams', { kind: 'ImageStream', humanizeKind: false })
90+
.set('user.openshift.io~v1~Group', {
91+
kind: 'user.openshift.io~v1~Group',
92+
namespaced: false,
93+
});
5894

5995
const testObjs = Cypress.env('openshift') === true ? k8sObjs.merge(openshiftObjs) : k8sObjs;
6096
const testLabel = 'automated-test-name';
@@ -82,7 +118,12 @@ describe('Kubernetes resource CRUD operations', () => {
82118
'ServiceAccount',
83119
'DaemonSet',
84120
'PodDisruptionBudget',
85-
'user.openshift.io~v1~Group',
121+
'HorizontalPodAutoscaler',
122+
'Job',
123+
'Pod',
124+
'ReplicaSet',
125+
'ReplicationController',
126+
'StatefulSet',
86127
]);
87128

88129
testObjs.forEach((testObj, resource) => {

frontend/public/components/configmap.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import { GetDataViewRows } from '@console/app/src/components/data-view/types';
2828
import { LoadingBox } from '@console/shared/src/components/loading';
2929
import { sortResourceByValue } from './factory/Table/sort';
3030
import { sorts } from './factory/table';
31-
import { ConfigMapModel } from '../models';
3231

3332
const menuActions = [...Kebab.factory.common];
3433
const kind = referenceForModel(ConfigMapModel);
@@ -60,7 +59,7 @@ const getDataViewRows: GetDataViewRows<ConfigMapKind, undefined> = (data, column
6059
cell: <ResourceLink kind="Namespace" name={namespace} />,
6160
},
6261
[tableColumnInfo[2].id]: {
63-
cell: <span>{dataSize}</span>,
62+
cell: dataSize,
6463
},
6564
[tableColumnInfo[3].id]: {
6665
cell: <Timestamp timestamp={configMap.metadata.creationTimestamp} />,

0 commit comments

Comments
 (0)