Skip to content

Commit

Permalink
Merge branch 'master' into issue-71932-ts-4
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Aug 26, 2020
2 parents 26ca40e + 789b67f commit fe1821b
Show file tree
Hide file tree
Showing 14 changed files with 1,310 additions and 245 deletions.
53 changes: 53 additions & 0 deletions src/core/public/chrome/chrome_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,59 @@ describe('start', () => {
`);
});
});

describe('erase chrome fields', () => {
it('while switching an app', async () => {
const startDeps = defaultStartDeps([new FakeApp('alpha')]);
const { navigateToApp } = startDeps.application;
const { chrome, service } = await start({ startDeps });

const helpExtensionPromise = chrome.getHelpExtension$().pipe(toArray()).toPromise();
const breadcrumbsPromise = chrome.getBreadcrumbs$().pipe(toArray()).toPromise();
const badgePromise = chrome.getBadge$().pipe(toArray()).toPromise();
const docTitleResetSpy = jest.spyOn(chrome.docTitle, 'reset');

const promises = Promise.all([helpExtensionPromise, breadcrumbsPromise, badgePromise]);

chrome.setHelpExtension({ appName: 'App name' });
chrome.setBreadcrumbs([{ text: 'App breadcrumb' }]);
chrome.setBadge({ text: 'App badge', tooltip: 'App tooltip' });

navigateToApp('alpha');

service.stop();

expect(docTitleResetSpy).toBeCalledTimes(1);
await expect(promises).resolves.toMatchInlineSnapshot(`
Array [
Array [
undefined,
Object {
"appName": "App name",
},
undefined,
],
Array [
Array [],
Array [
Object {
"text": "App breadcrumb",
},
],
Array [],
],
Array [
undefined,
Object {
"text": "App badge",
"tooltip": "App tooltip",
},
undefined,
],
]
`);
});
});
});

describe('stop', () => {
Expand Down
8 changes: 8 additions & 0 deletions src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ export class ChromeService {
const recentlyAccessed = await this.recentlyAccessed.start({ http });
const docTitle = this.docTitle.start({ document: window.document });

// erase chrome fields from a previous app while switching to a next app
application.currentAppId$.subscribe(() => {
helpExtension$.next(undefined);
breadcrumbs$.next([]);
badge$.next(undefined);
docTitle.reset();
});

const setIsNavDrawerLocked = (isLocked: boolean) => {
isNavDrawerLocked$.next(isLocked);
localStorage.setItem(IS_LOCKED_KEY, `${isLocked}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import React, { lazy, Suspense } from 'react';
import ReactDOM from 'react-dom';
import { Router, Switch, Route } from 'react-router-dom';
import { I18nProvider } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { EuiLoadingSpinner } from '@elastic/eui';
import { CoreSetup } from 'src/core/public';
import { ManagementAppMountParams } from '../../../management/public';
Expand All @@ -36,6 +37,10 @@ interface MountParams {

let allowedObjectTypes: string[] | undefined;

const title = i18n.translate('savedObjectsManagement.objects.savedObjectsTitle', {
defaultMessage: 'Saved Objects',
});

const SavedObjectsEditionPage = lazy(() => import('./saved_objects_edition_page'));
const SavedObjectsTablePage = lazy(() => import('./saved_objects_table_page'));
export const mountManagementSection = async ({
Expand All @@ -49,6 +54,8 @@ export const mountManagementSection = async ({
allowedObjectTypes = await getAllowedTypes(coreStart.http);
}

coreStart.chrome.docTitle.change(title);

const capabilities = coreStart.application.capabilities;

const RedirectToHomeIfUnauthorized: React.FunctionComponent = ({ children }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,29 @@ class StaticPlot extends PureComponent {
const data = serie.data.map((value) => {
return 'y' in value && isValidCoordinateValue(value.y)
? value
: {
...value,
y: undefined,
};
: { ...value, y: undefined };
});

// make sure individual markers are displayed in cases
// where there are gaps

const markersForGaps = serie.data.map((value, index) => {
const prevHasData = getNull(serie.data[index - 1] ?? {});
const nextHasData = getNull(serie.data[index + 1] ?? {});
const thisHasData = getNull(value);

const isGap = !prevHasData && !nextHasData && thisHasData;

if (!isGap) {
return {
...value,
y: undefined,
};
}

return value;
});

return [
<AreaSeries
getNull={getNull}
Expand All @@ -99,6 +117,21 @@ class StaticPlot extends PureComponent {
stack={true}
cluster="line"
/>,
<LineMarkSeries
getNull={getNull}
key={`${serie.title}-line-markers`}
xType="time-utc"
curve={'curveMonotoneX'}
data={markersForGaps}
stroke={serie.color}
color={serie.color}
lineStyle={{
opacity: 0,
}}
stack={true}
cluster="line-mark"
size={1}
/>,
];
}

Expand Down Expand Up @@ -132,7 +165,7 @@ class StaticPlot extends PureComponent {
curve={'curveMonotoneX'}
data={serie.data}
color={serie.color}
size={0.5}
size={1}
/>
);
default:
Expand Down
Loading

0 comments on commit fe1821b

Please sign in to comment.