Skip to content

Commit f2aef77

Browse files
Adds resource access management dashboard
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
1 parent 2151e12 commit f2aef77

File tree

11 files changed

+1232
-1
lines changed

11 files changed

+1232
-1
lines changed

common/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ export const PLUGIN_USERS_APP_ID = `${PLUGIN_NAME}_users`;
2222
export const PLUGIN_PERMISSIONS_APP_ID = `${PLUGIN_NAME}_permissions`;
2323
export const PLUGIN_TENANTS_APP_ID = `${PLUGIN_NAME}_tenants`;
2424
export const PLUGIN_AUDITLOG_APP_ID = `${PLUGIN_NAME}_auditlog`;
25+
export const PLUGIN_RESOURCE_ACCESS_MANAGEMENT_APP_ID = `${PLUGIN_NAME}_resource_access_management`;
2526

2627
export const APP_ID_LOGIN = 'login';
2728
export const APP_ID_CUSTOMERROR = 'customerror';
29+
export const APP_ID_RESOURCE_ACCESS_MANAGEMENT = 'resource_access_management';
2830
export const OPENDISTRO_SECURITY_ANONYMOUS = 'opendistro_security_anonymous';
2931

3032
export const API_PREFIX = '/api/v1';
@@ -34,6 +36,7 @@ export const API_ENDPOINT_DASHBOARDSINFO = API_PREFIX + '/auth/dashboardsinfo';
3436
export const API_ENDPOINT_AUTHTYPE = API_PREFIX + '/auth/type';
3537
export const LOGIN_PAGE_URI = '/app/' + APP_ID_LOGIN;
3638
export const CUSTOM_ERROR_PAGE_URI = '/app/' + APP_ID_CUSTOMERROR;
39+
export const RESOURCE_ACCESS_MANAGEMENT_URI = '/app/' + APP_ID_RESOURCE_ACCESS_MANAGEMENT;
3740
export const API_AUTH_LOGIN = '/auth/login';
3841
export const API_AUTH_LOGOUT = '/auth/logout';
3942
export const OPENID_AUTH_LOGIN = '/auth/openid/login';

public/apps/configuration/constants.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export const CLUSTER_PERMISSIONS: string[] = [
240240
'cluster:admin/search/pipeline/delete',
241241
'cluster:admin/search/pipeline/get',
242242
'cluster:admin/search/pipeline/put',
243+
'cluster:admin/security/resource/share',
243244
'cluster:admin/settings/update',
244245
'cluster:admin/snapshot/create',
245246
'cluster:admin/snapshot/clone',
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
// stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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 './_index.scss';
17+
18+
import React from 'react';
19+
import ReactDOM from 'react-dom';
20+
import { I18nProvider } from '@osd/i18n/react';
21+
22+
import { EuiPage, EuiPageBody, EuiPageHeader, EuiTitle, EuiText, EuiSpacer } from '@elastic/eui';
23+
24+
import { AppMountParameters, CoreStart } from '../../../../../src/core/public';
25+
import { DataSourceManagementPluginSetup } from '../../../../../src/plugins/data_source_management/public';
26+
import { SecurityPluginStartDependencies, ClientConfigType } from '../../types';
27+
28+
import { ResourceSharingPanel } from './resource-sharing-panel';
29+
import { buildResourceApi } from '../../utils/resource-sharing-utils';
30+
31+
interface Props {
32+
coreStart: CoreStart;
33+
depsStart: SecurityPluginStartDependencies;
34+
params: AppMountParameters;
35+
config: ClientConfigType;
36+
redirect: string;
37+
dataSourceManagement?: DataSourceManagementPluginSetup;
38+
}
39+
40+
const ResourceAccessManagementApp: React.FC<Props> = ({ coreStart, depsStart }) => {
41+
const {
42+
http,
43+
notifications: { toasts },
44+
} = coreStart;
45+
const TopNav = depsStart?.navigation?.ui?.TopNavMenu;
46+
47+
return (
48+
<>
49+
{TopNav ? (
50+
<TopNav appName="resource-access" showSearchBar={false} useDefaultBehaviors={true} />
51+
) : null}
52+
<EuiPage restrictWidth="2000px">
53+
<EuiPageBody component="main">
54+
<EuiPageHeader>
55+
<EuiTitle size="l">
56+
<h1>Resource Access Management</h1>
57+
</EuiTitle>
58+
<EuiText color="subdued">Manage sharing for detectors, forecasters, and more.</EuiText>
59+
</EuiPageHeader>
60+
61+
<EuiSpacer size="m" />
62+
63+
<ResourceSharingPanel api={buildResourceApi(http)} toasts={toasts} />
64+
</EuiPageBody>
65+
</EuiPage>
66+
</>
67+
);
68+
};
69+
70+
export function renderApp(
71+
coreStart: CoreStart,
72+
depsStart: SecurityPluginStartDependencies,
73+
params: AppMountParameters,
74+
config: ClientConfigType,
75+
redirect: string,
76+
dataSourceManagement?: DataSourceManagementPluginSetup
77+
) {
78+
const deps: Props = {
79+
coreStart,
80+
depsStart,
81+
params,
82+
config,
83+
dataSourceManagement,
84+
redirect,
85+
};
86+
87+
ReactDOM.render(
88+
<I18nProvider>
89+
<ResourceAccessManagementApp {...deps} />
90+
</I18nProvider>,
91+
params.element
92+
);
93+
94+
return () => ReactDOM.unmountComponentAtNode(params.element);
95+
}

0 commit comments

Comments
 (0)