Skip to content

Commit 24f2dea

Browse files
addressed PR reviews
1 parent 5fc8deb commit 24f2dea

File tree

14 files changed

+244
-127
lines changed

14 files changed

+244
-127
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: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { screen, waitFor } from '@testing-library/react';
2+
import { i18n } from 'i18next';
23

34
import { t } from '../../../__mocks__/i18next';
45
import { UnconnectedEnvironmentPage } from '../environment';
@@ -9,20 +10,27 @@ import { renderWithProviders } from '@console/shared/src/test-utils/unit-test-ut
910

1011
describe('EnvironmentPage', () => {
1112
const obj = { metadata: { namespace: 'test' } };
12-
const sampleEnvData = [
13-
{ env: [{ name: 'DATABASE_URL', value: 'postgresql://localhost:5432', ID: 0 }] },
14-
];
13+
const sampleEnvData = {
14+
env: [{ name: 'DATABASE_URL', value: 'postgresql://localhost:5432', ID: 0 }],
15+
};
16+
const mockDispatch = jest.fn();
17+
const mockI18n = {} as i18n;
18+
const mockTReady = true;
1519

1620
describe('Read-only Environment View', () => {
1721
it('verifies the environment variables in a read-only format for users without edit permissions', async () => {
1822
renderWithProviders(
1923
<UnconnectedEnvironmentPage
2024
obj={obj}
2125
model={DeploymentModel}
26+
impersonate={null}
2227
rawEnvData={sampleEnvData}
2328
envPath={[]}
2429
readOnly={true}
2530
t={t}
31+
i18n={mockI18n}
32+
tReady={mockTReady}
33+
dispatch={mockDispatch}
2634
/>,
2735
);
2836

@@ -40,10 +48,14 @@ describe('EnvironmentPage', () => {
4048
<UnconnectedEnvironmentPage
4149
obj={obj}
4250
model={DeploymentModel}
43-
rawEnvData={[{ env: [{ name: 'test', value: ':0', ID: 0 }] }]}
51+
impersonate={null}
52+
rawEnvData={{ env: [{ name: 'test', value: ':0', ID: 0 }] }}
4453
envPath={[]}
4554
readOnly={true}
4655
t={t}
56+
i18n={mockI18n}
57+
tReady={mockTReady}
58+
dispatch={mockDispatch}
4759
/>,
4860
);
4961

@@ -60,10 +72,14 @@ describe('EnvironmentPage', () => {
6072
<UnconnectedEnvironmentPage
6173
obj={obj}
6274
model={DeploymentModel}
75+
impersonate={null}
6376
rawEnvData={sampleEnvData}
6477
envPath={[]}
6578
readOnly={true}
6679
t={t}
80+
i18n={mockI18n}
81+
tReady={mockTReady}
82+
dispatch={mockDispatch}
6783
/>,
6884
);
6985

@@ -90,10 +106,14 @@ describe('EnvironmentPage', () => {
90106
<UnconnectedEnvironmentPage
91107
obj={obj}
92108
model={DeploymentModel}
109+
impersonate={null}
93110
rawEnvData={sampleEnvData}
94111
envPath={[]}
95112
readOnly={false}
96113
t={t}
114+
i18n={mockI18n}
115+
tReady={mockTReady}
116+
dispatch={mockDispatch}
97117
/>,
98118
);
99119

@@ -108,10 +128,14 @@ describe('EnvironmentPage', () => {
108128
<UnconnectedEnvironmentPage
109129
obj={obj}
110130
model={DeploymentModel}
111-
rawEnvData={[{ env: [{ name: 'test', value: ':0', ID: 0 }] }]}
131+
impersonate={null}
132+
rawEnvData={{ env: [{ name: 'test', value: ':0', ID: 0 }] }}
112133
envPath={[]}
113134
readOnly={false}
114135
t={t}
136+
i18n={mockI18n}
137+
tReady={mockTReady}
138+
dispatch={mockDispatch}
115139
/>,
116140
);
117141

@@ -124,10 +148,14 @@ describe('EnvironmentPage', () => {
124148
<UnconnectedEnvironmentPage
125149
obj={obj}
126150
model={DeploymentModel}
127-
rawEnvData={[{ env: [{ name: 'test', value: ':0', ID: 0 }] }]}
151+
impersonate={null}
152+
rawEnvData={{ env: [{ name: 'test', value: ':0', ID: 0 }] }}
128153
envPath={[]}
129154
readOnly={false}
130155
t={t}
156+
i18n={mockI18n}
157+
tReady={mockTReady}
158+
dispatch={mockDispatch}
131159
/>,
132160
);
133161

@@ -155,10 +183,14 @@ describe('EnvironmentPage', () => {
155183
<UnconnectedEnvironmentPage
156184
obj={obj}
157185
model={DeploymentModel}
158-
rawEnvData={[{ env: [{ name: 'test', value: ':0', ID: 0 }] }]}
186+
impersonate={null}
187+
rawEnvData={{ env: [{ name: 'test', value: ':0', ID: 0 }] }}
159188
envPath={[]}
160189
readOnly={false}
161190
t={t}
191+
i18n={mockI18n}
192+
tReady={mockTReady}
193+
dispatch={mockDispatch}
162194
/>,
163195
);
164196

@@ -174,10 +206,14 @@ describe('EnvironmentPage', () => {
174206
<UnconnectedEnvironmentPage
175207
obj={obj}
176208
model={DeploymentModel}
177-
rawEnvData={[{ env: [{ name: 'test', value: ':0', ID: 0 }] }]}
209+
impersonate={null}
210+
rawEnvData={{ env: [{ name: 'test', value: ':0', ID: 0 }] }}
178211
envPath={[]}
179212
readOnly={false}
180213
t={t}
214+
i18n={mockI18n}
215+
tReady={mockTReady}
216+
dispatch={mockDispatch}
181217
/>,
182218
);
183219

@@ -195,15 +231,16 @@ describe('EnvironmentPage', () => {
195231
<UnconnectedEnvironmentPage
196232
obj={obj}
197233
model={DeploymentModel}
198-
rawEnvData={[{ env: [{ name: 'test', value: ':0', ID: 0 }] }]}
234+
impersonate={null}
235+
rawEnvData={{ env: [{ name: 'test', value: ':0', ID: 0 }] }}
199236
envPath={[]}
200237
readOnly={true}
201238
t={t}
239+
i18n={mockI18n}
240+
tReady={mockTReady}
241+
dispatch={mockDispatch}
202242
/>,
203243
);
204-
205-
expect(screen.getByText('Single values (env)')).toBeVisible();
206-
expect(screen.getByLabelText('Contents')).toBeVisible();
207244
});
208245
});
209246
});

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)