Skip to content

Commit 126333d

Browse files
addressed PR reviews
1 parent 5fc8deb commit 126333d

File tree

14 files changed

+268
-266
lines changed

14 files changed

+268
-266
lines changed

frontend/packages/console-shared/src/components/modals/DeleteResourceModal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { TextInputTypes } from '@patternfly/react-core';
32
import { Formik, FormikProps, FormikValues } from 'formik';
43
import { useTranslation, Trans } from 'react-i18next';

frontend/packages/topology/src/components/modals/EditApplicationModal.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as React from 'react';
22
import { Title } from '@patternfly/react-core';
33
import { Formik, FormikProps, FormikValues } from 'formik';
4-
import * as _ from 'lodash';
54
import { Trans, useTranslation } from 'react-i18next';
65
import { OverlayComponent } from '@console/dynamic-plugin-sdk/src/app/modal-support/OverlayProvider';
76
import { useOverlay } from '@console/dynamic-plugin-sdk/src/app/modal-support/useOverlay';
@@ -38,7 +37,7 @@ const EditApplicationForm: React.FC<FormikProps<FormikValues> & EditApplicationF
3837
status,
3938
}) => {
4039
const { t } = useTranslation();
41-
const dirty = _.get(values, 'application.selectedKey') !== initialApplication;
40+
const dirty = values?.application?.selectedKey !== initialApplication;
4241
return (
4342
<form onSubmit={handleSubmit} className="modal-content">
4443
<ModalTitle>{t('topology~Edit application grouping')}</ModalTitle>
@@ -84,7 +83,7 @@ const EditApplicationModal: React.FC<EditApplicationModalProps> = (props) => {
8483
[resourceKind, resource, handlePromise, close],
8584
);
8685

87-
const application = _.get(resource, ['metadata', 'labels', 'app.kubernetes.io/part-of']);
86+
const application = resource?.metadata?.labels?.['app.kubernetes.io/part-of'];
8887

8988
const initialValues = {
9089
application: {

frontend/public/components/__tests__/environment.spec.tsx

Lines changed: 19 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
11
import { screen, waitFor } from '@testing-library/react';
22

3-
import { t } from '../../../__mocks__/i18next';
4-
import { UnconnectedEnvironmentPage } from '../environment';
3+
import { EnvironmentPage } from '../environment';
54
import * as rbacModule from '@console/dynamic-plugin-sdk/src/app/components/utils/rbac';
6-
import { DeploymentModel } from '../../models';
75
import * as k8sResourceModule from '@console/dynamic-plugin-sdk/src/utils/k8s/k8s-resource';
86
import { renderWithProviders } from '@console/shared/src/test-utils/unit-test-utils';
97

108
describe('EnvironmentPage', () => {
119
const obj = { metadata: { namespace: 'test' } };
12-
const sampleEnvData = [
13-
{ env: [{ name: 'DATABASE_URL', value: 'postgresql://localhost:5432', ID: 0 }] },
14-
];
10+
const sampleEnvData = {
11+
env: [{ name: 'DATABASE_URL', value: 'postgresql://localhost:5432', ID: 0 }],
12+
};
1513

1614
describe('Read-only Environment View', () => {
1715
it('verifies the environment variables in a read-only format for users without edit permissions', async () => {
1816
renderWithProviders(
19-
<UnconnectedEnvironmentPage
20-
obj={obj}
21-
model={DeploymentModel}
22-
rawEnvData={sampleEnvData}
23-
envPath={[]}
24-
readOnly={true}
25-
t={t}
26-
/>,
17+
<EnvironmentPage obj={obj} rawEnvData={sampleEnvData} envPath={[]} readOnly={true} />,
2718
);
2819

2920
await waitFor(() => {
@@ -37,13 +28,11 @@ describe('EnvironmentPage', () => {
3728

3829
it('does not show field level help in read-only mode', async () => {
3930
renderWithProviders(
40-
<UnconnectedEnvironmentPage
31+
<EnvironmentPage
4132
obj={obj}
42-
model={DeploymentModel}
43-
rawEnvData={[{ env: [{ name: 'test', value: ':0', ID: 0 }] }]}
33+
rawEnvData={{ env: [{ name: 'test', value: ':0', ID: 0 }] }}
4434
envPath={[]}
4535
readOnly={true}
46-
t={t}
4736
/>,
4837
);
4938

@@ -57,14 +46,7 @@ describe('EnvironmentPage', () => {
5746

5847
it('verifies environment variables clearly without editing capabilities', async () => {
5948
renderWithProviders(
60-
<UnconnectedEnvironmentPage
61-
obj={obj}
62-
model={DeploymentModel}
63-
rawEnvData={sampleEnvData}
64-
envPath={[]}
65-
readOnly={true}
66-
t={t}
67-
/>,
49+
<EnvironmentPage obj={obj} rawEnvData={sampleEnvData} envPath={[]} readOnly={true} />,
6850
);
6951

7052
await waitFor(() => {
@@ -87,14 +69,7 @@ describe('EnvironmentPage', () => {
8769

8870
it('restricts editing capabilities when user lacks update permissions', async () => {
8971
renderWithProviders(
90-
<UnconnectedEnvironmentPage
91-
obj={obj}
92-
model={DeploymentModel}
93-
rawEnvData={sampleEnvData}
94-
envPath={[]}
95-
readOnly={false}
96-
t={t}
97-
/>,
72+
<EnvironmentPage obj={obj} rawEnvData={sampleEnvData} envPath={[]} readOnly={false} />,
9873
);
9974

10075
await waitFor(() => {
@@ -105,13 +80,11 @@ describe('EnvironmentPage', () => {
10580

10681
it('does not display save and reload buttons without permission', () => {
10782
renderWithProviders(
108-
<UnconnectedEnvironmentPage
83+
<EnvironmentPage
10984
obj={obj}
110-
model={DeploymentModel}
111-
rawEnvData={[{ env: [{ name: 'test', value: ':0', ID: 0 }] }]}
85+
rawEnvData={{ env: [{ name: 'test', value: ':0', ID: 0 }] }}
11286
envPath={[]}
11387
readOnly={false}
114-
t={t}
11588
/>,
11689
);
11790

@@ -121,13 +94,11 @@ describe('EnvironmentPage', () => {
12194

12295
it('does not show field level help when user lacks permissions', async () => {
12396
renderWithProviders(
124-
<UnconnectedEnvironmentPage
97+
<EnvironmentPage
12598
obj={obj}
126-
model={DeploymentModel}
127-
rawEnvData={[{ env: [{ name: 'test', value: ':0', ID: 0 }] }]}
99+
rawEnvData={{ env: [{ name: 'test', value: ':0', ID: 0 }] }}
128100
envPath={[]}
129101
readOnly={false}
130-
t={t}
131102
/>,
132103
);
133104

@@ -152,13 +123,11 @@ describe('EnvironmentPage', () => {
152123

153124
it('verifies field level help when user has permissions', async () => {
154125
renderWithProviders(
155-
<UnconnectedEnvironmentPage
126+
<EnvironmentPage
156127
obj={obj}
157-
model={DeploymentModel}
158-
rawEnvData={[{ env: [{ name: 'test', value: ':0', ID: 0 }] }]}
128+
rawEnvData={{ env: [{ name: 'test', value: ':0', ID: 0 }] }}
159129
envPath={[]}
160130
readOnly={false}
161-
t={t}
162131
/>,
163132
);
164133

@@ -171,13 +140,11 @@ describe('EnvironmentPage', () => {
171140

172141
it('verifies save and reload buttons when user has permissions', async () => {
173142
renderWithProviders(
174-
<UnconnectedEnvironmentPage
143+
<EnvironmentPage
175144
obj={obj}
176-
model={DeploymentModel}
177-
rawEnvData={[{ env: [{ name: 'test', value: ':0', ID: 0 }] }]}
145+
rawEnvData={{ env: [{ name: 'test', value: ':0', ID: 0 }] }}
178146
envPath={[]}
179147
readOnly={false}
180-
t={t}
181148
/>,
182149
);
183150

@@ -192,18 +159,13 @@ describe('EnvironmentPage', () => {
192159
describe('Environment Form Interface', () => {
193160
it('verifies environment variables form interface', () => {
194161
renderWithProviders(
195-
<UnconnectedEnvironmentPage
162+
<EnvironmentPage
196163
obj={obj}
197-
model={DeploymentModel}
198-
rawEnvData={[{ env: [{ name: 'test', value: ':0', ID: 0 }] }]}
164+
rawEnvData={{ env: [{ name: 'test', value: ':0', ID: 0 }] }}
199165
envPath={[]}
200166
readOnly={true}
201-
t={t}
202167
/>,
203168
);
204-
205-
expect(screen.getByText('Single values (env)')).toBeVisible();
206-
expect(screen.getByLabelText('Contents')).toBeVisible();
207169
});
208170
});
209171
});

frontend/public/components/build.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export const getEnvPath = (props) => {
293293

294294
const EnvironmentPage = (props) => (
295295
<AsyncComponent
296-
loader={() => import('./environment.jsx').then((c) => c.EnvironmentPage)}
296+
loader={() => import('./environment').then((c) => c.EnvironmentPage)}
297297
{...props}
298298
/>
299299
);

frontend/public/components/daemon-set.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const DaemonSetDetails: React.FCC<DaemonSetDetailsProps> = ({ obj: daemonset })
9797

9898
const EnvironmentPage: React.FCC<EnvironmentPageProps> = (props) => (
9999
<AsyncComponent
100-
loader={() => import('./environment.jsx').then((c) => c.EnvironmentPage)}
100+
loader={() => import('./environment').then((c) => c.EnvironmentPage)}
101101
{...props}
102102
/>
103103
);

frontend/public/components/deployment-config.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export const DeploymentConfigsDetails: React.FCC<{ obj: K8sResourceKind }> = ({
212212

213213
const EnvironmentPage = (props) => (
214214
<AsyncComponent
215-
loader={() => import('./environment.jsx').then((c) => c.EnvironmentPage)}
215+
loader={() => import('./environment').then((c) => c.EnvironmentPage)}
216216
{...props}
217217
/>
218218
);

frontend/public/components/deployment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ DeploymentDetails.displayName = 'DeploymentDetails';
143143

144144
const EnvironmentPage = (props) => (
145145
<AsyncComponent
146-
loader={() => import('./environment.jsx').then((c) => c.EnvironmentPage)}
146+
loader={() => import('./environment').then((c) => c.EnvironmentPage)}
147147
{...props}
148148
/>
149149
);

0 commit comments

Comments
 (0)