Skip to content

Commit 309efba

Browse files
wanglamruanyl
authored andcommitted
Add workspace overview page (opensearch-project#19)
* feat: add workspace overview page Signed-off-by: Lin Wang <wonglam@amazon.com> * refactor: move paths to common constants Signed-off-by: Lin Wang <wonglam@amazon.com> * feat: add workspace overview item by custom nav in start phase Signed-off-by: Lin Wang <wonglam@amazon.com> * refactor: change to currentWorkspace$ in workspace client Signed-off-by: Lin Wang <wonglam@amazon.com> --------- Signed-off-by: Lin Wang <wonglam@amazon.com>
1 parent c596448 commit 309efba

File tree

4 files changed

+61
-6
lines changed

4 files changed

+61
-6
lines changed

src/plugins/workspace/common/constants.ts

+5
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@
66
export const WORKSPACE_APP_ID = 'workspace';
77
export const WORKSPACE_APP_NAME = 'Workspace';
88
export const WORKSPACE_ID_IN_SESSION_STORAGE = '_workspace_id_';
9+
10+
export const PATHS = {
11+
create: '/create',
12+
overview: '/overview',
13+
};

src/plugins/workspace/public/components/routes.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { WorkspaceCreator } from './workspace_creator';
6+
import { PATHS } from '../../common/constants';
77

8-
export const paths = {
9-
create: '/create',
10-
};
8+
import { WorkspaceCreator } from './workspace_creator';
9+
import { WorkspaceOverview } from './workspace_overview';
1110

1211
export interface RouteConfig {
1312
path: string;
@@ -18,8 +17,13 @@ export interface RouteConfig {
1817

1918
export const ROUTES: RouteConfig[] = [
2019
{
21-
path: paths.create,
20+
path: PATHS.create,
2221
Component: WorkspaceCreator,
2322
label: 'Create',
2423
},
24+
{
25+
path: PATHS.overview,
26+
Component: WorkspaceOverview,
27+
label: 'Overview',
28+
},
2529
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import React from 'react';
7+
import { EuiPageHeader, EuiButton, EuiPanel, EuiSpacer, EuiTitle } from '@elastic/eui';
8+
import { useObservable } from 'react-use';
9+
import { of } from 'rxjs';
10+
11+
import { useOpenSearchDashboards } from '../../../../../src/plugins/opensearch_dashboards_react/public';
12+
13+
export const WorkspaceOverview = () => {
14+
const {
15+
services: { workspaces },
16+
} = useOpenSearchDashboards();
17+
18+
const currentWorkspace = useObservable(
19+
workspaces ? workspaces.client.currentWorkspace$ : of(null)
20+
);
21+
22+
return (
23+
<>
24+
<EuiPageHeader
25+
pageTitle="Overview"
26+
rightSideItems={[
27+
<EuiButton color="danger">Delete</EuiButton>,
28+
<EuiButton>Update</EuiButton>,
29+
]}
30+
/>
31+
<EuiPanel>
32+
<EuiTitle size="m">
33+
<h3>Workspace</h3>
34+
</EuiTitle>
35+
<EuiSpacer />
36+
{JSON.stringify(currentWorkspace)}
37+
</EuiPanel>
38+
</>
39+
);
40+
};

src/plugins/workspace/public/plugin.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
AppMountParameters,
1212
AppNavLinkStatus,
1313
} from '../../../core/public';
14-
import { WORKSPACE_APP_ID, WORKSPACE_ID_IN_SESSION_STORAGE } from '../common/constants';
14+
import { WORKSPACE_APP_ID, WORKSPACE_ID_IN_SESSION_STORAGE, PATHS } from '../common/constants';
1515
import { WORKSPACE_ID_QUERYSTRING_NAME } from '../../../core/public';
1616
import { mountDropdownList } from './mount';
1717

@@ -102,6 +102,12 @@ export class WorkspacesPlugin implements Plugin<{}, {}> {
102102

103103
public start(core: CoreStart) {
104104
mountDropdownList(core);
105+
106+
core.chrome.setCustomNavLink({
107+
title: i18n.translate('workspace.nav.title', { defaultMessage: 'Workspace Overview' }),
108+
baseUrl: core.http.basePath.get(),
109+
href: core.application.getUrlForApp(WORKSPACE_APP_ID, { path: PATHS.overview }),
110+
});
105111
return {};
106112
}
107113
}

0 commit comments

Comments
 (0)