Skip to content

Commit 06df6df

Browse files
Merge pull request #332 from zenml-io/QA-Fixes
Qa fixes
2 parents 9e2f359 + 27986b8 commit 06df6df

File tree

3 files changed

+95
-69
lines changed

3 files changed

+95
-69
lines changed

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

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,34 @@ const Selector: React.FC<Props> = ({
3232
useEffect(() => {
3333
// ...values,
3434
// { key: '', value: '' },
35-
if (routeState?.state?.routeFromComponent) {
36-
const secretKeyValuefromRoute: any = {
37-
key: routeState?.state?.secretKey,
38-
value: routeState?.state?.inputData[routeState?.state?.secretKey],
39-
};
40-
41-
setInputFields([...inputFields, secretKeyValuefromRoute]);
42-
} else if (values?.length && !routeState?.state?.routeFromComponent) {
43-
setInputFields([...values]);
44-
} else {
45-
setInputFields([{ key: '', value: '' }]);
46-
}
47-
48-
if (routeState?.state?.routeFromEditComponent) {
49-
const secretKeyValuefromRoute: any = {
50-
key: routeState?.state?.secretKey,
51-
value:
52-
routeState?.state?.mappedConfiguration[routeState?.state?.secretKey],
53-
};
54-
55-
setInputFields([...inputFields, secretKeyValuefromRoute]);
56-
} else if (values?.length && !routeState?.state?.routeFromEditComponent) {
57-
setInputFields([...values]);
35+
if (
36+
routeState?.state?.routeFromComponent ||
37+
routeState?.state?.routeFromEditComponent
38+
) {
39+
if (routeState?.state?.routeFromComponent) {
40+
const secretKeyValuefromRoute: any = {
41+
key: routeState?.state?.secretKey,
42+
value: routeState?.state?.inputData[routeState?.state?.secretKey],
43+
};
44+
45+
setInputFields([...inputFields, secretKeyValuefromRoute]);
46+
} else if (values?.length && !routeState?.state?.routeFromComponent) {
47+
setInputFields([...values]);
48+
}
49+
50+
if (routeState?.state?.routeFromEditComponent) {
51+
const secretKeyValuefromRoute: any = {
52+
key: routeState?.state?.secretKey,
53+
value:
54+
routeState?.state?.mappedConfiguration[
55+
routeState?.state?.secretKey
56+
],
57+
};
58+
59+
setInputFields([...inputFields, secretKeyValuefromRoute]);
60+
} else if (values?.length && !routeState?.state?.routeFromEditComponent) {
61+
setInputFields([...values]);
62+
}
5863
} else {
5964
setInputFields([{ key: '', value: '' }]);
6065
}

src/ui/layouts/stackComponents/StackDetail/Configuration/index.tsx

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ export const Configuration: React.FC<{ stackId: TId; loading?: boolean }> = ({
423423
</>
424424
))}
425425
{inputFields.map((inputField: any, index: any) => (
426-
427426
<FlexBox.Row key={`${inputField}~${index}`}>
428427
<Box marginTop="lg">
429428
<EditField
@@ -482,7 +481,30 @@ export const Configuration: React.FC<{ stackId: TId; loading?: boolean }> = ({
482481

483482
<FlexBox.Row>
484483
<div className="form-row">
485-
{mappedObject &&
484+
{mappedObject && mappedObject[elementName].length < 1 ? (
485+
<>
486+
{' '}
487+
<Fragment>
488+
<div className="form-group col-sm-8">
489+
<EditField
490+
disabled
491+
className={styles.field}
492+
label={'Value'}
493+
value={''}
494+
placeholder={''}
495+
/>
496+
</div>
497+
<div
498+
className="col-sx-2 "
499+
style={{
500+
justifyContent: 'space-between',
501+
display: 'flex',
502+
marginTop: '10px',
503+
}}
504+
></div>
505+
</Fragment>
506+
</>
507+
) : (
486508
mappedObject[elementName]?.map((item: any, index: any) => (
487509
<Fragment>
488510
<div className="form-group col-sm-8">
@@ -501,18 +523,10 @@ export const Configuration: React.FC<{ stackId: TId; loading?: boolean }> = ({
501523
display: 'flex',
502524
marginTop: '10px',
503525
}}
504-
>
505-
<div
506-
style={{
507-
display: 'flex',
508-
flexDirection: 'row',
509-
justifyContent: 'space-between',
510-
alignItems: 'center',
511-
}}
512-
></div>
513-
</div>
526+
></div>
514527
</Fragment>
515-
))}
528+
))
529+
)}
516530
{/* {inputFields
517531
?.filter((x: any) => x.hasOwnProperty(props.name))
518532
.map((inputField: any, index: any) => (

src/ui/layouts/stackComponents/UpdateComponent/UpdateConfig/index.tsx

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,19 @@ export const UpdateConfig: React.FC<{
151151
function (r: any, name: any) {
152152
return (
153153
(r[name] =
154-
flavor?.configSchema?.properties[name].type === 'string' &&
155-
flavor?.configSchema?.properties[name].default === undefined
154+
flavor?.configSchema?.properties[name]?.type === 'string' &&
155+
flavor?.configSchema?.properties[name]?.default === undefined
156156
? ''
157-
: flavor?.configSchema?.properties[name].default),
157+
: flavor?.configSchema?.properties[name]?.type === 'array' &&
158+
!flavor?.configSchema?.properties[name]?.default?.length
159+
? ['']
160+
: flavor?.configSchema?.properties[name]?.default),
158161
r
159162
);
160163
},
161164
{},
162165
);
163-
166+
console.log(result, 'asdasdasd23232');
164167
const mappedObject = {
165168
...result,
166169
...stackComponent?.configuration,
@@ -209,41 +212,45 @@ export const UpdateConfig: React.FC<{
209212
let tempFinal: any = {};
210213

211214
Object.keys(inputFields).forEach((key) => {
212-
const newObj: any = {};
213-
inputFields[key].forEach((obj: any) => {
214-
if (obj.key !== undefined && (obj.key !== '' || obj.value !== '')) {
215-
if (newObj[obj.key] !== undefined) {
216-
dispatch(
217-
showToasterAction({
218-
description: 'Key already exists.',
219-
type: toasterTypes.failure,
220-
}),
221-
);
222-
} else {
223-
newObj[obj.key] = obj.value;
215+
if (flavor?.configSchema?.properties[key].type !== 'array') {
216+
const newObj: any = {};
217+
inputFields[key].forEach((obj: any) => {
218+
if (obj.key !== undefined && (obj.key !== '' || obj.value !== '')) {
219+
if (newObj[obj.key] !== undefined) {
220+
dispatch(
221+
showToasterAction({
222+
description: 'Key already exists.',
223+
type: toasterTypes.failure,
224+
}),
225+
);
226+
} else {
227+
newObj[obj.key] = obj.value;
228+
}
224229
}
225-
}
226-
});
227-
tempFinal[key] = newObj;
230+
});
231+
tempFinal[key] = newObj;
232+
}
228233
});
229234
const final: any = {};
230235

231236
Object.keys(inputFields).forEach((key) => {
232-
const newObj: any = {};
233-
inputFields[key].forEach((obj: any) => {
234-
if (obj.key !== undefined && (obj.key !== '' || obj.value !== '')) {
235-
if (newObj[obj.key] !== undefined) {
236-
dispatch(
237-
showToasterAction({
238-
description: 'Key already exists.',
239-
type: toasterTypes.failure,
240-
}),
241-
);
237+
if (flavor?.configSchema?.properties[key].type !== 'array') {
238+
const newObj: any = {};
239+
inputFields[key].forEach((obj: any) => {
240+
if (obj.key !== undefined && (obj.key !== '' || obj.value !== '')) {
241+
if (newObj[obj.key] !== undefined) {
242+
dispatch(
243+
showToasterAction({
244+
description: 'Key already exists.',
245+
type: toasterTypes.failure,
246+
}),
247+
);
248+
}
249+
newObj[obj.key] = obj.value;
242250
}
243-
newObj[obj.key] = obj.value;
244-
}
245-
});
246-
final[key] = newObj;
251+
});
252+
final[key] = newObj;
253+
}
247254
});
248255

249256
const body = {

0 commit comments

Comments
 (0)