Skip to content

Commit

Permalink
Merge branch 'master' into fix/remove-agg-formats
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jun 25, 2020
2 parents eb9c6e2 + ec40593 commit cb0d0af
Show file tree
Hide file tree
Showing 305 changed files with 8,481 additions and 6,920 deletions.
1 change: 1 addition & 0 deletions .backportrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
],
"targetPRLabels": ["backport"],
"branchLabelMapping": {
"^v8.0.0$": "master",
"^v7.9.0$": "7.x",
"^v(\\d+).(\\d+).\\d+$": "$1.$2"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [App](./kibana-plugin-core-public.app.md) &gt; [exactRoute](./kibana-plugin-core-public.app.exactroute.md)

## App.exactRoute property

If set to true, the application's route will only be checked against an exact match. Defaults to `false`<!-- -->.

<b>Signature:</b>

```typescript
exactRoute?: boolean;
```

## Example


```ts
core.application.register({
id: 'my_app',
title: 'My App'
exactRoute: true,
mount: () => { ... },
})

// '[basePath]/app/my_app' will be matched
// '[basePath]/app/my_app/some/path' will not be matched

```

Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export interface App<HistoryLocationState = unknown> extends AppBase
| --- | --- | --- |
| [appRoute](./kibana-plugin-core-public.app.approute.md) | <code>string</code> | Override the application's routing path from <code>/app/${id}</code>. Must be unique across registered applications. Should not include the base path from HTTP. |
| [chromeless](./kibana-plugin-core-public.app.chromeless.md) | <code>boolean</code> | Hide the UI chrome when the application is mounted. Defaults to <code>false</code>. Takes precedence over chrome service visibility settings. |
| [exactRoute](./kibana-plugin-core-public.app.exactroute.md) | <code>boolean</code> | If set to true, the application's route will only be checked against an exact match. Defaults to <code>false</code>. |
| [mount](./kibana-plugin-core-public.app.mount.md) | <code>AppMount&lt;HistoryLocationState&gt; &#124; AppMountDeprecated&lt;HistoryLocationState&gt;</code> | A mount function called when the user navigates to this app's route. May have signature of [AppMount](./kibana-plugin-core-public.appmount.md) or [AppMountDeprecated](./kibana-plugin-core-public.appmountdeprecated.md)<!-- -->. |
Binary file added docs/images/data-viz-homepage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions docs/setup/connect-to-elasticsearch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ to see all that you can do in {kib}.
[[upload-data-kibana]]
=== Upload a CSV, JSON, or log file

To visualize data in a CSV, JSON, or log file, you can
upload it using the File Data Visualizer. On the home page,
click *Import a CSV, NDSON, or log file*, and then drag your file into the
File Data Visualizer.
experimental[]

To visualize data in a CSV, JSON, or log file, you can upload it using the File
Data Visualizer. On the home page, click *Import a CSV, NDSON, or log file*, and
then drag your file into the File Data Visualizer. Alternatively, you can open
it by navigating to the Machine Learning app page from the sidebar menu and
selecting the Data Visualizer from the top navigation bar on the opening page.

[role="screenshot"]
image::images/data-viz-homepage.jpg[File Data Visualizer on the home page]

You can upload a file up to 100 MB. This value is configurable up to 1 GB in
<<kibana-ml-settings, Advanced Settings>>.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@
"babel-eslint": "^10.0.3",
"babel-jest": "^25.5.1",
"babel-plugin-istanbul": "^6.0.0",
"backport": "5.4.1",
"backport": "5.4.6",
"chai": "3.5.0",
"chance": "1.0.18",
"cheerio": "0.22.0",
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/application/application_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export class ApplicationService {
this.mounters.set(app.id, {
appRoute: app.appRoute!,
appBasePath: basePath.prepend(app.appRoute!),
exactRoute: app.exactRoute ?? false,
mount: wrapMount(plugin, app),
unmountBeforeMounting: false,
legacy: false,
Expand Down Expand Up @@ -236,6 +237,7 @@ export class ApplicationService {
this.mounters.set(app.id, {
appRoute,
appBasePath,
exactRoute: false,
mount,
unmountBeforeMounting: true,
legacy: true,
Expand Down
100 changes: 62 additions & 38 deletions src/core/public/application/integration_tests/router.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { ScopedHistory } from '../scoped_history';
describe('AppRouter', () => {
let mounters: MockedMounterMap<EitherApp>;
let globalHistory: History;
let appStatuses$: BehaviorSubject<Map<string, AppStatus>>;
let update: ReturnType<typeof createRenderer>;
let scopedAppHistory: History;

Expand All @@ -53,6 +52,17 @@ describe('AppRouter', () => {
);
};

const createMountersRenderer = () =>
createRenderer(
<AppRouter
history={globalHistory}
mounters={mockMountersToMounters()}
appStatuses$={mountersToAppStatus$()}
setAppLeaveHandler={noop}
setIsMounting={noop}
/>
);

beforeEach(() => {
mounters = new Map([
createAppMounter({ appId: 'app1', html: '<span>App 1</span>' }),
Expand Down Expand Up @@ -90,16 +100,7 @@ describe('AppRouter', () => {
}),
] as Array<MockedMounterTuple<EitherApp>>);
globalHistory = createMemoryHistory();
appStatuses$ = mountersToAppStatus$();
update = createRenderer(
<AppRouter
history={globalHistory}
mounters={mockMountersToMounters()}
appStatuses$={appStatuses$}
setAppLeaveHandler={noop}
setIsMounting={noop}
/>
);
update = createMountersRenderer();
});

it('calls mount handler and returned unmount function when navigating between apps', async () => {
Expand Down Expand Up @@ -220,15 +221,7 @@ describe('AppRouter', () => {
})
);
globalHistory = createMemoryHistory();
update = createRenderer(
<AppRouter
history={globalHistory}
mounters={mockMountersToMounters()}
appStatuses$={mountersToAppStatus$()}
setAppLeaveHandler={noop}
setIsMounting={noop}
/>
);
update = createMountersRenderer();

await navigate('/fake-login');

Expand All @@ -252,22 +245,61 @@ describe('AppRouter', () => {
})
);
globalHistory = createMemoryHistory();
update = createRenderer(
<AppRouter
history={globalHistory}
mounters={mockMountersToMounters()}
appStatuses$={mountersToAppStatus$()}
setAppLeaveHandler={noop}
setIsMounting={noop}
/>
);
update = createMountersRenderer();

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

expect(mounters.get('spaces')!.mounter.mount).toHaveBeenCalled();
expect(mounters.get('login')!.mounter.mount).not.toHaveBeenCalled();
});

it('should mount an exact route app only when the path is an exact match', async () => {
mounters.set(
...createAppMounter({
appId: 'exactApp',
html: '<div>exact app</div>',
exactRoute: true,
appRoute: '/app/exact-app',
})
);

globalHistory = createMemoryHistory();
update = createMountersRenderer();

await navigate('/app/exact-app/some-path');

expect(mounters.get('exactApp')!.mounter.mount).not.toHaveBeenCalled();

await navigate('/app/exact-app');

expect(mounters.get('exactApp')!.mounter.mount).toHaveBeenCalledTimes(1);
});

it('should mount an an app with a route nested in an exact route app', async () => {
mounters.set(
...createAppMounter({
appId: 'exactApp',
html: '<div>exact app</div>',
exactRoute: true,
appRoute: '/app/exact-app',
})
);
mounters.set(
...createAppMounter({
appId: 'nestedApp',
html: '<div>nested app</div>',
appRoute: '/app/exact-app/another-app',
})
);
globalHistory = createMemoryHistory();
update = createMountersRenderer();

await navigate('/app/exact-app/another-app');

expect(mounters.get('exactApp')!.mounter.mount).not.toHaveBeenCalled();
expect(mounters.get('nestedApp')!.mounter.mount).toHaveBeenCalledTimes(1);
});

it('should not remount when changing pages within app', async () => {
const { mounter, unmount } = mounters.get('app1')!;
await navigate('/app/app1/page1');
Expand Down Expand Up @@ -304,15 +336,7 @@ describe('AppRouter', () => {

it('should not remount when when changing pages within app using hash history', async () => {
globalHistory = createHashHistory();
update = createRenderer(
<AppRouter
history={globalHistory}
mounters={mockMountersToMounters()}
appStatuses$={mountersToAppStatus$()}
setAppLeaveHandler={noop}
setIsMounting={noop}
/>
);
update = createMountersRenderer();

const { mounter, unmount } = mounters.get('app1')!;
await navigate('/app/app1/page1');
Expand Down
4 changes: 4 additions & 0 deletions src/core/public/application/integration_tests/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ export const createAppMounter = ({
appId,
html = `<div>App ${appId}</div>`,
appRoute = `/app/${appId}`,
exactRoute = false,
extraMountHook,
}: {
appId: string;
html?: string;
appRoute?: string;
exactRoute?: boolean;
extraMountHook?: (params: AppMountParameters) => void;
}): MockedMounterTuple<App> => {
const unmount = jest.fn();
Expand All @@ -62,6 +64,7 @@ export const createAppMounter = ({
appRoute,
appBasePath: appRoute,
legacy: false,
exactRoute,
mount: jest.fn(async (params: AppMountParameters) => {
const { appBasePath: basename, element } = params;
Object.assign(element, {
Expand Down Expand Up @@ -90,6 +93,7 @@ export const createLegacyAppMounter = (
appBasePath: `/app/${appId.split(':')[0]}`,
unmountBeforeMounting: true,
legacy: true,
exactRoute: false,
mount: legacyMount,
},
unmount: jest.fn(),
Expand Down
19 changes: 19 additions & 0 deletions src/core/public/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,24 @@ export interface App<HistoryLocationState = unknown> extends AppBase {
* base path from HTTP.
*/
appRoute?: string;

/**
* If set to true, the application's route will only be checked against an exact match. Defaults to `false`.
*
* @example
* ```ts
* core.application.register({
* id: 'my_app',
* title: 'My App'
* exactRoute: true,
* mount: () => { ... },
* })
*
* // '[basePath]/app/my_app' will be matched
* // '[basePath]/app/my_app/some/path' will not be matched
* ```
*/
exactRoute?: boolean;
}

/** @public */
Expand Down Expand Up @@ -569,6 +587,7 @@ export type Mounter<T = App | LegacyApp> = SelectivePartial<
appBasePath: string;
mount: T extends LegacyApp ? LegacyAppMounter : AppMounter;
legacy: boolean;
exactRoute: boolean;
unmountBeforeMounting: T extends LegacyApp ? true : boolean;
},
T extends LegacyApp ? never : 'unmountBeforeMounting'
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/application/ui/app_container.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('AppContainer', () => {
appRoute: '/some-route',
unmountBeforeMounting: false,
legacy: false,
exactRoute: false,
mount: async ({ element }: AppMountParameters) => {
await promise;
const container = document.createElement('div');
Expand Down Expand Up @@ -143,6 +144,7 @@ describe('AppContainer', () => {
appRoute: '/some-route',
unmountBeforeMounting: false,
legacy: false,
exactRoute: false,
mount: async ({ element }: AppMountParameters) => {
await waitPromise;
throw new Error(`Mounting failed!`);
Expand Down
1 change: 1 addition & 0 deletions src/core/public/application/ui/app_router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const AppRouter: FunctionComponent<Props> = ({
<Route
key={mounter.appRoute}
path={mounter.appRoute}
exact={mounter.exactRoute}
render={({ match: { url } }) => (
<AppContainer
appPath={url}
Expand Down
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
Loading

0 comments on commit cb0d0af

Please sign in to comment.