fix(frontend): fixed logic for generating final values for service forms

pull/81/head
Samuel Rowe 3 years ago
parent df0b46ce59
commit 0ac83d064f

@ -1,6 +1,5 @@
import type { IEditServiceForm, IServiceNodeItem } from "../../../types"; import type { IEditServiceForm, IServiceNodeItem } from "../../../types";
import * as yup from "yup"; import * as yup from "yup";
import lodash from "lodash";
import { checkArray } from "../../../utils/forms"; import { checkArray } from "../../../utils/forms";
const initialValues: IEditServiceForm = { const initialValues: IEditServiceForm = {
@ -153,15 +152,12 @@ export const getFinalValues = (
): IServiceNodeItem => { ): IServiceNodeItem => {
const { environmentVariables, ports, volumes, labels } = values; const { environmentVariables, ports, volumes, labels } = values;
return lodash.mergeWith( return {
lodash.cloneDeep(previous) || { key: previous?.key ?? "service",
key: "service",
type: "SERVICE", type: "SERVICE",
inputs: ["op_source"], inputs: previous?.inputs ?? ["op_source"],
outputs: [], outputs: previous?.outputs ?? [],
config: {} config: (previous as any)?.config ?? {},
},
{
canvasConfig: { canvasConfig: {
node_name: values.serviceName node_name: values.serviceName
}, },
@ -192,12 +188,5 @@ export const getFinalValues = (
(label) => `${label.key}${label.value ? `=${label.value}` : ""}` (label) => `${label.key}${label.value ? `=${label.value}` : ""}`
) )
} }
}, } as any;
(obj, src) => {
if (!lodash.isNil(src)) {
return src;
}
return obj;
}
) as any;
}; };

Loading…
Cancel
Save