@@ -30,16 +30,25 @@ interface SidebarProps {
30
30
/**
31
31
* A combined deployment settings and organization menu.
32
32
*/
33
- export const SidebarView :FC < SidebarProps > = ( props ) => {
33
+ export const SidebarView :FC < SidebarProps > = ( {
34
+ activeSettings,
35
+ activeOrganizationName,
36
+ organizations,
37
+ permissions,
38
+ } ) => {
34
39
// TODO: Do something nice to scroll to the active org.
35
40
return (
36
41
< BaseSidebar >
37
42
< header css = { styles . sidebarHeader } > Deployment</ header >
38
43
< DeploymentSettingsNavigation
39
- active = { ! props . activeOrganizationName && props . activeSettings }
40
- permissions = { props . permissions }
44
+ active = { ! activeOrganizationName && activeSettings }
45
+ permissions = { permissions }
46
+ />
47
+ < OrganizationsSettingsNavigation
48
+ activeOrganizationName = { activeOrganizationName }
49
+ organizations = { organizations }
50
+ permissions = { permissions }
41
51
/>
42
- < OrganizationsSettingsNavigation { ...props } />
43
52
</ BaseSidebar >
44
53
) ;
45
54
} ;
@@ -58,15 +67,16 @@ interface DeploymentSettingsNavigationProps {
58
67
* Menu items are shown based on the permissions. If organizations can be
59
68
* viewed, groups are skipped since they will show under each org instead.
60
69
*/
61
- const DeploymentSettingsNavigation :FC < DeploymentSettingsNavigationProps > = (
62
- props ,
63
- ) => {
70
+ const DeploymentSettingsNavigation :FC < DeploymentSettingsNavigationProps > = ( {
71
+ active,
72
+ permissions,
73
+ } ) => {
64
74
return (
65
75
< div css = { { paddingBottom :12 } } >
66
76
< SidebarNavItem
67
- active = { props . active }
77
+ active = { active }
68
78
href = {
69
- props . permissions . viewDeploymentValues
79
+ permissions . viewDeploymentValues
70
80
?"/deployment/general"
71
81
:"/deployment/workspace-proxies"
72
82
}
@@ -77,23 +87,23 @@ const DeploymentSettingsNavigation: FC<DeploymentSettingsNavigationProps> = (
77
87
>
78
88
Deployment
79
89
</ SidebarNavItem >
80
- { props . active && (
90
+ { active && (
81
91
< Stack spacing = { 0.5 } css = { { marginBottom :8 , marginTop :8 } } >
82
- { props . permissions . viewDeploymentValues && (
92
+ { permissions . viewDeploymentValues && (
83
93
< SidebarNavSubItem href = "general" > General</ SidebarNavSubItem >
84
94
) }
85
- { props . permissions . viewAllLicenses && (
95
+ { permissions . viewAllLicenses && (
86
96
< SidebarNavSubItem href = "licenses" > Licenses</ SidebarNavSubItem >
87
97
) }
88
- { props . permissions . editDeploymentValues && (
98
+ { permissions . editDeploymentValues && (
89
99
< SidebarNavSubItem href = "appearance" > Appearance</ SidebarNavSubItem >
90
100
) }
91
- { props . permissions . viewDeploymentValues && (
101
+ { permissions . viewDeploymentValues && (
92
102
< SidebarNavSubItem href = "userauth" >
93
103
User Authentication
94
104
</ SidebarNavSubItem >
95
105
) }
96
- { props . permissions . viewDeploymentValues && (
106
+ { permissions . viewDeploymentValues && (
97
107
< SidebarNavSubItem href = "external-auth" >
98
108
External Authentication
99
109
</ SidebarNavSubItem >
@@ -102,27 +112,27 @@ const DeploymentSettingsNavigation: FC<DeploymentSettingsNavigationProps> = (
102
112
<SidebarNavSubItem href="oauth2-provider/ap>
103
113
OAuth2 Applications
104
114
</SidebarNavSubItem>*/ }
105
- { props . permissions . viewDeploymentValues && (
115
+ { permissions . viewDeploymentValues && (
106
116
< SidebarNavSubItem href = "network" > Network</ SidebarNavSubItem >
107
117
) }
108
118
{ /* All users can view workspace regions. */ }
109
119
< SidebarNavSubItem href = "workspace-proxies" >
110
120
Workspace Proxies
111
121
</ SidebarNavSubItem >
112
- { props . permissions . viewDeploymentValues && (
122
+ { permissions . viewDeploymentValues && (
113
123
< SidebarNavSubItem href = "security" > Security</ SidebarNavSubItem >
114
124
) }
115
- { props . permissions . viewDeploymentValues && (
125
+ { permissions . viewDeploymentValues && (
116
126
< SidebarNavSubItem href = "observability" >
117
127
Observability
118
128
</ SidebarNavSubItem >
119
129
) }
120
- { props . permissions . viewAllUsers && (
130
+ { permissions . viewAllUsers && (
121
131
< SidebarNavSubItem href = { linkToUsers . slice ( 1 ) } >
122
132
Users
123
133
</ SidebarNavSubItem >
124
134
) }
125
- { props . permissions . viewAnyAuditLog && (
135
+ { permissions . viewAnyAuditLog && (
126
136
< SidebarNavSubItem href = { linkToAuditing . slice ( 1 ) } >
127
137
Auditing
128
138
</ SidebarNavSubItem >
@@ -156,23 +166,20 @@ interface OrganizationsSettingsNavigationProps {
156
166
*/
157
167
const OrganizationsSettingsNavigation :FC <
158
168
OrganizationsSettingsNavigationProps
159
- > = ( props ) => {
169
+ > = ( { activeOrganizationName , organizations , permissions } ) => {
160
170
// Wait for organizations and their permissions to load in.
161
- if ( ! props . organizations ) {
171
+ if ( ! organizations ) {
162
172
return < Loader /> ;
163
173
}
164
174
165
- if (
166
- props . organizations . length <= 0 &&
167
- ! props . permissions . createOrganization
168
- ) {
175
+ if ( organizations . length <= 0 && ! permissions . createOrganization ) {
169
176
return null ;
170
177
}
171
178
172
179
return (
173
180
< >
174
181
< header css = { styles . sidebarHeader } > Organizations</ header >
175
- { props . permissions . createOrganization && (
182
+ { permissions . createOrganization && (
176
183
< SidebarNavItem
177
184
active = "auto"
178
185
href = "/organizations/new"
@@ -181,11 +188,11 @@ const OrganizationsSettingsNavigation: FC<
181
188
New organization
182
189
</ SidebarNavItem >
183
190
) }
184
- { props . organizations . map ( ( org ) => (
191
+ { organizations . map ( ( org ) => (
185
192
< OrganizationSettingsNavigation
186
193
key = { org . id }
187
194
organization = { org }
188
- active = { org . name === props . activeOrganizationName }
195
+ active = { org . name === activeOrganizationName }
189
196
/>
190
197
) ) }
191
198
</ >
@@ -208,55 +215,52 @@ interface OrganizationSettingsNavigationProps {
208
215
*/
209
216
const OrganizationSettingsNavigation :FC <
210
217
OrganizationSettingsNavigationProps
211
- > = ( props ) => {
218
+ > = ( { active , organization } ) => {
212
219
return (
213
220
< >
214
221
< SidebarNavItem
215
- active = { props . active }
216
- href = { urlForSubpage ( props . organization . name ) }
222
+ active = { active }
223
+ href = { urlForSubpage ( organization . name ) }
217
224
icon = {
218
225
< UserAvatar
219
- key = { props . organization . id }
226
+ key = { organization . id }
220
227
size = "sm"
221
- username = { props . organization . display_name }
222
- avatarURL = { props . organization . icon }
228
+ username = { organization . display_name }
229
+ avatarURL = { organization . icon }
223
230
/>
224
231
}
225
232
>
226
- { props . organization . display_name }
233
+ { organization . display_name }
227
234
</ SidebarNavItem >
228
- { props . active && (
235
+ { active && (
229
236
< Stack spacing = { 0.5 } css = { { marginBottom :8 , marginTop :8 } } >
230
- { props . organization . permissions . editOrganization && (
231
- < SidebarNavSubItem
232
- end
233
- href = { urlForSubpage ( props . organization . name ) }
234
- >
237
+ { organization . permissions . editOrganization && (
238
+ < SidebarNavSubItem end href = { urlForSubpage ( organization . name ) } >
235
239
Organization settings
236
240
</ SidebarNavSubItem >
237
241
) }
238
- { props . organization . permissions . editMembers && (
242
+ { organization . permissions . editMembers && (
239
243
< SidebarNavSubItem
240
- href = { urlForSubpage ( props . organization . name , "members" ) }
244
+ href = { urlForSubpage ( organization . name , "members" ) }
241
245
>
242
246
Members
243
247
</ SidebarNavSubItem >
244
248
) }
245
- { props . organization . permissions . editGroups && (
249
+ { organization . permissions . editGroups && (
246
250
< SidebarNavSubItem
247
- href = { urlForSubpage ( props . organization . name , "groups" ) }
251
+ href = { urlForSubpage ( organization . name , "groups" ) }
248
252
>
249
253
Groups
250
254
</ SidebarNavSubItem >
251
255
) }
252
256
{ /* For now redirect to the site-wide audit page with the organization
253
257
pre-filled into the filter. Based on user feedback we might want
254
258
to serve a copy of the audit page or even delete this link. */ }
255
- { props . organization . permissions . auditOrganization && (
259
+ { organization . permissions . auditOrganization && (
256
260
< SidebarNavSubItem
257
261
href = { `/deployment${ withFilter (
258
262
linkToAuditing ,
259
- `organization:${ props . organization . name } ` ,
263
+ `organization:${ organization . name } ` ,
260
264
) } `}
261
265
>
262
266
Auditing