Skip to content

Commit

Permalink
Data source inside stack management setup (#2017) (#2030)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristen Tian <[email protected]>
  • Loading branch information
kristenTian authored Aug 1, 2022
1 parent b288a12 commit f7a3a54
Show file tree
Hide file tree
Showing 12 changed files with 290 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/plugins/data_source_management/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# dataSourceManagement

A OpenSearch Dashboards plugin

---

## Development

See the [OpenSearch Dashboards contributing
guide](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/CONTRIBUTING.md) for instructions
setting up your development environment.
13 changes: 13 additions & 0 deletions src/plugins/data_source_management/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

export const PLUGIN_ID = 'dataSourceManagement';
export const PLUGIN_NAME = 'Data Sources';
10 changes: 10 additions & 0 deletions src/plugins/data_source_management/opensearch_dashboards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "dataSourceManagement",
"version": "1.0.0",

This comment has been minimized.

Copy link
@zengyan-amazon

zengyan-amazon Aug 2, 2022

Member

shall we use 'openSearchDashboards?'

This comment has been minimized.

Copy link
@kristenTian

kristenTian Aug 2, 2022

Author Contributor

got it, will use 'opensearchDashboards'

"opensearchDashboardsVersion": "opensearchDashboards",
"server": false,
"ui": true,
"requiredPlugins": ["management"],
"optionalPlugins": [],
"requiredBundles": ["opensearchDashboardsReact"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

import { EuiTitle } from '@elastic/eui';
import React from 'react';
import { withRouter } from 'react-router-dom';

export const CreateDataSourceWizard = () => {
return (
<EuiTitle>
<h2>{'This is the data source creation page'}</h2>
</EuiTitle>
);
};

export const CreateDataSourceWizardWithRouter = withRouter(CreateDataSourceWizard);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

export { CreateDataSourceWizardWithRouter } from './create_data_source_wizard';
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

import { EuiTitle } from '@elastic/eui';
import React from 'react';
import { withRouter } from 'react-router-dom';

export const DataSourceTable = () => {
return (
<EuiTitle>
<h2>{'This is the landing page, going to list data sources here...'}</h2>
</EuiTitle>
);
};

export const DataSourceTableWithRouter = withRouter(DataSourceTable);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

export { DataSourceTableWithRouter } from './data_source_table';
19 changes: 19 additions & 0 deletions src/plugins/data_source_management/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

import { DataSourceManagementPlugin } from './plugin';

// This exports static code and TypeScript types,
// as well as, OpenSearch Dashboards Platform `plugin()` initializer.
export function plugin() {
return new DataSourceManagementPlugin();
}
export { DataSourceManagementPluginStart } from './types';
12 changes: 12 additions & 0 deletions src/plugins/data_source_management/public/management_app/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

export { mountManagementSection } from './mount_management_section';
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

import { StartServicesAccessor } from 'src/core/public';

import { I18nProvider } from '@osd/i18n/react';
import React from 'react';
import ReactDOM from 'react-dom';
import { Route, Router, Switch } from 'react-router-dom';
import { ManagementAppMountParams } from '../../../management/public';

import { OpenSearchDashboardsContextProvider } from '../../../opensearch_dashboards_react/public';
import { CreateDataSourceWizardWithRouter } from '../components/create_data_source_wizard';
import { DataSourceTableWithRouter } from '../components/data_source_table';
import { DataSourceManagmentContext } from '../types';

export async function mountManagementSection(
getStartServices: StartServicesAccessor,
params: ManagementAppMountParams
) {
const [
{ chrome, application, savedObjects, uiSettings, notifications, overlays, http, docLinks },
] = await getStartServices();

const deps: DataSourceManagmentContext = {
chrome,
application,
savedObjects,
uiSettings,
notifications,
overlays,
http,
docLinks,
setBreadcrumbs: params.setBreadcrumbs,
};

ReactDOM.render(
<OpenSearchDashboardsContextProvider services={deps}>
<I18nProvider>
<Router history={params.history}>
<Switch>
<Route path={['/create']}>
<CreateDataSourceWizardWithRouter />
</Route>
<Route path={['/']}>
<DataSourceTableWithRouter />
</Route>
</Switch>
</Router>
</I18nProvider>
</OpenSearchDashboardsContextProvider>,
params.element
);

return () => {
chrome.docTitle.reset();
ReactDOM.unmountComponentAtNode(params.element);
};
}
45 changes: 45 additions & 0 deletions src/plugins/data_source_management/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

import { CoreSetup, CoreStart, Plugin } from '../../../core/public';
import { DataSourceManagementPluginStart, DataSourceManagementSetupDependencies } from './types';

import { PLUGIN_NAME } from '../common';

const IPM_APP_ID = 'dataSources';

export class DataSourceManagementPlugin
implements Plugin<void, DataSourceManagementPluginStart, DataSourceManagementSetupDependencies> {
public setup(core: CoreSetup, { management }: DataSourceManagementSetupDependencies) {
const opensearchDashboardsSection = management.sections.section.opensearchDashboards;

if (!opensearchDashboardsSection) {
throw new Error('`opensearchDashboards` management section not found.');
}

opensearchDashboardsSection.registerApp({
id: IPM_APP_ID,
title: PLUGIN_NAME,
order: 0,

This comment has been minimized.

Copy link
@noCharger

noCharger Aug 1, 2022

Contributor

Index pattern management app also had order 0, do we have plan to reorder all apps?

This comment has been minimized.

Copy link
@kristenTian

kristenTian Aug 2, 2022

Author Contributor

Yes, we should. We aligned it should be credential, data source ,index pattern ... etc

mount: async (params) => {
const { mountManagementSection } = await import('./management_app');

return mountManagementSection(core.getStartServices, params);
},
});
}

public start(core: CoreStart): DataSourceManagementPluginStart {
return {};
}

public stop() {}
}
41 changes: 41 additions & 0 deletions src/plugins/data_source_management/public/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

import {
ChromeStart,
ApplicationStart,
IUiSettingsClient,
OverlayStart,
SavedObjectsStart,
NotificationsStart,
DocLinksStart,
HttpSetup,
} from 'src/core/public';
import { ManagementAppMountParams, ManagementSetup } from 'src/plugins/management/public';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface DataSourceManagementPluginStart {}

export interface DataSourceManagementSetupDependencies {
management: ManagementSetup;
}

export interface DataSourceManagmentContext {
chrome: ChromeStart;
application: ApplicationStart;
savedObjects: SavedObjectsStart;
uiSettings: IUiSettingsClient;
notifications: NotificationsStart;
overlays: OverlayStart;
http: HttpSetup;
docLinks: DocLinksStart;
setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs'];
}

0 comments on commit f7a3a54

Please sign in to comment.