Skip to content

Commit

Permalink
Merge pull request #1615 from RoadieHQ/samn/argo-multi-fe
Browse files Browse the repository at this point in the history
Samn/argo multi fe
  • Loading branch information
Xantier authored Sep 16, 2024
2 parents 6095bfc + dc9664d commit b140119
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/nice-pets-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@roadiehq/backstage-plugin-argo-cd-backend': minor
'@roadiehq/backstage-plugin-argo-cd': minor
---

Allow setting up a separate frontend URL on multiple Ar instances for linking purposes.
4 changes: 4 additions & 0 deletions plugins/frontend/backstage-plugin-argo-cd/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export interface Config {
* @visibility frontend
*/
name: string;
/**
* @visibility frontend
*/
frontendUrl?: string;
/**
* @visibility frontend
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,18 @@ const OverviewComponent = ({

const getBaseUrl = (row: any): string | undefined => {
if (supportsMultipleArgoInstances && !baseUrl) {
return configApi
const instanceConfig = configApi
.getConfigArray('argocd.appLocatorMethods')
.find(value => value.getOptionalString('type') === 'config')
?.getOptionalConfigArray('instances')
?.find(
value =>
value.getOptionalString('name') === row.metadata?.instance?.name,
)
?.getOptionalString('url');
);
return (
instanceConfig?.getOptionalString('frontendUrl') ??
instanceConfig?.getOptionalString('url')
);
}
return baseUrl;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export type ArgoCDHistoryTableRow = ArgoCDAppHistoryDetails & {
app: string;
appNamespace: string;
instance?: string;
frontendUrl?: string;
revisionDetails?: ArgoCDAppDeployRevisionDetails;
};

Expand All @@ -40,21 +41,24 @@ export const ArgoCDHistoryTable = ({
retry: () => void;
}) => {
const configApi = useApi(configApiRef);
const baseUrl = configApi.getOptionalString('argocd.baseUrl');
const namespaced =
configApi.getOptionalBoolean('argocd.namespacedApps') ?? false;
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 columns: TableColumn[] = [
{
title: 'Name',
field: 'name',
render: (row: any): React.ReactNode =>
baseUrl ? (
linkUrl ? (
<Link
href={`${baseUrl}/applications/${
href={`${linkUrl}/applications/${
namespaced ? `${row.appNamespace}/${row.app}` : row.app
}`}
target="_blank"
Expand Down

0 comments on commit b140119

Please sign in to comment.