From cc65b3412a949a8c807fcbdb6c6afb2139bd3712 Mon Sep 17 00:00:00 2001 From: Vladyslav Palyvoda Date: Thu, 14 Nov 2024 16:30:34 +0200 Subject: [PATCH] fix: Empty variables list (#483) --- Dockerfile | 2 +- .../components/Variables/index.tsx | 149 +++++++++++------- 2 files changed, 89 insertions(+), 62 deletions(-) diff --git a/Dockerfile b/Dockerfile index 80c4908a..41964b89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM epamedp/headlamp:0.22.35 +FROM epamedp/headlamp:0.22.36 COPY --chown=100:101 assets/ /headlamp/frontend COPY --chown=100:101 dist/main.js /headlamp/plugins/edp/main.js diff --git a/src/pages/stage-details/components/Variables/index.tsx b/src/pages/stage-details/components/Variables/index.tsx index 9c60ca2d..5a5c0d2e 100644 --- a/src/pages/stage-details/components/Variables/index.tsx +++ b/src/pages/stage-details/components/Variables/index.tsx @@ -51,69 +51,70 @@ export const Variables = ({ configMap }: { configMap: ConfigMapKubeObjectInterfa const theme = useTheme(); - const onSubmit = (values) => { - const configMapCopy = { ...configMap }; - configMapCopy.data = values.variables.reduce((acc, { key, value }) => { - acc[key] = value; - return acc; - }, {}); + const onSubmit = React.useCallback( + (values) => { + const configMapCopy = { ...configMap }; + configMapCopy.data = values.variables.reduce((acc, { key, value }) => { + acc[key] = value; + return acc; + }, {}); - editConfigMap({ configMapData: configMapCopy }); - reset(values, { keepValues: true }); - }; + editConfigMap({ configMapData: configMapCopy }); + reset(values, { keepValues: true }); + }, + [configMap, editConfigMap, reset] + ); - const appendNewRow = () => append({ key: '', value: '' }); + const appendNewRow = React.useCallback(() => append({ key: '', value: '' }), [append]); - return ( - - {!fields?.length ? ( - - ) : ( + const renderContent = React.useCallback(() => { + if (fields.length || dataEntries?.length) { + return (
- { - return { - name: ( - - ), - value: ( - - - - - t.typography.pxToRem(FORM_CONTROL_LABEL_HEIGHT) }}> - handleDelete(index)} size="medium"> - - - - - ), - }; - })} - /> + {fields.length ? ( + { + return { + name: ( + + ), + value: ( + + + + + t.typography.pxToRem(FORM_CONTROL_LABEL_HEIGHT) }}> + handleDelete(index)} size="medium"> + + + + + ), + }; + })} + /> + ) : ( + + )} t.typography.pxToRem(16) }}>