diff --git a/frontend/packages/gitops-plugin/locales/en/gitops-plugin.json b/frontend/packages/gitops-plugin/locales/en/gitops-plugin.json index b03f1b00a0e..c3bf7e157e0 100644 --- a/frontend/packages/gitops-plugin/locales/en/gitops-plugin.json +++ b/frontend/packages/gitops-plugin/locales/en/gitops-plugin.json @@ -1,7 +1,9 @@ { "Environments": "Environments", + "Error cannot retrieve environments": "Cannot retrieve environments. Ensure the Argo CD applications are available and check the log for the 'cluster' pod created by the GitOps Operator.", "Compatibility Issue": "Compatibility Issue", "Compatibility Issue Message": "It is detected that an older version of the GitOps Operator is installed. Please upgrade the GitOps Operator", + "Error Encountered": "Error Encountered", "Cluster URL not available": "Cluster URL not available", "{{message}}": "{{message}}", "by {{author}}": "by {{author}}", @@ -32,6 +34,7 @@ "Environment": "Environment", "Last deployment": "Last deployment", "No GitOps manifest URLs found": "No GitOps manifest URLs found", + "Error cannot retrieve applications": "Cannot retrieve applications. Ensure the Argo CD applications are available and check the log for the 'cluster' pod created by the GitOps Operator.", "No Application groups found": "No Application groups found", "Environment details were not found. Try reloading the page or contacting an administrator.": "Environment details were not found. Try reloading the page or contacting an administrator." } \ No newline at end of file diff --git a/frontend/packages/gitops-plugin/src/components/GitOpsDetailsPage.tsx b/frontend/packages/gitops-plugin/src/components/GitOpsDetailsPage.tsx index 549010b8206..f0d2f54b5a5 100644 --- a/frontend/packages/gitops-plugin/src/components/GitOpsDetailsPage.tsx +++ b/frontend/packages/gitops-plugin/src/components/GitOpsDetailsPage.tsx @@ -26,6 +26,7 @@ const GitOpsDetailsPage: React.FC = ({ match, location } const environmentBaseURI = `/api/gitops/environments`; const environmentBaseURIV2 = `/api/gitops/environment`; const [envs, emptyStateMsg] = useEnvDetails(appName, manifestURL, pipelinesBaseURI); + const [error, setError] = React.useState(null); React.useEffect(() => { const getEnvsData = async () => { @@ -37,13 +38,15 @@ const GitOpsDetailsPage: React.FC = ({ match, location } getEnvData(environmentBaseURIV2, environmentBaseURI, env, applicationBaseURI), ), ); - } catch {} // eslint-disable-line no-empty + } catch (err) { + setError(err); + } setEnvsData(data); } }; getEnvsData(); - }, [applicationBaseURI, environmentBaseURIV2, environmentBaseURI, envs, manifestURL]); + }, [applicationBaseURI, environmentBaseURIV2, environmentBaseURI, envs, manifestURL, error]); return ( <> @@ -57,7 +60,7 @@ const GitOpsDetailsPage: React.FC = ({ match, location } badge={} /> {!emptyStateMsg ? ( - + ) : ( )} diff --git a/frontend/packages/gitops-plugin/src/components/details/GitOpsDetails.scss b/frontend/packages/gitops-plugin/src/components/details/GitOpsDetails.scss index a824e74973d..6a284eaf960 100644 --- a/frontend/packages/gitops-plugin/src/components/details/GitOpsDetails.scss +++ b/frontend/packages/gitops-plugin/src/components/details/GitOpsDetails.scss @@ -95,7 +95,7 @@ vertical-align: middle; } } - &__operator-upgrade-alert { + &__special-message-alert { margin-bottom: var(--pf-global--spacer--xl); } } diff --git a/frontend/packages/gitops-plugin/src/components/details/GitOpsDetails.tsx b/frontend/packages/gitops-plugin/src/components/details/GitOpsDetails.tsx index 9baa919ac7b..ec8fd97e12e 100644 --- a/frontend/packages/gitops-plugin/src/components/details/GitOpsDetails.tsx +++ b/frontend/packages/gitops-plugin/src/components/details/GitOpsDetails.tsx @@ -27,9 +27,10 @@ import './GitOpsDetails.scss'; interface GitOpsDetailsProps { envs: GitOpsEnvironment[]; appName: string; + error: Error; } -const GitOpsDetails: React.FC = ({ envs, appName }) => { +const GitOpsDetails: React.FC = ({ envs, appName, error }) => { const { t } = useTranslation(); const [consoleLinks] = useK8sWatchResource({ isList: true, @@ -46,19 +47,29 @@ const GitOpsDetails: React.FC = ({ envs, appName }) => { if (envs && envs.length > 0) { oldAPI = envs[0] && envs[0].deployments ? envs[0].deployments === null : true; } - + let errMsg = ''; + if (error != null) { + errMsg = t('gitops-plugin~Error cannot retrieve environments'); + } return (
{oldAPI && ( - <> - - {t('gitops-plugin~Compatibility Issue Message')} - - + + {t('gitops-plugin~Compatibility Issue Message')} + + )} + {error != null && ( + + {errMsg} + )} {_.map( envs, diff --git a/frontend/packages/gitops-plugin/src/components/utils/gitops-utils.ts b/frontend/packages/gitops-plugin/src/components/utils/gitops-utils.ts index d07b448b8c6..e8c1476e594 100644 --- a/frontend/packages/gitops-plugin/src/components/utils/gitops-utils.ts +++ b/frontend/packages/gitops-plugin/src/components/utils/gitops-utils.ts @@ -33,6 +33,7 @@ export const fetchAppGroups = async ( try { data = await coFetchJSON(`${baseURL}&url=${manifestURL}`); } catch {} // eslint-disable-line no-empty + // Ignore and let empty data be handled by fetchAllAppGroups } return data?.applications ?? []; }; @@ -53,7 +54,10 @@ export const fetchAllAppGroups = async (baseURL: string, manifestURLs: string[], ), ['name'], ); - } catch {} // eslint-disable-line no-empty + } catch { + emptyMsg = t('gitops-plugin~Error cannot retrieve applications'); + return [allAppGroups, emptyMsg]; + } if (_.isEmpty(allAppGroups)) { emptyMsg = t('gitops-plugin~No Application groups found'); } @@ -69,7 +73,9 @@ export const getEnvData = async (v2EnvURI: string, envURI: string, env: string, } catch { try { data = await coFetchJSON(`${envURI}/${env}${appURI}`); - } catch {} // eslint-disable-line no-empty + } catch (error) { + throw error; + } } return data; };