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

* Previously, final values were generated by merging with previous state.
   This caused unexpected overwriting of values. Therefore, we do not merge
   states anymore.
pull/78/head
Samuel Rowe 3 years ago
parent 2e2349f6ab
commit 46d03d809a

@ -127,41 +127,37 @@ export const getFinalValues = (
): INetworkNodeItem => { ): INetworkNodeItem => {
const { labels, driver, configurations, options } = values; const { labels, driver, configurations, options } = values;
return lodash.merge( return {
lodash.cloneDeep(previous) || { key: "network",
key: "network", type: "NETWORK",
type: "NETWORK", inputs: previous?.inputs ?? [],
inputs: [], outputs: previous?.outputs ?? [],
outputs: [], config: (previous as any)?.config ?? {},
config: {} canvasConfig: {
node_name: values.entryName
}, },
{ networkConfig: {
canvasConfig: { name: values.networkName,
node_name: values.entryName ipam: {
}, driver,
networkConfig: { config: configurations.map((configuration) => ({
name: values.networkName, subnet: configuration.subnet,
ipam: { ip_range: configuration.ipRange,
driver, gateway: configuration.gateway,
config: configurations.map((configuration) => ({ aux_addresses: Object.fromEntries(
subnet: configuration.subnet, configuration.auxAddresses.map((auxAddress) => [
ip_range: configuration.ipRange, auxAddress.hostName,
gateway: configuration.gateway, auxAddress.ipAddress
aux_addresses: Object.fromEntries( ])
configuration.auxAddresses.map((auxAddress) => [
auxAddress.hostName,
auxAddress.ipAddress
])
)
})),
options: Object.fromEntries(
options.map((option) => [option.key, option.value])
) )
}, })),
labels: Object.fromEntries( options: Object.fromEntries(
labels.map((label) => [label.key, label.value]) options.map((option) => [option.key, option.value])
) )
} },
labels: Object.fromEntries(
labels.map((label) => [label.key, label.value])
)
} }
) as any; } as any;
}; };

Loading…
Cancel
Save