From 8a3b8a29a70aa49e333d60f2163ad23c7d49cd6d Mon Sep 17 00:00:00 2001 From: zzxwill Date: Mon, 8 Feb 2021 19:29:29 +0800 Subject: [PATCH] don't set empty key into to Appfile --- .../src/pages/CreateApplication/index.tsx | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/dashboard/src/pages/CreateApplication/index.tsx b/dashboard/src/pages/CreateApplication/index.tsx index c3d676e56..7cde36855 100644 --- a/dashboard/src/pages/CreateApplication/index.tsx +++ b/dashboard/src/pages/CreateApplication/index.tsx @@ -71,12 +71,31 @@ export default (): React.ReactNode => { if (valid.length > 0) { alert(`invalid:${valid.toString()}`); } - const servicesDict = {} servicesDict[serviceName] = { type: workloadType, - formData, } + + Object.entries(formData).forEach((([key, value]) => { + // eslint-disable-next-line default-case + switch (typeof value) { + case "number": + servicesDict[serviceName][key] = value + break + case "string": + if ((value === null) || (value === "")){ + break + } + servicesDict[serviceName][key] = value + break + case "object": + if ((Array.isArray(value) && value.length)) { + servicesDict[serviceName][key] = value + break + } + } + })) + const appFile = { name: applicationName, services: servicesDict,