diff --git a/src/plugins/data_source_management/README.md b/src/plugins/data_source_management/README.md new file mode 100755 index 00000000000..fe1cc9875b0 --- /dev/null +++ b/src/plugins/data_source_management/README.md @@ -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. diff --git a/src/plugins/data_source_management/common/index.ts b/src/plugins/data_source_management/common/index.ts new file mode 100644 index 00000000000..7c0ba07d7de --- /dev/null +++ b/src/plugins/data_source_management/common/index.ts @@ -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'; diff --git a/src/plugins/data_source_management/opensearch_dashboards.json b/src/plugins/data_source_management/opensearch_dashboards.json new file mode 100644 index 00000000000..e6389d4a257 --- /dev/null +++ b/src/plugins/data_source_management/opensearch_dashboards.json @@ -0,0 +1,10 @@ +{ + "id": "dataSourceManagement", + "version": "1.0.0", + "opensearchDashboardsVersion": "opensearchDashboards", + "server": false, + "ui": true, + "requiredPlugins": ["management"], + "optionalPlugins": [], + "requiredBundles": ["opensearchDashboardsReact"] +} diff --git a/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx b/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx new file mode 100644 index 00000000000..59db342ef1b --- /dev/null +++ b/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx @@ -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 ( + +

{'This is the data source creation page'}

+
+ ); +}; + +export const CreateDataSourceWizardWithRouter = withRouter(CreateDataSourceWizard); diff --git a/src/plugins/data_source_management/public/components/create_data_source_wizard/index.ts b/src/plugins/data_source_management/public/components/create_data_source_wizard/index.ts new file mode 100644 index 00000000000..7975368f61d --- /dev/null +++ b/src/plugins/data_source_management/public/components/create_data_source_wizard/index.ts @@ -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'; diff --git a/src/plugins/data_source_management/public/components/data_source_table/data_source_table.tsx b/src/plugins/data_source_management/public/components/data_source_table/data_source_table.tsx new file mode 100644 index 00000000000..81e918f8eab --- /dev/null +++ b/src/plugins/data_source_management/public/components/data_source_table/data_source_table.tsx @@ -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 ( + +

{'This is the landing page, going to list data sources here...'}

+
+ ); +}; + +export const DataSourceTableWithRouter = withRouter(DataSourceTable); diff --git a/src/plugins/data_source_management/public/components/data_source_table/index.ts b/src/plugins/data_source_management/public/components/data_source_table/index.ts new file mode 100644 index 00000000000..0763b510783 --- /dev/null +++ b/src/plugins/data_source_management/public/components/data_source_table/index.ts @@ -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'; diff --git a/src/plugins/data_source_management/public/index.ts b/src/plugins/data_source_management/public/index.ts new file mode 100644 index 00000000000..1d5170c87a7 --- /dev/null +++ b/src/plugins/data_source_management/public/index.ts @@ -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'; diff --git a/src/plugins/data_source_management/public/management_app/index.ts b/src/plugins/data_source_management/public/management_app/index.ts new file mode 100644 index 00000000000..fe9249cb70e --- /dev/null +++ b/src/plugins/data_source_management/public/management_app/index.ts @@ -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'; diff --git a/src/plugins/data_source_management/public/management_app/mount_management_section.tsx b/src/plugins/data_source_management/public/management_app/mount_management_section.tsx new file mode 100644 index 00000000000..1ced84d2fdc --- /dev/null +++ b/src/plugins/data_source_management/public/management_app/mount_management_section.tsx @@ -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( + + + + + + + + + + + + + + , + params.element + ); + + return () => { + chrome.docTitle.reset(); + ReactDOM.unmountComponentAtNode(params.element); + }; +} diff --git a/src/plugins/data_source_management/public/plugin.ts b/src/plugins/data_source_management/public/plugin.ts new file mode 100644 index 00000000000..19dd1eb0caf --- /dev/null +++ b/src/plugins/data_source_management/public/plugin.ts @@ -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 { + 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, + mount: async (params) => { + const { mountManagementSection } = await import('./management_app'); + + return mountManagementSection(core.getStartServices, params); + }, + }); + } + + public start(core: CoreStart): DataSourceManagementPluginStart { + return {}; + } + + public stop() {} +} diff --git a/src/plugins/data_source_management/public/types.ts b/src/plugins/data_source_management/public/types.ts new file mode 100644 index 00000000000..11c8b303de4 --- /dev/null +++ b/src/plugins/data_source_management/public/types.ts @@ -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']; +}