Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[navigation]feat: add sample data menu back #8076

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
export interface AuthInfo {
backend_roles?: string[];
user_name?: string;
user_id?: string;
}

export const getPrincipalsFromRequest = (
Expand All @@ -31,7 +32,9 @@
if (authState?.authInfo?.backend_roles) {
payload[PrincipalType.Groups] = authState.authInfo.backend_roles;
}
if (authState?.authInfo?.user_name) {
if (authState?.authInfo?.user_id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unrelated, is it by accident?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, as the change is minor so I want to include the change into in this PR as well. No need to raise a new PR for such 1 line change.

payload[PrincipalType.Users] = [authState.authInfo.user_id];

Check warning on line 36 in src/core/server/utils/auth_info.ts

View check run for this annotation

Codecov / codecov/patch

src/core/server/utils/auth_info.ts#L36

Added line #L36 was not covered by tests
} 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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still have sample data card in overview pages?

Copy link
Member Author

@SuZhou-Joe SuZhou-Joe Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but we still need the menu in left nav or the bread crumb info of sample data page will be broken.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am having a hard time finding the Add Sample Data card in the workspaces other than Search. Is this something we added in the past day or two?

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
Loading