File tree 2 files changed +8
-2
lines changed
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -10,14 +10,15 @@ import GroupsPageView from "./GroupsPageView"
10
10
11
11
export const GroupsPage : FC = ( ) => {
12
12
const organizationId = useOrganizationId ( )
13
+ const { createGroup : canCreateGroup } = usePermissions ( )
14
+ const { template_rbac : isTemplateRBACEnabled } = useFeatureVisibility ( )
13
15
const [ state ] = useMachine ( groupsMachine , {
14
16
context : {
15
17
organizationId,
18
+ shouldFetchGroups : isTemplateRBACEnabled ,
16
19
} ,
17
20
} )
18
21
const { groups } = state . context
19
- const { createGroup : canCreateGroup } = usePermissions ( )
20
- const { template_rbac : isTemplateRBACEnabled } = useFeatureVisibility ( )
21
22
22
23
return (
23
24
< >
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export const groupsMachine = createMachine(
11
11
schema : {
12
12
context : { } as {
13
13
organizationId : string
14
+ shouldFetchGroups : boolean
14
15
groups ?: Group [ ]
15
16
} ,
16
17
services : { } as {
@@ -23,6 +24,7 @@ export const groupsMachine = createMachine(
23
24
initial : "loading" ,
24
25
states : {
25
26
loading : {
27
+ always : [ { target : "idle" , cond : "cantFetchGroups" } ] ,
26
28
invoke : {
27
29
src : "loadGroups" ,
28
30
onDone : {
@@ -39,6 +41,9 @@ export const groupsMachine = createMachine(
39
41
} ,
40
42
} ,
41
43
{
44
+ guards : {
45
+ cantFetchGroups : ( { shouldFetchGroups } ) => ! shouldFetchGroups ,
46
+ } ,
42
47
services : {
43
48
loadGroups : ( { organizationId } ) => getGroups ( organizationId ) ,
44
49
} ,
You can’t perform that action at this time.
0 commit comments