Skip to content

Commit 1ebeae6

Browse files
authored
Merge pull request #345 from zenml-io/QA-Fixes
Qa fixes
2 parents bc6939b + c4be137 commit 1ebeae6

File tree

11 files changed

+342
-91
lines changed

11 files changed

+342
-91
lines changed

src/ui/components/forms/index.tsx

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ export const MakeSecretField = (
282282
borderRadius: '4px',
283283
boxShadow: 'var(--cardShadow)',
284284
width: '100%',
285-
285+
286286
height: '185px',
287287
overflowY: 'auto',
288288
overflowX: 'hidden',
@@ -348,12 +348,14 @@ export const MakeSecretField = (
348348

349349
export const EditField = (
350350
props: {
351+
filteredSecretId?: string;
351352
label: string;
352353
labelColor: any;
353354
placeholder: any;
354355
value: string;
355356
defaultValue?: string;
356357
optional: boolean;
358+
viewSecretDetail?: any;
357359
} & any,
358360
): JSX.Element => {
359361
return (
@@ -365,16 +367,48 @@ export const EditField = (
365367
optional={props.optional}
366368
labelColor={props.labelColor}
367369
InputComponent={
368-
<TextInput
369-
{...props}
370-
style={{
371-
backgroundColor: props.disabled && '#E9EAEC',
372-
borderWidth: props.disabled && '0px',
373-
}}
374-
defaultValue={props?.defaultValue}
375-
value={props.value}
376-
placeholder={props.placeholder}
377-
/>
370+
<>
371+
{props.filteredSecretId ? (
372+
<Box
373+
paddingLeft="md"
374+
style={{
375+
height: '40px',
376+
width: '30vw',
377+
backgroundColor: props.disabled && '#F6F7F7',
378+
borderWidth: props.disabled && '0px',
379+
borderRadius: '4px',
380+
justifyContent: 'flex-start',
381+
alignItems: 'center',
382+
display: 'flex',
383+
}}
384+
>
385+
<Paragraph
386+
onClick={() => props.viewSecretDetail()}
387+
style={{
388+
cursor: 'pointer',
389+
textAlign: 'center',
390+
fontSize: '16px',
391+
color: '#22BBDD',
392+
textDecorationLine: 'underline',
393+
}}
394+
>
395+
{props.defaultValue}
396+
</Paragraph>
397+
</Box>
398+
) : (
399+
<TextInput
400+
{...props}
401+
style={{
402+
backgroundColor: props.disabled && '#E9EAEC',
403+
borderWidth: props.disabled && '0px',
404+
}}
405+
filteredSecretId={props.filteredSecretId}
406+
defaultValue={props?.defaultValue}
407+
value={props.value}
408+
placeholder={props.placeholder}
409+
/>
410+
)}
411+
</>
378412
}
379413
/>
380414
{!props.disabled && (

src/ui/layouts/NonEditableConfig/index.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ import {
99
import { ToggleField } from '../common/FormElement';
1010
import styles from './index.module.scss';
1111
import { useService } from './useService';
12+
import { routePaths } from '../../../routes/routePaths';
13+
import { useSelector } from 'react-redux';
14+
import { secretSelectors, workspaceSelectors } from '../../../redux/selectors';
15+
import { useHistory } from '../../hooks';
1216

1317
export const NonEditableConfig: React.FC<{ details: any }> = ({ details }) => {
18+
const secrets = useSelector(secretSelectors.mySecrets);
19+
const selectedWorkspace = useSelector(workspaceSelectors.selectedWorkspace);
20+
const history = useHistory();
1421
const { flavor } = useService({
1522
details,
1623
});
@@ -27,12 +34,26 @@ export const NonEditableConfig: React.FC<{ details: any }> = ({ details }) => {
2734

2835
const getFormElement: any = (elementName: any, elementSchema: any) => {
2936
if (flavor?.config_schema?.properties[elementName]?.type === 'string') {
37+
const extracted = elementSchema.split(/\./)[0];
38+
const secretName = extracted.replace(/{{|}}|\./g, '').trim();
39+
const filteredSecret = secrets?.filter(
40+
(item) => item.name === secretName,
41+
);
3042
return (
3143
<>
3244
{flavor?.config_schema?.properties[elementName].sensitive ? (
3345
<Box marginTop="lg" style={{ width: '30vw' }}>
3446
<EditField
3547
disabled
48+
viewSecretDetail={() => {
49+
history.push(
50+
routePaths.secret.configuration(
51+
filteredSecret[0]?.id,
52+
selectedWorkspace,
53+
),
54+
);
55+
}}
56+
filteredSecretId={filteredSecret[0]?.id}
3657
// onKeyDown={(e: any) => onPressEnter(e, 'string', elementName)}
3758
// onChangeText={(e: any) => onPressEnter(e, 'string', elementName)}
3859
label={titleCase(elementName) + ' (Secret)'}

src/ui/layouts/NonEditableConfig/useService.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import { useDispatch } from 'react-redux';
1+
import { useDispatch, useSelector } from 'react-redux';
22
// import { stackComponentSelectors } from '../../../redux/selectors';
33

44
// import YAML from 'json2yaml';
55
import { useEffect, useState } from 'react';
66
// import { useLocationPath } from '../../hooks';
7-
import { flavorPagesActions, flavorsActions } from '../../../redux/actions';
7+
import {
8+
flavorPagesActions,
9+
flavorsActions,
10+
secretsActions,
11+
} from '../../../redux/actions';
12+
import { workspaceSelectors } from '../../../redux/selectors';
813

914
interface ServiceInterface {
1015
flavor: any;
@@ -13,7 +18,7 @@ interface ServiceInterface {
1318
export const useService = ({ details }: { details: any }): ServiceInterface => {
1419
// const locationPath = useLocationPath();
1520
const [flavor, setFlavor] = useState();
16-
// debugger;
21+
const selectedWorkspace = useSelector(workspaceSelectors.selectedWorkspace);
1722
const dispatch = useDispatch();
1823
useEffect(() => {
1924
setFetching(true);
@@ -28,6 +33,12 @@ export const useService = ({ details }: { details: any }): ServiceInterface => {
2833
onFailure: () => setFetching(false),
2934
}),
3035
);
36+
dispatch(
37+
secretsActions.getMy({
38+
size: 1000,
39+
workspace: selectedWorkspace,
40+
}),
41+
);
3142
// eslint-disable-next-line react-hooks/exhaustive-deps
3243
}, []);
3344

src/ui/layouts/secrets/RegisterSecret/Register/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export const Register: React.FC<Props> = (state: any) => {
191191
updatedRouteState.state.inputData[
192192
state.state.secretKey
193193
] = `{{ ${secretName}.${inputFields[0].key} }}`;
194-
194+
updatedRouteState.state.secretId = id;
195195
history.push(state.state.pathName, updatedRouteState);
196196
} else if (state?.state?.routeFromEditComponent) {
197197
const updatedRouteState = {
@@ -201,6 +201,7 @@ export const Register: React.FC<Props> = (state: any) => {
201201
state.state.secretKey
202202
] = `{{ ${secretName}.${inputFields[0].key} }}`;
203203

204+
updatedRouteState.state.secretId = id;
204205
history.push(state.state.pathName, updatedRouteState);
205206
} else {
206207
history.push(routePaths.secret.configuration(id, selectedWorkspace));

src/ui/layouts/secrets/Selector/Selector.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface Props {
1717
onSetInputFields: any;
1818
routeState?: any;
1919
onSubmit?: any;
20+
childStateRef?: any;
2021
}
2122

2223
const Selector: React.FC<Props> = ({
@@ -25,14 +26,30 @@ const Selector: React.FC<Props> = ({
2526
values,
2627
routeState,
2728
onSubmit,
29+
childStateRef,
2830
}) => {
2931
// const [key, setKey] = useState('');
3032
// const [value, setValue] = useState('');
3133
const [inputFields, setInputFields] = useState([]) as any;
34+
useEffect(() => {
35+
if (values?.length) {
36+
childStateRef.current = inputFields;
37+
}
38+
// eslint-disable-next-line react-hooks/exhaustive-deps
39+
}, [inputFields, childStateRef]);
3240
useEffect(() => {
3341
// ...values,
3442
// { key: '', value: '' },
3543
if (
44+
(routeState?.state?.routeFromComponent ||
45+
routeState?.state?.routeFromEditComponent) &&
46+
routeState?.state?.secretId
47+
) {
48+
setInputFields([...values]);
49+
if (values?.length) {
50+
childStateRef.current = values;
51+
}
52+
} else if (
3653
routeState?.state?.routeFromComponent ||
3754
routeState?.state?.routeFromEditComponent
3855
) {
@@ -58,20 +75,21 @@ const Selector: React.FC<Props> = ({
5875
};
5976

6077
setInputFields([...inputFields, secretKeyValuefromRoute]);
78+
} else if (values?.length && !routeState?.state?.routeFromEditComponent) {
79+
setInputFields([...values]);
80+
childStateRef.current = values;
6181
}
62-
// else if (values?.length && !routeState?.state?.routeFromEditComponent) {
63-
// setInputFields([...values]);
64-
// }
6582
} else if (
6683
values?.length &&
6784
!routeState?.state?.routeFromComponent &&
6885
!routeState?.state?.routeFromEditComponent
6986
) {
7087
setInputFields([...values]);
88+
childStateRef.current = values;
7189
} else {
7290
setInputFields([{ key: '', value: '' }]);
7391
}
74-
92+
// debugger;
7593
// eslint-disable-next-line react-hooks/exhaustive-deps
7694
}, [routeState, setInputFields]);
7795
console.log(inputFields, routeState, 'inputFisdsdeldsinputFields');
@@ -107,6 +125,7 @@ const Selector: React.FC<Props> = ({
107125

108126
setInputFields(values);
109127
onSetInputFields(values);
128+
110129
// const keys = values.map((object) => object.key);
111130
// const value = values.map((object) => object.value);
112131

0 commit comments

Comments
 (0)