fix(frontend): fixed incorrect encoding of labels in volume forms

pull/81/head
Samuel Rowe 3 years ago
parent 7576d1693b
commit 6237bc0773

@ -1,7 +1,5 @@
import lodash from "lodash";
import * as yup from "yup"; import * as yup from "yup";
import { IEditVolumeForm, IVolumeNodeItem } from "../../../types"; import { IEditVolumeForm, IVolumeNodeItem } from "../../../types";
import { checkArray } from "../../../utils/forms";
export const validationSchema = yup.object({ export const validationSchema = yup.object({
entryName: yup entryName: yup
@ -36,19 +34,14 @@ export const getInitialValues = (node?: IVolumeNodeItem): IEditVolumeForm => {
const { node_name = "" } = canvasConfig; const { node_name = "" } = canvasConfig;
const { name = "", labels } = volumeConfig; const { name = "", labels } = volumeConfig;
const labels0: string[] = checkArray(labels, "labels");
return { return {
...initialValues, ...initialValues,
entryName: node_name, entryName: node_name,
volumeName: name, volumeName: name,
labels: labels0.map((label) => { labels: Object.entries(labels as any).map(([key, value]: any) => ({
const [key, value] = label.split("="); key,
return { value
key, }))
value
};
})
}; };
}; };
@ -69,8 +62,8 @@ export const getFinalValues = (
}, },
volumeConfig: { volumeConfig: {
name: values.volumeName, name: values.volumeName,
labels: labels.map( labels: Object.fromEntries(
(label) => `${label.key}${label.value ? `=${label.value}` : ""}` labels.map((label) => [label.key, label.value])
) )
} }
} as any; } as any;

Loading…
Cancel
Save