Skip to content

Commit

Permalink
[navigation]feat: add sample data menu back (opensearch-project#8076)
Browse files Browse the repository at this point in the history
* feat: add sample data back

Signed-off-by: SuZhou-Joe <[email protected]>

* Changeset file for PR opensearch-project#8076 created/updated

* fix: unit test failure

Signed-off-by: SuZhou-Joe <[email protected]>

---------

Signed-off-by: SuZhou-Joe <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
1 parent ecd33b0 commit faac756
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 10 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/8076.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [navigation] Add `sample data` menu back ([#8076](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8076))
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
- [Opensearch dashboards.release notes 2.14.0](../release-notes/opensearch-dashboards.release-notes-2.14.0.md)
- [Opensearch dashboards.release notes 2.15.0](../release-notes/opensearch-dashboards.release-notes-2.15.0.md)
- [Opensearch dashboards.release notes 2.16.0](../release-notes/opensearch-dashboards.release-notes-2.16.0.md)
- [Opensearch dashboards.release notes 2.17.0](../release-notes/opensearch-dashboards.release-notes-2.17.0.md)
- [Opensearch dashboards.release notes 2.2.0](../release-notes/opensearch-dashboards.release-notes-2.2.0.md)
- [Opensearch dashboards.release notes 2.2.1](../release-notes/opensearch-dashboards.release-notes-2.2.1.md)
- [Opensearch dashboards.release notes 2.3.0](../release-notes/opensearch-dashboards.release-notes-2.3.0.md)
Expand Down
5 changes: 4 additions & 1 deletion src/core/server/utils/auth_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/home/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
4 changes: 3 additions & 1 deletion src/plugins/home/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 10 additions & 4 deletions src/plugins/workspace/public/services/use_case_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
]);
Expand Down
16 changes: 12 additions & 4 deletions src/plugins/workspace/public/services/use_case_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}),
Expand Down

0 comments on commit faac756

Please sign in to comment.