Skip to content

Commit

Permalink
Merge branch 'master' into bug/missing-index-pattern-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Jun 2, 2020
2 parents fbd22ce + ce7940a commit f25a7fb
Show file tree
Hide file tree
Showing 52 changed files with 871 additions and 123 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- 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; [ApplicationStart](./kibana-plugin-core-public.applicationstart.md) &gt; [applications$](./kibana-plugin-core-public.applicationstart.applications_.md)

## ApplicationStart.applications$ property

Observable emitting the list of currently registered apps and their associated status.

<b>Signature:</b>

```typescript
applications$: Observable<ReadonlyMap<string, PublicAppInfo | PublicLegacyAppInfo>>;
```

## Remarks

Applications disabled by [Capabilities](./kibana-plugin-core-public.capabilities.md) will not be present in the map. Applications manually disabled from the client-side using an [application updater](./kibana-plugin-core-public.appupdater.md) are present, with their status properly set as `inaccessible`<!-- -->.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ApplicationStart

| Property | Type | Description |
| --- | --- | --- |
| [applications$](./kibana-plugin-core-public.applicationstart.applications_.md) | <code>Observable&lt;ReadonlyMap&lt;string, PublicAppInfo &#124; PublicLegacyAppInfo&gt;&gt;</code> | Observable emitting the list of currently registered apps and their associated status. |
| [capabilities](./kibana-plugin-core-public.applicationstart.capabilities.md) | <code>RecursiveReadonly&lt;Capabilities&gt;</code> | Gets the read-only capabilities. |
| [currentAppId$](./kibana-plugin-core-public.applicationstart.currentappid_.md) | <code>Observable&lt;string &#124; undefined&gt;</code> | An observable that emits the current application id and each subsequent id update. |

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- 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; [LegacyApp](./kibana-plugin-core-public.legacyapp.md) &gt; [appUrl](./kibana-plugin-core-public.legacyapp.appurl.md)

## LegacyApp.appUrl property

<b>Signature:</b>

```typescript
appUrl: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- 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; [LegacyApp](./kibana-plugin-core-public.legacyapp.md) &gt; [disableSubUrlTracking](./kibana-plugin-core-public.legacyapp.disablesuburltracking.md)

## LegacyApp.disableSubUrlTracking property

<b>Signature:</b>

```typescript
disableSubUrlTracking?: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- 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; [LegacyApp](./kibana-plugin-core-public.legacyapp.md) &gt; [linkToLastSubUrl](./kibana-plugin-core-public.legacyapp.linktolastsuburl.md)

## LegacyApp.linkToLastSubUrl property

<b>Signature:</b>

```typescript
linkToLastSubUrl?: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- 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; [LegacyApp](./kibana-plugin-core-public.legacyapp.md)

## LegacyApp interface


<b>Signature:</b>

```typescript
export interface LegacyApp extends AppBase
```
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [appUrl](./kibana-plugin-core-public.legacyapp.appurl.md) | <code>string</code> | |
| [disableSubUrlTracking](./kibana-plugin-core-public.legacyapp.disablesuburltracking.md) | <code>boolean</code> | |
| [linkToLastSubUrl](./kibana-plugin-core-public.legacyapp.linktolastsuburl.md) | <code>boolean</code> | |
| [subUrlBase](./kibana-plugin-core-public.legacyapp.suburlbase.md) | <code>string</code> | |
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- 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; [LegacyApp](./kibana-plugin-core-public.legacyapp.md) &gt; [subUrlBase](./kibana-plugin-core-public.legacyapp.suburlbase.md)

## LegacyApp.subUrlBase property

<b>Signature:</b>

```typescript
subUrlBase?: string;
```
3 changes: 3 additions & 0 deletions docs/development/core/public/kibana-plugin-core-public.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [IHttpResponseInterceptorOverrides](./kibana-plugin-core-public.ihttpresponseinterceptoroverrides.md) | Properties that can be returned by HttpInterceptor.request to override the response. |
| [ImageValidation](./kibana-plugin-core-public.imagevalidation.md) | |
| [IUiSettingsClient](./kibana-plugin-core-public.iuisettingsclient.md) | Client-side client that provides access to the advanced settings stored in elasticsearch. The settings provide control over the behavior of the Kibana application. For example, a user can specify how to display numeric or date fields. Users can adjust the settings via Management UI. [IUiSettingsClient](./kibana-plugin-core-public.iuisettingsclient.md) |
| [LegacyApp](./kibana-plugin-core-public.legacyapp.md) | |
| [LegacyCoreSetup](./kibana-plugin-core-public.legacycoresetup.md) | Setup interface exposed to the legacy platform via the <code>ui/new_platform</code> module. |
| [LegacyCoreStart](./kibana-plugin-core-public.legacycorestart.md) | Start interface exposed to the legacy platform via the <code>ui/new_platform</code> module. |
| [LegacyNavLink](./kibana-plugin-core-public.legacynavlink.md) | |
Expand Down Expand Up @@ -162,6 +163,8 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [NavType](./kibana-plugin-core-public.navtype.md) | |
| [PluginInitializer](./kibana-plugin-core-public.plugininitializer.md) | The <code>plugin</code> export at the root of a plugin's <code>public</code> directory should conform to this interface. |
| [PluginOpaqueId](./kibana-plugin-core-public.pluginopaqueid.md) | |
| [PublicAppInfo](./kibana-plugin-core-public.publicappinfo.md) | Public information about a registered [application](./kibana-plugin-core-public.app.md) |
| [PublicLegacyAppInfo](./kibana-plugin-core-public.publiclegacyappinfo.md) | Information about a registered [legacy application](./kibana-plugin-core-public.legacyapp.md) |
| [PublicUiSettingsParams](./kibana-plugin-core-public.publicuisettingsparams.md) | A sub-set of [UiSettingsParams](./kibana-plugin-core-public.uisettingsparams.md) exposed to the client-side. |
| [RecursiveReadonly](./kibana-plugin-core-public.recursivereadonly.md) | |
| [SavedObjectAttribute](./kibana-plugin-core-public.savedobjectattribute.md) | Type definition for a Saved Object attribute value |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- 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; [PublicAppInfo](./kibana-plugin-core-public.publicappinfo.md)

## PublicAppInfo type

Public information about a registered [application](./kibana-plugin-core-public.app.md)

<b>Signature:</b>

```typescript
export declare type PublicAppInfo = Omit<App, 'mount' | 'updater$'> & {
legacy: false;
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- 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; [PublicLegacyAppInfo](./kibana-plugin-core-public.publiclegacyappinfo.md)

## PublicLegacyAppInfo type

Information about a registered [legacy application](./kibana-plugin-core-public.legacyapp.md)

<b>Signature:</b>

```typescript
export declare type PublicLegacyAppInfo = Omit<LegacyApp, 'updater$'> & {
legacy: true;
};
```
7 changes: 4 additions & 3 deletions src/core/public/application/application_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import {
InternalApplicationStart,
ApplicationStart,
InternalApplicationSetup,
App,
LegacyApp,
PublicAppInfo,
PublicLegacyAppInfo,
} from './types';
import { ApplicationServiceContract } from './test_types';

Expand All @@ -47,6 +47,7 @@ const createStartContractMock = (): jest.Mocked<ApplicationStart> => {
const currentAppId$ = new Subject<string | undefined>();

return {
applications$: new BehaviorSubject<Map<string, PublicAppInfo | PublicLegacyAppInfo>>(new Map()),
currentAppId$: currentAppId$.asObservable(),
capabilities: capabilitiesServiceMock.createStartContract().capabilities,
navigateToApp: jest.fn(),
Expand All @@ -60,7 +61,7 @@ const createInternalStartContractMock = (): jest.Mocked<InternalApplicationStart
const currentAppId$ = new Subject<string | undefined>();

return {
applications$: new BehaviorSubject<Map<string, App | LegacyApp>>(new Map()),
applications$: new BehaviorSubject<Map<string, PublicAppInfo | PublicLegacyAppInfo>>(new Map()),
capabilities: capabilitiesServiceMock.createStartContract().capabilities,
currentAppId$: currentAppId$.asObservable(),
getComponent: jest.fn(),
Expand Down
15 changes: 13 additions & 2 deletions src/core/public/application/application_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ import { httpServiceMock } from '../http/http_service.mock';
import { overlayServiceMock } from '../overlays/overlay_service.mock';
import { MockLifecycle } from './test_types';
import { ApplicationService } from './application_service';
import { App, AppNavLinkStatus, AppStatus, AppUpdater, LegacyApp } from './types';
import {
App,
PublicAppInfo,
AppNavLinkStatus,
AppStatus,
AppUpdater,
LegacyApp,
PublicLegacyAppInfo,
} from './types';
import { act } from 'react-dom/test-utils';

const createApp = (props: Partial<App>): App => {
Expand Down Expand Up @@ -366,7 +374,10 @@ describe('#setup()', () => {
setup.registerAppUpdater(statusUpdater);

const start = await service.start(startDeps);
let latestValue: ReadonlyMap<string, App | LegacyApp> = new Map<string, App | LegacyApp>();
let latestValue: ReadonlyMap<string, PublicAppInfo | PublicLegacyAppInfo> = new Map<
string,
PublicAppInfo | PublicLegacyAppInfo
>();
start.applications$.subscribe((apps) => {
latestValue = apps;
});
Expand Down
7 changes: 5 additions & 2 deletions src/core/public/application/application_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
Mounter,
} from './types';
import { getLeaveAction, isConfirmAction } from './application_leave';
import { appendAppPath, parseAppUrl, relativeToAbsolute } from './utils';
import { appendAppPath, parseAppUrl, relativeToAbsolute, getAppInfo } from './utils';

interface SetupDeps {
context: ContextSetup;
Expand Down Expand Up @@ -291,7 +291,10 @@ export class ApplicationService {
};

return {
applications$,
applications$: applications$.pipe(
map((apps) => new Map([...apps.entries()].map(([id, app]) => [id, getAppInfo(app)]))),
shareReplay(1)
),
capabilities,
currentAppId$: this.currentAppId$.pipe(
filter((appId) => appId !== undefined),
Expand Down
4 changes: 3 additions & 1 deletion src/core/public/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export {
AppLeaveAction,
AppLeaveDefaultAction,
AppLeaveConfirmAction,
LegacyApp,
PublicAppInfo,
PublicLegacyAppInfo,
// Internal types
InternalApplicationStart,
LegacyApp,
} from './types';
42 changes: 29 additions & 13 deletions src/core/public/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,32 @@ export interface App<HistoryLocationState = unknown> extends AppBase {
appRoute?: string;
}

/** @internal */
/** @public */
export interface LegacyApp extends AppBase {
appUrl: string;
subUrlBase?: string;
linkToLastSubUrl?: boolean;
disableSubUrlTracking?: boolean;
}

/**
* Public information about a registered {@link App | application}
*
* @public
*/
export type PublicAppInfo = Omit<App, 'mount' | 'updater$'> & {
legacy: false;
};

/**
* Information about a registered {@link LegacyApp | legacy application}
*
* @public
*/
export type PublicLegacyAppInfo = Omit<LegacyApp, 'updater$'> & {
legacy: true;
};

/**
* A mount function called when the user navigates to this app's route.
*
Expand Down Expand Up @@ -649,6 +667,15 @@ export interface ApplicationStart {
*/
capabilities: RecursiveReadonly<Capabilities>;

/**
* Observable emitting the list of currently registered apps and their associated status.
*
* @remarks
* Applications disabled by {@link Capabilities} will not be present in the map. Applications manually disabled from
* the client-side using an {@link AppUpdater | application updater} are present, with their status properly set as `inaccessible`.
*/
applications$: Observable<ReadonlyMap<string, PublicAppInfo | PublicLegacyAppInfo>>;

/**
* Navigate to a given app
*
Expand Down Expand Up @@ -721,18 +748,7 @@ export interface ApplicationStart {
}

/** @internal */
export interface InternalApplicationStart
extends Pick<
ApplicationStart,
'capabilities' | 'navigateToApp' | 'navigateToUrl' | 'getUrlForApp' | 'currentAppId$'
> {
/**
* Apps available based on the current capabilities.
* Should be used to show navigation links and make routing decisions.
* Applications manually disabled from the client-side using {@link AppUpdater}
*/
applications$: Observable<ReadonlyMap<string, App | LegacyApp>>;

export interface InternalApplicationStart extends Omit<ApplicationStart, 'registerMountContext'> {
/**
* Register a context provider for application mounting. Will only be available to applications that depend on the
* plugin that registered this context. Deprecated, use {@link CoreSetup.getStartServices}.
Expand Down
57 changes: 56 additions & 1 deletion src/core/public/application/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
* under the License.
*/

import { LegacyApp, App } from './types';
import { of } from 'rxjs';
import { LegacyApp, App, AppStatus, AppNavLinkStatus } from './types';
import { BasePath } from '../http/base_path';
import {
removeSlashes,
appendAppPath,
isLegacyApp,
relativeToAbsolute,
parseAppUrl,
getAppInfo,
} from './utils';

describe('removeSlashes', () => {
Expand Down Expand Up @@ -459,3 +461,56 @@ describe('parseAppUrl', () => {
});
});
});

describe('getAppInfo', () => {
const createApp = (props: Partial<App> = {}): App => ({
mount: () => () => undefined,
updater$: of(() => undefined),
id: 'some-id',
title: 'some-title',
status: AppStatus.accessible,
navLinkStatus: AppNavLinkStatus.default,
appRoute: `/app/some-id`,
legacy: false,
...props,
});

const createLegacyApp = (props: Partial<LegacyApp> = {}): LegacyApp => ({
appUrl: '/my-app-url',
updater$: of(() => undefined),
id: 'some-id',
title: 'some-title',
status: AppStatus.accessible,
navLinkStatus: AppNavLinkStatus.default,
legacy: true,
...props,
});

it('converts an application and remove sensitive properties', () => {
const app = createApp();
const info = getAppInfo(app);

expect(info).toEqual({
id: 'some-id',
title: 'some-title',
status: AppStatus.accessible,
navLinkStatus: AppNavLinkStatus.default,
appRoute: `/app/some-id`,
legacy: false,
});
});

it('converts a legacy application and remove sensitive properties', () => {
const app = createLegacyApp();
const info = getAppInfo(app);

expect(info).toEqual({
appUrl: '/my-app-url',
id: 'some-id',
title: 'some-title',
status: AppStatus.accessible,
navLinkStatus: AppNavLinkStatus.default,
legacy: true,
});
});
});
Loading

0 comments on commit f25a7fb

Please sign in to comment.