Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into cleanup-data-inde…
Browse files Browse the repository at this point in the history
…x-pattern
  • Loading branch information
alexwizp committed May 7, 2020
2 parents 9bc23d8 + 7d0ac59 commit bd13289
Show file tree
Hide file tree
Showing 178 changed files with 4,574 additions and 3,084 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ module.exports = {
files: ['x-pack/plugins/lens/**/*.{js,ts,tsx}'],
rules: {
'react-hooks/exhaustive-deps': 'off',
'react-hooks/rules-of-hooks': 'off',
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"kibana_utils": "src/plugins/kibana_utils",
"navigation": "src/plugins/navigation",
"newsfeed": "src/plugins/newsfeed",
"regionMap": "src/legacy/core_plugins/region_map",
"regionMap": "src/plugins/region_map",
"savedObjects": "src/plugins/saved_objects",
"savedObjectsManagement": "src/plugins/saved_objects_management",
"server": "src/legacy/server",
Expand Down
9 changes: 7 additions & 2 deletions src/core/public/application/application_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export class ApplicationService {
context,
http: { basePath },
injectedMetadata,
redirectTo = (path: string) => (window.location.href = path),
redirectTo = (path: string) => {
window.location.assign(path);
},
history,
}: SetupDeps): InternalApplicationSetup {
const basename = basePath.get();
Expand Down Expand Up @@ -210,7 +212,10 @@ export class ApplicationService {
}

const appBasePath = basePath.prepend(appRoute);
const mount: LegacyAppMounter = () => redirectTo(appBasePath);
const mount: LegacyAppMounter = ({ history: appHistory }) => {
redirectTo(appHistory.createHref(appHistory.location));
window.location.reload();
};

const { updater$, ...appProps } = app;
this.apps.set(app.id, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@
*/

import { take } from 'rxjs/operators';
import { createRenderer } from './utils';
import { act } from 'react-dom/test-utils';
import { createMemoryHistory, MemoryHistory } from 'history';

import { createRenderer } from './utils';
import { ApplicationService } from '../application_service';
import { httpServiceMock } from '../../http/http_service.mock';
import { contextServiceMock } from '../../context/context_service.mock';
import { injectedMetadataServiceMock } from '../../injected_metadata/injected_metadata_service.mock';
import { MockLifecycle } from '../test_types';
import { overlayServiceMock } from '../../overlays/overlay_service.mock';
import { AppMountParameters } from '../types';
import { ScopedHistory } from '../scoped_history';

const flushPromises = () => new Promise(resolve => setImmediate(resolve));

describe('ApplicationService', () => {
let setupDeps: MockLifecycle<'setup'>;
Expand Down Expand Up @@ -83,7 +88,10 @@ describe('ApplicationService', () => {

expect(await currentAppId$.pipe(take(1)).toPromise()).toEqual('app1');

resolveMount!();
await act(async () => {
resolveMount!();
await flushPromises();
});

expect(await currentAppId$.pipe(take(1)).toPromise()).toEqual('app1');
});
Expand All @@ -109,7 +117,7 @@ describe('ApplicationService', () => {

const { navigateToApp, currentAppId$ } = await service.start(startDeps);

await navigateToApp('app1');
await act(() => navigateToApp('app1'));

expect(await currentAppId$.pipe(take(1)).toPromise()).toEqual('app1');

Expand All @@ -120,6 +128,46 @@ describe('ApplicationService', () => {
});
});

it('redirects to full path when navigating to legacy app', async () => {
const redirectTo = jest.fn();
const reloadSpy = jest.spyOn(window.location, 'reload').mockImplementation(() => {});

// In the real application, we use a BrowserHistory instance configured with `basename`. However, in tests we must
// use MemoryHistory which does not support `basename`. In order to emulate this behavior, we will wrap this
// instance with a ScopedHistory configured with a basepath.
history.push(setupDeps.http.basePath.get()); // ScopedHistory constructor will fail if underlying history is not currently at basePath.
const { register, registerLegacyApp } = service.setup({
...setupDeps,
redirectTo,
history: new ScopedHistory(history, setupDeps.http.basePath.get()),
});

register(Symbol(), {
id: 'app1',
title: 'App1',
mount: ({ onAppLeave }: AppMountParameters) => {
onAppLeave(actions => actions.default());
return () => undefined;
},
});
registerLegacyApp({
id: 'myLegacyTestApp',
appUrl: '/app/myLegacyTestApp',
title: 'My Legacy Test App',
});

const { navigateToApp, getComponent } = await service.start(startDeps);

update = createRenderer(getComponent());

await navigate('/test/app/app1');
await act(() => navigateToApp('myLegacyTestApp', { path: '#/some-path' }));

expect(redirectTo).toHaveBeenCalledWith('/test/app/myLegacyTestApp#/some-path');
expect(reloadSpy).toHaveBeenCalled();
reloadSpy.mockRestore();
});

describe('leaving an application that registered an app leave handler', () => {
it('navigates to the new app if action is default', async () => {
startDeps.overlays.openConfirm.mockResolvedValue(true);
Expand All @@ -146,8 +194,10 @@ describe('ApplicationService', () => {

update = createRenderer(getComponent());

await navigate('/app/app1');
await navigateToApp('app2');
await act(async () => {
await navigate('/app/app1');
await navigateToApp('app2');
});

expect(startDeps.overlays.openConfirm).not.toHaveBeenCalled();
expect(history.entries.length).toEqual(3);
Expand Down Expand Up @@ -179,8 +229,10 @@ describe('ApplicationService', () => {

update = createRenderer(getComponent());

await navigate('/app/app1');
await navigateToApp('app2');
await act(async () => {
await navigate('/app/app1');
await navigateToApp('app2');
});

expect(startDeps.overlays.openConfirm).toHaveBeenCalledTimes(1);
expect(startDeps.overlays.openConfirm).toHaveBeenCalledWith(
Expand Down Expand Up @@ -216,8 +268,10 @@ describe('ApplicationService', () => {

update = createRenderer(getComponent());

await navigate('/app/app1');
await navigateToApp('app2');
await act(async () => {
await navigate('/app/app1');
await navigateToApp('app2');
});

expect(startDeps.overlays.openConfirm).toHaveBeenCalledTimes(1);
expect(startDeps.overlays.openConfirm).toHaveBeenCalledWith(
Expand Down
49 changes: 0 additions & 49 deletions src/legacy/core_plugins/region_map/index.ts

This file was deleted.

28 changes: 14 additions & 14 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1809,20 +1809,20 @@ export type TSearchStrategyProvider<T extends TStrategyTypes> = (context: ISearc
// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "getFromSavedObject" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:375:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:375:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:375:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:375:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:377:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:378:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:387:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:388:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:389:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:393:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:394:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:397:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:398:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:374:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:374:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:374:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:374:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:376:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:377:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:386:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:387:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:388:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:392:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:393:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:396:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:397:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:400:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:33:33 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:37:1 - (ae-forgotten-export) The symbol "QueryStateChange" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/types.ts:52:5 - (ae-forgotten-export) The symbol "createFiltersFromValueClickAction" needs to be exported by the entry point index.d.ts
Expand Down
26 changes: 1 addition & 25 deletions src/plugins/maps_legacy/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,7 @@

import { schema, TypeOf } from '@kbn/config-schema';
import { configSchema as tilemapSchema } from '../tile_map/config';

// TODO: Pull this portion from region_map
export const regionmapSchema = schema.object({
includeElasticMapsService: schema.boolean({ defaultValue: true }),
layers: schema.arrayOf(
schema.object({
url: schema.string(),
format: schema.object({
type: schema.string({ defaultValue: 'geojson' }),
}),
meta: schema.object({
feature_collection_path: schema.string({ defaultValue: 'data' }),
}),
attribution: schema.string(),
name: schema.string(),
fields: schema.arrayOf(
schema.object({
name: schema.string(),
description: schema.string(),
})
),
}),
{ defaultValue: [] }
),
});
import { configSchema as regionmapSchema } from '../region_map/config';

export const configSchema = schema.object({
includeElasticMapsService: schema.boolean({ defaultValue: true }),
Expand Down
1 change: 1 addition & 0 deletions src/plugins/maps_legacy/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
import { mapTooltipProvider } from './tooltip_provider';

export interface MapsLegacyConfigType {
regionmap: any;
emsTileLayerId: string;
includeElasticMapsService: boolean;
proxyElasticMapsServiceInMaps: boolean;
Expand Down
46 changes: 46 additions & 0 deletions src/plugins/region_map/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { schema, TypeOf } from '@kbn/config-schema';

export const configSchema = schema.object({
includeElasticMapsService: schema.boolean({ defaultValue: true }),
layers: schema.arrayOf(
schema.object({
url: schema.string(),
format: schema.object({
type: schema.string({ defaultValue: 'geojson' }),
}),
meta: schema.object({
feature_collection_path: schema.string({ defaultValue: 'data' }),
}),
attribution: schema.string(),
name: schema.string(),
fields: schema.arrayOf(
schema.object({
name: schema.string(),
description: schema.string(),
})
),
}),
{ defaultValue: [] }
),
});

export type ConfigSchema = TypeOf<typeof configSchema>;
14 changes: 14 additions & 0 deletions src/plugins/region_map/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "regionMap",
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": ["map", "regionmap"],
"ui": true,
"server": true,
"requiredPlugins": [
"visualizations",
"expressions",
"mapsLegacy",
"data"
]
}
File renamed without changes.
Loading

0 comments on commit bd13289

Please sign in to comment.