Skip to content

Commit

Permalink
Add a function to register all plugin Nav groups and categories (#406)
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Tackett <[email protected]>
Co-authored-by: Adam Tackett <[email protected]>
  • Loading branch information
TackAdam and Adam Tackett authored Jul 17, 2024
1 parent ece9876 commit 40cfcf1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
SearchRelevancePluginSetup,
SearchRelevancePluginStart,
} from './types';
import { registerAllPluginNavGroups } from './plugin_nav';

export interface SearchRelevancePluginSetupDependencies {
dataSource: DataSourcePluginSetup;
Expand Down Expand Up @@ -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() {
Expand Down
29 changes: 29 additions & 0 deletions public/plugin_nav.tsx
Original file line number Diff line number Diff line change
@@ -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<string, AppCategory & { group?: AppCategory }> = {
evaluateSearch: {
id: "evaluateSearch",
label: i18n.translate("core.ui.indexesNavList.label", {
defaultMessage: "Evaluate search",
}),
order: 3000,
},
};

export function registerAllPluginNavGroups(core: CoreSetup<SearchRelevancePluginSetup>) {
core.chrome.navGroup.addNavLinksToGroup(DEFAULT_NAV_GROUPS.search, [
{
id: PLUGIN_ID,
category: searchRelevance_category.evaluateSearch,//change to Evaluate Search
},
]);
}

0 comments on commit 40cfcf1

Please sign in to comment.