From 40cfcf1e96dcfadd170a4535d2b70fe1f3f82e74 Mon Sep 17 00:00:00 2001 From: Adam Tackett <105462877+TackAdam@users.noreply.github.com> Date: Wed, 17 Jul 2024 14:56:28 -0700 Subject: [PATCH] Add a function to register all plugin Nav groups and categories (#406) Signed-off-by: Adam Tackett Co-authored-by: Adam Tackett --- public/plugin.ts | 3 ++- public/plugin_nav.tsx | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 public/plugin_nav.tsx diff --git a/public/plugin.ts b/public/plugin.ts index 2c5bc55..fe62802 100644 --- a/public/plugin.ts +++ b/public/plugin.ts @@ -13,6 +13,7 @@ import { SearchRelevancePluginSetup, SearchRelevancePluginStart, } from './types'; +import { registerAllPluginNavGroups } from './plugin_nav'; export interface SearchRelevancePluginSetupDependencies { dataSource: DataSourcePluginSetup; @@ -44,7 +45,7 @@ export class SearchRelevancePlugin return renderApp(coreStart, depsStart as AppPluginStartDependencies, params, dataSourceManagement); }, }); - + registerAllPluginNavGroups(core); // Return methods that should be available to other plugins return { getGreeting() { diff --git a/public/plugin_nav.tsx b/public/plugin_nav.tsx new file mode 100644 index 0000000..500567e --- /dev/null +++ b/public/plugin_nav.tsx @@ -0,0 +1,29 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { CoreSetup } from '../../../src/core/public'; +import { SearchRelevancePluginSetup } from './types'; +import { PLUGIN_ID } from '../common'; +import { DEFAULT_NAV_GROUPS, DEFAULT_APP_CATEGORIES, AppCategory } from '../../../src/core/public'; +import { i18n } from "@osd/i18n"; + +const searchRelevance_category: Record = { + evaluateSearch: { + id: "evaluateSearch", + label: i18n.translate("core.ui.indexesNavList.label", { + defaultMessage: "Evaluate search", + }), + order: 3000, + }, +}; + +export function registerAllPluginNavGroups(core: CoreSetup) { + core.chrome.navGroup.addNavLinksToGroup(DEFAULT_NAV_GROUPS.search, [ + { + id: PLUGIN_ID, + category: searchRelevance_category.evaluateSearch,//change to Evaluate Search + }, + ]); +} \ No newline at end of file