Skip to content

Commit

Permalink
Merge branch 'master' into rename-kibana-config
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jun 25, 2020
2 parents 05b1a4e + 1ae5d32 commit acfbadc
Show file tree
Hide file tree
Showing 119 changed files with 2,958 additions and 3,118 deletions.
3 changes: 3 additions & 0 deletions src/core/public/chrome/chrome_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ const createStartContractMock = () => {
setHelpSupportUrl: jest.fn(),
getIsNavDrawerLocked$: jest.fn(),
getNavType$: jest.fn(),
getCustomNavLink$: jest.fn(),
setCustomNavLink: jest.fn(),
};
startContract.navLinks.getAll.mockReturnValue([]);
startContract.getBrand$.mockReturnValue(new BehaviorSubject({} as ChromeBrand));
startContract.getIsVisible$.mockReturnValue(new BehaviorSubject(false));
startContract.getApplicationClasses$.mockReturnValue(new BehaviorSubject(['class-name']));
startContract.getBadge$.mockReturnValue(new BehaviorSubject({} as ChromeBadge));
startContract.getBreadcrumbs$.mockReturnValue(new BehaviorSubject([{} as ChromeBreadcrumb]));
startContract.getCustomNavLink$.mockReturnValue(new BehaviorSubject(undefined));
startContract.getHelpExtension$.mockReturnValue(new BehaviorSubject(undefined));
startContract.getIsNavDrawerLocked$.mockReturnValue(new BehaviorSubject(false));
startContract.getNavType$.mockReturnValue(new BehaviorSubject('modern' as NavType));
Expand Down
21 changes: 21 additions & 0 deletions src/core/public/chrome/chrome_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,27 @@ describe('start', () => {
});
});

describe('custom nav link', () => {
it('updates/emits the current custom nav link', async () => {
const { chrome, service } = await start();
const promise = chrome.getCustomNavLink$().pipe(toArray()).toPromise();

chrome.setCustomNavLink({ title: 'Manage cloud deployment' });
chrome.setCustomNavLink(undefined);
service.stop();

await expect(promise).resolves.toMatchInlineSnapshot(`
Array [
undefined,
Object {
"title": "Manage cloud deployment",
},
undefined,
]
`);
});
});

describe('help extension', () => {
it('updates/emits the current help extension', async () => {
const { chrome, service } = await start();
Expand Down
20 changes: 19 additions & 1 deletion src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { IUiSettingsClient } from '../ui_settings';
import { KIBANA_ASK_ELASTIC_LINK } from './constants';
import { ChromeDocTitle, DocTitleService } from './doc_title';
import { ChromeNavControls, NavControlsService } from './nav_controls';
import { ChromeNavLinks, NavLinksService } from './nav_links';
import { ChromeNavLinks, NavLinksService, ChromeNavLink } from './nav_links';
import { ChromeRecentlyAccessed, RecentlyAccessedService } from './recently_accessed';
import { Header } from './ui';
import { NavType } from './ui/header';
Expand Down Expand Up @@ -148,6 +148,7 @@ export class ChromeService {
const helpExtension$ = new BehaviorSubject<ChromeHelpExtension | undefined>(undefined);
const breadcrumbs$ = new BehaviorSubject<ChromeBreadcrumb[]>([]);
const badge$ = new BehaviorSubject<ChromeBadge | undefined>(undefined);
const customNavLink$ = new BehaviorSubject<ChromeNavLink | undefined>(undefined);
const helpSupportUrl$ = new BehaviorSubject<string>(KIBANA_ASK_ELASTIC_LINK);
const isNavDrawerLocked$ = new BehaviorSubject(localStorage.getItem(IS_LOCKED_KEY) === 'true');

Expand Down Expand Up @@ -221,6 +222,7 @@ export class ChromeService {
badge$={badge$.pipe(takeUntil(this.stop$))}
basePath={http.basePath}
breadcrumbs$={breadcrumbs$.pipe(takeUntil(this.stop$))}
customNavLink$={customNavLink$.pipe(takeUntil(this.stop$))}
kibanaDocLink={docLinks.links.kibana}
forceAppSwitcherNavigation$={navLinks.getForceAppSwitcherNavigation$()}
helpExtension$={helpExtension$.pipe(takeUntil(this.stop$))}
Expand Down Expand Up @@ -297,6 +299,12 @@ export class ChromeService {
getIsNavDrawerLocked$: () => getIsNavDrawerLocked$,

getNavType$: () => getNavType$,

getCustomNavLink$: () => customNavLink$.pipe(takeUntil(this.stop$)),

setCustomNavLink: (customNavLink?: ChromeNavLink) => {
customNavLink$.next(customNavLink);
},
};
}

Expand Down Expand Up @@ -423,6 +431,16 @@ export interface ChromeStart {
*/
setBreadcrumbs(newBreadcrumbs: ChromeBreadcrumb[]): void;

/**
* Get an observable of the current custom nav link
*/
getCustomNavLink$(): Observable<Partial<ChromeNavLink> | undefined>;

/**
* Override the current set of custom nav link
*/
setCustomNavLink(newCustomNavLink?: Partial<ChromeNavLink>): void;

/**
* Get an observable of the current custom help conttent
*/
Expand Down
Loading

0 comments on commit acfbadc

Please sign in to comment.