Skip to content

Commit ddc8078

Browse files
authored
Merge pull request #171 from keithchong/8773-ApplicationListFix-ZeroIndex
Applications page is broken - Zero index array (#8773)
2 parents 860e46b + 1fae2ef commit ddc8078

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/gitops/components/application/ApplicationDetailsTab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ const ApplicationDetailsTab: React.FC<ApplicationDetailsTabProps> = ({ obj }) =>
103103
};
104104

105105
let sources: ApplicationSource[];
106-
let revisions: string[];
106+
let revisions: string[] = [];
107107
if (obj?.spec?.source) {
108108
sources = [obj?.spec?.source];
109109
revisions = [obj.status?.sync?.revision];
110110
} else if (obj?.spec?.sources) {
111111
sources = obj.spec.sources;
112-
revisions = obj.status?.sync?.revisions;
112+
revisions = obj.status?.sync?.revisions || [];
113113
} else {
114114
sources = [];
115115
revisions = [];

src/gitops/components/shared/ApplicationList.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,13 @@ const useApplicationRowsDV = (applicationsList, namespace): DataViewTr[] => {
308308
const rows: DataViewTr[] = [];
309309
applicationsList.forEach((app, index) => {
310310
let sources: ApplicationSource[];
311-
let revisions: string[];
311+
let revisions: string[] = [];
312312
if (app.spec?.source) {
313313
sources = [app.spec?.source];
314314
revisions = [app.status?.sync?.revision];
315315
} else if (app.spec?.sources) {
316-
sources = app.spec.sources;
317-
revisions = app.status?.sync?.revisions;
316+
sources = app.spec.sources || [];
317+
revisions = app.status?.sync?.revisions || [];
318318
} else {
319319
//Should never fall here since there always has to be a source or sources
320320
sources = [];
@@ -371,11 +371,11 @@ const useApplicationRowsDV = (applicationsList, namespace): DataViewTr[] => {
371371
id: app?.status?.sync?.revision,
372372
cell: (
373373
<>
374-
{sources[0].targetRevision ? sources[0].targetRevision : 'HEAD'}&nbsp;
374+
{sources[0]?.targetRevision ? sources[0].targetRevision : 'HEAD'}&nbsp;
375375
{!(app.status?.sourceType == 'Helm' && sources[0].chart) && (
376376
<RevisionFragment
377377
revision={revisions[0] || ''}
378-
repoURL={sources[0].repoURL}
378+
repoURL={sources[0]?.repoURL || ''}
379379
helm={app.status?.sourceType == 'Helm' && sources[0].chart ? true : false}
380380
revisionExtra={revisions.length > 1 && ' and ' + (revisions.length - 1) + ' more'}
381381
/>

0 commit comments

Comments
 (0)