Skip to content

Commit 1fae2ef

Browse files
committed
Applications page is broken - Zero index array (#8773)
Signed-off-by: Keith Chong <kykchong@redhat.com>
1 parent cb041b7 commit 1fae2ef

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
@@ -150,13 +150,13 @@ const ApplicationDetailsTab: React.FC<ApplicationDetailsTabProps> = ({ obj }) =>
150150
};
151151

152152
let sources: ApplicationSource[];
153-
let revisions: string[];
153+
let revisions: string[] = [];
154154
if (obj?.spec?.source) {
155155
sources = [obj?.spec?.source];
156156
revisions = [obj.status?.sync?.revision];
157157
} else if (obj?.spec?.sources) {
158158
sources = obj.spec.sources;
159-
revisions = obj.status?.sync?.revisions;
159+
revisions = obj.status?.sync?.revisions || [];
160160
} else {
161161
sources = [];
162162
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)