Skip to content

Commit 2c1bbfb

Browse files
committed
add dynamic namespace resolution for Progressive Sync panel
Signed-off-by: Atif Ali <[email protected]>
1 parent bef0337 commit 2c1bbfb

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

ui/src/app/applications/components/application-status-panel/application-status-panel.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const ProgressiveSyncStatus = ({application}: {application: models.Application})
9191
<div className='application-status-panel__item'>
9292
{sectionHeader({
9393
title: 'PROGRESSIVE SYNC',
94-
helpContent: 'Shows the current status of progressive sync for applications managed by an ApplicationSet with RollingSync strategy.'
94+
helpContent: 'Shows the current status of progressive sync for applications managed by an ApplicationSet.'
9595
})}
9696
<div className='application-status-panel__item-value'>
9797
<i className='fa fa-exclamation-triangle' style={{color: COLORS.sync.unknown}} /> Error
@@ -101,7 +101,14 @@ const ProgressiveSyncStatus = ({application}: {application: models.Application})
101101
);
102102
}}
103103
load={async () => {
104-
const appSet = await services.applications.getApplicationSet(appSetRef.name, application.metadata.namespace);
104+
// Find ApplicationSet by searching all namespaces dynamically
105+
const appSetList = await services.applications.listApplicationSets();
106+
const appSet = appSetList.items?.find(item => item.metadata.name === appSetRef.name);
107+
108+
if (!appSet) {
109+
throw new Error(`ApplicationSet ${appSetRef.name} not found in any namespace`);
110+
}
111+
105112
// Only return the ApplicationSet if it has a strategy (Progressive Sync enabled)
106113
if (appSet?.spec?.strategy) {
107114
return appSet;
@@ -111,7 +118,7 @@ const ProgressiveSyncStatus = ({application}: {application: models.Application})
111118
}}>
112119
{(appSet: models.ApplicationSet | 'NO_STRATEGY') => {
113120
if (appSet === 'NO_STRATEGY') {
114-
// If the ApplicationSet has no strategy (Progressive Sync disabled), don't show Progressive Sync at all
121+
// If the ApplicationSet has no strategy (Progressive Sync disabled), don't show Progressive Sync panel
115122
return null;
116123
}
117124

@@ -125,13 +132,16 @@ const ProgressiveSyncStatus = ({application}: {application: models.Application})
125132
);
126133
}
127134

135+
// Determine strategy type and display accordingly
136+
const strategyType = appSet.spec?.strategy?.type || 'AllAtOnce';
137+
128138
// If no application status is found, show a default status
129139
if (!appResource && !appResourceFromResources) {
130140
return (
131141
<div className='application-status-panel__item'>
132142
{sectionHeader({
133143
title: 'PROGRESSIVE SYNC',
134-
helpContent: 'Shows the current status of progressive sync for applications managed by an ApplicationSet with RollingSync strategy.'
144+
helpContent: `Shows the current status of progressive sync for applications managed by an ApplicationSet with ${strategyType} strategy.`
135145
})}
136146
<div className='application-status-panel__item-value'>
137147
<i className='fa fa-clock' style={{color: COLORS.sync.out_of_sync}} /> Waiting
@@ -140,9 +150,6 @@ const ProgressiveSyncStatus = ({application}: {application: models.Application})
140150
</div>
141151
);
142152
}
143-
144-
// Determine strategy type and display accordingly
145-
const strategyType = appSet.spec?.strategy?.type || 'AllAtOnce';
146153
const isRollingSync = strategyType === 'RollingSync';
147154

148155
// Use the appropriate resource based on strategy

ui/src/app/shared/models.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,3 +1118,8 @@ export interface ApplicationSet {
11181118
resources?: ApplicationSetResource[];
11191119
};
11201120
}
1121+
1122+
export interface ApplicationSetList {
1123+
metadata: models.ListMeta;
1124+
items: ApplicationSet[];
1125+
}

ui/src/app/shared/services/applications-service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,4 +550,8 @@ export class ApplicationsService {
550550
.query({appsetNamespace: namespace})
551551
.then(res => res.body as models.ApplicationSet);
552552
}
553+
554+
public async listApplicationSets(): Promise<models.ApplicationSetList> {
555+
return requests.get(`/applicationsets`).then(res => res.body as models.ApplicationSetList);
556+
}
553557
}

0 commit comments

Comments
 (0)