Skip to content

Commit

Permalink
[navigation-next]fix: breadcrumb issue found in data source managemen…
Browse files Browse the repository at this point in the history
…t and other similar cases. (#7401)

* feat: add scoped breadcrumbs

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* Changeset file for PR #7401 created/updated

* feat: move data source management register logic up a little bit

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add unit test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: revert the home related change

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* fix: overview error in all use case when workspace is enabled

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* fix: update snapshot

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* Changeset file for PR #7401 created/updated

* fix: hide nav groups that should be displayed

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: hide expand icon in left navigation

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: ZilongX <99905560+ZilongX@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 24, 2024
1 parent f872b02 commit 3f78c94
Show file tree
Hide file tree
Showing 17 changed files with 411 additions and 89 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7401.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Make breadcrumb of 4 new added applications comply with BrowserRouter. ([#7401](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7401))

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

148 changes: 148 additions & 0 deletions src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ describe('<CollapsibleNavGroupEnabled />', () => {
function mockProps(
props?: Partial<CollapsibleNavGroupEnabledProps> & {
navGroupsMap?: Record<string, NavGroupItemInMap>;
currentNavGroupId?: string;
navLinks?: ChromeNavLink[];
}
): CollapsibleNavGroupEnabledProps {
const currentNavGroup$ = new BehaviorSubject<NavGroupItemInMap | undefined>(undefined);
const navGroupsMap$ = new BehaviorSubject<Record<string, NavGroupItemInMap>>({
[ALL_USE_CASE_ID]: {
...DEFAULT_NAV_GROUPS[ALL_USE_CASE_ID],
Expand All @@ -121,6 +122,9 @@ describe('<CollapsibleNavGroupEnabled />', () => {
},
...props?.navGroupsMap,
});
const currentNavGroup$ = new BehaviorSubject<NavGroupItemInMap | undefined>(
props?.currentNavGroupId ? navGroupsMap$.getValue()[props.currentNavGroupId] : undefined
);
return {
appId$: new BehaviorSubject('test'),
basePath: mockBasePath,
Expand All @@ -146,6 +150,7 @@ describe('<CollapsibleNavGroupEnabled />', () => {
baseUrl: '',
href: '',
},
...(props?.navLinks || []),
]),
storage: new StubBrowserStorage(),
onIsLockedUpdate: () => {},
Expand Down Expand Up @@ -226,8 +231,9 @@ describe('<CollapsibleNavGroupEnabled />', () => {
expect(getAllByTestId('collapsibleNavAppLink-link-in-analytics').length).toEqual(2);
});

it('should hide left navigation when in home page when workspace is enabled', async () => {
it('should show all use case when current nav group is `all`', async () => {
const props = mockProps({
currentNavGroupId: ALL_USE_CASE_ID,
navGroupsMap: {
[DEFAULT_NAV_GROUPS.analytics.id]: {
...DEFAULT_NAV_GROUPS.analytics,
Expand All @@ -241,12 +247,45 @@ describe('<CollapsibleNavGroupEnabled />', () => {
},
},
});
props.appId$ = new BehaviorSubject('home');
if (props.capabilities.workspaces) {
(props.capabilities.workspaces as Record<string, unknown>) = {};
(props.capabilities.workspaces as Record<string, unknown>).enabled = true;
}
const { container } = render(<CollapsibleNavGroupEnabled {...props} isNavOpen />);
const { container, getAllByTestId, getByTestId } = render(
<CollapsibleNavGroupEnabled {...props} isNavOpen />
);
fireEvent.click(getAllByTestId('collapsibleNavAppLink-link-in-analytics')[1]);
expect(getAllByTestId('collapsibleNavAppLink-link-in-analytics').length).toEqual(1);
expect(container).toMatchSnapshot();
fireEvent.click(getByTestId('back'));
expect(getAllByTestId('collapsibleNavAppLink-link-in-analytics').length).toEqual(2);
});

it('should not show group if the nav link is hidden', async () => {
const props = mockProps({
currentNavGroupId: ALL_USE_CASE_ID,
navGroupsMap: {
[DEFAULT_NAV_GROUPS.analytics.id]: {
...DEFAULT_NAV_GROUPS.analytics,
navLinks: [
{
id: 'link-in-analytics-but-hidden',
title: 'link-in-analytics-but-hidden',
showInAllNavGroup: true,
},
],
},
},
navLinks: [
{
id: 'link-in-analytics-but-hidden',
hidden: true,
title: 'link-in-analytics-but-hidden',
baseUrl: '',
href: '',
},
],
});
const { queryAllByTestId } = render(<CollapsibleNavGroupEnabled {...props} isNavOpen />);
expect(queryAllByTestId('collapsibleNavAppLink-link-in-analytics-but-hidden').length).toEqual(
0
);
expect(queryAllByTestId('collapsibleNavAppLink-link-in-all').length).toEqual(1);
});
});
Loading

0 comments on commit 3f78c94

Please sign in to comment.