Skip to content

Commit

Permalink
Merge pull request #1715 from tdabasinskas/argo_url_fix
Browse files Browse the repository at this point in the history
fix(argocd): update linkUrl logic for multi-instance support
  • Loading branch information
Xantier authored Nov 12, 2024
2 parents b59b4b4 + 7520be9 commit d440218
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/fresh-pears-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@roadiehq/backstage-plugin-argo-cd': patch
---

update linkUrl logic in ArgoCDHistory component for multi-instance support
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,25 @@ export const ArgoCDHistoryTable = ({
const configApi = useApi(configApiRef);
const namespaced =
configApi.getOptionalBoolean('argocd.namespacedApps') ?? false;
const baseUrl = configApi.getOptionalString('argocd.baseUrl');
const supportsMultipleArgoInstances: boolean = Boolean(
configApi.getOptionalConfigArray('argocd.appLocatorMethods')?.length,
);
const linkUrl = (row: any) =>
supportsMultipleArgoInstances && row.metadata?.instance?.frontendUrl
? row.metadata?.instance?.frontendUrl
: configApi.getOptionalString('argocd.baseUrl');

const linkUrl = (row: any): string | undefined => {
if (supportsMultipleArgoInstances && !baseUrl) {
const instanceConfig = configApi
.getConfigArray('argocd.appLocatorMethods')
.find(value => value.getOptionalString('type') === 'config')
?.getOptionalConfigArray('instances')
?.find(value => value.getOptionalString('name') === row?.instance);
return (
instanceConfig?.getOptionalString('frontendUrl') ??
instanceConfig?.getOptionalString('url')
);
}
return baseUrl;
};

const columns: TableColumn[] = [
{
Expand Down

0 comments on commit d440218

Please sign in to comment.