@@ -62,16 +62,6 @@ const getApplicationSetOwnerRef = (application: models.Application) => {
62
62
return application . metadata . ownerReferences ?. find ( ref => ref . kind === 'ApplicationSet' ) ;
63
63
} ;
64
64
65
- const extractErrorText = ( error : any ) : string => {
66
- const errorChildren = error . props ?. children || [ ] ;
67
- return Array . isArray ( errorChildren ) ? errorChildren . map ( child => ( typeof child === 'string' ? child : '' ) ) . join ( '' ) : String ( errorChildren ) ;
68
- } ;
69
-
70
- const isPermissionError = ( error : any ) : boolean => {
71
- const errorText = extractErrorText ( error ) ;
72
- return errorText . includes ( 'Failed to load data' ) ;
73
- } ;
74
-
75
65
const ProgressiveSyncStatus = ( { application} : { application : models . Application } ) => {
76
66
const appSetRef = getApplicationSetOwnerRef ( application ) ;
77
67
if ( ! appSetRef ) {
@@ -81,12 +71,8 @@ const ProgressiveSyncStatus = ({application}: {application: models.Application})
81
71
return (
82
72
< DataLoader
83
73
input = { application }
84
- errorRenderer = { ( error : any ) => {
85
- // If user doesn't have permission to read ApplicationSet, hide the panel
86
- if ( isPermissionError ( error ) ) {
87
- return null ;
88
- }
89
- // For other errors, show a minimal error state
74
+ errorRenderer = { ( ) => {
75
+ // For any errors, show a minimal error state
90
76
return (
91
77
< div className = 'application-status-panel__item' >
92
78
{ sectionHeader ( {
@@ -101,6 +87,9 @@ const ProgressiveSyncStatus = ({application}: {application: models.Application})
101
87
) ;
102
88
} }
103
89
load = { async ( ) => {
90
+ // Check if user has permission to read ApplicationSets
91
+ const canReadApplicationSets = await services . accounts . canI ( 'applicationsets' , 'get' , application . spec . project + '/' + application . metadata . name ) ;
92
+
104
93
// Find ApplicationSet by searching all namespaces dynamically
105
94
const appSetList = await services . applications . listApplicationSets ( ) ;
106
95
const appSet = appSetList . items ?. find ( item => item . metadata . name === appSetRef . name ) ;
@@ -109,16 +98,16 @@ const ProgressiveSyncStatus = ({application}: {application: models.Application})
109
98
throw new Error ( `ApplicationSet ${ appSetRef . name } not found in any namespace` ) ;
110
99
}
111
100
112
- // Only return the ApplicationSet if it has a strategy (Progressive Sync enabled)
113
- if ( appSet ?. spec ?. strategy ) {
114
- return appSet ;
115
- }
116
- // Return a special value to indicate no strategy (Progressive Sync disabled)
117
- return 'NO_STRATEGY' ;
101
+ return { canReadApplicationSets, appSet} ;
118
102
} } >
119
- { ( appSet : models . ApplicationSet | 'NO_STRATEGY' ) => {
120
- if ( appSet === 'NO_STRATEGY' ) {
121
- // If the ApplicationSet has no strategy (Progressive Sync disabled), don't show Progressive Sync panel
103
+ { ( { canReadApplicationSets, appSet} : { canReadApplicationSets : boolean ; appSet : models . ApplicationSet } ) => {
104
+ // If user doesn't have permission to read ApplicationSets, don't show Progressive Sync panel
105
+ if ( ! canReadApplicationSets ) {
106
+ return null ;
107
+ }
108
+
109
+ // If the ApplicationSet has no strategy (Progressive Sync disabled), don't show Progressive Sync panel
110
+ if ( ! appSet ?. spec ?. strategy ) {
122
111
return null ;
123
112
}
124
113
0 commit comments