Skip to content

Commit a60ba1c

Browse files
Merge branch 'main' into ism
2 parents ac2c4ce + b1148fb commit a60ba1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2149
-575
lines changed

.github/CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @cliu123 @cwperks @DarshitChanpura @derek-ho @RyanL1997 @scrawfor99
1+
* @cwperks @DarshitChanpura @derek-ho @RyanL1997 @stephen-crawford

MAINTAINERS.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ This document contains a list of maintainers in this repo. See [opensearch-proje
66

77
| Maintainer | GitHub ID | Affiliation |
88
| ---------------- | ----------------------------------------------------- | ----------- |
9-
| Chang Liu | [cliu123](https://github.com/cliu123) | Amazon |
109
| Darshit Chanpura | [DarshitChanpura](https://github.com/DarshitChanpura) | Amazon |
1110
| Craig Perkins | [cwperks](https://github.com/cwperks) | Amazon |
1211
| Ryan Liang | [RyanL1997](https://github.com/RyanL1997) | Amazon |
13-
| Stephen Crawford | [scrawfor99](https://github.com/scrawfor99) | Amazon |
12+
| Stephen Crawford | [scrawfor99](https://github.com/stephen-crawford) | Amazon |
1413
| Derek Ho | [derek-ho](https://github.com/derek-ho) | Amazon |
1514

1615
## Emeritus
@@ -22,3 +21,5 @@ This document contains a list of maintainers in this repo. See [opensearch-proje
2221
| Tianle Huang | [tianleh](https://github.com/tianleh) | Amazon |
2322
| Dave Lago | [davidlago](https://github.com/davidlago) | Contributor |
2423
| Peter Nied | [peternied](https://github.com/peternied) | Amazon |
24+
| Chang Liu | [cliu123](https://github.com/cliu123) | Amazon |
25+

public/apps/configuration/app-router.tsx

+16-62
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* permissions and limitations under the License.
1414
*/
1515

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';
1818
import React, { createContext, useState } from 'react';
1919
import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom';
2020
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';
3838
import { UserList } from './panels/user-list';
3939
import { Action, RouteItem, SubAction } from './types';
4040
import { ResourceType } from '../../../common';
41-
import { buildHashUrl, buildUrl } from './utils/url-builder';
41+
import { buildUrl } from './utils/url-builder';
4242
import { CrossPageToast } from './cross-page-toast';
4343
import { getDataSourceFromUrl, LocalCluster } from '../../utils/datasource-utils';
44+
import { getBreadcrumbs } from './utils/resource-utils';
4445

4546
const LANDING_PAGE_URL = '/getstarted';
4647

4748
export const ROUTE_MAP: { [key: string]: RouteItem } = {
4849
getStarted: {
4950
name: 'Get Started',
51+
breadCrumbDisplayNameWithoutSecurityBase: 'Get started with access control',
5052
href: LANDING_PAGE_URL,
5153
},
5254
[ResourceType.roles]: {
5355
name: 'Roles',
56+
breadCrumbDisplayNameWithoutSecurityBase: 'Roles',
5457
href: buildUrl(ResourceType.roles),
5558
},
5659
[ResourceType.users]: {
5760
name: 'Internal users',
61+
breadCrumbDisplayNameWithoutSecurityBase: 'Internal users',
5862
href: buildUrl(ResourceType.users),
5963
},
6064
[ResourceType.permissions]: {
6165
name: 'Permissions',
66+
breadCrumbDisplayNameWithoutSecurityBase: 'Permissions',
6267
href: buildUrl(ResourceType.permissions),
6368
},
6469
[ResourceType.tenants]: {
6570
name: 'Tenants',
71+
breadCrumbDisplayNameWithoutSecurityBase: 'Dashboard multi-tenancy',
6672
href: buildUrl(ResourceType.tenants),
6773
},
6874
[ResourceType.tenantsConfigureTab]: {
@@ -71,10 +77,12 @@ export const ROUTE_MAP: { [key: string]: RouteItem } = {
7177
},
7278
[ResourceType.auth]: {
7379
name: 'Authentication',
80+
breadCrumbDisplayNameWithoutSecurityBase: 'Authentication and authorization',
7481
href: buildUrl(ResourceType.auth),
7582
},
7683
[ResourceType.auditLogging]: {
7784
name: 'Audit logs',
85+
breadCrumbDisplayNameWithoutSecurityBase: 'Audit logs',
7886
href: buildUrl(ResourceType.auditLogging),
7987
},
8088
};
@@ -100,39 +108,6 @@ export const allNavPanelUrls = (multitenancyEnabled: boolean) =>
100108
...(multitenancyEnabled ? [buildUrl(ResourceType.tenantsConfigureTab)] : []),
101109
]);
102110

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-
136111
function decodeParams(params: { [k: string]: string }): any {
137112
return Object.keys(params).reduce((obj: { [k: string]: string }, key: string) => {
138113
obj[key] = decodeURIComponent(params[key]);
@@ -154,6 +129,7 @@ export function AppRouter(props: AppDependencies) {
154129
const dataSourceFromUrl = dataSourceEnabled ? getDataSourceFromUrl() : LocalCluster;
155130

156131
const [dataSource, setDataSource] = useState<DataSourceOption>(dataSourceFromUrl);
132+
const includeSecurityBase = !props.coreStart.uiSettings.get('home:useNewHomePage');
157133

158134
return (
159135
<DataSourceContext.Provider value={{ dataSource, setDataSource }}>
@@ -173,100 +149,79 @@ export function AppRouter(props: AppDependencies) {
173149
<Route
174150
path={buildUrl(ResourceType.roles, Action.edit) + '/:roleName/' + SubAction.mapuser}
175151
render={(match) => (
176-
<RoleEditMappedUser
177-
buildBreadcrumbs={partial(setGlobalBreadcrumbs, ResourceType.roles)}
178-
{...{ ...props, ...decodeParams(match.match.params) }}
179-
/>
152+
<RoleEditMappedUser {...{ ...props, ...decodeParams(match.match.params) }} />
180153
)}
181154
/>
182155
<Route
183156
path={buildUrl(ResourceType.roles, Action.view) + '/:roleName/:prevAction?'}
184157
render={(match) => (
185-
<RoleView
186-
buildBreadcrumbs={partial(setGlobalBreadcrumbs, ResourceType.roles)}
187-
{...{ ...props, ...decodeParams(match.match.params) }}
188-
/>
158+
<RoleView {...{ ...props, ...decodeParams(match.match.params) }} />
189159
)}
190160
/>
191161
<Route
192162
path={buildUrl(ResourceType.roles) + '/:action/:sourceRoleName?'}
193163
render={(match) => (
194-
<RoleEdit
195-
buildBreadcrumbs={partial(setGlobalBreadcrumbs, ResourceType.roles)}
196-
{...{ ...props, ...decodeParams(match.match.params) }}
197-
/>
164+
<RoleEdit {...{ ...props, ...decodeParams(match.match.params) }} />
198165
)}
199166
/>
200167
<Route
201168
path={ROUTE_MAP.roles.href}
202169
render={() => {
203-
setGlobalBreadcrumbs(ResourceType.roles);
204170
return <RoleList {...props} />;
205171
}}
206172
/>
207173
<Route
208174
path={ROUTE_MAP.auth.href}
209175
render={() => {
210-
setGlobalBreadcrumbs(ResourceType.auth);
211176
return <AuthView {...props} />;
212177
}}
213178
/>
214179
<Route
215180
path={buildUrl(ResourceType.users) + '/:action/:sourceUserName?'}
216181
render={(match) => (
217-
<InternalUserEdit
218-
buildBreadcrumbs={partial(setGlobalBreadcrumbs, ResourceType.users)}
219-
{...{ ...props, ...decodeParams(match.match.params) }}
220-
/>
182+
<InternalUserEdit {...{ ...props, ...decodeParams(match.match.params) }} />
221183
)}
222184
/>
223185
<Route
224186
path={ROUTE_MAP.users.href}
225187
render={() => {
226-
setGlobalBreadcrumbs(ResourceType.users);
227188
return <UserList {...props} />;
228189
}}
229190
/>
230191
<Route
231192
path={buildUrl(ResourceType.auditLogging) + SUB_URL_FOR_GENERAL_SETTINGS_EDIT}
232193
render={() => {
233-
setGlobalBreadcrumbs(ResourceType.auditLogging, 'General settings');
234194
return <AuditLoggingEditSettings setting={'general'} {...props} />;
235195
}}
236196
/>
237197
<Route
238198
path={buildUrl(ResourceType.auditLogging) + SUB_URL_FOR_COMPLIANCE_SETTINGS_EDIT}
239199
render={() => {
240-
setGlobalBreadcrumbs(ResourceType.auditLogging, 'Compliance settings');
241200
return <AuditLoggingEditSettings setting={'compliance'} {...props} />;
242201
}}
243202
/>
244203
<Route
245204
path={ROUTE_MAP.auditLogging.href + '/:fromType?'}
246205
render={(match) => {
247-
setGlobalBreadcrumbs(ResourceType.auditLogging);
248206
return <AuditLogging {...{ ...props, ...match.match.params }} />;
249207
}}
250208
/>
251209
<Route
252210
path={ROUTE_MAP.permissions.href}
253211
render={() => {
254-
setGlobalBreadcrumbs(ResourceType.permissions);
255212
return <PermissionList {...props} />;
256213
}}
257214
/>
258215
<Route
259216
path={ROUTE_MAP.getStarted.href}
260217
render={() => {
261-
setGlobalBreadcrumbs();
262218
return <GetStarted {...props} />;
263219
}}
264220
/>
265221
{multitenancyEnabled && (
266222
<Route
267223
path={ROUTE_MAP.tenants.href}
268224
render={() => {
269-
setGlobalBreadcrumbs(ResourceType.tenants);
270225
return <TenantList tabID={'Manage'} {...props} />;
271226
}}
272227
/>
@@ -275,7 +230,6 @@ export function AppRouter(props: AppDependencies) {
275230
<Route
276231
path={ROUTE_MAP.tenantsConfigureTab.href}
277232
render={() => {
278-
setGlobalBreadcrumbs(ResourceType.tenants);
279233
return <TenantList tabID={'Configure'} {...props} />;
280234
}}
281235
/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
import React from 'react';
17+
import { flow } from 'lodash';
18+
import { ControlProps, DescriptionProps, HeaderProps } from './header-props';
19+
import { getBreadcrumbs } from '../utils/resource-utils';
20+
21+
export const HeaderButtonOrLink = React.memo((props: HeaderProps & ControlProps) => {
22+
const { HeaderControl } = props.navigation.ui;
23+
24+
return (
25+
<HeaderControl
26+
setMountPoint={props.coreStart.application.setAppRightControls}
27+
controls={props.appRightControls}
28+
/>
29+
);
30+
});
31+
32+
export const PageHeader = (props: HeaderProps & DescriptionProps & ControlProps) => {
33+
const { HeaderControl } = props.navigation.ui; // need to get this from SecurityPluginStartDependencies
34+
const useNewUx = props.coreStart.uiSettings.get('home:useNewHomePage');
35+
flow(getBreadcrumbs, props.coreStart.chrome.setBreadcrumbs)(
36+
!useNewUx,
37+
props.resourceType,
38+
props.pageTitle,
39+
props.subAction,
40+
props.count
41+
);
42+
if (useNewUx) {
43+
return (
44+
<>
45+
{props.descriptionControls ? (
46+
<HeaderControl
47+
setMountPoint={props.coreStart.application.setAppDescriptionControls}
48+
controls={props.descriptionControls}
49+
/>
50+
) : null}
51+
{props.appRightControls ? (
52+
<HeaderControl
53+
setMountPoint={props.coreStart.application.setAppRightControls}
54+
controls={props.appRightControls}
55+
/>
56+
) : null}
57+
</>
58+
);
59+
} else {
60+
return props.fallBackComponent;
61+
}
62+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
import { CoreStart } from 'opensearch-dashboards/public';
17+
import { NavigationPublicPluginStart } from 'src/plugins/navigation/public';
18+
import { TopNavControlData } from 'src/plugins/navigation/public/top_nav_menu/top_nav_control_data';
19+
import { ResourceType } from '../../../../common';
20+
21+
export interface HeaderProps {
22+
navigation: NavigationPublicPluginStart;
23+
coreStart: CoreStart;
24+
fallBackComponent: JSX.Element;
25+
resourceType?: ResourceType;
26+
pageTitle?: string;
27+
subAction?: string;
28+
count?: number;
29+
}
30+
31+
export interface ControlProps {
32+
appRightControls?: TopNavControlData[];
33+
}
34+
35+
export interface DescriptionProps {
36+
descriptionControls?: TopNavControlData[];
37+
}

0 commit comments

Comments
 (0)