From 662190af93f9b08d3854ae600937605a532fdbef Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Wed, 3 Apr 2024 19:57:47 +0200 Subject: [PATCH 1/6] fix error handling --- cyclops-ui/src/components/pages/new_module.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cyclops-ui/src/components/pages/new_module.tsx b/cyclops-ui/src/components/pages/new_module.tsx index 729c0fac..5d066738 100644 --- a/cyclops-ui/src/components/pages/new_module.tsx +++ b/cyclops-ui/src/components/pages/new_module.tsx @@ -340,8 +340,8 @@ const NewModule = () => { }); } else { setError({ - message: error.message, - description: error.response.data, + message: error.response.data.message, + description: error.response.data.description, }); } }); @@ -381,9 +381,10 @@ const NewModule = () => { window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { + console.log("error za initial", error) setError({ - message: error.message, - description: error.response.data, + message: error.response.data.message, + description: error.response.data.description, }); } }); From b644dbf741e2a259c464dedca7b2a8b513710069 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Wed, 3 Apr 2024 19:59:31 +0200 Subject: [PATCH 2/6] remove logging --- cyclops-ui/src/components/pages/new_module.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/cyclops-ui/src/components/pages/new_module.tsx b/cyclops-ui/src/components/pages/new_module.tsx index 5d066738..6f4e3692 100644 --- a/cyclops-ui/src/components/pages/new_module.tsx +++ b/cyclops-ui/src/components/pages/new_module.tsx @@ -381,7 +381,6 @@ const NewModule = () => { window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { - console.log("error za initial", error) setError({ message: error.response.data.message, description: error.response.data.description, From a9bd5d7baae26fdb01f3a0fdcd412e7a465c8d54 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Wed, 3 Apr 2024 20:57:05 +0200 Subject: [PATCH 3/6] handle default error --- .../src/components/pages/new_module.tsx | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/cyclops-ui/src/components/pages/new_module.tsx b/cyclops-ui/src/components/pages/new_module.tsx index 6f4e3692..c42456ec 100644 --- a/cyclops-ui/src/components/pages/new_module.tsx +++ b/cyclops-ui/src/components/pages/new_module.tsx @@ -339,10 +339,17 @@ const NewModule = () => { window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { - setError({ - message: error.response.data.message, - description: error.response.data.description, - }); + if (error.response.data) { + setError({ + message: error.response.data.message || "Error calling Cyclops backend", + description: error.response.data.description || "Error calling Cyclops backend", + }); + } else { + setError({ + message: "Error calling Cyclops backend", + description: "Error calling Cyclops backend", + }); + } } }); @@ -381,10 +388,17 @@ const NewModule = () => { window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { - setError({ - message: error.response.data.message, - description: error.response.data.description, - }); + if (error.response.data) { + setError({ + message: error.response.data.message || "Error calling Cyclops backend", + description: error.response.data.description || "Error calling Cyclops backend", + }); + } else { + setError({ + message: "Error calling Cyclops backend", + description: "Error calling Cyclops backend", + }); + } } }); From 1a20c26ec363e7b6f36b59f43f195f692bf679b5 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Wed, 3 Apr 2024 21:15:31 +0200 Subject: [PATCH 4/6] =?UTF-8?q?=E2=9A=A0=EF=B8=8F=20handle=20axios=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/pages/new_module.tsx | 70 ++++++++----------- 1 file changed, 28 insertions(+), 42 deletions(-) diff --git a/cyclops-ui/src/components/pages/new_module.tsx b/cyclops-ui/src/components/pages/new_module.tsx index c42456ec..3d32911c 100644 --- a/cyclops-ui/src/components/pages/new_module.tsx +++ b/cyclops-ui/src/components/pages/new_module.tsx @@ -264,17 +264,17 @@ const NewModule = () => { }) .catch((error) => { setLoading(false); - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), - description: - "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + message: error.response.data.message || String(error), + description: error.response.data.description || "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ - message: error.message, - description: error.response.data, + message: String(error), + description: + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); @@ -331,25 +331,18 @@ const NewModule = () => { }) .catch(function (error) { setLoadingTemplate(false); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: error.response.data.message || String(error), + description: error.response.data.description || "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: - "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - if (error.response.data) { - setError({ - message: error.response.data.message || "Error calling Cyclops backend", - description: error.response.data.description || "Error calling Cyclops backend", - }); - } else { - setError({ - message: "Error calling Cyclops backend", - description: "Error calling Cyclops backend", - }); - } } }); @@ -380,25 +373,18 @@ const NewModule = () => { }) .catch(function (error) { setLoadingTemplateInitialValues(false); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: error.response.data.message || String(error), + description: error.response.data.description || "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: - "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - if (error.response.data) { - setError({ - message: error.response.data.message || "Error calling Cyclops backend", - description: error.response.data.description || "Error calling Cyclops backend", - }); - } else { - setError({ - message: "Error calling Cyclops backend", - description: "Error calling Cyclops backend", - }); - } } }); @@ -1029,17 +1015,17 @@ const NewModule = () => { .catch(function (error) { // setLoadingTemplate(false); // setSuccessLoad(false); - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), + message: error.response.data.message, description: - "Error loading file; Check if the file path is correct", + "Unable to fetch values file; Check if the file path is correct", }); } else { setError({ - message: error.response.data, + message: String(error), description: - "Unable to fetch values file; Check if the file path is correct", + "Error loading file; Check if the file path is correct", }); } }); From ec164f960cde9a37212200e6f21b9ff592adb448 Mon Sep 17 00:00:00 2001 From: KaradzaJuraj Date: Wed, 3 Apr 2024 22:31:06 +0200 Subject: [PATCH 5/6] fix error handling on axios requests --- .../components/k8s-resources/ConfigMap.tsx | 13 +++- .../components/k8s-resources/Deployment.tsx | 43 +++++++---- .../src/components/k8s-resources/Pod.tsx | 41 ++++++---- .../src/components/k8s-resources/Service.tsx | 13 +++- .../components/k8s-resources/StatefulSet.tsx | 43 +++++++---- .../src/components/pages/ModuleDetails.tsx | 75 ++++++++++--------- .../src/components/pages/edit_module.tsx | 39 ++++++---- cyclops-ui/src/components/pages/modules.tsx | 13 ++-- .../src/components/pages/new_module.tsx | 29 ++++--- .../src/components/pages/node_details.tsx | 13 ++-- cyclops-ui/src/components/pages/nodes.tsx | 13 ++-- 11 files changed, 213 insertions(+), 122 deletions(-) diff --git a/cyclops-ui/src/components/k8s-resources/ConfigMap.tsx b/cyclops-ui/src/components/k8s-resources/ConfigMap.tsx index 88d898e9..29140c46 100644 --- a/cyclops-ui/src/components/k8s-resources/ConfigMap.tsx +++ b/cyclops-ui/src/components/k8s-resources/ConfigMap.tsx @@ -30,16 +30,21 @@ const ConfigMap = ({ name, namespace }: Props) => { setConfigMap(res.data); }) .catch((error) => { - console.log(error); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: error.response.data.message || String(error), + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - setError(error.response.data); } }); } diff --git a/cyclops-ui/src/components/k8s-resources/Deployment.tsx b/cyclops-ui/src/components/k8s-resources/Deployment.tsx index 883ca719..53fc38e7 100644 --- a/cyclops-ui/src/components/k8s-resources/Deployment.tsx +++ b/cyclops-ui/src/components/k8s-resources/Deployment.tsx @@ -54,16 +54,21 @@ const Deployment = ({ name, namespace }: Props) => { setDeployment(res.data); }) .catch((error) => { - console.log(error); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: error.response.data.message || String(error), + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - setError(error.response.data); } }); } @@ -185,16 +190,21 @@ const Deployment = ({ name, namespace }: Props) => { } }) .catch((error) => { - console.log(error); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: error.response.data.message || String(error), + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - setError(error.response.data); } }); }; @@ -291,8 +301,17 @@ const Deployment = ({ name, namespace }: Props) => { } }) .catch((error) => { - console.log(error); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: + error.response.data.message || String(error), + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__ + .REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: @@ -300,8 +319,6 @@ const Deployment = ({ name, namespace }: Props) => { window.__RUNTIME_CONFIG__ .REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - setError(error.response.data); } }); setLogsModal({ @@ -327,7 +344,7 @@ const Deployment = ({ name, namespace }: Props) => { open={logsModal.on} onOk={handleCancelLogs} onCancel={handleCancelLogs} - cancelButtonProps={{ style: { display: 'none' } }} + cancelButtonProps={{ style: { display: "none" } }} width={"60%"} > diff --git a/cyclops-ui/src/components/k8s-resources/Pod.tsx b/cyclops-ui/src/components/k8s-resources/Pod.tsx index d6b32618..5ece824b 100644 --- a/cyclops-ui/src/components/k8s-resources/Pod.tsx +++ b/cyclops-ui/src/components/k8s-resources/Pod.tsx @@ -77,16 +77,21 @@ const Pod = ({ name, namespace }: Props) => { setPod(res.data); }) .catch((error) => { - console.log(error); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: error.response.data.message || String(error), + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - setError(error.response.data); } }); } @@ -206,16 +211,21 @@ const Pod = ({ name, namespace }: Props) => { } }) .catch((error) => { - console.log(error); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: error.response.data.message || String(error), + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - setError(error.response.data); } }); }; @@ -292,16 +302,21 @@ const Pod = ({ name, namespace }: Props) => { } }) .catch((error) => { - console.log(error); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: error.response.data.message || String(error), + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - setError(error.response.data); } }); setLogsModal({ @@ -321,7 +336,7 @@ const Pod = ({ name, namespace }: Props) => { open={logsModal.on} onOk={handleCancelLogs} onCancel={handleCancelLogs} - cancelButtonProps={{ style: { display: 'none' } }} + cancelButtonProps={{ style: { display: "none" } }} width={"60%"} > diff --git a/cyclops-ui/src/components/k8s-resources/Service.tsx b/cyclops-ui/src/components/k8s-resources/Service.tsx index 4ee35d9d..c4ff0e13 100644 --- a/cyclops-ui/src/components/k8s-resources/Service.tsx +++ b/cyclops-ui/src/components/k8s-resources/Service.tsx @@ -42,16 +42,21 @@ const Service = ({ name, namespace }: Props) => { setService(res.data); }) .catch((error) => { - console.log(error); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: error.response.data.message || String(error), + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - setError(error.response.data); } }); } diff --git a/cyclops-ui/src/components/k8s-resources/StatefulSet.tsx b/cyclops-ui/src/components/k8s-resources/StatefulSet.tsx index 08a48b49..6f0c052b 100644 --- a/cyclops-ui/src/components/k8s-resources/StatefulSet.tsx +++ b/cyclops-ui/src/components/k8s-resources/StatefulSet.tsx @@ -54,16 +54,21 @@ const StatefulSet = ({ name, namespace }: Props) => { setStatefulSet(res.data); }) .catch((error) => { - console.log(error); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: error.response.data.message || String(error), + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - setError(error.response.data); } }); } @@ -185,16 +190,21 @@ const StatefulSet = ({ name, namespace }: Props) => { } }) .catch((error) => { - console.log(error); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: error.response.data.message || String(error), + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - setError(error.response.data); } }); }; @@ -291,8 +301,17 @@ const StatefulSet = ({ name, namespace }: Props) => { } }) .catch((error) => { - console.log(error); - if (error.response === undefined) { + if (error?.response?.data) { + setError({ + message: + error.response.data.message || String(error), + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__ + .REACT_APP_CYCLOPS_CTRL_HOST, + }); + } else { setError({ message: String(error), description: @@ -300,8 +319,6 @@ const StatefulSet = ({ name, namespace }: Props) => { window.__RUNTIME_CONFIG__ .REACT_APP_CYCLOPS_CTRL_HOST, }); - } else { - setError(error.response.data); } }); setLogsModal({ @@ -327,7 +344,7 @@ const StatefulSet = ({ name, namespace }: Props) => { open={logsModal.on} onOk={handleCancelLogs} onCancel={handleCancelLogs} - cancelButtonProps={{ style: { display: 'none' } }} + cancelButtonProps={{ style: { display: "none" } }} width={"60%"} > diff --git a/cyclops-ui/src/components/pages/ModuleDetails.tsx b/cyclops-ui/src/components/pages/ModuleDetails.tsx index acbe0c28..13a5a5d5 100644 --- a/cyclops-ui/src/components/pages/ModuleDetails.tsx +++ b/cyclops-ui/src/components/pages/ModuleDetails.tsx @@ -152,21 +152,22 @@ const ModuleDetails = () => { }); }) .catch((error) => { - console.log(error); - console.log(error.response); setLoading(false); setLoadModule(true); - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), + message: error.response.data.message || String(error), description: + error.response.data.description || "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ - message: error.message, - description: error.response.data, + message: String(error), + description: + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); @@ -180,21 +181,22 @@ const ModuleDetails = () => { setLoadModule(true); }) .catch((error) => { - console.log(error); - console.log(error.response); setLoading(false); setLoadModule(true); - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), + message: error.response.data.message || String(error), description: + error.response.data.description || "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ - message: error.message, - description: error.response.data, + message: String(error), + description: + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); @@ -208,21 +210,22 @@ const ModuleDetails = () => { setLoadResources(true); }) .catch((error) => { - console.log(error); - console.log(error.response); setLoading(false); setLoadResources(true); - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), + message: error.response.data.message || String(error), description: + error.response.data.description || "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ - message: error.message, - description: error.response.data, + message: String(error), + description: + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); @@ -285,20 +288,21 @@ const ModuleDetails = () => { window.location.href = "/modules"; }) .catch((error) => { - console.log(error); - console.log(error.response); setLoading(false); - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), + message: error.response.data.message || String(error), description: + error.response.data.description || "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ - message: error.message, - description: error.response.data, + message: String(error), + description: + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); @@ -642,20 +646,21 @@ const ModuleDetails = () => { fetchModuleResources(); }) .catch((error) => { - console.log(error); - console.log(error.response); setLoading(false); - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), + message: error.response.data.message || String(error), description: + error.response.data.description || "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ - message: error.message, - description: error.response.data, + message: String(error), + description: + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); diff --git a/cyclops-ui/src/components/pages/edit_module.tsx b/cyclops-ui/src/components/pages/edit_module.tsx index af49c872..8428f730 100644 --- a/cyclops-ui/src/components/pages/edit_module.tsx +++ b/cyclops-ui/src/components/pages/edit_module.tsx @@ -193,33 +193,39 @@ const EditModule = () => { }) .catch((error) => { setLoadTemplate(true); - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), + message: error.response.data.message || String(error), description: + error.response.data.description || "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ - message: error.message, - description: error.response.data, + message: String(error), + description: + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); }) .catch((error) => { - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), + message: error.response.data.message || String(error), description: + error.response.data.description || "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ - message: error.message, - description: error.response.data, + message: String(error), + description: + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); @@ -307,17 +313,20 @@ const EditModule = () => { window.location.href = "/modules/" + moduleName; }) .catch((error) => { - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), + message: error.response.data.message || String(error), description: + error.response.data.description || "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ - message: error.message, - description: error.response.data, + message: String(error), + description: + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); diff --git a/cyclops-ui/src/components/pages/modules.tsx b/cyclops-ui/src/components/pages/modules.tsx index daad952e..5084bcf0 100644 --- a/cyclops-ui/src/components/pages/modules.tsx +++ b/cyclops-ui/src/components/pages/modules.tsx @@ -37,17 +37,20 @@ const Modules = () => { setFilteredData(res.data); }) .catch((error) => { - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), + message: error.response.data.message || String(error), description: + error.response.data.description || "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ - message: error.message, - description: error.response.data, + message: String(error), + description: + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); diff --git a/cyclops-ui/src/components/pages/new_module.tsx b/cyclops-ui/src/components/pages/new_module.tsx index 3d32911c..627a0e88 100644 --- a/cyclops-ui/src/components/pages/new_module.tsx +++ b/cyclops-ui/src/components/pages/new_module.tsx @@ -267,14 +267,17 @@ const NewModule = () => { if (error?.response?.data) { setError({ message: error.response.data.message || String(error), - description: error.response.data.description || "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ message: String(error), description: - "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); @@ -334,14 +337,17 @@ const NewModule = () => { if (error?.response?.data) { setError({ message: error.response.data.message || String(error), - description: error.response.data.description || "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ message: String(error), description: - "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); @@ -376,14 +382,17 @@ const NewModule = () => { if (error?.response?.data) { setError({ message: error.response.data.message || String(error), - description: error.response.data.description || "Check if Cyclops backend is available on: " + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + description: + error.response.data.description || + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ message: String(error), description: - "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); @@ -1019,7 +1028,7 @@ const NewModule = () => { setError({ message: error.response.data.message, description: - "Unable to fetch values file; Check if the file path is correct", + "Unable to fetch values file; Check if the file path is correct", }); } else { setError({ diff --git a/cyclops-ui/src/components/pages/node_details.tsx b/cyclops-ui/src/components/pages/node_details.tsx index 0c9a577b..dcea5b1b 100644 --- a/cyclops-ui/src/components/pages/node_details.tsx +++ b/cyclops-ui/src/components/pages/node_details.tsx @@ -205,17 +205,20 @@ const NodeDetails = () => { }); }) .catch((error) => { - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), + message: error.response.data.message || String(error), description: + error.response.data.description || "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ - message: error.message, - description: error.response.data, + message: String(error), + description: + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); diff --git a/cyclops-ui/src/components/pages/nodes.tsx b/cyclops-ui/src/components/pages/nodes.tsx index 9895703a..30dfa1c4 100644 --- a/cyclops-ui/src/components/pages/nodes.tsx +++ b/cyclops-ui/src/components/pages/nodes.tsx @@ -23,17 +23,20 @@ const Nodes = () => { setFilteredNodes(res.data); }) .catch((error) => { - if (error.response === undefined) { + if (error?.response?.data) { setError({ - message: String(error), + message: error.response.data.message || String(error), description: + error.response.data.description || "Check if Cyclops backend is available on: " + - window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } else { setError({ - message: error.message, - description: error.response.data, + message: String(error), + description: + "Check if Cyclops backend is available on: " + + window.__RUNTIME_CONFIG__.REACT_APP_CYCLOPS_CTRL_HOST, }); } }); From 6f906e88682b26d68d66913fdd1e1b015825f5c9 Mon Sep 17 00:00:00 2001 From: KaradzaJuraj Date: Wed, 3 Apr 2024 23:08:55 +0200 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=93=8F=20resolve=20merge=20conflict?= =?UTF-8?q?=20and=20standardise=20page=20names?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/{edit_module.tsx => EditModule.tsx} | 0 .../pages/{new_module.tsx => NewModule.tsx} | 0 .../pages/{node_details.tsx => NodeDetails.tsx} | 0 .../src/components/pages/{nodes.tsx => Nodes.tsx} | 0 cyclops-ui/src/routes/index.tsx | 12 +++++------- 5 files changed, 5 insertions(+), 7 deletions(-) rename cyclops-ui/src/components/pages/{edit_module.tsx => EditModule.tsx} (100%) rename cyclops-ui/src/components/pages/{new_module.tsx => NewModule.tsx} (100%) rename cyclops-ui/src/components/pages/{node_details.tsx => NodeDetails.tsx} (100%) rename cyclops-ui/src/components/pages/{nodes.tsx => Nodes.tsx} (100%) diff --git a/cyclops-ui/src/components/pages/edit_module.tsx b/cyclops-ui/src/components/pages/EditModule.tsx similarity index 100% rename from cyclops-ui/src/components/pages/edit_module.tsx rename to cyclops-ui/src/components/pages/EditModule.tsx diff --git a/cyclops-ui/src/components/pages/new_module.tsx b/cyclops-ui/src/components/pages/NewModule.tsx similarity index 100% rename from cyclops-ui/src/components/pages/new_module.tsx rename to cyclops-ui/src/components/pages/NewModule.tsx diff --git a/cyclops-ui/src/components/pages/node_details.tsx b/cyclops-ui/src/components/pages/NodeDetails.tsx similarity index 100% rename from cyclops-ui/src/components/pages/node_details.tsx rename to cyclops-ui/src/components/pages/NodeDetails.tsx diff --git a/cyclops-ui/src/components/pages/nodes.tsx b/cyclops-ui/src/components/pages/Nodes.tsx similarity index 100% rename from cyclops-ui/src/components/pages/nodes.tsx rename to cyclops-ui/src/components/pages/Nodes.tsx diff --git a/cyclops-ui/src/routes/index.tsx b/cyclops-ui/src/routes/index.tsx index 33e9557f..327284e6 100644 --- a/cyclops-ui/src/routes/index.tsx +++ b/cyclops-ui/src/routes/index.tsx @@ -3,16 +3,14 @@ import PathConstants from "./PathConstants"; const Home = React.lazy(() => import("../components/pages/Modules/Modules")); const Modules = React.lazy(() => import("../components/pages/Modules/Modules")); -const NewModule = React.lazy(() => import("../components/pages/new_module")); +const NewModule = React.lazy(() => import("../components/pages/NewModule")); const ModuleDetails = React.lazy( () => import("../components/pages/ModuleDetails") ); -const EditModule = React.lazy(() => import("../components/pages/edit_module")); -const ModuleHistory = React.lazy(() => import("../components/pages/history")); -const Nodes = React.lazy(() => import("../components/pages/nodes")); -const NodeDetails = React.lazy( - () => import("../components/pages/node_details") -); +const EditModule = React.lazy(() => import("../components/pages/EditModule")); +const ModuleHistory = React.lazy(() => import("../components/pages/History")); +const Nodes = React.lazy(() => import("../components/pages/Nodes")); +const NodeDetails = React.lazy(() => import("../components/pages/NodeDetails")); const routes = [ { path: PathConstants.HOME, element: },