Skip to content

Commit

Permalink
Merge branch 'master' into update-asset-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ruflin committed Jul 2, 2020
2 parents 8c1143a + 7b74094 commit e007300
Show file tree
Hide file tree
Showing 456 changed files with 13,785 additions and 6,281 deletions.
2 changes: 1 addition & 1 deletion docs/api/using-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NOTE: The {kib} Console supports only Elasticsearch APIs. You are unable to inte
[float]
[[api-authentication]]
=== Authentication
{kib} supports token-based authentication with the same username and password that you use to log into the {kib} Console.
{kib} supports token-based authentication with the same username and password that you use to log into the {kib} Console. In a given HTTP tool, and when available, you can select to use its 'Basic Authentication' option, which is where the username and password are stored in order to be passed as part of the call.

[float]
[[api-calls]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

## SavedObjectTypeRegistry.getAllTypes() method

Return all [types](./kibana-plugin-core-server.savedobjectstype.md) currently registered.
Return all [types](./kibana-plugin-core-server.savedobjectstype.md) currently registered, including the hidden ones.

To only get the visible types (which is the most common use case), use `getVisibleTypes` instead.

<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectTypeRegistry](./kibana-plugin-core-server.savedobjecttyperegistry.md) &gt; [getVisibleTypes](./kibana-plugin-core-server.savedobjecttyperegistry.getvisibletypes.md)

## SavedObjectTypeRegistry.getVisibleTypes() method

Returns all visible [types](./kibana-plugin-core-server.savedobjectstype.md)<!-- -->.

A visible type is a type that doesn't explicitly define `hidden=true` during registration.

<b>Signature:</b>

```typescript
getVisibleTypes(): SavedObjectsType[];
```
<b>Returns:</b>

`SavedObjectsType[]`

Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ export declare class SavedObjectTypeRegistry

| Method | Modifiers | Description |
| --- | --- | --- |
| [getAllTypes()](./kibana-plugin-core-server.savedobjecttyperegistry.getalltypes.md) | | Return all [types](./kibana-plugin-core-server.savedobjectstype.md) currently registered. |
| [getAllTypes()](./kibana-plugin-core-server.savedobjecttyperegistry.getalltypes.md) | | Return all [types](./kibana-plugin-core-server.savedobjectstype.md) currently registered, including the hidden ones.<!-- -->To only get the visible types (which is the most common use case), use <code>getVisibleTypes</code> instead. |
| [getImportableAndExportableTypes()](./kibana-plugin-core-server.savedobjecttyperegistry.getimportableandexportabletypes.md) | | Return all [types](./kibana-plugin-core-server.savedobjectstype.md) currently registered that are importable/exportable. |
| [getIndex(type)](./kibana-plugin-core-server.savedobjecttyperegistry.getindex.md) | | Returns the <code>indexPattern</code> property for given type, or <code>undefined</code> if the type is not registered. |
| [getType(type)](./kibana-plugin-core-server.savedobjecttyperegistry.gettype.md) | | Return the [type](./kibana-plugin-core-server.savedobjectstype.md) definition for given type name. |
| [getVisibleTypes()](./kibana-plugin-core-server.savedobjecttyperegistry.getvisibletypes.md) | | Returns all visible [types](./kibana-plugin-core-server.savedobjectstype.md)<!-- -->.<!-- -->A visible type is a type that doesn't explicitly define <code>hidden=true</code> during registration. |
| [isHidden(type)](./kibana-plugin-core-server.savedobjecttyperegistry.ishidden.md) | | Returns the <code>hidden</code> property for given type, or <code>false</code> if the type is not registered. |
| [isImportableAndExportable(type)](./kibana-plugin-core-server.savedobjecttyperegistry.isimportableandexportable.md) | | Returns the <code>management.importableAndExportable</code> property for given type, or <code>false</code> if the type is not registered or does not define a management section. |
| [isMultiNamespace(type)](./kibana-plugin-core-server.savedobjecttyperegistry.ismultinamespace.md) | | Returns whether the type is multi-namespace (shareable); resolves to <code>false</code> if the type is not registered |
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-config-kibana/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ module.exports = {
}],
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'warn',
'constructor-super': 'error',
'dot-notation': 'error',
'eqeqeq': ['error', 'always', {'null': 'ignore'}],
Expand Down
40 changes: 20 additions & 20 deletions src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,27 +185,27 @@ export class ChromeService {
/>
),
});
}

if (isIE()) {
notifications.toasts.addWarning({
title: mountReactNode(
<FormattedMessage
id="core.chrome.browserDeprecationWarning"
defaultMessage="Support for Internet Explorer will be dropped in future versions of this software, please check {link}."
values={{
link: (
<EuiLink target="_blank" href="https://www.elastic.co/support/matrix" external>
<FormattedMessage
id="core.chrome.browserDeprecationLink"
defaultMessage="the support matrix on our website"
/>
</EuiLink>
),
}}
/>
),
});
}
if (isIE()) {
notifications.toasts.addWarning({
title: mountReactNode(
<FormattedMessage
id="core.chrome.browserDeprecationWarning"
defaultMessage="Support for Internet Explorer will be dropped in future versions of this software, please check {link}."
values={{
link: (
<EuiLink target="_blank" href="https://www.elastic.co/support/matrix" external>
<FormattedMessage
id="core.chrome.browserDeprecationLink"
defaultMessage="the support matrix on our website"
/>
</EuiLink>
),
}}
/>
),
});
}

return {
Expand Down
34 changes: 30 additions & 4 deletions src/core/server/plugins/plugins_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const logger = loggingSystemMock.create();

expect.addSnapshotSerializer(createAbsolutePathSerializer());

['path-1', 'path-2', 'path-3', 'path-4', 'path-5'].forEach((path) => {
['path-1', 'path-2', 'path-3', 'path-4', 'path-5', 'path-6', 'path-7', 'path-8'].forEach((path) => {
jest.doMock(join(path, 'server'), () => ({}), {
virtual: true,
});
Expand Down Expand Up @@ -227,14 +227,34 @@ describe('PluginsService', () => {
path: 'path-4',
configPath: 'path-4-disabled',
}),
createPlugin('plugin-with-disabled-optional-dep', {
path: 'path-5',
configPath: 'path-5',
optionalPlugins: ['explicitly-disabled-plugin'],
}),
createPlugin('plugin-with-missing-optional-dep', {
path: 'path-6',
configPath: 'path-6',
optionalPlugins: ['missing-plugin'],
}),
createPlugin('plugin-with-disabled-nested-transitive-dep', {
path: 'path-7',
configPath: 'path-7',
requiredPlugins: ['plugin-with-disabled-transitive-dep'],
}),
createPlugin('plugin-with-missing-nested-dep', {
path: 'path-8',
configPath: 'path-8',
requiredPlugins: ['plugin-with-missing-required-deps'],
}),
]),
});

await pluginsService.discover();
const setup = await pluginsService.setup(setupDeps);

expect(setup.contracts).toBeInstanceOf(Map);
expect(mockPluginSystem.addPlugin).not.toHaveBeenCalled();
expect(mockPluginSystem.addPlugin).toHaveBeenCalledTimes(2);
expect(mockPluginSystem.setupPlugins).toHaveBeenCalledTimes(1);
expect(mockPluginSystem.setupPlugins).toHaveBeenCalledWith(setupDeps);

Expand All @@ -244,14 +264,20 @@ describe('PluginsService', () => {
"Plugin \\"explicitly-disabled-plugin\\" is disabled.",
],
Array [
"Plugin \\"plugin-with-missing-required-deps\\" has been disabled since some of its direct or transitive dependencies are missing or disabled.",
"Plugin \\"plugin-with-missing-required-deps\\" has been disabled since the following direct or transitive dependencies are missing or disabled: [missing-plugin]",
],
Array [
"Plugin \\"plugin-with-disabled-transitive-dep\\" has been disabled since some of its direct or transitive dependencies are missing or disabled.",
"Plugin \\"plugin-with-disabled-transitive-dep\\" has been disabled since the following direct or transitive dependencies are missing or disabled: [another-explicitly-disabled-plugin]",
],
Array [
"Plugin \\"another-explicitly-disabled-plugin\\" is disabled.",
],
Array [
"Plugin \\"plugin-with-disabled-nested-transitive-dep\\" has been disabled since the following direct or transitive dependencies are missing or disabled: [plugin-with-disabled-transitive-dep]",
],
Array [
"Plugin \\"plugin-with-missing-nested-dep\\" has been disabled since the following direct or transitive dependencies are missing or disabled: [plugin-with-missing-required-deps]",
],
]
`);
});
Expand Down
45 changes: 33 additions & 12 deletions src/core/server/plugins/plugins_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,15 @@ export class PluginsService implements CoreService<PluginsServiceSetup, PluginsS
.toPromise();

for (const [pluginName, { plugin, isEnabled }] of pluginEnableStatuses) {
if (this.shouldEnablePlugin(pluginName, pluginEnableStatuses)) {
const pluginEnablement = this.shouldEnablePlugin(pluginName, pluginEnableStatuses);

if (pluginEnablement.enabled) {
this.pluginsSystem.addPlugin(plugin);
} else if (isEnabled) {
this.log.info(
`Plugin "${pluginName}" has been disabled since some of its direct or transitive dependencies are missing or disabled.`
`Plugin "${pluginName}" has been disabled since the following direct or transitive dependencies are missing or disabled: [${pluginEnablement.missingDependencies.join(
', '
)}]`
);
} else {
this.log.info(`Plugin "${pluginName}" is disabled.`);
Expand All @@ -257,17 +261,34 @@ export class PluginsService implements CoreService<PluginsServiceSetup, PluginsS
pluginName: PluginName,
pluginEnableStatuses: Map<PluginName, { plugin: PluginWrapper; isEnabled: boolean }>,
parents: PluginName[] = []
): boolean {
): { enabled: true } | { enabled: false; missingDependencies: string[] } {
const pluginInfo = pluginEnableStatuses.get(pluginName);
return (
pluginInfo !== undefined &&
pluginInfo.isEnabled &&
pluginInfo.plugin.requiredPlugins
.filter((dep) => !parents.includes(dep))
.every((dependencyName) =>
this.shouldEnablePlugin(dependencyName, pluginEnableStatuses, [...parents, pluginName])
)
);

if (pluginInfo === undefined || !pluginInfo.isEnabled) {
return {
enabled: false,
missingDependencies: [],
};
}

const missingDependencies = pluginInfo.plugin.requiredPlugins
.filter((dep) => !parents.includes(dep))
.filter(
(dependencyName) =>
!this.shouldEnablePlugin(dependencyName, pluginEnableStatuses, [...parents, pluginName])
.enabled
);

if (missingDependencies.length === 0) {
return {
enabled: true,
};
}

return {
enabled: false,
missingDependencies,
};
}

private registerPluginStaticDirs(deps: PluginsServiceSetupDeps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const createRegistryMock = (): jest.Mocked<
const mock = {
registerType: jest.fn(),
getType: jest.fn(),
getVisibleTypes: jest.fn(),
getAllTypes: jest.fn(),
getImportableAndExportableTypes: jest.fn(),
isNamespaceAgnostic: jest.fn(),
Expand All @@ -35,6 +36,7 @@ const createRegistryMock = (): jest.Mocked<
isImportableAndExportable: jest.fn(),
};

mock.getVisibleTypes.mockReturnValue([]);
mock.getAllTypes.mockReturnValue([]);
mock.getImportableAndExportableTypes.mockReturnValue([]);
mock.getIndex.mockReturnValue('.kibana-test');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,37 @@ describe('SavedObjectTypeRegistry', () => {
});
});

describe('#getVisibleTypes', () => {
it('returns only visible registered types', () => {
const typeA = createType({ name: 'typeA', hidden: false });
const typeB = createType({ name: 'typeB', hidden: true });
const typeC = createType({ name: 'typeC', hidden: false });
registry.registerType(typeA);
registry.registerType(typeB);
registry.registerType(typeC);

const registered = registry.getVisibleTypes();
expect(registered.length).toEqual(2);
expect(registered).toContainEqual(typeA);
expect(registered).toContainEqual(typeC);
});

it('does not mutate the registered types when altering the list', () => {
registry.registerType(createType({ name: 'typeA', hidden: false }));
registry.registerType(createType({ name: 'typeB', hidden: true }));
registry.registerType(createType({ name: 'typeC', hidden: false }));

const types = registry.getVisibleTypes();
types.splice(0, 2);

expect(registry.getVisibleTypes().length).toEqual(2);
});
});

describe('#getAllTypes', () => {
it('returns all registered types', () => {
const typeA = createType({ name: 'typeA' });
const typeB = createType({ name: 'typeB' });
const typeB = createType({ name: 'typeB', hidden: true });
const typeC = createType({ name: 'typeC' });
registry.registerType(typeA);
registry.registerType(typeB);
Expand Down
13 changes: 12 additions & 1 deletion src/core/server/saved_objects/saved_objects_type_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,18 @@ export class SavedObjectTypeRegistry {
}

/**
* Return all {@link SavedObjectsType | types} currently registered.
* Returns all visible {@link SavedObjectsType | types}.
*
* A visible type is a type that doesn't explicitly define `hidden=true` during registration.
*/
public getVisibleTypes() {
return [...this.types.values()].filter((type) => !this.isHidden(type.name));
}

/**
* Return all {@link SavedObjectsType | types} currently registered, including the hidden ones.
*
* To only get the visible types (which is the most common use case), use `getVisibleTypes` instead.
*/
public getAllTypes() {
return [...this.types.values()];
Expand Down
1 change: 1 addition & 0 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2468,6 +2468,7 @@ export class SavedObjectTypeRegistry {
getImportableAndExportableTypes(): SavedObjectsType[];
getIndex(type: string): string | undefined;
getType(type: string): SavedObjectsType | undefined;
getVisibleTypes(): SavedObjectsType[];
isHidden(type: string): boolean;
isImportableAndExportable(type: string): boolean;
isMultiNamespace(type: string): boolean;
Expand Down
5 changes: 1 addition & 4 deletions src/core/server/ui_settings/saved_objects/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ export const uiSettingsType: SavedObjectsType = {
hidden: false,
namespaceType: 'single',
mappings: {
// we don't want to allow `true` in the public `SavedObjectsTypeMappingDefinition` type, however
// this is needed for the config that is kinda a special type. To avoid adding additional internal types
// just for this, we hardcast to any here.
dynamic: true as any,
dynamic: false,
properties: {
buildNum: {
type: 'keyword',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ import {
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../../plugins/vis_type_vega/public/services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { setInjectedVarFunc } from '../../../../../../plugins/maps_legacy/public/kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ServiceSettings } from '../../../../../../plugins/maps_legacy/public/map/service_settings';
import { getKibanaMapFactoryProvider } from '../../../../../../plugins/maps_legacy/public';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { KibanaMap } from '../../../../../../plugins/maps_legacy/public/map/kibana_map';

const THRESHOLD = 0.1;
const PIXEL_DIFF = 30;
Expand All @@ -82,18 +81,7 @@ describe('VegaVisualizations', () => {
let vegaVisualizationDependencies;
let vegaVisType;

const coreSetupMock = {
notifications: {
toasts: {},
},
uiSettings: {
get: () => {},
},
injectedMetadata: {
getInjectedVar: () => {},
},
};
setKibanaMapFactory(getKibanaMapFactoryProvider(coreSetupMock));
setKibanaMapFactory((...args) => new KibanaMap(...args));
setInjectedVars({
emsTileLayerId: {},
enableExternalUrls: true,
Expand Down Expand Up @@ -139,30 +127,6 @@ describe('VegaVisualizations', () => {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(() => {
setInjectedVarFunc((injectedVar) => {
switch (injectedVar) {
case 'mapConfig':
return {
emsFileApiUrl: '',
emsTileApiUrl: '',
emsLandingPageUrl: '',
};
case 'tilemapsConfig':
return {
deprecated: {
config: {
options: {
attribution: '123',
},
},
},
};
case 'version':
return '123';
default:
return 'not found';
}
});
const serviceSettings = new ServiceSettings(mockMapConfig, mockMapConfig.tilemap);
vegaVisualizationDependencies = {
serviceSettings,
Expand Down
Loading

0 comments on commit e007300

Please sign in to comment.