File tree Expand file tree Collapse file tree 1 file changed +17
-13
lines changed
frontend/src/pages/projects/projectSharing Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -2,22 +2,26 @@ import * as React from 'react';
22import useFetchState , { FetchState } from '~/utilities/useFetchState' ;
33import { listGroups } from '~/api' ;
44import { GroupKind } from '~/k8sTypes' ;
5- import { useUser } from '~/redux/selectors' ;
65
76const useGroups = ( ) : FetchState < GroupKind [ ] > => {
8- const { isAdmin } = useUser ( ) ;
7+ const is403 = React . useRef ( false ) ;
98
10- const getGroup = React . useCallback ( ( ) => {
11- if ( ! isAdmin ) {
12- return Promise . resolve ( [ ] ) ;
13- }
14- return listGroups ( ) . catch ( ( e ) => {
15- if ( e . statusObject ?. code === 404 ) {
16- throw new Error ( 'No groups found.' ) ;
17- }
18- throw e ;
19- } ) ;
20- } , [ isAdmin ] ) ;
9+ const getGroup = React . useCallback (
10+ async ( ) =>
11+ is403 . current
12+ ? [ ]
13+ : listGroups ( ) . catch ( ( e ) => {
14+ if ( e . statusObject ?. code === 403 ) {
15+ is403 . current = true ;
16+ return [ ] ;
17+ }
18+ if ( e . statusObject ?. code === 404 ) {
19+ throw new Error ( 'No groups found.' ) ;
20+ }
21+ throw e ;
22+ } ) ,
23+ [ ] ,
24+ ) ;
2125
2226 return useFetchState < GroupKind [ ] > ( getGroup , [ ] ) ;
2327} ;
You can’t perform that action at this time.
0 commit comments