Skip to content

Commit

Permalink
[navigation-next] Add new left navigation (opensearch-project#7230)
Browse files Browse the repository at this point in the history
* [navigation-next] Add CollapsibleNavGroupEnabled component into chrome_service.(opensearch-project#7093)

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

* feat: enable parent nav link id

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

* feat: modify left navigation

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

* feat: modify style

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

* feat: enable left bottom

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

* temp: merge

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

* feat: save

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

* feat: merge

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

* temp change

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

* temp change

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

* fix: overview page can not be load

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

* feat: remove useless change

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

* feat: add unit test

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

* feat: update snapshot

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

* fix: unit test error

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

* fix: new application

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

* feat: add unit test

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

* feat: update category based on latest design

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

* feat: update

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

* feat: update snapshot

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

* feat: do not emphasize see all link

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

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

* feat: update

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

* feat: update

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
SuZhou-Joe and opensearch-changeset-bot[bot] committed Jul 18, 2024
1 parent 49677e9 commit 5eedfb4
Show file tree
Hide file tree
Showing 46 changed files with 2,343 additions and 126 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7230.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [navigation-next] Add new left navigation ([#7230](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7230))
2 changes: 2 additions & 0 deletions src/core/public/chrome/chrome_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ const createStartContractMock = () => {
registerLeft: jest.fn(),
registerCenter: jest.fn(),
registerRight: jest.fn(),
registerLeftBottom: jest.fn(),
getLeft$: jest.fn(),
getCenter$: jest.fn(),
getRight$: jest.fn(),
getLeftBottom$: jest.fn(),
},
navGroup: {
getNavGroupsMap$: jest.fn(() => new BehaviorSubject({})),
Expand Down
5 changes: 4 additions & 1 deletion src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ export class ChromeService {
navControlsRight$={navControls.getRight$()}
navControlsExpandedCenter$={navControls.getExpandedCenter$()}
navControlsExpandedRight$={navControls.getExpandedRight$()}
navControlsLeftBottom$={navControls.getLeftBottom$()}
onIsLockedUpdate={setIsNavDrawerLocked}
isLocked$={getIsNavDrawerLocked$}
branding={injectedMetadata.getBranding()}
Expand All @@ -303,7 +304,9 @@ export class ChromeService {
collapsibleNavHeaderRender={this.collapsibleNavHeaderRender}
sidecarConfig$={sidecarConfig$}
navGroupEnabled={navGroup.getNavGroupEnabled()}
currentNavgroup$={navGroup.getCurrentNavGroup$()}
currentNavGroup$={navGroup.getCurrentNavGroup$()}
navGroupsMap$={navGroup.getNavGroupsMap$()}
setCurrentNavGroup={navGroup.setCurrentNavGroup}
/>
),

Expand Down
2 changes: 1 addition & 1 deletion src/core/public/chrome/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ export { ChromeRecentlyAccessed, ChromeRecentlyAccessedHistoryItem } from './rec
export { ChromeNavControl, ChromeNavControls } from './nav_controls';
export { ChromeDocTitle } from './doc_title';
export { RightNavigationOrder } from './constants';
export { ChromeRegistrationNavLink, ChromeNavGroupUpdater } from './nav_group';
export { ChromeRegistrationNavLink, ChromeNavGroupUpdater, NavGroupItemInMap } from './nav_group';
20 changes: 20 additions & 0 deletions src/core/public/chrome/nav_controls/nav_controls_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,24 @@ describe('RecentlyAccessed#start()', () => {
]);
});
});

describe('expanded left bottom controls', () => {
it('allows registration', async () => {
const navControls = getStart();
const nc = { mount: jest.fn() };
navControls.registerLeftBottom(nc);
expect(await navControls.getLeftBottom$().pipe(take(1)).toPromise()).toEqual([nc]);
});

it('sorts controls by order property', async () => {
const navControls = getStart();
const nc1 = { mount: jest.fn(), order: 10 };
const nc2 = { mount: jest.fn(), order: 0 };
const nc3 = { mount: jest.fn(), order: 20 };
navControls.registerLeftBottom(nc1);
navControls.registerLeftBottom(nc2);
navControls.registerLeftBottom(nc3);
expect(await navControls.getLeftBottom$().pipe(take(1)).toPromise()).toEqual([nc2, nc1, nc3]);
});
});
});
15 changes: 15 additions & 0 deletions src/core/public/chrome/nav_controls/nav_controls_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ export interface ChromeNavControls {
registerRight(navControl: ChromeNavControl): void;
/** Register a nav control to be presented on the top-center side of the chrome header. */
registerCenter(navControl: ChromeNavControl): void;
/** Register a nav control to be presented on the left-bottom side of the left navigation. */
registerLeftBottom(navControl: ChromeNavControl): void;
/** @internal */
getLeft$(): Observable<ChromeNavControl[]>;
/** @internal */
getRight$(): Observable<ChromeNavControl[]>;
/** @internal */
getCenter$(): Observable<ChromeNavControl[]>;
/** @internal */
getLeftBottom$(): Observable<ChromeNavControl[]>;
}

/** @internal */
Expand All @@ -82,6 +86,7 @@ export class NavControlsService {
const navControlsExpandedCenter$ = new BehaviorSubject<ReadonlySet<ChromeNavControl>>(
new Set()
);
const navControlsLeftBottom$ = new BehaviorSubject<ReadonlySet<ChromeNavControl>>(new Set());

return {
// In the future, registration should be moved to the setup phase. This
Expand All @@ -105,6 +110,11 @@ export class NavControlsService {
new Set([...navControlsExpandedCenter$.value.values(), navControl])
),

registerLeftBottom: (navControl: ChromeNavControl) =>
navControlsLeftBottom$.next(
new Set([...navControlsLeftBottom$.value.values(), navControl])
),

getLeft$: () =>
navControlsLeft$.pipe(
map((controls) => sortBy([...controls.values()], 'order')),
Expand All @@ -130,6 +140,11 @@ export class NavControlsService {
map((controls) => sortBy([...controls.values()], 'order')),
takeUntil(this.stop$)
),
getLeftBottom$: () =>
navControlsLeftBottom$.pipe(
map((controls) => sortBy([...controls.values()], 'order')),
takeUntil(this.stop$)
),
};
}

Expand Down
Loading

0 comments on commit 5eedfb4

Please sign in to comment.