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] Left navigation collective #7655

Merged
merged 29 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d49631d
feat: change nav groups
SuZhou-Joe Aug 8, 2024
f09e773
Changeset file for PR #7655 created/updated
opensearch-changeset-bot[bot] Aug 8, 2024
f92e4f5
feat: move visualizations to all use case
SuZhou-Joe Aug 8, 2024
b72e508
feat: change the scrollable area
SuZhou-Joe Aug 8, 2024
54fdae4
feat: merge main
SuZhou-Joe Aug 12, 2024
9651bc1
feat: register manage workspace category when in a workspace
SuZhou-Joe Aug 12, 2024
3110391
feat: register index patterns to settings and setup
SuZhou-Joe Aug 12, 2024
baacc38
feat: show correct icon in top
SuZhou-Joe Aug 12, 2024
b4246ce
feat: use gap to replace margin
SuZhou-Joe Aug 12, 2024
c817bb3
feat: make new left nav work in mobile mode
SuZhou-Joe Aug 12, 2024
f3d3427
fix: bootstrap error
SuZhou-Joe Aug 12, 2024
0c2feca
feat: merge main
SuZhou-Joe Aug 13, 2024
e91c997
fix: unit test error
SuZhou-Joe Aug 13, 2024
2e7cc01
feat: justify content
SuZhou-Joe Aug 13, 2024
4705ac8
fix: unit test
SuZhou-Joe Aug 13, 2024
fe1329f
fix: unit test
SuZhou-Joe Aug 13, 2024
b856c3e
Merge branch 'main' into feature/left-nav-2.17
SuZhou-Joe Aug 13, 2024
7df3fca
feat: add descriptions to core features
SuZhou-Joe Aug 13, 2024
c0c543d
feat: add description to index pattern
SuZhou-Joe Aug 13, 2024
b4b421c
feat: use smaller font size in left nav
SuZhou-Joe Aug 14, 2024
585e01d
feat: append navLinks inside second level to custom category if no e…
SuZhou-Joe Aug 14, 2024
8beff2b
Merge branch 'main' into feature/left-nav-2.17
SuZhou-Joe Aug 14, 2024
bec5b08
feat: some optimize
SuZhou-Joe Aug 14, 2024
049a7e8
feat: optimize code
SuZhou-Joe Aug 14, 2024
ddda8ca
feat: fix unit test
SuZhou-Joe Aug 14, 2024
9b168a2
feat: filter all use case
SuZhou-Joe Aug 14, 2024
1e703dc
fix: unit test
SuZhou-Joe Aug 15, 2024
71587aa
merge main
SuZhou-Joe Aug 15, 2024
5352851
feat: merge main
SuZhou-Joe Aug 15, 2024
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/7655.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [navigation] Left navigation collective ([#7655](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7655))
1 change: 1 addition & 0 deletions src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ export class ChromeService {
navGroupsMap$={navGroup.getNavGroupsMap$()}
setCurrentNavGroup={navGroup.setCurrentNavGroup}
workspaceList$={workspaces.workspaceList$}
currentWorkspace$={workspaces.currentWorkspace$}
useUpdatedHeader={this.useUpdatedHeader}
/>
),
Expand Down

Large diffs are not rendered by default.

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 @@ -55,7 +55,7 @@
border-right: $euiBorderThin;
}

.scrollable-container {
.flex-1-container {
flex: 1;
}

Expand All @@ -66,14 +66,19 @@
&.bottom-container-collapsed {
flex-direction: column;
align-items: center;
gap: $euiSize;
padding-top: $euiSizeS;
padding-bottom: $euiSizeS;

> * {
margin: $euiSizeS 0;
justify-content: center;
}
}
}

.nav-controls-padding {
padding: $euiSize;
&.bottom-container-expanded {
gap: 16px;
padding-top: $euiSize;
padding-bottom: $euiSize;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ import { ChromeNavLink } from '../../nav_links';
import { ChromeRegistrationNavLink, NavGroupItemInMap } from '../../nav_group';
import { httpServiceMock } from '../../../mocks';
import { getLogos } from '../../../../common';
import { ALL_USE_CASE_ID, DEFAULT_NAV_GROUPS } from '../../../../public';
import { CollapsibleNavTopProps } from './collapsible_nav_group_enabled_top';
import { ALL_USE_CASE_ID, DEFAULT_NAV_GROUPS, WorkspaceObject } from '../../../../public';
import { capabilitiesServiceMock } from '../../../application/capabilities/capabilities_service.mock';

jest.mock('./collapsible_nav_group_enabled_top', () => ({
CollapsibleNavTop: (props: CollapsibleNavTopProps) => (
<button data-test-subj="back" onClick={props.onClickBack}>
go back
</button>
),
CollapsibleNavTop: () => <button data-test-subj="back">go back</button>,
}));

const mockBasePath = httpServiceMock.createSetupContract({ basePath: '/test' }).basePath;
Expand Down Expand Up @@ -99,6 +94,28 @@ describe('<NavGroups />', () => {
});
});

const defaultNavGroupMap = {
[ALL_USE_CASE_ID]: {
...DEFAULT_NAV_GROUPS[ALL_USE_CASE_ID],
navLinks: [
{
id: 'link-in-all',
title: 'link-in-all',
},
],
},
[DEFAULT_NAV_GROUPS.observability.id]: {
...DEFAULT_NAV_GROUPS.observability,
navLinks: [
{
id: 'link-in-observability',
title: 'link-in-observability',
showInAllNavGroup: true,
},
],
},
};

describe('<CollapsibleNavGroupEnabled />', () => {
function mockProps(
props?: Partial<CollapsibleNavGroupEnabledProps> & {
Expand All @@ -107,28 +124,9 @@ describe('<CollapsibleNavGroupEnabled />', () => {
navLinks?: ChromeNavLink[];
}
): CollapsibleNavGroupEnabledProps {
const navGroupsMap$ = new BehaviorSubject<Record<string, NavGroupItemInMap>>({
[ALL_USE_CASE_ID]: {
...DEFAULT_NAV_GROUPS[ALL_USE_CASE_ID],
navLinks: [
{
id: 'link-in-all',
title: 'link-in-all',
},
],
},
[DEFAULT_NAV_GROUPS.observability.id]: {
...DEFAULT_NAV_GROUPS.observability,
navLinks: [
{
id: 'link-in-observability',
title: 'link-in-observability',
showInAllNavGroup: true,
},
],
},
...props?.navGroupsMap,
});
const navGroupsMap$ = new BehaviorSubject<Record<string, NavGroupItemInMap>>(
props?.navGroupsMap || defaultNavGroupMap
);
const currentNavGroup$ = new BehaviorSubject<NavGroupItemInMap | undefined>(
props?.currentNavGroupId ? navGroupsMap$.getValue()[props.currentNavGroupId] : undefined
);
Expand All @@ -138,6 +136,7 @@ describe('<CollapsibleNavGroupEnabled />', () => {
id: 'collapsibe-nav',
isLocked: false,
isNavOpen: false,
currentWorkspace$: new BehaviorSubject<WorkspaceObject | null>({ id: 'test', name: 'test' }),
navLinks$: new BehaviorSubject([
{
id: 'link-in-all',
Expand Down Expand Up @@ -187,6 +186,7 @@ describe('<CollapsibleNavGroupEnabled />', () => {
const props = mockProps({
isNavOpen: true,
navGroupsMap: {
...defaultNavGroupMap,
[DEFAULT_NAV_GROUPS.essentials.id]: {
...DEFAULT_NAV_GROUPS.essentials,
navLinks: [
Expand All @@ -208,14 +208,20 @@ describe('<CollapsibleNavGroupEnabled />', () => {
});

it('should render correctly when only one visible use case is provided', () => {
const props = mockProps();
const props = mockProps({
navGroupsMap: {
[DEFAULT_NAV_GROUPS.observability.id]:
defaultNavGroupMap[DEFAULT_NAV_GROUPS.observability.id],
},
});
const { getAllByTestId } = render(<CollapsibleNavGroupEnabled {...props} isNavOpen />);
expect(getAllByTestId('collapsibleNavAppLink-link-in-observability').length).toEqual(1);
});

it('should show all use case by default and able to click see all', async () => {
const props = mockProps({
navGroupsMap: {
...defaultNavGroupMap,
[DEFAULT_NAV_GROUPS.essentials.id]: {
...DEFAULT_NAV_GROUPS.essentials,
navLinks: [
Expand All @@ -228,20 +234,19 @@ describe('<CollapsibleNavGroupEnabled />', () => {
},
},
});
const { container, getAllByTestId, getByTestId } = render(
const { container, getAllByTestId } = render(
<CollapsibleNavGroupEnabled {...props} isNavOpen />
);
fireEvent.click(getAllByTestId('collapsibleNavAppLink-link-in-essentials')[1]);
expect(getAllByTestId('collapsibleNavAppLink-link-in-essentials').length).toEqual(1);
expect(container).toMatchSnapshot();
fireEvent.click(getByTestId('back'));
expect(getAllByTestId('collapsibleNavAppLink-link-in-essentials').length).toEqual(2);
});

it('should show all use case when current nav group is `all`', async () => {
const props = mockProps({
currentNavGroupId: ALL_USE_CASE_ID,
navGroupsMap: {
...defaultNavGroupMap,
[DEFAULT_NAV_GROUPS.essentials.id]: {
...DEFAULT_NAV_GROUPS.essentials,
navLinks: [
Expand All @@ -254,20 +259,19 @@ describe('<CollapsibleNavGroupEnabled />', () => {
},
},
});
const { container, getAllByTestId, getByTestId } = render(
const { container, getAllByTestId } = render(
<CollapsibleNavGroupEnabled {...props} isNavOpen />
);
fireEvent.click(getAllByTestId('collapsibleNavAppLink-link-in-essentials')[1]);
expect(getAllByTestId('collapsibleNavAppLink-link-in-essentials').length).toEqual(1);
expect(container).toMatchSnapshot();
fireEvent.click(getByTestId('back'));
expect(getAllByTestId('collapsibleNavAppLink-link-in-essentials').length).toEqual(2);
});

it('should not show group if the nav link is hidden', async () => {
const props = mockProps({
currentNavGroupId: ALL_USE_CASE_ID,
navGroupsMap: {
...defaultNavGroupMap,
[DEFAULT_NAV_GROUPS.essentials.id]: {
...DEFAULT_NAV_GROUPS.essentials,
navLinks: [
Expand Down Expand Up @@ -295,4 +299,47 @@ describe('<CollapsibleNavGroupEnabled />', () => {
);
expect(queryAllByTestId('collapsibleNavAppLink-link-in-all').length).toEqual(1);
});

it('should show links with custom category if the nav link is inside second level but no entry in all use case', async () => {
const props = mockProps({
currentNavGroupId: ALL_USE_CASE_ID,
navGroupsMap: {
...defaultNavGroupMap,
[DEFAULT_NAV_GROUPS.essentials.id]: {
...DEFAULT_NAV_GROUPS.essentials,
navLinks: [
{
id: 'link-in-essentials',
title: 'link-in-essentials',
},
{
id: 'link-in-all',
title: 'link-in-all',
},
],
},
},
navLinks: [
{
id: 'link-in-essentials',
title: 'link-in-essentials',
baseUrl: '',
href: '',
},
{
id: 'link-in-all',
title: 'link-in-all',
baseUrl: '',
href: '',
},
],
});
const { queryAllByTestId, getByText, getByTestId } = render(
<CollapsibleNavGroupEnabled {...props} isNavOpen />
);
// Should render custom category
expect(getByText('Custom')).toBeInTheDocument();
expect(getByTestId('collapsibleNavAppLink-link-in-essentials')).toBeInTheDocument();
expect(queryAllByTestId('collapsibleNavAppLink-link-in-all').length).toEqual(1);
});
});
Loading
Loading