13
13
* permissions and limitations under the License.
14
14
*/
15
15
16
- import { EuiBreadcrumb , EuiPage , EuiPageBody , EuiPageSideBar } from '@elastic/eui' ;
17
- import { flow , partial } from 'lodash' ;
16
+ import { EuiPage , EuiPageBody , EuiPageSideBar } from '@elastic/eui' ;
17
+ import { flow } from 'lodash' ;
18
18
import React , { createContext , useState } from 'react' ;
19
19
import { HashRouter as Router , Route , Switch , Redirect } from 'react-router-dom' ;
20
20
import { DataSourceOption } from 'src/plugins/data_source_management/public/components/data_source_menu/types' ;
@@ -38,31 +38,37 @@ import { TenantList } from './panels/tenant-list/tenant-list';
38
38
import { UserList } from './panels/user-list' ;
39
39
import { Action , RouteItem , SubAction } from './types' ;
40
40
import { ResourceType } from '../../../common' ;
41
- import { buildHashUrl , buildUrl } from './utils/url-builder' ;
41
+ import { buildUrl } from './utils/url-builder' ;
42
42
import { CrossPageToast } from './cross-page-toast' ;
43
43
import { getDataSourceFromUrl , LocalCluster } from '../../utils/datasource-utils' ;
44
+ import { getBreadcrumbs } from './utils/resource-utils' ;
44
45
45
46
const LANDING_PAGE_URL = '/getstarted' ;
46
47
47
48
export const ROUTE_MAP : { [ key : string ] : RouteItem } = {
48
49
getStarted : {
49
50
name : 'Get Started' ,
51
+ breadCrumbDisplayNameWithoutSecurityBase : 'Get started with access control' ,
50
52
href : LANDING_PAGE_URL ,
51
53
} ,
52
54
[ ResourceType . roles ] : {
53
55
name : 'Roles' ,
56
+ breadCrumbDisplayNameWithoutSecurityBase : 'Roles' ,
54
57
href : buildUrl ( ResourceType . roles ) ,
55
58
} ,
56
59
[ ResourceType . users ] : {
57
60
name : 'Internal users' ,
61
+ breadCrumbDisplayNameWithoutSecurityBase : 'Internal users' ,
58
62
href : buildUrl ( ResourceType . users ) ,
59
63
} ,
60
64
[ ResourceType . permissions ] : {
61
65
name : 'Permissions' ,
66
+ breadCrumbDisplayNameWithoutSecurityBase : 'Permissions' ,
62
67
href : buildUrl ( ResourceType . permissions ) ,
63
68
} ,
64
69
[ ResourceType . tenants ] : {
65
70
name : 'Tenants' ,
71
+ breadCrumbDisplayNameWithoutSecurityBase : 'Dashboard multi-tenancy' ,
66
72
href : buildUrl ( ResourceType . tenants ) ,
67
73
} ,
68
74
[ ResourceType . tenantsConfigureTab ] : {
@@ -71,10 +77,12 @@ export const ROUTE_MAP: { [key: string]: RouteItem } = {
71
77
} ,
72
78
[ ResourceType . auth ] : {
73
79
name : 'Authentication' ,
80
+ breadCrumbDisplayNameWithoutSecurityBase : 'Authentication and authorization' ,
74
81
href : buildUrl ( ResourceType . auth ) ,
75
82
} ,
76
83
[ ResourceType . auditLogging ] : {
77
84
name : 'Audit logs' ,
85
+ breadCrumbDisplayNameWithoutSecurityBase : 'Audit logs' ,
78
86
href : buildUrl ( ResourceType . auditLogging ) ,
79
87
} ,
80
88
} ;
@@ -100,39 +108,6 @@ export const allNavPanelUrls = (multitenancyEnabled: boolean) =>
100
108
...( multitenancyEnabled ? [ buildUrl ( ResourceType . tenantsConfigureTab ) ] : [ ] ) ,
101
109
] ) ;
102
110
103
- export function getBreadcrumbs (
104
- resourceType ?: ResourceType ,
105
- pageTitle ?: string ,
106
- subAction ?: string
107
- ) : EuiBreadcrumb [ ] {
108
- const breadcrumbs : EuiBreadcrumb [ ] = [
109
- {
110
- text : 'Security' ,
111
- href : buildHashUrl ( ) ,
112
- } ,
113
- ] ;
114
-
115
- if ( resourceType ) {
116
- breadcrumbs . push ( {
117
- text : ROUTE_MAP [ resourceType ] . name ,
118
- href : buildHashUrl ( resourceType ) ,
119
- } ) ;
120
- }
121
-
122
- if ( pageTitle ) {
123
- breadcrumbs . push ( {
124
- text : pageTitle ,
125
- } ) ;
126
- }
127
-
128
- if ( subAction ) {
129
- breadcrumbs . push ( {
130
- text : subAction ,
131
- } ) ;
132
- }
133
- return breadcrumbs ;
134
- }
135
-
136
111
function decodeParams ( params : { [ k : string ] : string } ) : any {
137
112
return Object . keys ( params ) . reduce ( ( obj : { [ k : string ] : string } , key : string ) => {
138
113
obj [ key ] = decodeURIComponent ( params [ key ] ) ;
@@ -154,6 +129,7 @@ export function AppRouter(props: AppDependencies) {
154
129
const dataSourceFromUrl = dataSourceEnabled ? getDataSourceFromUrl ( ) : LocalCluster ;
155
130
156
131
const [ dataSource , setDataSource ] = useState < DataSourceOption > ( dataSourceFromUrl ) ;
132
+ const includeSecurityBase = ! props . coreStart . uiSettings . get ( 'home:useNewHomePage' ) ;
157
133
158
134
return (
159
135
< DataSourceContext . Provider value = { { dataSource, setDataSource } } >
@@ -173,100 +149,79 @@ export function AppRouter(props: AppDependencies) {
173
149
< Route
174
150
path = { buildUrl ( ResourceType . roles , Action . edit ) + '/:roleName/' + SubAction . mapuser }
175
151
render = { ( match ) => (
176
- < RoleEditMappedUser
177
- buildBreadcrumbs = { partial ( setGlobalBreadcrumbs , ResourceType . roles ) }
178
- { ...{ ...props , ...decodeParams ( match . match . params ) } }
179
- />
152
+ < RoleEditMappedUser { ...{ ...props , ...decodeParams ( match . match . params ) } } />
180
153
) }
181
154
/>
182
155
< Route
183
156
path = { buildUrl ( ResourceType . roles , Action . view ) + '/:roleName/:prevAction?' }
184
157
render = { ( match ) => (
185
- < RoleView
186
- buildBreadcrumbs = { partial ( setGlobalBreadcrumbs , ResourceType . roles ) }
187
- { ...{ ...props , ...decodeParams ( match . match . params ) } }
188
- />
158
+ < RoleView { ...{ ...props , ...decodeParams ( match . match . params ) } } />
189
159
) }
190
160
/>
191
161
< Route
192
162
path = { buildUrl ( ResourceType . roles ) + '/:action/:sourceRoleName?' }
193
163
render = { ( match ) => (
194
- < RoleEdit
195
- buildBreadcrumbs = { partial ( setGlobalBreadcrumbs , ResourceType . roles ) }
196
- { ...{ ...props , ...decodeParams ( match . match . params ) } }
197
- />
164
+ < RoleEdit { ...{ ...props , ...decodeParams ( match . match . params ) } } />
198
165
) }
199
166
/>
200
167
< Route
201
168
path = { ROUTE_MAP . roles . href }
202
169
render = { ( ) => {
203
- setGlobalBreadcrumbs ( ResourceType . roles ) ;
204
170
return < RoleList { ...props } /> ;
205
171
} }
206
172
/>
207
173
< Route
208
174
path = { ROUTE_MAP . auth . href }
209
175
render = { ( ) => {
210
- setGlobalBreadcrumbs ( ResourceType . auth ) ;
211
176
return < AuthView { ...props } /> ;
212
177
} }
213
178
/>
214
179
< Route
215
180
path = { buildUrl ( ResourceType . users ) + '/:action/:sourceUserName?' }
216
181
render = { ( match ) => (
217
- < InternalUserEdit
218
- buildBreadcrumbs = { partial ( setGlobalBreadcrumbs , ResourceType . users ) }
219
- { ...{ ...props , ...decodeParams ( match . match . params ) } }
220
- />
182
+ < InternalUserEdit { ...{ ...props , ...decodeParams ( match . match . params ) } } />
221
183
) }
222
184
/>
223
185
< Route
224
186
path = { ROUTE_MAP . users . href }
225
187
render = { ( ) => {
226
- setGlobalBreadcrumbs ( ResourceType . users ) ;
227
188
return < UserList { ...props } /> ;
228
189
} }
229
190
/>
230
191
< Route
231
192
path = { buildUrl ( ResourceType . auditLogging ) + SUB_URL_FOR_GENERAL_SETTINGS_EDIT }
232
193
render = { ( ) => {
233
- setGlobalBreadcrumbs ( ResourceType . auditLogging , 'General settings' ) ;
234
194
return < AuditLoggingEditSettings setting = { 'general' } { ...props } /> ;
235
195
} }
236
196
/>
237
197
< Route
238
198
path = { buildUrl ( ResourceType . auditLogging ) + SUB_URL_FOR_COMPLIANCE_SETTINGS_EDIT }
239
199
render = { ( ) => {
240
- setGlobalBreadcrumbs ( ResourceType . auditLogging , 'Compliance settings' ) ;
241
200
return < AuditLoggingEditSettings setting = { 'compliance' } { ...props } /> ;
242
201
} }
243
202
/>
244
203
< Route
245
204
path = { ROUTE_MAP . auditLogging . href + '/:fromType?' }
246
205
render = { ( match ) => {
247
- setGlobalBreadcrumbs ( ResourceType . auditLogging ) ;
248
206
return < AuditLogging { ...{ ...props , ...match . match . params } } /> ;
249
207
} }
250
208
/>
251
209
< Route
252
210
path = { ROUTE_MAP . permissions . href }
253
211
render = { ( ) => {
254
- setGlobalBreadcrumbs ( ResourceType . permissions ) ;
255
212
return < PermissionList { ...props } /> ;
256
213
} }
257
214
/>
258
215
< Route
259
216
path = { ROUTE_MAP . getStarted . href }
260
217
render = { ( ) => {
261
- setGlobalBreadcrumbs ( ) ;
262
218
return < GetStarted { ...props } /> ;
263
219
} }
264
220
/>
265
221
{ multitenancyEnabled && (
266
222
< Route
267
223
path = { ROUTE_MAP . tenants . href }
268
224
render = { ( ) => {
269
- setGlobalBreadcrumbs ( ResourceType . tenants ) ;
270
225
return < TenantList tabID = { 'Manage' } { ...props } /> ;
271
226
} }
272
227
/>
@@ -275,7 +230,6 @@ export function AppRouter(props: AppDependencies) {
275
230
< Route
276
231
path = { ROUTE_MAP . tenantsConfigureTab . href }
277
232
render = { ( ) => {
278
- setGlobalBreadcrumbs ( ResourceType . tenants ) ;
279
233
return < TenantList tabID = { 'Configure' } { ...props } /> ;
280
234
} }
281
235
/>
0 commit comments