Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/72875
Browse files Browse the repository at this point in the history
elasticmachine authored Sep 1, 2020
2 parents ec84c3f + b5faf41 commit de5d560
Showing 189 changed files with 4,475 additions and 1,756 deletions.
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/APM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: APM Issue
about: Issues related to the APM solution in Kibana
labels: Team:apm
title: [APM]
---

**Versions**
Kibana: (if relevant)
APM Server: (if relevant)
Elasticsearch: (if relevant)
31 changes: 0 additions & 31 deletions docs/canvas/canvas-tinymath-functions.asciidoc
Original file line number Diff line number Diff line change
@@ -492,37 +492,6 @@ find the mean by index.
|one or more numbers or arrays of numbers
|===

*Returns*: `number` | `Array.<number>`. The maximum value of all numbers if
`args` contains only numbers. Returns an array with the the maximum values at each
index, including all scalar numbers in `args` in the calculation at each index if
`args` contains at least one array.

*Throws*: `'Array length mismatch'` if `args` contains arrays of different lengths

*Example*
[source, js]
------------
max(1, 2, 3) // returns 3
max([10, 20, 30, 40], 15) // returns [15, 20, 30, 40]
max([1, 9], 4, [3, 5]) // returns [max([1, 4, 3]), max([9, 4, 5])] = [4, 9]
------------

[float]
=== mean( ...args )

Finds the mean value of one of more numbers/arrays of numbers passed into the function.
If at least one array of numbers is passed into the function, the function will
find the mean by index.

[cols="3*^<"]
|===
|Param |Type |Description

|...args
|number \| Array.<number>
|one or more numbers or arrays of numbers
|===

*Returns*: `number` | `Array.<number>`. The mean value of all numbers if `args`
contains only numbers. Returns an array with the the mean values of each index,
including all scalar numbers in `args` in the calculation at each index if `args`
Original file line number Diff line number Diff line change
@@ -19,4 +19,5 @@ export interface AppMountParameters<HistoryLocationState = unknown>
| [element](./kibana-plugin-core-public.appmountparameters.element.md) | <code>HTMLElement</code> | The container element to render the application into. |
| [history](./kibana-plugin-core-public.appmountparameters.history.md) | <code>ScopedHistory&lt;HistoryLocationState&gt;</code> | A scoped history instance for your application. Should be used to wire up your applications Router. |
| [onAppLeave](./kibana-plugin-core-public.appmountparameters.onappleave.md) | <code>(handler: AppLeaveHandler) =&gt; void</code> | A function that can be used to register a handler that will be called when the user is leaving the current application, allowing to prompt a confirmation message before actually changing the page.<!-- -->This will be called either when the user goes to another application, or when trying to close the tab or manually changing the url. |
| [setHeaderActionMenu](./kibana-plugin-core-public.appmountparameters.setheaderactionmenu.md) | <code>(menuMount: MountPoint &#124; undefined) =&gt; void</code> | A function that can be used to set the mount point used to populate the application action container in the chrome header.<!-- -->Calling the handler multiple time will erase the current content of the action menu with the mount from the latest call. Calling the handler with <code>undefined</code> will unmount the current mount point. Calling the handler after the application has been unmounted will have no effect. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!-- 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; [AppMountParameters](./kibana-plugin-core-public.appmountparameters.md) &gt; [setHeaderActionMenu](./kibana-plugin-core-public.appmountparameters.setheaderactionmenu.md)

## AppMountParameters.setHeaderActionMenu property

A function that can be used to set the mount point used to populate the application action container in the chrome header.

Calling the handler multiple time will erase the current content of the action menu with the mount from the latest call. Calling the handler with `undefined` will unmount the current mount point. Calling the handler after the application has been unmounted will have no effect.

<b>Signature:</b>

```typescript
setHeaderActionMenu: (menuMount: MountPoint | undefined) => void;
```

## Example


```ts
// application.tsx
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter, Route } from 'react-router-dom';

import { CoreStart, AppMountParameters } from 'src/core/public';
import { MyPluginDepsStart } from './plugin';

export renderApp = ({ element, history, setHeaderActionMenu }: AppMountParameters) => {
const { renderApp } = await import('./application');
const { renderActionMenu } = await import('./action_menu');
setHeaderActionMenu((element) => {
return renderActionMenu(element);
})
return renderApp({ element, history });
}

```

Original file line number Diff line number Diff line change
@@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
filter?: string;
filter?: string | KueryNode;
```
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ export interface SavedObjectsFindOptions
| --- | --- | --- |
| [defaultSearchOperator](./kibana-plugin-core-public.savedobjectsfindoptions.defaultsearchoperator.md) | <code>'AND' &#124; 'OR'</code> | |
| [fields](./kibana-plugin-core-public.savedobjectsfindoptions.fields.md) | <code>string[]</code> | An array of fields to include in the results |
| [filter](./kibana-plugin-core-public.savedobjectsfindoptions.filter.md) | <code>string</code> | |
| [filter](./kibana-plugin-core-public.savedobjectsfindoptions.filter.md) | <code>string &#124; KueryNode</code> | |
| [hasReference](./kibana-plugin-core-public.savedobjectsfindoptions.hasreference.md) | <code>{</code><br/><code> type: string;</code><br/><code> id: string;</code><br/><code> }</code> | |
| [namespaces](./kibana-plugin-core-public.savedobjectsfindoptions.namespaces.md) | <code>string[]</code> | |
| [page](./kibana-plugin-core-public.savedobjectsfindoptions.page.md) | <code>number</code> | |
Original file line number Diff line number Diff line change
@@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
filter?: string;
filter?: string | KueryNode;
```
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ export interface SavedObjectsFindOptions
| --- | --- | --- |
| [defaultSearchOperator](./kibana-plugin-core-server.savedobjectsfindoptions.defaultsearchoperator.md) | <code>'AND' &#124; 'OR'</code> | |
| [fields](./kibana-plugin-core-server.savedobjectsfindoptions.fields.md) | <code>string[]</code> | An array of fields to include in the results |
| [filter](./kibana-plugin-core-server.savedobjectsfindoptions.filter.md) | <code>string</code> | |
| [filter](./kibana-plugin-core-server.savedobjectsfindoptions.filter.md) | <code>string &#124; KueryNode</code> | |
| [hasReference](./kibana-plugin-core-server.savedobjectsfindoptions.hasreference.md) | <code>{</code><br/><code> type: string;</code><br/><code> id: string;</code><br/><code> }</code> | |
| [namespaces](./kibana-plugin-core-server.savedobjectsfindoptions.namespaces.md) | <code>string[]</code> | |
| [page](./kibana-plugin-core-server.savedobjectsfindoptions.page.md) | <code>number</code> | |
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -49,7 +49,6 @@
"test:ftr:server": "node scripts/functional_tests_server",
"test:ftr:runner": "node scripts/functional_test_runner",
"test:coverage": "grunt test:coverage",
"typespec": "typings-tester --config x-pack/plugins/canvas/public/lib/aeroelastic/tsconfig.json x-pack/plugins/canvas/public/lib/aeroelastic/__fixtures__/typescript/typespec_tests.ts",
"checkLicenses": "node scripts/check_licenses --dev",
"build": "node scripts/build --all-platforms",
"start": "node scripts/kibana --dev",
@@ -473,7 +472,6 @@
"topojson-client": "3.0.0",
"tree-kill": "^1.2.2",
"typescript": "4.0.2",
"typings-tester": "^0.3.2",
"ui-select": "0.19.8",
"vega": "^5.13.0",
"vega-lite": "^4.13.1",

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/core/public/application/application_service.mock.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
import { History } from 'history';
import { BehaviorSubject, Subject } from 'rxjs';

import type { MountPoint } from '../types';
import { capabilitiesServiceMock } from './capabilities/capabilities_service.mock';
import {
ApplicationSetup,
@@ -87,6 +88,7 @@ const createInternalStartContractMock = (): jest.Mocked<InternalApplicationStart
applications$: new BehaviorSubject<Map<string, PublicAppInfo | PublicLegacyAppInfo>>(new Map()),
capabilities: capabilitiesServiceMock.createStartContract().capabilities,
currentAppId$: currentAppId$.asObservable(),
currentActionMenu$: new BehaviorSubject<MountPoint | undefined>(undefined),
getComponent: jest.fn(),
getUrlForApp: jest.fn(),
navigateToApp: jest.fn().mockImplementation((appId) => currentAppId$.next(appId)),
42 changes: 37 additions & 5 deletions src/core/public/application/application_service.tsx
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs';
import { map, shareReplay, takeUntil, distinctUntilChanged, filter } from 'rxjs/operators';
import { createBrowserHistory, History } from 'history';

import { MountPoint } from '../types';
import { InjectedMetadataSetup } from '../injected_metadata';
import { HttpSetup, HttpStart } from '../http';
import { OverlayStart } from '../overlays';
@@ -90,6 +91,11 @@ interface AppUpdaterWrapper {
updater: AppUpdater;
}

interface AppInternalState {
leaveHandler?: AppLeaveHandler;
actionMenu?: MountPoint;
}

/**
* Service that is responsible for registering new applications.
* @internal
@@ -98,8 +104,9 @@ export class ApplicationService {
private readonly apps = new Map<string, App<any> | LegacyApp>();
private readonly mounters = new Map<string, Mounter>();
private readonly capabilities = new CapabilitiesService();
private readonly appLeaveHandlers = new Map<string, AppLeaveHandler>();
private readonly appInternalStates = new Map<string, AppInternalState>();
private currentAppId$ = new BehaviorSubject<string | undefined>(undefined);
private currentActionMenu$ = new BehaviorSubject<MountPoint | undefined>(undefined);
private readonly statusUpdaters$ = new BehaviorSubject<Map<symbol, AppUpdaterWrapper>>(new Map());
private readonly subscriptions: Subscription[] = [];
private stop$ = new Subject();
@@ -293,12 +300,14 @@ export class ApplicationService {
if (path === undefined) {
path = applications$.value.get(appId)?.defaultPath;
}
this.appLeaveHandlers.delete(this.currentAppId$.value!);
this.appInternalStates.delete(this.currentAppId$.value!);
this.navigate!(getAppUrl(availableMounters, appId, path), state, replace);
this.currentAppId$.next(appId);
}
};

this.currentAppId$.subscribe(() => this.refreshCurrentActionMenu());

return {
applications$: applications$.pipe(
map((apps) => new Map([...apps.entries()].map(([id, app]) => [id, getAppInfo(app)]))),
@@ -310,6 +319,10 @@ export class ApplicationService {
distinctUntilChanged(),
takeUntil(this.stop$)
),
currentActionMenu$: this.currentActionMenu$.pipe(
distinctUntilChanged(),
takeUntil(this.stop$)
),
history: this.history,
registerMountContext: this.mountContext.registerContext,
getUrlForApp: (
@@ -338,6 +351,7 @@ export class ApplicationService {
mounters={availableMounters}
appStatuses$={applicationStatuses$}
setAppLeaveHandler={this.setAppLeaveHandler}
setAppActionMenu={this.setAppActionMenu}
setIsMounting={(isMounting) => httpLoadingCount$.next(isMounting ? 1 : 0)}
/>
);
@@ -346,15 +360,32 @@ export class ApplicationService {
}

private setAppLeaveHandler = (appId: string, handler: AppLeaveHandler) => {
this.appLeaveHandlers.set(appId, handler);
this.appInternalStates.set(appId, {
...(this.appInternalStates.get(appId) ?? {}),
leaveHandler: handler,
});
};

private setAppActionMenu = (appId: string, mount: MountPoint | undefined) => {
this.appInternalStates.set(appId, {
...(this.appInternalStates.get(appId) ?? {}),
actionMenu: mount,
});
this.refreshCurrentActionMenu();
};

private refreshCurrentActionMenu = () => {
const appId = this.currentAppId$.getValue();
const currentActionMenu = appId ? this.appInternalStates.get(appId)?.actionMenu : undefined;
this.currentActionMenu$.next(currentActionMenu);
};

private async shouldNavigate(overlays: OverlayStart): Promise<boolean> {
const currentAppId = this.currentAppId$.value;
if (currentAppId === undefined) {
return true;
}
const action = getLeaveAction(this.appLeaveHandlers.get(currentAppId));
const action = getLeaveAction(this.appInternalStates.get(currentAppId)?.leaveHandler);
if (isConfirmAction(action)) {
const confirmed = await overlays.openConfirm(action.text, {
title: action.title,
@@ -372,7 +403,7 @@ export class ApplicationService {
if (currentAppId === undefined) {
return;
}
const action = getLeaveAction(this.appLeaveHandlers.get(currentAppId));
const action = getLeaveAction(this.appInternalStates.get(currentAppId)?.leaveHandler);
if (isConfirmAction(action)) {
event.preventDefault();
// some browsers accept a string return value being the message displayed
@@ -383,6 +414,7 @@ export class ApplicationService {
public stop() {
this.stop$.next();
this.currentAppId$.complete();
this.currentActionMenu$.complete();
this.statusUpdaters$.complete();
this.subscriptions.forEach((sub) => sub.unsubscribe());
window.removeEventListener('beforeunload', this.onBeforeUnload);
Loading

0 comments on commit de5d560

Please sign in to comment.