Skip to content

Commit 43c4e96

Browse files
Hailong-amwanglam
andauthored
Workspace overview blank (opensearch-project#317)
* Add workspace overview page (#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> * restore yml Signed-off-by: Hailong Cui <ihailong@amazon.com> --------- Signed-off-by: Lin Wang <wonglam@amazon.com> Signed-off-by: Hailong Cui <ihailong@amazon.com> Co-authored-by: Lin Wang <wonglam@amazon.com>
1 parent 55d9b82 commit 43c4e96

File tree

4 files changed

+93
-0
lines changed

4 files changed

+93
-0
lines changed

src/plugins/workspace/public/application.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { WorkspaceFatalError } from './components/workspace_fatal_error';
1212
import { WorkspaceCreatorApp } from './components/workspace_creator_app';
1313
import { WorkspaceUpdaterApp } from './components/workspace_updater_app';
1414
import { Services } from './types';
15+
import { WorkspaceOverviewApp } from './components/workspace_overview_app';
1516

1617
export const renderCreatorApp = ({ element }: AppMountParameters, services: Services) => {
1718
ReactDOM.render(
@@ -66,3 +67,16 @@ export const renderListApp = ({ element }: AppMountParameters, services: Service
6667
ReactDOM.unmountComponentAtNode(element);
6768
};
6869
};
70+
71+
export const renderOverviewApp = ({ element }: AppMountParameters, services: Services) => {
72+
ReactDOM.render(
73+
<OpenSearchDashboardsContextProvider services={services}>
74+
<WorkspaceOverviewApp />
75+
</OpenSearchDashboardsContextProvider>,
76+
element
77+
);
78+
79+
return () => {
80+
ReactDOM.unmountComponentAtNode(element);
81+
};
82+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import React from 'react';
7+
import { EuiPanel, EuiSpacer, EuiTitle } from '@elastic/eui';
8+
import { useObservable } from 'react-use';
9+
import { of } from 'rxjs';
10+
11+
import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public';
12+
13+
export const WorkspaceOverview = () => {
14+
const {
15+
services: { workspaces },
16+
} = useOpenSearchDashboards();
17+
18+
const currentWorkspace = useObservable(workspaces ? workspaces.currentWorkspace$ : of(null));
19+
20+
return (
21+
<>
22+
<EuiPanel>
23+
<EuiTitle size="m">
24+
<h3>Workspace</h3>
25+
</EuiTitle>
26+
<EuiSpacer />
27+
{JSON.stringify(currentWorkspace)}
28+
</EuiPanel>
29+
</>
30+
);
31+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import React, { useEffect } from 'react';
7+
import { I18nProvider } from '@osd/i18n/react';
8+
import { i18n } from '@osd/i18n';
9+
import { useOpenSearchDashboards } from '../../../opensearch_dashboards_react/public';
10+
import { WorkspaceOverview } from './workspace_overview/workspace_overview';
11+
12+
export const WorkspaceOverviewApp = () => {
13+
const {
14+
services: { chrome },
15+
} = useOpenSearchDashboards();
16+
17+
/**
18+
* set breadcrumbs to chrome
19+
*/
20+
useEffect(() => {
21+
chrome?.setBreadcrumbs([
22+
{
23+
text: i18n.translate('workspace.workspaceOverviewTitle', {
24+
defaultMessage: 'Workspace overview',
25+
}),
26+
},
27+
]);
28+
}, [chrome]);
29+
30+
return (
31+
<I18nProvider>
32+
<WorkspaceOverview />
33+
</I18nProvider>
34+
);
35+
};

src/plugins/workspace/public/plugin.ts

+13
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
190190
},
191191
});
192192

193+
// overview
194+
core.application.register({
195+
id: WORKSPACE_OVERVIEW_APP_ID,
196+
title: i18n.translate('workspace.settings.workspaceOverview', {
197+
defaultMessage: 'Workspace Overview',
198+
}),
199+
navLinkStatus: AppNavLinkStatus.hidden,
200+
async mount(params: AppMountParameters) {
201+
const { renderOverviewApp } = await import('./application');
202+
return mountWorkspaceApp(params, renderOverviewApp);
203+
},
204+
});
205+
193206
// workspace fatal error
194207
core.application.register({
195208
id: WORKSPACE_FATAL_ERROR_APP_ID,

0 commit comments

Comments
 (0)