diff --git a/changelogs/fragments/8076.yml b/changelogs/fragments/8076.yml new file mode 100644 index 000000000000..13920d42c75f --- /dev/null +++ b/changelogs/fragments/8076.yml @@ -0,0 +1,2 @@ +feat: +- [navigation] Add `sample data` menu back ([#8076](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8076)) \ No newline at end of file diff --git a/src/core/server/utils/auth_info.ts b/src/core/server/utils/auth_info.ts index 7d965ad05ca9..f37632807daa 100644 --- a/src/core/server/utils/auth_info.ts +++ b/src/core/server/utils/auth_info.ts @@ -11,6 +11,7 @@ import { PrincipalType, Principals } from '../saved_objects/permission_control/a export interface AuthInfo { backend_roles?: string[]; user_name?: string; + user_id?: string; } export const getPrincipalsFromRequest = ( @@ -31,7 +32,9 @@ export const getPrincipalsFromRequest = ( if (authState?.authInfo?.backend_roles) { payload[PrincipalType.Groups] = authState.authInfo.backend_roles; } - if (authState?.authInfo?.user_name) { + if (authState?.authInfo?.user_id) { + payload[PrincipalType.Users] = [authState.authInfo.user_id]; + } else if (authState?.authInfo?.user_name) { payload[PrincipalType.Users] = [authState.authInfo.user_name]; } return payload; diff --git a/src/plugins/home/common/constants.ts b/src/plugins/home/common/constants.ts index 25c78c59c4ac..2760cc328b5b 100644 --- a/src/plugins/home/common/constants.ts +++ b/src/plugins/home/common/constants.ts @@ -31,4 +31,8 @@ export const PLUGIN_ID = 'home'; export const HOME_APP_BASE_PATH = `/app/${PLUGIN_ID}`; export const USE_NEW_HOME_PAGE = 'home:useNewHomePage'; + +/** + * The id is used in src/plugins/workspace/public/plugin.ts and please change that accordingly if you change the id here. + */ export const IMPORT_SAMPLE_DATA_APP_ID = 'import_sample_data'; diff --git a/src/plugins/home/public/plugin.ts b/src/plugins/home/public/plugin.ts index 59be17d70c1c..7ede9a32ecdb 100644 --- a/src/plugins/home/public/plugin.ts +++ b/src/plugins/home/public/plugin.ts @@ -210,7 +210,9 @@ export class HomePublicPlugin title: i18n.translate('home.tutorialDirectory.featureCatalogueTitle', { defaultMessage: 'Add sample data', }), - navLinkStatus: AppNavLinkStatus.hidden, + navLinkStatus: core.chrome.navGroup.getNavGroupEnabled() + ? AppNavLinkStatus.default + : AppNavLinkStatus.hidden, mount: async (params: AppMountParameters) => { const [coreStart] = await core.getStartServices(); setCommonService(); diff --git a/src/plugins/workspace/public/services/use_case_service.test.ts b/src/plugins/workspace/public/services/use_case_service.test.ts index 203cb48fe842..bdd819145f82 100644 --- a/src/plugins/workspace/public/services/use_case_service.test.ts +++ b/src/plugins/workspace/public/services/use_case_service.test.ts @@ -88,24 +88,30 @@ describe('UseCaseService', () => { await waitFor(() => { expect(coreSetup.chrome.navGroup.addNavLinksToGroup).toBeCalledWith(navGroupInfo, [ { - id: 'dataSources', + id: 'objects', category: DEFAULT_APP_CATEGORIES.manageWorkspace, order: 100, }, { - id: 'indexPatterns', + id: 'dataSources', category: DEFAULT_APP_CATEGORIES.manageWorkspace, order: 200, }, { - id: 'objects', + id: 'indexPatterns', category: DEFAULT_APP_CATEGORIES.manageWorkspace, order: 300, }, { - id: WORKSPACE_DETAIL_APP_ID, + id: 'import_sample_data', category: DEFAULT_APP_CATEGORIES.manageWorkspace, order: 400, + title: 'Sample data', + }, + { + id: WORKSPACE_DETAIL_APP_ID, + category: DEFAULT_APP_CATEGORIES.manageWorkspace, + order: 500, title: 'Workspace settings', }, ]); diff --git a/src/plugins/workspace/public/services/use_case_service.ts b/src/plugins/workspace/public/services/use_case_service.ts index 630ba9f15e29..31e15977d9a5 100644 --- a/src/plugins/workspace/public/services/use_case_service.ts +++ b/src/plugins/workspace/public/services/use_case_service.ts @@ -65,24 +65,32 @@ export class UseCaseService { if (navGroupInfo) { setupDeps.chrome.navGroup.addNavLinksToGroup(navGroupInfo, [ { - id: 'dataSources', + id: 'objects', category: DEFAULT_APP_CATEGORIES.manageWorkspace, order: 100, }, { - id: 'indexPatterns', + id: 'dataSources', category: DEFAULT_APP_CATEGORIES.manageWorkspace, order: 200, }, { - id: 'objects', + id: 'indexPatterns', category: DEFAULT_APP_CATEGORIES.manageWorkspace, order: 300, }, { - id: WORKSPACE_DETAIL_APP_ID, + id: 'import_sample_data', category: DEFAULT_APP_CATEGORIES.manageWorkspace, order: 400, + title: i18n.translate('workspace.left.sampleData.label', { + defaultMessage: 'Sample data', + }), + }, + { + id: WORKSPACE_DETAIL_APP_ID, + category: DEFAULT_APP_CATEGORIES.manageWorkspace, + order: 500, title: i18n.translate('workspace.settings.workspaceSettings', { defaultMessage: 'Workspace settings', }),