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

Adds link for Cloud deployment settings #66486

Merged
merged 19 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
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 @@ -362,6 +362,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