From 9f6ef2f58eec71102db9349dafce506c529527c6 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Mon, 31 Aug 2026 11:53:49 -0400 Subject: [PATCH] fix: history tab throws runtime error for multi-source Applications Signed-off-by: Atif Ali --- .../application/History/History.tsx | 100 +++++++++--------- src/gitops/models/ApplicationModel.ts | 3 +- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/src/gitops/components/application/History/History.tsx b/src/gitops/components/application/History/History.tsx index d6d81a578..d6437258c 100644 --- a/src/gitops/components/application/History/History.tsx +++ b/src/gitops/components/application/History/History.tsx @@ -109,6 +109,16 @@ const HistoryList: React.FC = ({ history, obj }) => { ); }; +const renderRepoUrl = (repoURL?: string) => { + if (!repoURL) { + return '-'; + } + if (repoURL.startsWith('oci://')) { + return repoURL; + } + return {repoUrl(repoURL)}; +}; + const useRowsDV = (history: ApplicationHistory[], app: ApplicationKind): DataViewTr[] => { const rows: DataViewTr[] = []; @@ -121,61 +131,55 @@ const useRowsDV = (history: ApplicationHistory[], app: ApplicationKind): DataVie ? 'Automated' : '' + (initBy.username ? initBy.username : '-'); - const isOci = obj.source?.repoURL?.startsWith('oci://'); - let revisionValue = <>-; + let revisionValue: React.ReactNode = '-'; if (obj.revision) { + const source = obj.source; revisionValue = ( <> - {!isOci ? ( - - {'('} - {repoUrl(obj.source.repoURL)} - {')'} - - ) : ( - - {'('} - {obj.source.repoURL} - {')'} - - )} + + {'('} + {renderRepoUrl(source?.repoURL)} + {')'} + + + ); + } else if (obj.revisions?.length) { + const historySources = obj.sources?.length ? obj.sources : app.spec?.sources; + revisionValue = ( + <> + {obj.revisions.map((revision, index) => { + const source = historySources?.[index]; + return ( + + + + {'('} + {renderRepoUrl(source?.repoURL)} + {')'} + + +
+
+ ); + })} ); - } else if (obj.revisions && app.spec.sources) { - const rv: React.ReactNode[] = []; - obj.revisions?.forEach((revision, index) => { - rv.push( - <> - - {'('} - <> - - {repoUrl(app.spec.sources[index].repoURL)} - - {')'} - - -
- , - ); - }); - revisionValue = <>{rv}; } rows.push([ { diff --git a/src/gitops/models/ApplicationModel.ts b/src/gitops/models/ApplicationModel.ts index aea259c15..e9e521957 100644 --- a/src/gitops/models/ApplicationModel.ts +++ b/src/gitops/models/ApplicationModel.ts @@ -80,7 +80,8 @@ export type ApplicationHistory = { deployedAt?: string; revision?: string; revisions?: string[]; - source: ApplicationSource; + source?: ApplicationSource; + sources?: ApplicationSource[]; }; export type Resource = {