Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into add-back-maps-tel…
Browse files Browse the repository at this point in the history
…emetry-with-index-false
  • Loading branch information
Aaron Caldwell committed Jun 26, 2020
2 parents cd0401c + be3886b commit bca48e9
Show file tree
Hide file tree
Showing 76 changed files with 1,059 additions and 1,034 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ target
/x-pack/plugins/canvas/shareable_runtime/build
/x-pack/plugins/canvas/storybook
/x-pack/plugins/monitoring/public/lib/jquery_flot
/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/**
/x-pack/legacy/plugins/infra/common/graphql/types.ts
/x-pack/legacy/plugins/infra/public/graphql/types.ts
/x-pack/legacy/plugins/infra/server/graphql/types.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- 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; [ChromeStart](./kibana-plugin-core-public.chromestart.md) &gt; [getCustomNavLink$](./kibana-plugin-core-public.chromestart.getcustomnavlink_.md)

## ChromeStart.getCustomNavLink$() method

Get an observable of the current custom nav link

<b>Signature:</b>

```typescript
getCustomNavLink$(): Observable<Partial<ChromeNavLink> | undefined>;
```
<b>Returns:</b>

`Observable<Partial<ChromeNavLink> | undefined>`

Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ core.chrome.setHelpExtension(elem => {
| [getBadge$()](./kibana-plugin-core-public.chromestart.getbadge_.md) | Get an observable of the current badge |
| [getBrand$()](./kibana-plugin-core-public.chromestart.getbrand_.md) | Get an observable of the current brand information. |
| [getBreadcrumbs$()](./kibana-plugin-core-public.chromestart.getbreadcrumbs_.md) | Get an observable of the current list of breadcrumbs |
| [getCustomNavLink$()](./kibana-plugin-core-public.chromestart.getcustomnavlink_.md) | Get an observable of the current custom nav link |
| [getHelpExtension$()](./kibana-plugin-core-public.chromestart.gethelpextension_.md) | Get an observable of the current custom help conttent |
| [getIsNavDrawerLocked$()](./kibana-plugin-core-public.chromestart.getisnavdrawerlocked_.md) | Get an observable of the current locked state of the nav drawer. |
| [getIsVisible$()](./kibana-plugin-core-public.chromestart.getisvisible_.md) | Get an observable of the current visibility state of the chrome. |
Expand All @@ -64,6 +65,7 @@ core.chrome.setHelpExtension(elem => {
| [setBadge(badge)](./kibana-plugin-core-public.chromestart.setbadge.md) | Override the current badge |
| [setBrand(brand)](./kibana-plugin-core-public.chromestart.setbrand.md) | Set the brand configuration. |
| [setBreadcrumbs(newBreadcrumbs)](./kibana-plugin-core-public.chromestart.setbreadcrumbs.md) | Override the current set of breadcrumbs |
| [setCustomNavLink(newCustomNavLink)](./kibana-plugin-core-public.chromestart.setcustomnavlink.md) | Override the current set of custom nav link |
| [setHelpExtension(helpExtension)](./kibana-plugin-core-public.chromestart.sethelpextension.md) | Override the current set of custom help content |
| [setHelpSupportUrl(url)](./kibana-plugin-core-public.chromestart.sethelpsupporturl.md) | Override the default support URL shown in the help menu |
| [setIsVisible(isVisible)](./kibana-plugin-core-public.chromestart.setisvisible.md) | Set the temporary visibility for the chrome. This does nothing if the chrome is hidden by default and should be used to hide the chrome for things like full-screen modes with an exit button. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- 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; [ChromeStart](./kibana-plugin-core-public.chromestart.md) &gt; [setCustomNavLink](./kibana-plugin-core-public.chromestart.setcustomnavlink.md)

## ChromeStart.setCustomNavLink() method

Override the current set of custom nav link

<b>Signature:</b>

```typescript
setCustomNavLink(newCustomNavLink?: Partial<ChromeNavLink>): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| newCustomNavLink | <code>Partial&lt;ChromeNavLink&gt;</code> | |

<b>Returns:</b>

`void`

2 changes: 1 addition & 1 deletion docs/development/core/server/kibana-plugin-core-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [SavedObjectsBulkUpdateResponse](./kibana-plugin-core-server.savedobjectsbulkupdateresponse.md) | |
| [SavedObjectsClientProviderOptions](./kibana-plugin-core-server.savedobjectsclientprovideroptions.md) | Options to control the creation of the Saved Objects Client. |
| [SavedObjectsClientWrapperOptions](./kibana-plugin-core-server.savedobjectsclientwrapperoptions.md) | Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance. |
| [SavedObjectsComplexFieldMapping](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.md) | See [SavedObjectsFieldMapping](./kibana-plugin-core-server.savedobjectsfieldmapping.md) for documentation. |
| [SavedObjectsComplexFieldMapping](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.md) | See [SavedObjectsFieldMapping](./kibana-plugin-core-server.savedobjectsfieldmapping.md) for documentation.<!-- -->Note: this type intentially doesn't include a type definition for defining the <code>dynamic</code> mapping parameter. Saved Object fields should always inherit the <code>dynamic: 'strict'</code> paramater. If you are unsure of the shape of your data use <code>type: 'object', enabled: false</code> instead. |
| [SavedObjectsCoreFieldMapping](./kibana-plugin-core-server.savedobjectscorefieldmapping.md) | See [SavedObjectsFieldMapping](./kibana-plugin-core-server.savedobjectsfieldmapping.md) for documentation. |
| [SavedObjectsCreateOptions](./kibana-plugin-core-server.savedobjectscreateoptions.md) | |
| [SavedObjectsDeleteByNamespaceOptions](./kibana-plugin-core-server.savedobjectsdeletebynamespaceoptions.md) | |
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

See [SavedObjectsFieldMapping](./kibana-plugin-core-server.savedobjectsfieldmapping.md) for documentation.

Note: this type intentially doesn't include a type definition for defining the `dynamic` mapping parameter. Saved Object fields should always inherit the `dynamic: 'strict'` paramater. If you are unsure of the shape of your data use `type: 'object', enabled: false` instead.

<b>Signature:</b>

```typescript
Expand All @@ -16,7 +18,6 @@ export interface SavedObjectsComplexFieldMapping

| Property | Type | Description |
| --- | --- | --- |
| [dynamic](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.dynamic.md) | <code>string</code> | |
| [properties](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.properties.md) | <code>SavedObjectsMappingProperties</code> | |
| [type](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.type.md) | <code>string</code> | |

3 changes: 2 additions & 1 deletion scripts/backport.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
*/

require('../src/setup_node_env/node_version_validator');
require('backport');
var backport = require('backport');
backport.run();
6 changes: 5 additions & 1 deletion src/core/server/saved_objects/mappings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,14 @@ export interface SavedObjectsCoreFieldMapping {
/**
* See {@link SavedObjectsFieldMapping} for documentation.
*
* Note: this type intentially doesn't include a type definition for defining
* the `dynamic` mapping parameter. Saved Object fields should always inherit
* the `dynamic: 'strict'` paramater. If you are unsure of the shape of your
* data use `type: 'object', enabled: false` instead.
*
* @public
*/
export interface SavedObjectsComplexFieldMapping {
dynamic?: string;
type?: string;
properties: SavedObjectsMappingProperties;
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ function defaultMapping(): IndexMapping {
dynamic: 'strict',
properties: {
migrationVersion: {
// Saved Objects can't redefine dynamic, but we cheat here to support migrations
// @ts-expect-error
dynamic: 'true',
type: 'object',
},
Expand Down
2 changes: 0 additions & 2 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1970,8 +1970,6 @@ export interface SavedObjectsClientWrapperOptions {

// @public
export interface SavedObjectsComplexFieldMapping {
// (undocumented)
dynamic?: string;
// (undocumented)
properties: SavedObjectsMappingProperties;
// (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export class DiscoverHistogram extends Component<DiscoverHistogramProps, Discove
/>
<HistogramBarSeries
id="discover-histogram"
minBarHeight={2}
xScaleType={ScaleType.Time}
yScaleType={ScaleType.Linear}
xAccessor="x"
Expand Down
2 changes: 1 addition & 1 deletion x-pack/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { licensingMock } from './plugins/licensing/server/mocks';
function createCoreRequestHandlerContextMock() {
return {
core: coreMock.createRequestHandlerContext(),
licensing: { license: licensingMock.createLicense() },
licensing: licensingMock.createRequestHandlerContext(),
};
}

Expand Down
4 changes: 1 addition & 3 deletions x-pack/plugins/features/server/routes/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import { FeatureConfig } from '../../common';
function createContextMock(licenseType: LicenseType = 'gold') {
return {
core: coreMock.createRequestHandlerContext(),
licensing: {
license: licensingMock.createLicense({ license: { type: licenseType } }),
},
licensing: licensingMock.createRequestHandlerContext({ license: { type: licenseType } }),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('Expression', () => {
};

const mocks = coreMock.createSetup();
const startMocks = coreMock.createStart();
const [
{
application: { capabilities },
Expand All @@ -48,7 +49,7 @@ describe('Expression', () => {
toastNotifications: mocks.notifications.toasts,
actionTypeRegistry: actionTypeRegistryMock.create() as any,
alertTypeRegistry: alertTypeRegistryMock.create() as any,
docLinks: mocks.docLinks,
docLinks: startMocks.docLinks,
capabilities: {
...capabilities,
actions: {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ingest_manager/server/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export {
PACKAGES_SAVED_OBJECT_TYPE,
INDEX_PATTERN_SAVED_OBJECT_TYPE,
ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE,
GLOBAL_SETTINGS_SAVED_OBJECT_TYPE as GLOBAL_SETTINGS_SAVED_OBJET_TYPE,
GLOBAL_SETTINGS_SAVED_OBJECT_TYPE,
// Defaults
DEFAULT_AGENT_CONFIG,
DEFAULT_OUTPUT,
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/ingest_manager/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
AGENT_EVENT_SAVED_OBJECT_TYPE,
AGENT_ACTION_SAVED_OBJECT_TYPE,
ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE,
GLOBAL_SETTINGS_SAVED_OBJET_TYPE,
GLOBAL_SETTINGS_SAVED_OBJECT_TYPE,
} from '../constants';
import { migrateDatasourcesToV790 } from './migrations/datasources_v790';
import { migrateAgentConfigToV790 } from './migrations/agent_config_v790';
Expand All @@ -26,8 +26,8 @@ import { migrateAgentConfigToV790 } from './migrations/agent_config_v790';
*/

const savedObjectTypes: { [key: string]: SavedObjectsType } = {
[GLOBAL_SETTINGS_SAVED_OBJET_TYPE]: {
name: GLOBAL_SETTINGS_SAVED_OBJET_TYPE,
[GLOBAL_SETTINGS_SAVED_OBJECT_TYPE]: {
name: GLOBAL_SETTINGS_SAVED_OBJECT_TYPE,
hidden: false,
namespaceType: 'agnostic',
management: {
Expand Down Expand Up @@ -246,7 +246,7 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = {
internal: { type: 'boolean' },
removable: { type: 'boolean' },
es_index_patterns: {
dynamic: 'false',
enabled: false,
type: 'object',
},
installed: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@
*/

import { BehaviorSubject } from 'rxjs';
import { licenseMock } from '../common/licensing.mock';

import { licenseMock } from '../common/licensing.mock';
import { createRouteHandlerContext } from './licensing_route_handler_context';
import { featureUsageMock } from './services/feature_usage_service.mock';
import { FeatureUsageServiceStart } from './services';
import { StartServicesAccessor } from 'src/core/server';
import { LicensingPluginStart } from './types';

const createStartServices = (
featureUsage: FeatureUsageServiceStart = featureUsageMock.createStart()
): StartServicesAccessor<{}, LicensingPluginStart> => {
return async () => [{} as any, {}, { featureUsage } as LicensingPluginStart];
};

describe('createRouteHandlerContext', () => {
it('returns a function providing the last license value', async () => {
const firstLicense = licenseMock.createLicense();
const secondLicense = licenseMock.createLicense();
const license$ = new BehaviorSubject(firstLicense);

const routeHandler = createRouteHandlerContext(license$);
const routeHandler = createRouteHandlerContext(license$, createStartServices());

const firstCtx = await routeHandler({} as any, {} as any, {} as any);
license$.next(secondLicense);
Expand All @@ -24,4 +34,14 @@ describe('createRouteHandlerContext', () => {
expect(firstCtx.license).toBe(firstLicense);
expect(secondCtx.license).toBe(secondLicense);
});

it('returns a the feature usage API', async () => {
const license$ = new BehaviorSubject(licenseMock.createLicense());
const featureUsage = featureUsageMock.createStart();

const routeHandler = createRouteHandlerContext(license$, createStartServices(featureUsage));
const ctx = await routeHandler({} as any, {} as any, {} as any);

expect(ctx.featureUsage).toBe(featureUsage);
});
});
14 changes: 11 additions & 3 deletions x-pack/plugins/licensing/server/licensing_route_handler_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,29 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { IContextProvider, RequestHandler } from 'src/core/server';
import { IContextProvider, RequestHandler, StartServicesAccessor } from 'src/core/server';
import { Observable } from 'rxjs';
import { take } from 'rxjs/operators';

import { ILicense } from '../common/types';
import { LicensingPluginStart } from './types';

/**
* Create a route handler context for access to Kibana license information.
* @param license$ An observable of a License instance.
* @public
*/
export function createRouteHandlerContext(
license$: Observable<ILicense>
license$: Observable<ILicense>,
getStartServices: StartServicesAccessor<{}, LicensingPluginStart>
): IContextProvider<RequestHandler<any, any, any>, 'licensing'> {
return async function licensingRouteHandlerContext() {
return { license: await license$.pipe(take(1)).toPromise() };
const [, , { featureUsage }] = await getStartServices();
const license = await license$.pipe(take(1)).toPromise();

return {
featureUsage,
license,
};
};
}
18 changes: 17 additions & 1 deletion x-pack/plugins/licensing/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { BehaviorSubject } from 'rxjs';
import { LicensingPluginSetup, LicensingPluginStart } from './types';
import {
LicensingPluginSetup,
LicensingPluginStart,
LicensingRequestHandlerContext,
} from './types';
import { licenseMock } from '../common/licensing.mock';
import { featureUsageMock } from './services/feature_usage_service.mock';

Expand Down Expand Up @@ -43,8 +47,20 @@ const createStartMock = (): jest.Mocked<LicensingPluginStart> => {
return mock;
};

const createRequestHandlerContextMock = (
...options: Parameters<typeof licenseMock.createLicense>
): jest.Mocked<LicensingRequestHandlerContext> => {
const mock: jest.Mocked<LicensingRequestHandlerContext> = {
license: licenseMock.createLicense(...options),
featureUsage: featureUsageMock.createStart(),
};

return mock;
};

export const licensingMock = {
createSetup: createSetupMock,
createStart: createStartMock,
createRequestHandlerContext: createRequestHandlerContextMock,
...licenseMock,
};
5 changes: 4 additions & 1 deletion x-pack/plugins/licensing/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ export class LicensingPlugin implements Plugin<LicensingPluginSetup, LicensingPl
pollingFrequency.asMilliseconds()
);

core.http.registerRouteHandlerContext('licensing', createRouteHandlerContext(license$));
core.http.registerRouteHandlerContext(
'licensing',
createRouteHandlerContext(license$, core.getStartServices)
);

registerRoutes(core.http.createRouter(), core.getStartServices);
core.http.registerOnPreResponse(createOnPreResponseHandler(refresh, license$));
Expand Down
13 changes: 10 additions & 3 deletions x-pack/plugins/licensing/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@ export interface RawLicense {
mode: LicenseType;
}

/**
* The APIs exposed on the `licensing` key of {@link RequestHandlerContext} for plugins that depend on licensing.
* @public
*/
export interface LicensingRequestHandlerContext {
featureUsage: FeatureUsageServiceStart;
license: ILicense;
}

declare module 'src/core/server' {
interface RequestHandlerContext {
licensing: {
license: ILicense;
};
licensing: LicensingRequestHandlerContext;
}
}

Expand Down
Loading

0 comments on commit bca48e9

Please sign in to comment.