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 = {