From cb4bc833bf00ae2714bb0c21053c22c227eeb153 Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Fri, 16 Jun 2023 14:41:39 +0800 Subject: [PATCH] Remove plugins pages for management overview registration Signed-off-by: Hailong Cui --- .eslintrc.js | 33 ++++++++++++++++++++++++++++ package.json | 4 ++-- public/pages/Main/Main.tsx | 4 ++-- public/plugin.ts | 44 ++++++++++++++------------------------ public/types.ts | 5 +++++ 5 files changed, 58 insertions(+), 32 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/package.json b/package.json index 36990356..42fc3d43 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/pages/Main/Main.tsx b/public/pages/Main/Main.tsx index ea4bac8b..091fdcb7 100644 --- a/public/pages/Main/Main.tsx +++ b/public/pages/Main/Main.tsx @@ -21,7 +21,7 @@ import { CreateSESSender } from '../Emails/CreateSESSender'; import { EmailGroups } from '../Emails/EmailGroups'; import { EmailSenders } from '../Emails/EmailSenders'; -export enum Navigation { +enum Navigation { Notifications = 'Notifications', Channels = 'Channels', EmailSenders = 'Email senders', @@ -32,7 +32,7 @@ enum Pathname { Channels = '/channels', } -interface MainProps extends RouteComponentProps {} +type MainProps = RouteComponentProps; export interface MainState { availableChannels: Partial; diff --git a/public/plugin.ts b/public/plugin.ts index 692badf4..9e3579f0 100644 --- a/public/plugin.ts +++ b/public/plugin.ts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { i18n } from '@osd/i18n'; import { AppMountParameters, CoreSetup, @@ -13,16 +14,9 @@ import { import { notificationsDashboardsPluginSetup, notificationsDashboardsPluginStart, - AppPluginStartDependencies, + NotificationsDashboardsSetupDeps, } from './types'; import { PLUGIN_NAME } from '../common'; -import { Navigation } from "./pages/Main/Main"; -import { ROUTES } from "./utils/constants"; -import { ManagementOverViewPluginSetup } from "../../../src/plugins/management_overview/public"; - -interface NotificationsDashboardsSetupDeps { - managementOverview?: ManagementOverViewPluginSetup; -} export class notificationsDashboardsPlugin implements @@ -30,11 +24,18 @@ export class notificationsDashboardsPlugin notificationsDashboardsPluginSetup, notificationsDashboardsPluginStart > { - public setup(core: CoreSetup, { managementOverview }: NotificationsDashboardsSetupDeps): 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', + title: this.title, category: DEFAULT_APP_CATEGORIES.management, order: 9060, async mount(params: AppMountParameters) { @@ -50,25 +51,12 @@ export class notificationsDashboardsPlugin if (managementOverview) { managementOverview.register({ id: PLUGIN_NAME, - title: 'Notifications', + title: this.title, order: 9060, - pages: [ - { - title: Navigation.Channels, - url: `#${ROUTES.CHANNELS}`, - order: 100 - }, - { - title: Navigation.EmailSenders, - url: `#${ROUTES.EMAIL_SENDERS}`, - order: 200 - }, - { - title: Navigation.EmailGroups, - url: `#${ROUTES.EMAIL_GROUPS}`, - order: 300 - }, - ] + description: i18n.translate('notification.notificationDescription', { + defaultMessage: + 'Connect with your communication service to receive notifications from supported OpenSearch plugins.', + }), }); } 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; +}