File tree Expand file tree Collapse file tree 1 file changed +29
-12
lines changed Expand file tree Collapse file tree 1 file changed +29
-12
lines changed Original file line number Diff line number Diff line change @@ -211,19 +211,36 @@ export const useOrganizationsFilterMenu = ({
211
211
return null ;
212
212
} ,
213
213
getOptions : async ( ) => {
214
- const organizationsRes = await API . getOrganizations ( ) ;
215
- return organizationsRes . map < SelectFilterOption > ( ( organization ) => ( {
216
- label : organization . display_name || organization . name ,
217
- value : organization . name ,
218
- startIcon : (
219
- < UserAvatar
220
- key = { organization . id }
221
- size = "xs"
222
- username = { organization . display_name || organization . name }
223
- avatarURL = { organization . icon }
224
- />
214
+ // Only show the organizations for which you can view audit logs.
215
+ const organizations = await API . getOrganizations ( ) ;
216
+ const permissions = await API . checkAuthorization ( {
217
+ checks : Object . fromEntries (
218
+ organizations . map ( ( organization ) => [
219
+ organization . id ,
220
+ {
221
+ object : {
222
+ resource_type : "audit_log" ,
223
+ organization_id : organization . id ,
224
+ } ,
225
+ action : "read" ,
226
+ } ,
227
+ ] ) ,
225
228
) ,
226
- } ) ) ;
229
+ } ) ;
230
+ return organizations
231
+ . filter ( ( organization ) => permissions [ organization . id ] )
232
+ . map < SelectFilterOption > ( ( organization ) => ( {
233
+ label : organization . display_name || organization . name ,
234
+ value : organization . name ,
235
+ startIcon : (
236
+ < UserAvatar
237
+ key = { organization . id }
238
+ size = "xs"
239
+ username = { organization . display_name || organization . name }
240
+ avatarURL = { organization . icon }
241
+ />
242
+ ) ,
243
+ } ) ) ;
227
244
} ,
228
245
} ) ;
229
246
} ;
You can’t perform that action at this time.
0 commit comments