1
1
import React , { useMemo } from "react" ;
2
2
import { FormattedMessage } from "react-intl" ;
3
3
4
- import { useCurrentWorkspace , useOrganization } from "core/api" ;
4
+ import { useCurrentOrganizationInfo } from "core/api" ;
5
5
import { FeatureItem , useFeature } from "core/services/features" ;
6
6
import { isOsanoActive , showOsanoDrawer } from "core/utils/dataPrivacy" ;
7
+ import { useIntent } from "core/utils/rbac" ;
7
8
import { DbtCloudSettingsView } from "packages/cloud/views/settings/integrations/DbtCloudSettingsView" ;
8
9
import { AccountSettingsView } from "packages/cloud/views/users/AccountSettingsView" ;
9
10
import { UsersSettingsView } from "packages/cloud/views/users/UsersSettingsView" ;
@@ -21,103 +22,10 @@ import { PageConfig, SettingsPageBase } from "pages/SettingsPage/SettingsPageBas
21
22
22
23
import { CloudSettingsRoutePaths } from "./routePaths" ;
23
24
24
- export const CloudSettingsPageContent : React . FC = ( ) => {
25
- const supportsCloudDbtIntegration = useFeature ( FeatureItem . AllowDBTCloudIntegration ) ;
26
- const supportsDataResidency = useFeature ( FeatureItem . AllowChangeDataGeographies ) ;
27
-
28
- const basePageConfig = useMemo < PageConfig > (
29
- ( ) => ( {
30
- menuConfig : [
31
- {
32
- category : < FormattedMessage id = "settings.userSettings" /> ,
33
- routes : [
34
- {
35
- path : CloudSettingsRoutePaths . Account ,
36
- name : < FormattedMessage id = "settings.account" /> ,
37
- component : AccountSettingsView ,
38
- } ,
39
- ...( isOsanoActive ( )
40
- ? [
41
- {
42
- name : < FormattedMessage id = "settings.cookiePreferences" /> ,
43
- path : "__COOKIE_PREFERENCES__" , // Special path with no meaning, since the onClick will be triggered
44
- onClick : ( ) => showOsanoDrawer ( ) ,
45
- } ,
46
- ]
47
- : [ ] ) ,
48
- ] ,
49
- } ,
50
-
51
- {
52
- category : < FormattedMessage id = "settings.workspaceSettings" /> ,
53
- routes : [
54
- {
55
- path : CloudSettingsRoutePaths . Workspace ,
56
- name : < FormattedMessage id = "settings.generalSettings" /> ,
57
- component : WorkspaceSettingsView ,
58
- id : "workspaceSettings.generalSettings" ,
59
- } ,
60
- ...( supportsDataResidency
61
- ? [
62
- {
63
- path : CloudSettingsRoutePaths . DataResidency ,
64
- name : < FormattedMessage id = "settings.dataResidency" /> ,
65
- component : DataResidencyView ,
66
- } ,
67
- ]
68
- : [ ] ) ,
69
- {
70
- path : CloudSettingsRoutePaths . Source ,
71
- name : < FormattedMessage id = "tables.sources" /> ,
72
- // indicatorCount: countNewSourceVersion,
73
- component : SettingsSourcesPage ,
74
- } ,
75
- {
76
- path : CloudSettingsRoutePaths . Destination ,
77
- name : < FormattedMessage id = "tables.destinations" /> ,
78
- // indicatorCount: countNewDestinationVersion,
79
- component : SettingsDestinationPage ,
80
- } ,
81
- {
82
- path : CloudSettingsRoutePaths . AccessManagement ,
83
- name : < FormattedMessage id = "settings.accessManagementSettings" /> ,
84
- component : UsersSettingsView ,
85
- id : "workspaceSettings.accessManagementSettings" ,
86
- } ,
87
- {
88
- path : CloudSettingsRoutePaths . Notifications ,
89
- name : < FormattedMessage id = "settings.notifications" /> ,
90
- component : NotificationPage ,
91
- } ,
92
- ] ,
93
- } ,
94
-
95
- ...( supportsCloudDbtIntegration
96
- ? [
97
- {
98
- category : < FormattedMessage id = "settings.integrationSettings" /> ,
99
- routes : [
100
- {
101
- path : CloudSettingsRoutePaths . DbtCloud ,
102
- name : < FormattedMessage id = "settings.integrationSettings.dbtCloudSettings" /> ,
103
- component : DbtCloudSettingsView ,
104
- id : "integrationSettings.dbtCloudSettings" ,
105
- } ,
106
- ] ,
107
- } ,
108
- ]
109
- : [ ] ) ,
110
- ] ,
111
- } ) ,
112
- [ supportsCloudDbtIntegration , supportsDataResidency ]
113
- ) ;
114
-
115
- return < SettingsPageBase pageConfig = { basePageConfig } /> ;
116
- } ;
117
-
118
- const CloudSettingsPageContentWithOrg : React . FC < { organizationId : string } > = ( { organizationId } ) => {
119
- const organization = useOrganization ( organizationId ) ;
120
- const hasSsoOrg = organization . ssoRealm !== null ;
25
+ const CloudSettingsPage : React . FC = ( ) => {
26
+ const organization = useCurrentOrganizationInfo ( ) ;
27
+ const isSsoEnabled = organization ?. sso ;
28
+ const canViewOrgSettings = useIntent ( "ViewOrganizationSettings" , { organizationId : organization ?. organizationId } ) ;
121
29
const supportsCloudDbtIntegration = useFeature ( FeatureItem . AllowDBTCloudIntegration ) ;
122
30
const supportsDataResidency = useFeature ( FeatureItem . AllowChangeDataGeographies ) ;
123
31
@@ -173,7 +81,7 @@ const CloudSettingsPageContentWithOrg: React.FC<{ organizationId: string }> = ({
173
81
// indicatorCount: countNewDestinationVersion,
174
82
component : SettingsDestinationPage ,
175
83
} ,
176
- ...( hasSsoOrg
84
+ ...( isSsoEnabled
177
85
? [
178
86
{
179
87
path : `${ CloudSettingsRoutePaths . Workspace } /${ CloudSettingsRoutePaths . AccessManagement } ` ,
@@ -197,8 +105,7 @@ const CloudSettingsPageContentWithOrg: React.FC<{ organizationId: string }> = ({
197
105
} ,
198
106
] ,
199
107
} ,
200
-
201
- ...( hasSsoOrg
108
+ ...( canViewOrgSettings
202
109
? [
203
110
{
204
111
category : < FormattedMessage id = "settings.organizationSettings" /> ,
@@ -208,12 +115,16 @@ const CloudSettingsPageContentWithOrg: React.FC<{ organizationId: string }> = ({
208
115
name : < FormattedMessage id = "settings.generalSettings" /> ,
209
116
component : GeneralOrganizationSettingsPage ,
210
117
} ,
211
- {
212
- path : `${ CloudSettingsRoutePaths . Organization } /${ CloudSettingsRoutePaths . AccessManagement } ` ,
213
- name : < FormattedMessage id = "settings.accessManagementSettings" /> ,
214
- component : OrganizationAccessManagementPage ,
215
- id : "organizationSettings.accessManagementSettings" ,
216
- } ,
118
+ ...( isSsoEnabled
119
+ ? [
120
+ {
121
+ path : `${ CloudSettingsRoutePaths . Organization } /${ CloudSettingsRoutePaths . AccessManagement } ` ,
122
+ name : < FormattedMessage id = "settings.accessManagementSettings" /> ,
123
+ component : OrganizationAccessManagementPage ,
124
+ id : "organizationSettings.accessManagementSettings" ,
125
+ } ,
126
+ ]
127
+ : [ ] ) ,
217
128
] ,
218
129
} ,
219
130
]
@@ -235,22 +146,10 @@ const CloudSettingsPageContentWithOrg: React.FC<{ organizationId: string }> = ({
235
146
: [ ] ) ,
236
147
] ,
237
148
} ) ,
238
- [ hasSsoOrg , supportsCloudDbtIntegration , supportsDataResidency ]
149
+ [ canViewOrgSettings , isSsoEnabled , supportsCloudDbtIntegration , supportsDataResidency ]
239
150
) ;
240
151
241
- if ( ! organization . ssoRealm ) {
242
- return < CloudSettingsPageContent /> ;
243
- }
244
-
245
152
return < SettingsPageBase pageConfig = { ssoPageConfig } /> ;
246
153
} ;
247
154
248
- export const CloudSettingsPage : React . FC = ( ) => {
249
- const { organizationId } = useCurrentWorkspace ( ) ;
250
-
251
- if ( organizationId ) {
252
- return < CloudSettingsPageContentWithOrg organizationId = { organizationId } /> ;
253
- }
254
- return < CloudSettingsPageContent /> ;
255
- } ;
256
155
export default CloudSettingsPage ;
0 commit comments