Skip to content

Commit 2f3f261

Browse files
Merge branch 'master' into dev/remove-generic-hooks
2 parents 1fd7d00 + 650fcda commit 2f3f261

File tree

54 files changed

+555
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+555
-116
lines changed

NOTICE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Kibana source code with Kibana X-Pack source code
2-
Copyright 2012-2019 Elasticsearch B.V.
2+
Copyright 2012-2020 Elasticsearch B.V.
33

44
---
55
Pretty handling of logarithmic axes.

src/core/public/application/integration_tests/router.test.tsx

Lines changed: 70 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
import React from 'react';
21-
import { createMemoryHistory, History } from 'history';
21+
import { createMemoryHistory, History, createHashHistory } from 'history';
2222

2323
import { AppRouter, AppNotFound } from '../ui';
2424
import { EitherApp, MockedMounterMap, MockedMounterTuple } from '../test_types';
@@ -27,7 +27,15 @@ import { createRenderer, createAppMounter, createLegacyAppMounter } from './util
2727
describe('AppContainer', () => {
2828
let mounters: MockedMounterMap<EitherApp>;
2929
let history: History;
30-
let navigate: ReturnType<typeof createRenderer>;
30+
let update: ReturnType<typeof createRenderer>;
31+
32+
const navigate = (path: string) => {
33+
history.push(path);
34+
return update();
35+
};
36+
37+
const mockMountersToMounters = () =>
38+
new Map([...mounters].map(([appId, { mounter }]) => [appId, mounter]));
3139

3240
beforeEach(() => {
3341
mounters = new Map([
@@ -38,26 +46,26 @@ describe('AppContainer', () => {
3846
createAppMounter('app3', '<div>App 3</div>', '/custom/path'),
3947
] as Array<MockedMounterTuple<EitherApp>>);
4048
history = createMemoryHistory();
41-
navigate = createRenderer(<AppRouter history={history} mounters={mounters} />, history.push);
49+
update = createRenderer(<AppRouter history={history} mounters={mockMountersToMounters()} />);
4250
});
4351

4452
it('calls mount handler and returned unmount function when navigating between apps', async () => {
4553
const dom1 = await navigate('/app/app1');
4654
const app1 = mounters.get('app1')!;
4755

48-
expect(app1.mount).toHaveBeenCalled();
56+
expect(app1.mounter.mount).toHaveBeenCalled();
4957
expect(dom1?.html()).toMatchInlineSnapshot(`
5058
"<div><div>
5159
basename: /app/app1
5260
html: <span>App 1</span>
5361
</div></div>"
5462
`);
5563

56-
const app1Unmount = await app1.mount.mock.results[0].value;
64+
const app1Unmount = await app1.mounter.mount.mock.results[0].value;
5765
const dom2 = await navigate('/app/app2');
5866

5967
expect(app1Unmount).toHaveBeenCalled();
60-
expect(mounters.get('app2')!.mount).toHaveBeenCalled();
68+
expect(mounters.get('app2')!.mounter.mount).toHaveBeenCalled();
6169
expect(dom2?.html()).toMatchInlineSnapshot(`
6270
"<div><div>
6371
basename: /app/app2
@@ -70,29 +78,77 @@ describe('AppContainer', () => {
7078
mounters.set(...createAppMounter('spaces', '<div>Custom Space</div>', '/spaces/fake-login'));
7179
mounters.set(...createAppMounter('login', '<div>Login Page</div>', '/fake-login'));
7280
history = createMemoryHistory();
73-
navigate = createRenderer(<AppRouter history={history} mounters={mounters} />, history.push);
81+
update = createRenderer(<AppRouter history={history} mounters={mockMountersToMounters()} />);
7482

7583
await navigate('/fake-login');
7684

77-
expect(mounters.get('spaces')!.mount).not.toHaveBeenCalled();
78-
expect(mounters.get('login')!.mount).toHaveBeenCalled();
85+
expect(mounters.get('spaces')!.mounter.mount).not.toHaveBeenCalled();
86+
expect(mounters.get('login')!.mounter.mount).toHaveBeenCalled();
7987
});
8088

8189
it('should not mount when partial route path has higher specificity', async () => {
8290
mounters.set(...createAppMounter('login', '<div>Login Page</div>', '/fake-login'));
8391
mounters.set(...createAppMounter('spaces', '<div>Custom Space</div>', '/spaces/fake-login'));
8492
history = createMemoryHistory();
85-
navigate = createRenderer(<AppRouter history={history} mounters={mounters} />, history.push);
93+
update = createRenderer(<AppRouter history={history} mounters={mockMountersToMounters()} />);
8694

8795
await navigate('/spaces/fake-login');
8896

89-
expect(mounters.get('spaces')!.mount).toHaveBeenCalled();
90-
expect(mounters.get('login')!.mount).not.toHaveBeenCalled();
97+
expect(mounters.get('spaces')!.mounter.mount).toHaveBeenCalled();
98+
expect(mounters.get('login')!.mounter.mount).not.toHaveBeenCalled();
99+
});
100+
101+
it('should not remount when changing pages within app', async () => {
102+
const { mounter, unmount } = mounters.get('app1')!;
103+
await navigate('/app/app1/page1');
104+
expect(mounter.mount).toHaveBeenCalledTimes(1);
105+
106+
// Navigating to page within app does not trigger re-render
107+
await navigate('/app/app1/page2');
108+
expect(mounter.mount).toHaveBeenCalledTimes(1);
109+
expect(unmount).not.toHaveBeenCalled();
110+
});
111+
112+
it('should not remount when going back within app', async () => {
113+
const { mounter, unmount } = mounters.get('app1')!;
114+
await navigate('/app/app1/page1');
115+
expect(mounter.mount).toHaveBeenCalledTimes(1);
116+
117+
// Hitting back button within app does not trigger re-render
118+
await navigate('/app/app1/page2');
119+
history.goBack();
120+
await update();
121+
expect(mounter.mount).toHaveBeenCalledTimes(1);
122+
expect(unmount).not.toHaveBeenCalled();
123+
});
124+
125+
it('should not remount when when changing pages within app using hash history', async () => {
126+
history = createHashHistory();
127+
update = createRenderer(<AppRouter history={history} mounters={mockMountersToMounters()} />);
128+
129+
const { mounter, unmount } = mounters.get('app1')!;
130+
await navigate('/app/app1/page1');
131+
expect(mounter.mount).toHaveBeenCalledTimes(1);
132+
133+
// Changing hash history does not trigger re-render
134+
await navigate('/app/app1/page2');
135+
expect(mounter.mount).toHaveBeenCalledTimes(1);
136+
expect(unmount).not.toHaveBeenCalled();
137+
});
138+
139+
it('should unmount when changing between apps', async () => {
140+
const { mounter, unmount } = mounters.get('app1')!;
141+
await navigate('/app/app1/page1');
142+
expect(mounter.mount).toHaveBeenCalledTimes(1);
143+
144+
// Navigating to other app triggers unmount
145+
await navigate('/app/app2/page1');
146+
expect(unmount).toHaveBeenCalledTimes(1);
91147
});
92148

93149
it('calls legacy mount handler', async () => {
94150
await navigate('/app/legacyApp1');
95-
expect(mounters.get('legacyApp1')!.mount.mock.calls[0]).toMatchInlineSnapshot(`
151+
expect(mounters.get('legacyApp1')!.mounter.mount.mock.calls[0]).toMatchInlineSnapshot(`
96152
Array [
97153
Object {
98154
"appBasePath": "/app/legacyApp1",
@@ -104,7 +160,7 @@ describe('AppContainer', () => {
104160

105161
it('handles legacy apps with subapps', async () => {
106162
await navigate('/app/baseApp');
107-
expect(mounters.get('baseApp:legacyApp2')!.mount.mock.calls[0]).toMatchInlineSnapshot(`
163+
expect(mounters.get('baseApp:legacyApp2')!.mounter.mount.mock.calls[0]).toMatchInlineSnapshot(`
108164
Array [
109165
Object {
110166
"appBasePath": "/app/baseApp",

src/core/public/application/integration_tests/utils.tsx

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,13 @@ import { App, LegacyApp, AppMountParameters } from '../types';
2626
import { MockedMounter, MockedMounterTuple } from '../test_types';
2727

2828
type Dom = ReturnType<typeof mount> | null;
29-
type Renderer = (item: string) => Dom | Promise<Dom>;
29+
type Renderer = () => Dom | Promise<Dom>;
3030

31-
export const createRenderer = (
32-
element: ReactElement | null,
33-
callback?: (item: string) => void | Promise<void>
34-
): Renderer => {
31+
export const createRenderer = (element: ReactElement | null): Renderer => {
3532
const dom: Dom = element && mount(<I18nProvider>{element}</I18nProvider>);
3633

37-
return item =>
34+
return () =>
3835
new Promise(async resolve => {
39-
if (callback) {
40-
await callback(item);
41-
}
4236
if (dom) {
4337
dom.update();
4438
}
@@ -50,29 +44,39 @@ export const createAppMounter = (
5044
appId: string,
5145
html: string,
5246
appRoute = `/app/${appId}`
53-
): MockedMounterTuple<App> => [
54-
appId,
55-
{
56-
appRoute,
57-
appBasePath: appRoute,
58-
mount: jest.fn(async ({ appBasePath: basename, element }: AppMountParameters) => {
59-
Object.assign(element, {
60-
innerHTML: `<div>\nbasename: ${basename}\nhtml: ${html}\n</div>`,
61-
});
62-
return jest.fn(() => Object.assign(element, { innerHTML: '' }));
63-
}),
64-
},
65-
];
47+
): MockedMounterTuple<App> => {
48+
const unmount = jest.fn();
49+
return [
50+
appId,
51+
{
52+
mounter: {
53+
appRoute,
54+
appBasePath: appRoute,
55+
mount: jest.fn(async ({ appBasePath: basename, element }: AppMountParameters) => {
56+
Object.assign(element, {
57+
innerHTML: `<div>\nbasename: ${basename}\nhtml: ${html}\n</div>`,
58+
});
59+
unmount.mockImplementation(() => Object.assign(element, { innerHTML: '' }));
60+
return unmount;
61+
}),
62+
},
63+
unmount,
64+
},
65+
];
66+
};
6667

6768
export const createLegacyAppMounter = (
6869
appId: string,
6970
legacyMount: MockedMounter<LegacyApp>['mount']
7071
): MockedMounterTuple<LegacyApp> => [
7172
appId,
7273
{
73-
appRoute: `/app/${appId.split(':')[0]}`,
74-
appBasePath: `/app/${appId.split(':')[0]}`,
75-
unmountBeforeMounting: true,
76-
mount: legacyMount,
74+
mounter: {
75+
appRoute: `/app/${appId.split(':')[0]}`,
76+
appBasePath: `/app/${appId.split(':')[0]}`,
77+
unmountBeforeMounting: true,
78+
mount: legacyMount,
79+
},
80+
unmount: jest.fn(),
7781
},
7882
];

src/core/public/application/test_types.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,27 @@
1717
* under the License.
1818
*/
1919

20-
import { App, LegacyApp, Mounter } from './types';
20+
import { App, LegacyApp, Mounter, AppUnmount } from './types';
2121
import { ApplicationService } from './application_service';
2222

2323
/** @internal */
2424
export type ApplicationServiceContract = PublicMethodsOf<ApplicationService>;
2525
/** @internal */
2626
export type EitherApp = App | LegacyApp;
2727
/** @internal */
28+
export type MockedUnmount = jest.Mocked<AppUnmount>;
29+
/** @internal */
2830
export type MockedMounter<T extends EitherApp> = jest.Mocked<Mounter<jest.Mocked<T>>>;
2931
/** @internal */
30-
export type MockedMounterTuple<T extends EitherApp> = [string, MockedMounter<T>];
32+
export type MockedMounterTuple<T extends EitherApp> = [
33+
string,
34+
{ mounter: MockedMounter<T>; unmount: MockedUnmount }
35+
];
3136
/** @internal */
32-
export type MockedMounterMap<T extends EitherApp> = Map<string, MockedMounter<T>>;
37+
export type MockedMounterMap<T extends EitherApp> = Map<
38+
string,
39+
{ mounter: MockedMounter<T>; unmount: MockedUnmount }
40+
>;
3341
/** @internal */
3442
export type MockLifecycle<
3543
T extends keyof ApplicationService,

src/core/public/application/ui/app_container.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const AppContainer: FunctionComponent<Props> = ({ mounter, appId }: Props
6565

6666
mount();
6767
return unmount;
68-
});
68+
}, [mounter]);
6969

7070
return (
7171
<Fragment>

src/core/server/rendering/views/styles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const Styles: FunctionComponent<Props> = ({ darkMode }) => {
7878
background-repeat: no-repeat;
7979
background-size: contain;
8080
/* SVG optimized according to http://codepen.io/tigt/post/optimizing-svgs-in-data-uris */
81-
background-image: url'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMCIgaGVpZ2h0PSIzOSIgdmlld0JveD0iMCAwIDMwIDM5Ij4gIDxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+ICAgIDxwb2x5Z29uIGZpbGw9IiNGMDRFOTgiIHBvaW50cz0iMCAwIDAgMzQuNTQ3IDI5LjkyMiAuMDIiLz4gICAgPHBhdGggZmlsbD0iIzM0Mzc0MSIgZD0iTTAsMTQuNCBMMCwzNC41NDY4IEwxNC4yODcyLDE4LjA2MTIgQzEwLjA0MTYsMTUuNzM4IDUuMTgwNCwxNC40IDAsMTQuNCIvPiAgICA8cGF0aCBmaWxsPSIjMDBCRkIzIiBkPSJNMTcuMzc0MiwxOS45OTY4IEwyLjcyMSwzNi45MDQ4IEwxLjQzMzQsMzguMzg5MiBMMjkuMjYzOCwzOC4zODkyIEMyNy43NjE0LDMwLjgzODggMjMuNDA0MiwyNC4zMjY0IDE3LjM3NDIsMTkuOTk2OCIvPiAgPC9nPjwvc3ZnPg==');
81+
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMCIgaGVpZ2h0PSIzOSIgdmlld0JveD0iMCAwIDMwIDM5Ij4gIDxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+ICAgIDxwb2x5Z29uIGZpbGw9IiNGMDRFOTgiIHBvaW50cz0iMCAwIDAgMzQuNTQ3IDI5LjkyMiAuMDIiLz4gICAgPHBhdGggZmlsbD0iIzM0Mzc0MSIgZD0iTTAsMTQuNCBMMCwzNC41NDY4IEwxNC4yODcyLDE4LjA2MTIgQzEwLjA0MTYsMTUuNzM4IDUuMTgwNCwxNC40IDAsMTQuNCIvPiAgICA8cGF0aCBmaWxsPSIjMDBCRkIzIiBkPSJNMTcuMzc0MiwxOS45OTY4IEwyLjcyMSwzNi45MDQ4IEwxLjQzMzQsMzguMzg5MiBMMjkuMjYzOCwzOC4zODkyIEMyNy43NjE0LDMwLjgzODggMjMuNDA0MiwyNC4zMjY0IDE3LjM3NDIsMTkuOTk2OCIvPiAgPC9nPjwvc3ZnPg==');
8282
}
8383
8484
.kibanaWelcomeTitle {

src/legacy/core_plugins/tile_map/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ const tileMapPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPlu
3030
uiExports: {
3131
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
3232
hacks: [resolve(__dirname, 'public/legacy')],
33-
injectDefaultVars: server => ({}),
33+
injectDefaultVars: server => {
34+
const serverConfig = server.config();
35+
const mapConfig: Record<string, any> = serverConfig.get('map');
36+
37+
return {
38+
emsTileLayerId: mapConfig.emsTileLayerId,
39+
};
40+
},
3441
},
3542
config(Joi: any) {
3643
return Joi.object({

src/legacy/core_plugins/vis_type_vega/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@ const vegaPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPlugin
3333
uiExports: {
3434
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
3535
hacks: [resolve(__dirname, 'public/legacy')],
36-
injectDefaultVars: server => ({
37-
enableExternalUrls: server.config().get('vega.enableExternalUrls'),
38-
}),
36+
injectDefaultVars: server => {
37+
const serverConfig = server.config();
38+
const mapConfig: Record<string, any> = serverConfig.get('map');
39+
40+
return {
41+
emsTileLayerId: mapConfig.emsTileLayerId,
42+
enableExternalUrls: serverConfig.get('vega.enableExternalUrls'),
43+
};
44+
},
3945
},
4046
init: (server: Legacy.Server) => ({}),
4147
config(Joi: any) {

test/functional/apps/home/_newsfeed.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
2424
const globalNav = getService('globalNav');
2525
const PageObjects = getPageObjects(['common', 'newsfeed']);
2626

27-
describe('Newsfeed', () => {
27+
// Failing: https://github.com/elastic/kibana/issues/53860
28+
describe.skip('Newsfeed', () => {
2829
before(async () => {
2930
await PageObjects.newsfeed.resetPage();
3031
});

vars/githubPr.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def withDefaultPrComments(closure) {
3535
def message = getNextCommentMessage(info)
3636
postComment(message)
3737

38-
if (lastComment) {
38+
if (lastComment && lastComment.user.login == 'kibanamachine') {
3939
deleteComment(lastComment.id)
4040
}
4141
}
@@ -49,7 +49,7 @@ def isPr() {
4949
def getLatestBuildComment() {
5050
return getComments()
5151
.reverse()
52-
.find { it.user.login == 'elasticmachine' && it.body =~ /<!--PIPELINE/ }
52+
.find { (it.user.login == 'elasticmachine' || it.user.login == 'kibanamachine') && it.body =~ /<!--PIPELINE/ }
5353
}
5454

5555
def getBuildInfoFromComment(commentText) {

0 commit comments

Comments
 (0)