1
1
import LaunchOutlined from "@mui/icons-material/LaunchOutlined" ;
2
2
import Button from "@mui/material/Button" ;
3
+ import { getErrorMessage } from "api/errors" ;
3
4
import { groupsByOrganization } from "api/queries/groups" ;
4
5
import {
5
6
groupIdpSyncSettings ,
6
7
roleIdpSyncSettings ,
7
8
} from "api/queries/organizations" ;
8
- import { ErrorAlert } from "components/Alert/ErrorAlert" ;
9
9
import { EmptyState } from "components/EmptyState/EmptyState" ;
10
10
import { FeatureStageBadge } from "components/FeatureStageBadge/FeatureStageBadge" ;
11
+ import { displayError } from "components/GlobalSnackbar/utils" ;
11
12
import { Loader } from "components/Loader/Loader" ;
12
13
import { SettingsHeader } from "components/SettingsHeader/SettingsHeader" ;
13
14
import { Stack } from "components/Stack/Stack" ;
14
- import type { FC } from "react" ;
15
+ import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility" ;
16
+ import { type FC , useEffect } from "react" ;
15
17
import { Helmet } from "react-helmet-async" ;
16
18
import { useQueries } from "react-query" ;
17
19
import { useParams } from "react-router-dom" ;
@@ -25,6 +27,8 @@ export const IdpSyncPage: FC = () => {
25
27
const { organization : organizationName } = useParams ( ) as {
26
28
organization : string ;
27
29
} ;
30
+ // IdP sync does not have its own entitlement and is based on templace_rbac
31
+ const { template_rbac : isIdpSyncEnabled } = useFeatureVisibility ( ) ;
28
32
const { organizations } = useOrganizationSettings ( ) ;
29
33
const organization = organizations ?. find ( ( o ) => o . name === organizationName ) ;
30
34
@@ -37,6 +41,36 @@ export const IdpSyncPage: FC = () => {
37
41
] ,
38
42
} ) ;
39
43
44
+ useEffect ( ( ) => {
45
+ if ( groupIdpSyncSettingsQuery . error ) {
46
+ displayError (
47
+ getErrorMessage (
48
+ groupIdpSyncSettingsQuery . error ,
49
+ "Unable to load group IdP sync settings." ,
50
+ ) ,
51
+ ) ;
52
+ }
53
+ } , [ groupIdpSyncSettingsQuery . error ] ) ;
54
+
55
+ useEffect ( ( ) => {
56
+ if ( roleIdpSyncSettingsQuery . error ) {
57
+ displayError (
58
+ getErrorMessage (
59
+ roleIdpSyncSettingsQuery . error ,
60
+ "Unable to load role IdP sync settings." ,
61
+ ) ,
62
+ ) ;
63
+ }
64
+ } , [ roleIdpSyncSettingsQuery . error ] ) ;
65
+
66
+ useEffect ( ( ) => {
67
+ if ( groupsQuery . error ) {
68
+ displayError (
69
+ getErrorMessage ( groupsQuery . error , "Unable to load groups." ) ,
70
+ ) ;
71
+ }
72
+ } , [ groupsQuery . error ] ) ;
73
+
40
74
if ( ! organization ) {
41
75
return < EmptyState message = "Organization not found" /> ;
42
76
}
@@ -49,19 +83,6 @@ export const IdpSyncPage: FC = () => {
49
83
return < Loader /> ;
50
84
}
51
85
52
- const error =
53
- groupIdpSyncSettingsQuery . error ||
54
- roleIdpSyncSettingsQuery . error ||
55
- groupsQuery . error ;
56
- if (
57
- error ||
58
- ! groupIdpSyncSettingsQuery . data ||
59
- ! roleIdpSyncSettingsQuery . data ||
60
- ! groupsQuery . data
61
- ) {
62
- return < ErrorAlert error = { error } /> ;
63
- }
64
-
65
86
const groupsMap = new Map < string , string > ( ) ;
66
87
if ( groupsQuery . data ) {
67
88
for ( const group of groupsQuery . data ) {
@@ -104,6 +125,7 @@ export const IdpSyncPage: FC = () => {
104
125
groups = { groupsQuery . data }
105
126
groupsMap = { groupsMap }
106
127
organization = { organization }
128
+ isIdpSyncEnabled = { isIdpSyncEnabled }
107
129
/>
108
130
</ >
109
131
) ;
0 commit comments