Skip to content

Commit 333d8b5

Browse files
Merge branch 'master' into maps/mvt_fields
2 parents 7853299 + 80ae564 commit 333d8b5

File tree

58 files changed

+1192
-856
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1192
-856
lines changed

packages/eslint-config-kibana/typescript.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ module.exports = {
124124
}],
125125
'@typescript-eslint/no-var-requires': 'error',
126126
'@typescript-eslint/unified-signatures': 'error',
127-
'@typescript-eslint/prefer-ts-expect-error': 'warn',
128127
'constructor-super': 'error',
129128
'dot-notation': 'error',
130129
'eqeqeq': ['error', 'always', {'null': 'ignore'}],

src/core/public/chrome/chrome_service.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -185,27 +185,27 @@ export class ChromeService {
185185
/>
186186
),
187187
});
188+
}
188189

189-
if (isIE()) {
190-
notifications.toasts.addWarning({
191-
title: mountReactNode(
192-
<FormattedMessage
193-
id="core.chrome.browserDeprecationWarning"
194-
defaultMessage="Support for Internet Explorer will be dropped in future versions of this software, please check {link}."
195-
values={{
196-
link: (
197-
<EuiLink target="_blank" href="https://www.elastic.co/support/matrix" external>
198-
<FormattedMessage
199-
id="core.chrome.browserDeprecationLink"
200-
defaultMessage="the support matrix on our website"
201-
/>
202-
</EuiLink>
203-
),
204-
}}
205-
/>
206-
),
207-
});
208-
}
190+
if (isIE()) {
191+
notifications.toasts.addWarning({
192+
title: mountReactNode(
193+
<FormattedMessage
194+
id="core.chrome.browserDeprecationWarning"
195+
defaultMessage="Support for Internet Explorer will be dropped in future versions of this software, please check {link}."
196+
values={{
197+
link: (
198+
<EuiLink target="_blank" href="https://www.elastic.co/support/matrix" external>
199+
<FormattedMessage
200+
id="core.chrome.browserDeprecationLink"
201+
defaultMessage="the support matrix on our website"
202+
/>
203+
</EuiLink>
204+
),
205+
}}
206+
/>
207+
),
208+
});
209209
}
210210

211211
return {

src/core/server/plugins/plugins_service.test.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const logger = loggingSystemMock.create();
5151

5252
expect.addSnapshotSerializer(createAbsolutePathSerializer());
5353

54-
['path-1', 'path-2', 'path-3', 'path-4', 'path-5'].forEach((path) => {
54+
['path-1', 'path-2', 'path-3', 'path-4', 'path-5', 'path-6', 'path-7', 'path-8'].forEach((path) => {
5555
jest.doMock(join(path, 'server'), () => ({}), {
5656
virtual: true,
5757
});
@@ -227,14 +227,34 @@ describe('PluginsService', () => {
227227
path: 'path-4',
228228
configPath: 'path-4-disabled',
229229
}),
230+
createPlugin('plugin-with-disabled-optional-dep', {
231+
path: 'path-5',
232+
configPath: 'path-5',
233+
optionalPlugins: ['explicitly-disabled-plugin'],
234+
}),
235+
createPlugin('plugin-with-missing-optional-dep', {
236+
path: 'path-6',
237+
configPath: 'path-6',
238+
optionalPlugins: ['missing-plugin'],
239+
}),
240+
createPlugin('plugin-with-disabled-nested-transitive-dep', {
241+
path: 'path-7',
242+
configPath: 'path-7',
243+
requiredPlugins: ['plugin-with-disabled-transitive-dep'],
244+
}),
245+
createPlugin('plugin-with-missing-nested-dep', {
246+
path: 'path-8',
247+
configPath: 'path-8',
248+
requiredPlugins: ['plugin-with-missing-required-deps'],
249+
}),
230250
]),
231251
});
232252

233253
await pluginsService.discover();
234254
const setup = await pluginsService.setup(setupDeps);
235255

236256
expect(setup.contracts).toBeInstanceOf(Map);
237-
expect(mockPluginSystem.addPlugin).not.toHaveBeenCalled();
257+
expect(mockPluginSystem.addPlugin).toHaveBeenCalledTimes(2);
238258
expect(mockPluginSystem.setupPlugins).toHaveBeenCalledTimes(1);
239259
expect(mockPluginSystem.setupPlugins).toHaveBeenCalledWith(setupDeps);
240260

@@ -244,14 +264,20 @@ describe('PluginsService', () => {
244264
"Plugin \\"explicitly-disabled-plugin\\" is disabled.",
245265
],
246266
Array [
247-
"Plugin \\"plugin-with-missing-required-deps\\" has been disabled since some of its direct or transitive dependencies are missing or disabled.",
267+
"Plugin \\"plugin-with-missing-required-deps\\" has been disabled since the following direct or transitive dependencies are missing or disabled: [missing-plugin]",
248268
],
249269
Array [
250-
"Plugin \\"plugin-with-disabled-transitive-dep\\" has been disabled since some of its direct or transitive dependencies are missing or disabled.",
270+
"Plugin \\"plugin-with-disabled-transitive-dep\\" has been disabled since the following direct or transitive dependencies are missing or disabled: [another-explicitly-disabled-plugin]",
251271
],
252272
Array [
253273
"Plugin \\"another-explicitly-disabled-plugin\\" is disabled.",
254274
],
275+
Array [
276+
"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]",
277+
],
278+
Array [
279+
"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]",
280+
],
255281
]
256282
`);
257283
});

src/core/server/plugins/plugins_service.ts

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,15 @@ export class PluginsService implements CoreService<PluginsServiceSetup, PluginsS
239239
.toPromise();
240240

241241
for (const [pluginName, { plugin, isEnabled }] of pluginEnableStatuses) {
242-
if (this.shouldEnablePlugin(pluginName, pluginEnableStatuses)) {
242+
const pluginEnablement = this.shouldEnablePlugin(pluginName, pluginEnableStatuses);
243+
244+
if (pluginEnablement.enabled) {
243245
this.pluginsSystem.addPlugin(plugin);
244246
} else if (isEnabled) {
245247
this.log.info(
246-
`Plugin "${pluginName}" has been disabled since some of its direct or transitive dependencies are missing or disabled.`
248+
`Plugin "${pluginName}" has been disabled since the following direct or transitive dependencies are missing or disabled: [${pluginEnablement.missingDependencies.join(
249+
', '
250+
)}]`
247251
);
248252
} else {
249253
this.log.info(`Plugin "${pluginName}" is disabled.`);
@@ -257,17 +261,34 @@ export class PluginsService implements CoreService<PluginsServiceSetup, PluginsS
257261
pluginName: PluginName,
258262
pluginEnableStatuses: Map<PluginName, { plugin: PluginWrapper; isEnabled: boolean }>,
259263
parents: PluginName[] = []
260-
): boolean {
264+
): { enabled: true } | { enabled: false; missingDependencies: string[] } {
261265
const pluginInfo = pluginEnableStatuses.get(pluginName);
262-
return (
263-
pluginInfo !== undefined &&
264-
pluginInfo.isEnabled &&
265-
pluginInfo.plugin.requiredPlugins
266-
.filter((dep) => !parents.includes(dep))
267-
.every((dependencyName) =>
268-
this.shouldEnablePlugin(dependencyName, pluginEnableStatuses, [...parents, pluginName])
269-
)
270-
);
266+
267+
if (pluginInfo === undefined || !pluginInfo.isEnabled) {
268+
return {
269+
enabled: false,
270+
missingDependencies: [],
271+
};
272+
}
273+
274+
const missingDependencies = pluginInfo.plugin.requiredPlugins
275+
.filter((dep) => !parents.includes(dep))
276+
.filter(
277+
(dependencyName) =>
278+
!this.shouldEnablePlugin(dependencyName, pluginEnableStatuses, [...parents, pluginName])
279+
.enabled
280+
);
281+
282+
if (missingDependencies.length === 0) {
283+
return {
284+
enabled: true,
285+
};
286+
}
287+
288+
return {
289+
enabled: false,
290+
missingDependencies,
291+
};
271292
}
272293

273294
private registerPluginStaticDirs(deps: PluginsServiceSetupDeps) {

src/legacy/core_plugins/kibana/public/__tests__/vis_type_vega/vega_visualization.js

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ import {
6666
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
6767
} from '../../../../../../plugins/vis_type_vega/public/services';
6868
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
69-
import { setInjectedVarFunc } from '../../../../../../plugins/maps_legacy/public/kibana_services';
70-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
7169
import { ServiceSettings } from '../../../../../../plugins/maps_legacy/public/map/service_settings';
72-
import { getKibanaMapFactoryProvider } from '../../../../../../plugins/maps_legacy/public';
70+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
71+
import { KibanaMap } from '../../../../../../plugins/maps_legacy/public/map/kibana_map';
7372

7473
const THRESHOLD = 0.1;
7574
const PIXEL_DIFF = 30;
@@ -82,18 +81,7 @@ describe('VegaVisualizations', () => {
8281
let vegaVisualizationDependencies;
8382
let vegaVisType;
8483

85-
const coreSetupMock = {
86-
notifications: {
87-
toasts: {},
88-
},
89-
uiSettings: {
90-
get: () => {},
91-
},
92-
injectedMetadata: {
93-
getInjectedVar: () => {},
94-
},
95-
};
96-
setKibanaMapFactory(getKibanaMapFactoryProvider(coreSetupMock));
84+
setKibanaMapFactory((...args) => new KibanaMap(...args));
9785
setInjectedVars({
9886
emsTileLayerId: {},
9987
enableExternalUrls: true,
@@ -139,30 +127,6 @@ describe('VegaVisualizations', () => {
139127
beforeEach(ngMock.module('kibana'));
140128
beforeEach(
141129
ngMock.inject(() => {
142-
setInjectedVarFunc((injectedVar) => {
143-
switch (injectedVar) {
144-
case 'mapConfig':
145-
return {
146-
emsFileApiUrl: '',
147-
emsTileApiUrl: '',
148-
emsLandingPageUrl: '',
149-
};
150-
case 'tilemapsConfig':
151-
return {
152-
deprecated: {
153-
config: {
154-
options: {
155-
attribution: '123',
156-
},
157-
},
158-
},
159-
};
160-
case 'version':
161-
return '123';
162-
default:
163-
return 'not found';
164-
}
165-
});
166130
const serviceSettings = new ServiceSettings(mockMapConfig, mockMapConfig.tilemap);
167131
vegaVisualizationDependencies = {
168132
serviceSettings,

src/plugins/console/public/plugin.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@
1818
*/
1919

2020
import { i18n } from '@kbn/i18n';
21-
22-
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
21+
import { Plugin, CoreSetup } from 'src/core/public';
2322

2423
import { FeatureCatalogueCategory } from '../../home/public';
25-
2624
import { AppSetupUIPluginDependencies } from './types';
2725

2826
export class ConsoleUIPlugin implements Plugin<void, void, AppSetupUIPluginDependencies> {
29-
constructor() {}
30-
31-
async setup(
27+
public setup(
3228
{ notifications, getStartServices }: CoreSetup,
3329
{ devTools, home, usageCollection }: AppSetupUIPluginDependencies
3430
) {
@@ -53,16 +49,25 @@ export class ConsoleUIPlugin implements Plugin<void, void, AppSetupUIPluginDepen
5349
defaultMessage: 'Console',
5450
}),
5551
enableRouting: false,
56-
mount: async ({ core: { docLinks, i18n: i18nDep } }, { element }) => {
52+
mount: async ({ element }) => {
53+
const [core] = await getStartServices();
54+
55+
const {
56+
injectedMetadata,
57+
i18n: { Context: I18nContext },
58+
docLinks: { DOC_LINK_VERSION },
59+
} = core;
60+
5761
const { renderApp } = await import('./application');
58-
const [{ injectedMetadata }] = await getStartServices();
62+
5963
const elasticsearchUrl = injectedMetadata.getInjectedVar(
6064
'elasticsearchUrl',
6165
'http://localhost:9200'
6266
) as string;
67+
6368
return renderApp({
64-
docLinkVersion: docLinks.DOC_LINK_VERSION,
65-
I18nContext: i18nDep.Context,
69+
docLinkVersion: DOC_LINK_VERSION,
70+
I18nContext,
6671
notifications,
6772
elasticsearchUrl,
6873
usageCollection,
@@ -72,5 +77,5 @@ export class ConsoleUIPlugin implements Plugin<void, void, AppSetupUIPluginDepen
7277
});
7378
}
7479

75-
async start(core: CoreStart) {}
80+
public start() {}
7681
}

src/plugins/data/public/ui/filter_bar/filter_editor/phrase_suggestor.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class PhraseSuggestorUI<T extends PhraseSuggestorProps> extends React.Com
4545
PhraseSuggestorState
4646
> {
4747
private services = this.props.kibana.services;
48+
private abortController?: AbortController;
4849
public state: PhraseSuggestorState = {
4950
suggestions: [],
5051
isLoading: false,
@@ -54,6 +55,10 @@ export class PhraseSuggestorUI<T extends PhraseSuggestorProps> extends React.Com
5455
this.updateSuggestions();
5556
}
5657

58+
public componentWillUnmount() {
59+
if (this.abortController) this.abortController.abort();
60+
}
61+
5762
protected isSuggestingValues() {
5863
const shouldSuggestValues = this.services.uiSettings.get(
5964
UI_SETTINGS.FILTERS_EDITOR_SUGGEST_VALUES
@@ -67,6 +72,8 @@ export class PhraseSuggestorUI<T extends PhraseSuggestorProps> extends React.Com
6772
};
6873

6974
protected updateSuggestions = debounce(async (query: string = '') => {
75+
if (this.abortController) this.abortController.abort();
76+
this.abortController = new AbortController();
7077
const { indexPattern, field } = this.props as PhraseSuggestorProps;
7178
if (!field || !this.isSuggestingValues()) {
7279
return;
@@ -77,6 +84,7 @@ export class PhraseSuggestorUI<T extends PhraseSuggestorProps> extends React.Com
7784
indexPattern,
7885
field,
7986
query,
87+
signal: this.abortController.signal,
8088
});
8189

8290
this.setState({ suggestions, isLoading: false });

src/plugins/data/public/ui/query_string_input/query_string_input.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class QueryStringInputUI extends Component<Props, State> {
9595
public inputRef: HTMLInputElement | null = null;
9696

9797
private persistedLog: PersistedLog | undefined;
98-
private abortController: AbortController | undefined;
98+
private abortController?: AbortController;
9999
private services = this.props.kibana.services;
100100
private componentIsUnmounting = false;
101101

@@ -497,6 +497,7 @@ export class QueryStringInputUI extends Component<Props, State> {
497497
}
498498

499499
public componentWillUnmount() {
500+
if (this.abortController) this.abortController.abort();
500501
this.updateSuggestions.cancel();
501502
this.componentIsUnmounting = true;
502503
}

0 commit comments

Comments
 (0)