From 4b8826e7ffa6562825ca8aad676a8d89983c2d70 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Sat, 3 Aug 2024 00:26:55 +0800 Subject: [PATCH] [navigation]fix: add sample data to left navigation (#7613) (#7615) * feat: add sample data to left navigation * Changeset file for PR #7613 created/updated * feat: add sample data to left navigation --------- (cherry picked from commit 352d2e9edf3e3603464a35ba9275a780cf73ebdd) Signed-off-by: SuZhou-Joe Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> --- changelogs/fragments/7613.yml | 2 ++ src/plugins/home/public/plugin.ts | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/7613.yml diff --git a/changelogs/fragments/7613.yml b/changelogs/fragments/7613.yml new file mode 100644 index 000000000000..ff6c8f6c521a --- /dev/null +++ b/changelogs/fragments/7613.yml @@ -0,0 +1,2 @@ +fix: +- [navigation] add sample data to left navigation ([#7613](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7613)) \ No newline at end of file diff --git a/src/plugins/home/public/plugin.ts b/src/plugins/home/public/plugin.ts index fe1099a8e635..0e555f9a3011 100644 --- a/src/plugins/home/public/plugin.ts +++ b/src/plugins/home/public/plugin.ts @@ -64,7 +64,7 @@ import { PLUGIN_ID, HOME_APP_BASE_PATH, IMPORT_SAMPLE_DATA_APP_ID } from '../com import { DataSourcePluginStart } from '../../data_source/public'; import { workWithDataSection } from './application/components/homepage/sections/work_with_data'; import { learnBasicsSection } from './application/components/homepage/sections/learn_basics'; -import { DEFAULT_NAV_GROUPS } from '../../../core/public'; +import { DEFAULT_NAV_GROUPS, DEFAULT_APP_CATEGORIES } from '../../../core/public'; import { ContentManagementPluginSetup, ContentManagementPluginStart, @@ -179,7 +179,9 @@ export class HomePublicPlugin title: i18n.translate('home.tutorialDirectory.featureCatalogueTitle', { defaultMessage: 'Add sample data', }), - navLinkStatus: AppNavLinkStatus.hidden, + navLinkStatus: core.chrome.navGroup.getNavGroupEnabled() + ? AppNavLinkStatus.visible + : AppNavLinkStatus.hidden, mount: async (params: AppMountParameters) => { const [coreStart] = await core.getStartServices(); setCommonService(); @@ -194,6 +196,26 @@ export class HomePublicPlugin }); urlForwarding.forwardApp('home', 'home'); + const configurationInfoForImportSampleData = { + id: IMPORT_SAMPLE_DATA_APP_ID, + title: i18n.translate('home.nav.sampleData.label', { + defaultMessage: 'Sample data', + }), + order: 400, + category: DEFAULT_APP_CATEGORIES.manage, + }; + + // Register sample data to all of the use cases in 2.16 + [ + DEFAULT_NAV_GROUPS.all, + DEFAULT_NAV_GROUPS.analytics, + DEFAULT_NAV_GROUPS['security-analytics'], + DEFAULT_NAV_GROUPS.observability, + DEFAULT_NAV_GROUPS.search, + ].forEach((navGroup) => + core.chrome.navGroup.addNavLinksToGroup(navGroup, [configurationInfoForImportSampleData]) + ); + const featureCatalogue = { ...this.featuresCatalogueRegistry.setup() }; featureCatalogue.register({