Skip to content

Commit

Permalink
Merge branch 'master' into alerting/built-in-alerts-feature
Browse files Browse the repository at this point in the history
* master: (46 commits)
  [Visualize] Add missing advanced settings and custom label for pipeline aggs (elastic#69688)
  Use dynamic: false for config saved object mappings (elastic#70436)
  [Ingest Pipelines] Error messages (elastic#70167)
  [APM] Show transaction rate per minute on Observability Overview page (elastic#70336)
  Filter out error when calculating a label (elastic#69934)
  [Visualizations] Each visType returns its supported triggers (elastic#70177)
  [Telemetry] Report data shippers (elastic#64935)
  Reduce SavedObjects mappings for Application Usage (elastic#70475)
  [Lens] fix dimension label performance issues (elastic#69978)
  Skip failing endgame tests (elastic#70548)
  [SIEM] Reenabling Cypress tests (elastic#70397)
  [SIEM][Security Solution][Endpoint] Endpoint Artifact Manifest Management + Artifact Download and Distribution (elastic#67707)
  [Security] Adds field mapping support to rule creation (elastic#70288)
  SECURITY-ENDPOINT: add fields for events to metadata document (elastic#70491)
  Fixed assertion in hybrid index pattern test to iterate through indices (elastic#70130)
  [SIEM][Exceptions] - Exception builder component (elastic#67013)
  [Ingest Manager] Rename data sources to package configs (elastic#70259)
  skip suites blocking es snapshot promomotion (elastic#70532)
  [Metrics UI] Fix asynchronicity and error handling in Snapshot API (elastic#70503)
  fix export response (elastic#70473)
  ...
  • Loading branch information
gmmorris committed Jul 2, 2020
2 parents c0d09cc + a8347fa commit 0e001e6
Show file tree
Hide file tree
Showing 611 changed files with 16,003 additions and 14,991 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
3 changes: 3 additions & 0 deletions packages/kbn-ui-shared-deps/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,8 @@ if (window.__kbnThemeVersion__ === 'v7') {
ElasticEuiDarkTheme = require('@elastic/eui/dist/eui_theme_amsterdam_dark.json');
}

import * as Theme from './theme.ts';
export { Theme };

// massive deps that we should really get rid of or reduce in size substantially
export const ElasticsearchBrowser = require('elasticsearch-browser/elasticsearch.js');
5 changes: 3 additions & 2 deletions packages/kbn-ui-shared-deps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ exports.externals = {
'react-router-dom': '__kbnSharedDeps__.ReactRouterDom',
'styled-components': '__kbnSharedDeps__.StyledComponents',
'@kbn/monaco': '__kbnSharedDeps__.KbnMonaco',
'@kbn/ui-shared-deps/theme': '__kbnSharedDeps__.Theme',
// this is how plugins/consumers from npm load monaco
'monaco-editor/esm/vs/editor/editor.api': '__kbnSharedDeps__.MonacoBarePluginApi',

Expand All @@ -59,8 +60,8 @@ exports.externals = {
'@elastic/eui/lib/services': '__kbnSharedDeps__.ElasticEuiLibServices',
'@elastic/eui/lib/services/format': '__kbnSharedDeps__.ElasticEuiLibServicesFormat',
'@elastic/eui/dist/eui_charts_theme': '__kbnSharedDeps__.ElasticEuiChartsTheme',
'@elastic/eui/dist/eui_theme_light.json': '__kbnSharedDeps__.ElasticEuiLightTheme',
'@elastic/eui/dist/eui_theme_dark.json': '__kbnSharedDeps__.ElasticEuiDarkTheme',
'@elastic/eui/dist/eui_theme_light.json': '__kbnSharedDeps__.Theme.euiLightVars',
'@elastic/eui/dist/eui_theme_dark.json': '__kbnSharedDeps__.Theme.euiDarkVars',

/**
* massive deps that we should really get rid of or reduce in size substantially
Expand Down
44 changes: 44 additions & 0 deletions packages/kbn-ui-shared-deps/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import LightTheme from '@elastic/eui/dist/eui_theme_light.json';

const globals: any = typeof window === 'undefined' ? {} : window;

export type Theme = typeof LightTheme;

export let euiLightVars: Theme;
export let euiDarkVars: Theme;
if (globals.__kbnThemeVersion__ === 'v7') {
euiLightVars = require('@elastic/eui/dist/eui_theme_light.json');
euiDarkVars = require('@elastic/eui/dist/eui_theme_dark.json');
} else {
euiLightVars = require('@elastic/eui/dist/eui_theme_amsterdam_light.json');
euiDarkVars = require('@elastic/eui/dist/eui_theme_amsterdam_dark.json');
}

/**
* EUI Theme vars that automatically adjust to light/dark theme
*/
export let euiThemeVars: Theme;
if (globals.__kbnDarkTheme__) {
euiThemeVars = euiDarkVars;
} else {
euiThemeVars = euiLightVars;
}
5 changes: 4 additions & 1 deletion packages/kbn-ui-shared-deps/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"extends": "../../tsconfig.json",
"include": ["index.d.ts", "./monaco"]
"include": [
"index.d.ts",
"theme.ts"
]
}
11 changes: 11 additions & 0 deletions packages/kbn-ui-shared-deps/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
include: [require.resolve('./theme.ts')],
use: [
{
loader: 'babel-loader',
options: {
presets: [require.resolve('@kbn/babel-preset/webpack_preset')],
},
},
],
},
],
},

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
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
3 changes: 2 additions & 1 deletion src/dev/i18n/integrate_locale_files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { mockMakeDirAsync, mockWriteFileAsync } from './integrate_locale_files.t

import path from 'path';
import { integrateLocaleFiles, verifyMessages } from './integrate_locale_files';
// @ts-ignore
// @ts-expect-error
import { normalizePath } from './utils';

const localePath = path.resolve(__dirname, '__fixtures__', 'integrate_locale_files', 'fr.json');
Expand All @@ -36,6 +36,7 @@ const defaultIntegrateOptions = {
sourceFileName: localePath,
dryRun: false,
ignoreIncompatible: false,
ignoreMalformed: false,
ignoreMissing: false,
ignoreUnused: false,
config: {
Expand Down
21 changes: 20 additions & 1 deletion src/dev/i18n/integrate_locale_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import {
normalizePath,
readFileAsync,
writeFileAsync,
// @ts-ignore
verifyICUMessage,
// @ts-expect-error
} from './utils';

import { I18nConfig } from './config';
Expand All @@ -41,6 +42,7 @@ export interface IntegrateOptions {
sourceFileName: string;
targetFileName?: string;
dryRun: boolean;
ignoreMalformed: boolean;
ignoreIncompatible: boolean;
ignoreUnused: boolean;
ignoreMissing: boolean;
Expand Down Expand Up @@ -105,6 +107,23 @@ export function verifyMessages(
}
}

for (const messageId of localizedMessagesIds) {
const defaultMessage = defaultMessagesMap.get(messageId);
if (defaultMessage) {
try {
const message = localizedMessagesMap.get(messageId)!;
verifyICUMessage(message);
} catch (err) {
if (options.ignoreMalformed) {
localizedMessagesMap.delete(messageId);
options.log.warning(`Malformed translation ignored (${messageId}): ${err}`);
} else {
errorMessage += `\nMalformed translation (${messageId}): ${err}\n`;
}
}
}
}

if (errorMessage) {
throw createFailError(errorMessage);
}
Expand Down
4 changes: 3 additions & 1 deletion src/dev/i18n/tasks/check_compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import { integrateLocaleFiles, I18nConfig } from '..';

export interface I18nFlags {
fix: boolean;
ignoreMalformed: boolean;
ignoreIncompatible: boolean;
ignoreUnused: boolean;
ignoreMissing: boolean;
}

export function checkCompatibility(config: I18nConfig, flags: I18nFlags, log: ToolingLog) {
const { fix, ignoreIncompatible, ignoreUnused, ignoreMissing } = flags;
const { fix, ignoreIncompatible, ignoreUnused, ignoreMalformed, ignoreMissing } = flags;
return config.translations.map((translationsPath) => ({
task: async ({ messages }: { messages: Map<string, { message: string }> }) => {
// If `fix` is set we should try apply all possible fixes and override translations file.
Expand All @@ -37,6 +38,7 @@ export function checkCompatibility(config: I18nConfig, flags: I18nFlags, log: To
ignoreIncompatible: fix || ignoreIncompatible,
ignoreUnused: fix || ignoreUnused,
ignoreMissing: fix || ignoreMissing,
ignoreMalformed: fix || ignoreMalformed,
sourceFileName: translationsPath,
targetFileName: fix ? translationsPath : undefined,
config,
Expand Down
Loading

0 comments on commit 0e001e6

Please sign in to comment.