File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 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"
1010
1111export const GroupsPage : FC = ( ) => {
1212 const organizationId = useOrganizationId ( )
13+ const { createGroup : canCreateGroup } = usePermissions ( )
14+ const { template_rbac : isTemplateRBACEnabled } = useFeatureVisibility ( )
1315 const [ state ] = useMachine ( groupsMachine , {
1416 context : {
1517 organizationId,
18+ shouldFetchGroups : isTemplateRBACEnabled ,
1619 } ,
1720 } )
1821 const { groups } = state . context
19- const { createGroup : canCreateGroup } = usePermissions ( )
20- const { template_rbac : isTemplateRBACEnabled } = useFeatureVisibility ( )
2122
2223 return (
2324 < >
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export const groupsMachine = createMachine(
1111 schema : {
1212 context : { } as {
1313 organizationId : string
14+ shouldFetchGroups : boolean
1415 groups ?: Group [ ]
1516 } ,
1617 services : { } as {
@@ -23,6 +24,7 @@ export const groupsMachine = createMachine(
2324 initial : "loading" ,
2425 states : {
2526 loading : {
27+ always : [ { target : "idle" , cond : "cantFetchGroups" } ] ,
2628 invoke : {
2729 src : "loadGroups" ,
2830 onDone : {
@@ -39,6 +41,9 @@ export const groupsMachine = createMachine(
3941 } ,
4042 } ,
4143 {
44+ guards : {
45+ cantFetchGroups : ( { shouldFetchGroups } ) => ! shouldFetchGroups ,
46+ } ,
4247 services : {
4348 loadGroups : ( { organizationId } ) => getGroups ( organizationId ) ,
4449 } ,
You can’t perform that action at this time.
0 commit comments