Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data source inside stack management setup (#2017) #2030

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
kristenTian marked this conversation as resolved.
Show resolved Hide resolved

---

## 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",
"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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since index pattern management app also has order 0, do we have plan to reorder all apps together?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since index pattern management app also has order 0, do we have plan to reorder all apps together?

i believe that's task #2028

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'];
}