浏览代码

fix: porterYAMLErrors undefined

Soham Parekh 3 年之前
父节点
当前提交
bcf176a998

+ 4 - 7
dashboard/src/main/home/cluster-dashboard/preview-environments/deployments/DeploymentDetail.tsx

@@ -89,7 +89,7 @@ const DeploymentDetail = () => {
           return;
         }
 
-        setPorterYAMLErrors(data.errors);
+        setPorterYAMLErrors(data.errors ?? []);
       })
       .catch((err) => {
         console.error(err);
@@ -183,12 +183,9 @@ const DeploymentDetail = () => {
             Your porter.yaml file has errors. Please fix them before deploying.
             <LinkButton
               onClick={() => {
-                let yamlErrors = "";
-
-                porterYAMLErrors.forEach((err) => {
-                  yamlErrors += "- " + err + "\n";
-                });
-
+                const yamlErrors = porterYAMLErrors
+                  .map((err) => `- ${err}`)
+                  .join("\n");
                 setExpandedPorterYAMLErrors(yamlErrors);
               }}
             >

+ 2 - 2
dashboard/src/main/home/cluster-dashboard/preview-environments/deployments/DeploymentList.tsx

@@ -179,14 +179,14 @@ const DeploymentList = () => {
               : {};
           const porterYAMLErrors =
             validatePorterYAMLResponse.status === "fulfilled"
-              ? validatePorterYAMLResponse.value.data
+              ? validatePorterYAMLResponse.value.data.errors
               : [];
 
           if (!isSubscribed) {
             return;
           }
 
-          setPorterYAMLErrors(porterYAMLErrors.errors);
+          setPorterYAMLErrors(porterYAMLErrors);
           setDeploymentList(
             deploymentList.deployments || HARD_CODED_DEPLOYMENTS
           );