From 7895e5c5dcde9e134f26b2d6a3df54a2d62e9274 Mon Sep 17 00:00:00 2001 From: yuye-aws Date: Thu, 6 Jul 2023 10:30:45 +0800 Subject: [PATCH] Remove recently accessed and custom nav props in test Signed-off-by: yuye-aws --- src/core/public/chrome/chrome_service.tsx | 2 - .../chrome/ui/header/collapsible_nav.test.tsx | 57 ++----------------- .../chrome/ui/header/collapsible_nav.tsx | 5 +- .../public/chrome/ui/header/header.test.tsx | 13 ----- src/core/public/chrome/ui/header/header.tsx | 14 +---- 5 files changed, 8 insertions(+), 83 deletions(-) diff --git a/src/core/public/chrome/chrome_service.tsx b/src/core/public/chrome/chrome_service.tsx index cabbc36b90b4..8f2269018c5b 100644 --- a/src/core/public/chrome/chrome_service.tsx +++ b/src/core/public/chrome/chrome_service.tsx @@ -289,8 +289,6 @@ export class ChromeService { isVisible$={this.isVisible$} opensearchDashboardsVersion={injectedMetadata.getOpenSearchDashboardsVersion()} navLinks$={navLinks.getNavLinks$()} - customNavLink$={customNavLink$.pipe(takeUntil(this.stop$))} - recentlyAccessed$={recentlyAccessed.get$()} navControlsLeft$={navControls.getLeft$()} navControlsCenter$={navControls.getCenter$()} navControlsRight$={navControls.getRight$()} diff --git a/src/core/public/chrome/ui/header/collapsible_nav.test.tsx b/src/core/public/chrome/ui/header/collapsible_nav.test.tsx index 9d9e06ca5673..64bdef24940a 100644 --- a/src/core/public/chrome/ui/header/collapsible_nav.test.tsx +++ b/src/core/public/chrome/ui/header/collapsible_nav.test.tsx @@ -35,7 +35,6 @@ import sinon from 'sinon'; import { StubBrowserStorage } from 'test_utils/stub_browser_storage'; import { ChromeNavLink, DEFAULT_APP_CATEGORIES } from '../../..'; import { httpServiceMock } from '../../../http/http_service.mock'; -import { ChromeRecentlyAccessedHistoryItem } from '../../recently_accessed'; import { CollapsibleNav } from './collapsible_nav'; import { workspacesServiceMock } from '../../../fatal_errors/fatal_errors_service.mock'; @@ -56,15 +55,6 @@ function mockLink({ title = 'discover', category }: Partial) { 'data-test-subj': title, }; } - -function mockRecentNavLink({ label = 'recent' }: Partial) { - return { - label, - link: label, - id: label, - }; -} - function mockProps() { return { appId$: new BehaviorSubject('test'), @@ -74,7 +64,6 @@ function mockProps() { isNavOpen: false, homeHref: '/', navLinks$: new BehaviorSubject([]), - recentlyAccessed$: new BehaviorSubject([]), storage: new StubBrowserStorage(), onIsLockedUpdate: () => {}, closeNav: () => {}, @@ -82,7 +71,6 @@ function mockProps() { navigateToUrl: () => Promise.resolve(), exitWorkspace: () => {}, getWorkspaceUrl: (id: string) => '', - customNavLink$: new BehaviorSubject(undefined), currentWorkspace$: workspacesServiceMock.createStartContract().client.currentWorkspace$, workspaceList$: workspacesServiceMock.createStartContract().client.workspaceList$, branding: { @@ -139,19 +127,8 @@ describe('CollapsibleNav', () => { mockLink({ title: 'canvas' }), // links should be able to be rendered top level as well mockLink({ title: 'logs', category: observability }), ]; - const recentNavLinks = [ - mockRecentNavLink({ label: 'recent 1' }), - mockRecentNavLink({ label: 'recent 2' }), - ]; - const customNavLink = mockLink({ title: 'Custom link' }); const component = mount( - + ); expect(component).toMatchSnapshot(); }); @@ -161,14 +138,8 @@ describe('CollapsibleNav', () => { mockLink({ category: opensearchDashboards }), mockLink({ category: observability }), ]; - const recentNavLinks = [mockRecentNavLink({})]; const component = mount( - + ); expectShownNavLinksCount(component, 3); clickGroup(component, 'opensearchDashboards'); @@ -186,14 +157,8 @@ describe('CollapsibleNav', () => { mockLink({ category: opensearchDashboards }), mockLink({ title: 'categoryless' }), ]; - const recentNavLinks = [mockRecentNavLink({})]; const component = mount( - + ); component.setProps({ closeNav: () => { @@ -222,14 +187,8 @@ describe('CollapsibleNav', () => { mockLink({ category: opensearchDashboards }), mockLink({ category: observability }), ]; - const recentNavLinks = [mockRecentNavLink({})]; const component = mount( - + ); // check if nav bar renders default mode custom logo expect(component).toMatchSnapshot(); @@ -249,14 +208,8 @@ describe('CollapsibleNav', () => { mockLink({ category: opensearchDashboards }), mockLink({ category: observability }), ]; - const recentNavLinks = [mockRecentNavLink({})]; const component = mount( - + ); // check if nav bar renders dark mode custom logo component.setProps({ diff --git a/src/core/public/chrome/ui/header/collapsible_nav.tsx b/src/core/public/chrome/ui/header/collapsible_nav.tsx index 4c5db1a31d4a..e1bcdbbff291 100644 --- a/src/core/public/chrome/ui/header/collapsible_nav.tsx +++ b/src/core/public/chrome/ui/header/collapsible_nav.tsx @@ -43,7 +43,7 @@ import { groupBy, sortBy } from 'lodash'; import React, { useRef } from 'react'; import useObservable from 'react-use/lib/useObservable'; import * as Rx from 'rxjs'; -import { ChromeNavLink, ChromeRecentlyAccessedHistoryItem } from '../..'; +import { ChromeNavLink } from '../..'; import { AppCategory } from '../../../../types'; import { InternalApplicationStart } from '../../../application'; import { HttpStart } from '../../../http'; @@ -94,13 +94,11 @@ interface Props { isNavOpen: boolean; homeHref: string; navLinks$: Rx.Observable; - recentlyAccessed$: Rx.Observable; storage?: Storage; onIsLockedUpdate: OnIsLockedUpdate; closeNav: () => void; navigateToApp: InternalApplicationStart['navigateToApp']; navigateToUrl: InternalApplicationStart['navigateToUrl']; - customNavLink$: Rx.Observable; branding: ChromeBranding; exitWorkspace: () => void; getWorkspaceUrl: (id: string) => string; @@ -125,7 +123,6 @@ export function CollapsibleNav({ ...observables }: Props) { const navLinks = useObservable(observables.navLinks$, []).filter((link) => !link.hidden); - const appId = useObservable(observables.appId$, ''); const currentWorkspace = useObservable(observables.currentWorkspace$); const workspaceList = useObservable(observables.workspaceList$, []).slice(0, 5); diff --git a/src/core/public/chrome/ui/header/header.test.tsx b/src/core/public/chrome/ui/header/header.test.tsx index 08d050575385..df29abc6ef48 100644 --- a/src/core/public/chrome/ui/header/header.test.tsx +++ b/src/core/public/chrome/ui/header/header.test.tsx @@ -56,8 +56,6 @@ function mockProps() { isVisible$: new BehaviorSubject(true), opensearchDashboardsDocLink: '/docs', navLinks$: new BehaviorSubject([]), - customNavLink$: new BehaviorSubject(undefined), - recentlyAccessed$: new BehaviorSubject([]), forceAppSwitcherNavigation$: new BehaviorSubject(false), helpExtension$: new BehaviorSubject(undefined), helpSupportUrl$: new BehaviorSubject(''), @@ -98,24 +96,13 @@ describe('Header', () => { const navLinks$ = new BehaviorSubject([ { id: 'opensearchDashboards', title: 'opensearchDashboards', baseUrl: '', href: '' }, ]); - const customNavLink$ = new BehaviorSubject({ - id: 'cloud-deployment-link', - title: 'Manage cloud deployment', - baseUrl: '', - href: '', - }); - const recentlyAccessed$ = new BehaviorSubject([ - { link: '', label: 'dashboard', id: 'dashboard' }, - ]); const component = mountWithIntl(
); expect(component.find('EuiHeader').exists()).toBeFalsy(); diff --git a/src/core/public/chrome/ui/header/header.tsx b/src/core/public/chrome/ui/header/header.tsx index c0fc9622fe5d..eecea4bec58a 100644 --- a/src/core/public/chrome/ui/header/header.tsx +++ b/src/core/public/chrome/ui/header/header.tsx @@ -44,14 +44,8 @@ import React, { createRef, useState } from 'react'; import useObservable from 'react-use/lib/useObservable'; import { Observable, BehaviorSubject } from 'rxjs'; import { LoadingIndicator } from '../'; -import { - ChromeBadge, - ChromeBreadcrumb, - ChromeNavControl, - ChromeNavLink, - ChromeRecentlyAccessedHistoryItem, -} from '../..'; -import { InternalApplicationStart } from '../../../application/types'; +import { ChromeBadge, ChromeBreadcrumb, ChromeNavControl, ChromeNavLink } from '../..'; +import { InternalApplicationStart } from '../../../application'; import { HttpStart } from '../../../http'; import { ChromeHelpExtension, ChromeBranding } from '../../chrome_service'; import { OnIsLockedUpdate } from './'; @@ -71,12 +65,10 @@ export interface HeaderProps { appTitle$: Observable; badge$: Observable; breadcrumbs$: Observable; - customNavLink$: Observable; homeHref: string; isVisible$: Observable; opensearchDashboardsDocLink: string; navLinks$: Observable; - recentlyAccessed$: Observable; forceAppSwitcherNavigation$: Observable; helpExtension$: Observable; helpSupportUrl$: Observable; @@ -247,7 +239,6 @@ export function Header({ id={navId} isLocked={isLocked} navLinks$={observables.navLinks$} - recentlyAccessed$={observables.recentlyAccessed$} isNavOpen={isNavOpen} homeHref={homeHref} basePath={basePath} @@ -262,7 +253,6 @@ export function Header({ toggleCollapsibleNavRef.current.focus(); } }} - customNavLink$={observables.customNavLink$} branding={branding} currentWorkspace$={observables.currentWorkspace$} workspaceList$={observables.workspaceList$}