From adf4832de839ede4fc98ebe7d08c8332ee14f056 Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Fri, 7 Jul 2023 11:39:22 +0800 Subject: [PATCH] Move notification plugin into management section on left navigation menu (#46) * move notification into management section Signed-off-by: Hailong Cui * Fix eslint Signed-off-by: Hailong Cui * Remove plugins pages for management overview registration Signed-off-by: Hailong Cui * wording update Signed-off-by: Hailong Cui --------- Signed-off-by: Hailong Cui (cherry picked from commit f26c1caeda08919798c854abbd2424f7af5a4414) --- .eslintrc.js | 33 +++++++++++++++++++++++++++++++++ opensearch_dashboards.json | 3 ++- package.json | 4 ++-- public/plugin.ts | 35 ++++++++++++++++++++++++++--------- public/types.ts | 5 +++++ 5 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..6151f2ca --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,33 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +const LICENSE_HEADER = ` +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ +` + +module.exports = { + root: true, + extends: ['@elastic/eslint-config-kibana', 'plugin:@elastic/eui/recommended'], + rules: { + // "@osd/eslint/require-license-header": "off" + }, + overrides: [ + { + files: ['**/*.{js,ts,tsx}'], + rules: { + '@osd/eslint/require-license-header': [ + 'error', + { + licenses: [ LICENSE_HEADER ], + }, + ], + "no-console": 0 + } + } + ], +}; diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index 03ce95eb..55ccc5ef 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -7,7 +7,8 @@ "data" ], "optionalPlugins": [ - "share" + "share", + "managementOverview" ], "server": true, "ui": true diff --git a/package.json b/package.json index 5f611641..baa53da6 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "scripts": { "osd": "node ../../scripts/osd", "opensearch": "node ../../scripts/opensearch", - "lint": "eslint .", + "lint": "node ../../scripts/eslint . && node ../../scripts/stylelint", "start": "yarn plugin_helpers start", "build": "yarn plugin_helpers build", "test:jest": "TZ=UTC ../../node_modules/.bin/jest --config ./test/jest.config.js", @@ -34,4 +34,4 @@ "async": "^3.2.3", "minimist": "^1.2.6" } -} \ No newline at end of file +} diff --git a/public/plugin.ts b/public/plugin.ts index 6e71895e..baf9bee2 100644 --- a/public/plugin.ts +++ b/public/plugin.ts @@ -3,16 +3,18 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { i18n } from '@osd/i18n'; import { AppMountParameters, CoreSetup, CoreStart, + DEFAULT_APP_CATEGORIES, Plugin, } from '../../../src/core/public'; import { notificationsDashboardsPluginSetup, notificationsDashboardsPluginStart, - AppPluginStartDependencies, + NotificationsDashboardsSetupDeps, } from './types'; import { PLUGIN_NAME } from '../common'; @@ -22,17 +24,20 @@ export class notificationsDashboardsPlugin notificationsDashboardsPluginSetup, notificationsDashboardsPluginStart > { - public setup(core: CoreSetup): notificationsDashboardsPluginSetup { + private title = i18n.translate('notification.notificationTitle', { + defaultMessage: 'Notifications', + }); + + public setup( + core: CoreSetup, + { managementOverview }: NotificationsDashboardsSetupDeps + ): notificationsDashboardsPluginSetup { // Register an application into the side navigation menu core.application.register({ id: PLUGIN_NAME, - title: 'Notifications', - category: { - id: 'opensearch', - label: 'OpenSearch Plugins', - order: 2000, - }, - order: 6000, + title: this.title, + category: DEFAULT_APP_CATEGORIES.management, + order: 9060, async mount(params: AppMountParameters) { // Load application bundle const { renderApp } = await import('./application'); @@ -43,6 +48,18 @@ export class notificationsDashboardsPlugin }, }); + if (managementOverview) { + managementOverview.register({ + id: PLUGIN_NAME, + title: this.title, + order: 9060, + description: i18n.translate('notification.notificationDescription', { + defaultMessage: + 'Connect with your communication services to receive notifications from supported OpenSearch plugins.', + }), + }); + } + // Return methods that should be available to other plugins return {}; } diff --git a/public/types.ts b/public/types.ts index 5f7eec2a..94dcd332 100644 --- a/public/types.ts +++ b/public/types.ts @@ -4,6 +4,7 @@ */ import { NavigationPublicPluginStart } from '../../../src/plugins/navigation/public'; +import { ManagementOverViewPluginSetup } from "../../../src/plugins/management_overview/public"; export interface notificationsDashboardsPluginSetup {} // eslint-disable-next-line @typescript-eslint/no-empty-interface @@ -12,3 +13,7 @@ export interface notificationsDashboardsPluginStart {} export interface AppPluginStartDependencies { navigation: NavigationPublicPluginStart; } + +export interface NotificationsDashboardsSetupDeps { + managementOverview?: ManagementOverViewPluginSetup; +}