Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ingest/rename-dat…
Browse files Browse the repository at this point in the history
…asources
  • Loading branch information
jen-huang committed Jul 1, 2020
2 parents 7761eb9 + 80ae564 commit c762e2a
Show file tree
Hide file tree
Showing 54 changed files with 1,142 additions and 851 deletions.
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 @@ -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
27 changes: 16 additions & 11 deletions src/plugins/console/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@
*/

import { i18n } from '@kbn/i18n';

import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { Plugin, CoreSetup } from 'src/core/public';

import { FeatureCatalogueCategory } from '../../home/public';

import { AppSetupUIPluginDependencies } from './types';

export class ConsoleUIPlugin implements Plugin<void, void, AppSetupUIPluginDependencies> {
constructor() {}

async setup(
public setup(
{ notifications, getStartServices }: CoreSetup,
{ devTools, home, usageCollection }: AppSetupUIPluginDependencies
) {
Expand All @@ -53,16 +49,25 @@ export class ConsoleUIPlugin implements Plugin<void, void, AppSetupUIPluginDepen
defaultMessage: 'Console',
}),
enableRouting: false,
mount: async ({ core: { docLinks, i18n: i18nDep } }, { element }) => {
mount: async ({ element }) => {
const [core] = await getStartServices();

const {
injectedMetadata,
i18n: { Context: I18nContext },
docLinks: { DOC_LINK_VERSION },
} = core;

const { renderApp } = await import('./application');
const [{ injectedMetadata }] = await getStartServices();

const elasticsearchUrl = injectedMetadata.getInjectedVar(
'elasticsearchUrl',
'http://localhost:9200'
) as string;

return renderApp({
docLinkVersion: docLinks.DOC_LINK_VERSION,
I18nContext: i18nDep.Context,
docLinkVersion: DOC_LINK_VERSION,
I18nContext,
notifications,
elasticsearchUrl,
usageCollection,
Expand All @@ -72,5 +77,5 @@ export class ConsoleUIPlugin implements Plugin<void, void, AppSetupUIPluginDepen
});
}

async start(core: CoreStart) {}
public start() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class PhraseSuggestorUI<T extends PhraseSuggestorProps> extends React.Com
PhraseSuggestorState
> {
private services = this.props.kibana.services;
private abortController?: AbortController;
public state: PhraseSuggestorState = {
suggestions: [],
isLoading: false,
Expand All @@ -54,6 +55,10 @@ export class PhraseSuggestorUI<T extends PhraseSuggestorProps> extends React.Com
this.updateSuggestions();
}

public componentWillUnmount() {
if (this.abortController) this.abortController.abort();
}

protected isSuggestingValues() {
const shouldSuggestValues = this.services.uiSettings.get(
UI_SETTINGS.FILTERS_EDITOR_SUGGEST_VALUES
Expand All @@ -67,6 +72,8 @@ export class PhraseSuggestorUI<T extends PhraseSuggestorProps> extends React.Com
};

protected updateSuggestions = debounce(async (query: string = '') => {
if (this.abortController) this.abortController.abort();
this.abortController = new AbortController();
const { indexPattern, field } = this.props as PhraseSuggestorProps;
if (!field || !this.isSuggestingValues()) {
return;
Expand All @@ -77,6 +84,7 @@ export class PhraseSuggestorUI<T extends PhraseSuggestorProps> extends React.Com
indexPattern,
field,
query,
signal: this.abortController.signal,
});

this.setState({ suggestions, isLoading: false });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class QueryStringInputUI extends Component<Props, State> {
public inputRef: HTMLInputElement | null = null;

private persistedLog: PersistedLog | undefined;
private abortController: AbortController | undefined;
private abortController?: AbortController;
private services = this.props.kibana.services;
private componentIsUnmounting = false;

Expand Down Expand Up @@ -497,6 +497,7 @@ export class QueryStringInputUI extends Component<Props, State> {
}

public componentWillUnmount() {
if (this.abortController) this.abortController.abort();
this.updateSuggestions.cancel();
this.componentIsUnmounting = true;
}
Expand Down
Loading

0 comments on commit c762e2a

Please sign in to comment.