Skip to content

Commit

Permalink
Merge branch 'master' into stabilize-dashboard-snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Mar 3, 2020
2 parents 5bc0392 + 6a02b3a commit f958e89
Show file tree
Hide file tree
Showing 132 changed files with 6,960 additions and 1,041 deletions.
3 changes: 2 additions & 1 deletion docs/management/advanced-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ cluster alert notifications from Monitoring.
==== Dashboard

[horizontal]
`xpackDashboardMode:roles`:: The roles that belong to <<xpack-dashboard-only-mode, dashboard only mode>>.
`xpackDashboardMode:roles`:: **Deprecated. Use <<kibana-feature-privileges,feature privileges>> instead.**
The roles that belong to <<xpack-dashboard-only-mode, dashboard only mode>>.

[float]
[[kibana-discover-settings]]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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.
*/

export function foo() {}
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@

export * from './lib';
export * from './ext';

export async function getFoo() {
return await import('./async_import');
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,21 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
Fs.readFileSync(Path.resolve(MOCK_REPO_DIR, 'plugins/foo/target/public/foo.plugin.js'), 'utf8')
).toMatchSnapshot('foo bundle');

expect(
Fs.readFileSync(Path.resolve(MOCK_REPO_DIR, 'plugins/foo/target/public/1.plugin.js'), 'utf8')
).toMatchSnapshot('1 async bundle');

expect(
Fs.readFileSync(Path.resolve(MOCK_REPO_DIR, 'plugins/bar/target/public/bar.plugin.js'), 'utf8')
).toMatchSnapshot('bar bundle');

const foo = config.bundles.find(b => b.id === 'foo')!;
expect(foo).toBeTruthy();
foo.cache.refresh();
expect(foo.cache.getModuleCount()).toBe(3);
expect(foo.cache.getModuleCount()).toBe(4);
expect(foo.cache.getReferencedFiles()).toMatchInlineSnapshot(`
Array [
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/async_import.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/ext.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/index.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/lib.ts,
Expand All @@ -148,8 +153,8 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
expect(bar).toBeTruthy();
bar.cache.refresh();
expect(bar.cache.getModuleCount()).toBe(
// code + styles + style/css-loader runtime
14
// code + styles + style/css-loader runtimes
15
);

expect(bar.cache.getReferencedFiles()).toMatchInlineSnapshot(`
Expand All @@ -159,6 +164,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/index.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/legacy/styles.scss,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/lib.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/async_import.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/ext.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/index.ts,
<absolute path>/packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/lib.ts,
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-optimizer/src/worker/run_compilers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const observeCompiler = (
);
}

const files = Array.from(referencedFiles);
const files = Array.from(referencedFiles).sort(ascending(p => p));
const mtimes = new Map(
files.map((path): [string, number | undefined] => {
try {
Expand All @@ -146,7 +146,7 @@ const observeCompiler = (
optimizerCacheKey: workerConfig.optimizerCacheKey,
cacheKey: bundle.createCacheKey(files, mtimes),
moduleCount: normalModules.length,
files: files.sort(ascending(f => f)),
files,
});

return compilerMsgs.compilerSuccess({
Expand Down
15 changes: 13 additions & 2 deletions packages/kbn-test/src/failed_tests_reporter/github_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ export interface GithubIssue {
body: string;
}

/**
* Minimal GithubIssue type that can be easily replicated by dry-run helpers
*/
export interface GithubIssueMini {
number: GithubIssue['number'];
body: GithubIssue['body'];
html_url: GithubIssue['html_url'];
}

type RequestOptions = AxiosRequestConfig & {
safeForDryRun?: boolean;
maxAttempts?: number;
Expand Down Expand Up @@ -162,7 +171,7 @@ export class GithubApi {
}

async createIssue(title: string, body: string, labels?: string[]) {
const resp = await this.request(
const resp = await this.request<GithubIssueMini>(
{
method: 'POST',
url: Url.resolve(BASE_URL, 'issues'),
Expand All @@ -173,11 +182,13 @@ export class GithubApi {
},
},
{
body,
number: 999,
html_url: 'https://dryrun',
}
);

return resp.data.html_url;
return resp.data;
}

private async request<T>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ describe('updateFailureIssue()', () => {
'https://build-url',
{
html_url: 'https://github.com/issues/1234',
labels: ['some-label'],
number: 1234,
title: 'issue title',
body: dedent`
# existing issue body
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-test/src/failed_tests_reporter/report_failure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { TestFailure } from './get_failures';
import { GithubIssue, GithubApi } from './github_api';
import { GithubIssueMini, GithubApi } from './github_api';
import { getIssueMetadata, updateIssueMetadata } from './issue_metadata';

export async function createFailureIssue(buildUrl: string, failure: TestFailure, api: GithubApi) {
Expand All @@ -44,7 +44,7 @@ export async function createFailureIssue(buildUrl: string, failure: TestFailure,
return await api.createIssue(title, body, ['failed-test']);
}

export async function updateFailureIssue(buildUrl: string, issue: GithubIssue, api: GithubApi) {
export async function updateFailureIssue(buildUrl: string, issue: GithubIssueMini, api: GithubApi) {
// Increment failCount
const newCount = getIssueMetadata(issue.body, 'test.failCount', 0) + 1;
const newBody = updateIssueMetadata(issue.body, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import { REPO_ROOT, run, createFailError, createFlagError } from '@kbn/dev-utils';
import globby from 'globby';

import { getFailures } from './get_failures';
import { GithubApi } from './github_api';
import { getFailures, TestFailure } from './get_failures';
import { GithubApi, GithubIssueMini } from './github_api';
import { updateFailureIssue, createFailureIssue } from './report_failure';
import { getIssueMetadata } from './issue_metadata';
import { readTestReport } from './test_report';
Expand Down Expand Up @@ -73,6 +73,11 @@ export function runFailedTestsReporterCli() {
absolute: true,
});

const newlyCreatedIssues: Array<{
failure: TestFailure;
newIssue: GithubIssueMini;
}> = [];

for (const reportPath of reportPaths) {
const report = await readTestReport(reportPath);
const messages = Array.from(getReportMessageIter(report));
Expand All @@ -94,12 +99,22 @@ export function runFailedTestsReporterCli() {
continue;
}

const existingIssue = await githubApi.findFailedTestIssue(
let existingIssue: GithubIssueMini | undefined = await githubApi.findFailedTestIssue(
i =>
getIssueMetadata(i.body, 'test.class') === failure.classname &&
getIssueMetadata(i.body, 'test.name') === failure.name
);

if (!existingIssue) {
const newlyCreated = newlyCreatedIssues.find(
({ failure: f }) => f.classname === failure.classname && f.name === failure.name
);

if (newlyCreated) {
existingIssue = newlyCreated.newIssue;
}
}

if (existingIssue) {
const newFailureCount = await updateFailureIssue(buildUrl, existingIssue, githubApi);
const url = existingIssue.html_url;
Expand All @@ -110,11 +125,12 @@ export function runFailedTestsReporterCli() {
continue;
}

const newIssueUrl = await createFailureIssue(buildUrl, failure, githubApi);
const newIssue = await createFailureIssue(buildUrl, failure, githubApi);
pushMessage('Test has not failed recently on tracked branches');
if (updateGithub) {
pushMessage(`Created new issue: ${newIssueUrl}`);
pushMessage(`Created new issue: ${newIssue.html_url}`);
}
newlyCreatedIssues.push({ failure, newIssue });
}

// mutates report to include messages and writes updated report to disk
Expand Down
1 change: 1 addition & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export class DocLinksService {
},
management: {
kibanaSearchSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-search-settings`,
dashboardSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-dashboard-settings`,
},
},
});
Expand Down
1 change: 1 addition & 0 deletions src/dev/storybook/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
export const storybookAliases = {
apm: 'x-pack/legacy/plugins/apm/scripts/storybook.js',
canvas: 'x-pack/legacy/plugins/canvas/scripts/storybook_new.js',
codeeditor: 'src/plugins/kibana_react/public/code_editor/scripts/storybook.ts',
drilldowns: 'x-pack/plugins/drilldowns/scripts/storybook.js',
embeddable: 'src/plugins/embeddable/scripts/storybook.js',
infra: 'x-pack/legacy/plugins/infra/scripts/storybook.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { I18nProvider } from '@kbn/i18n/react';
import { act } from 'react-dom/test-utils';
import * as sinon from 'sinon';

import { notificationServiceMock } from '../../../../../../../../core/public/mocks';
import { serviceContextMock } from '../../../../contexts/services_context.mock';

import { nextTick } from 'test_utils/enzyme_helpers';
import {
Expand Down Expand Up @@ -61,21 +61,7 @@ describe('Legacy (Ace) Console Editor Component Smoke Test', () => {

beforeEach(() => {
document.queryCommandSupported = sinon.fake(() => true);
mockedAppContextValue = {
elasticsearchUrl: 'test',
services: {
trackUiMetric: { count: () => {}, load: () => {} },
settings: {} as any,
storage: {} as any,
history: {
getSavedEditorState: () => ({} as any),
updateCurrentState: jest.fn(),
} as any,
notifications: notificationServiceMock.createSetupContract(),
objectStorageClient: {} as any,
},
docLinkVersion: 'NA',
};
mockedAppContextValue = serviceContextMock.create();
});

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const inputId = 'ConAppInputTextarea';

function EditorUI({ initialTextValue }: EditorProps) {
const {
services: { history, notifications },
services: { history, notifications, settings: settingsService },
docLinkVersion,
elasticsearchUrl,
} = useServicesContext();
Expand Down Expand Up @@ -172,7 +172,7 @@ function EditorUI({ initialTextValue }: EditorProps) {
setInputEditor(editor);
setTextArea(editorRef.current!.querySelector('textarea'));

mappings.retrieveAutoCompleteInfo();
mappings.retrieveAutoCompleteInfo(settingsService, settingsService.getAutocomplete());

const unsubscribeResizer = subscribeResizeChecker(editorRef.current!, editor);
setupAutosave();
Expand All @@ -182,7 +182,7 @@ function EditorUI({ initialTextValue }: EditorProps) {
mappings.clearSubscriptions();
window.removeEventListener('hashchange', onHashChange);
};
}, [saveCurrentTextObject, initialTextValue, history, setInputEditor]);
}, [saveCurrentTextObject, initialTextValue, history, setInputEditor, settingsService]);

useEffect(() => {
const { current: editor } = editorInstanceRef;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ import { createReadOnlyAceEditor, CustomAceEditor } from '../../../../models/leg
import { subscribeResizeChecker } from '../subscribe_console_resize_checker';
import { applyCurrentSettings } from './apply_editor_settings';

function modeForContentType(contentType: string) {
function modeForContentType(contentType?: string) {
if (!contentType) {
return 'ace/mode/text';
}
if (contentType.indexOf('application/json') >= 0) {
return 'ace/mode/json';
} else if (contentType.indexOf('application/yaml') >= 0) {
Expand Down
19 changes: 11 additions & 8 deletions src/plugins/console/public/application/containers/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { AutocompleteOptions, DevToolsSettingsModal } from '../components';
// @ts-ignore
import mappings from '../../lib/mappings/mappings';
import { useServicesContext, useEditorActionContext } from '../contexts';
import { DevToolsSettings } from '../../services';
import { DevToolsSettings, Settings as SettingsService } from '../../services';

const getAutocompleteDiff = (newSettings: DevToolsSettings, prevSettings: DevToolsSettings) => {
return Object.keys(newSettings.autocomplete).filter(key => {
Expand All @@ -32,11 +32,12 @@ const getAutocompleteDiff = (newSettings: DevToolsSettings, prevSettings: DevToo
});
};

const refreshAutocompleteSettings = (selectedSettings: any) => {
mappings.retrieveAutoCompleteInfo(selectedSettings);
const refreshAutocompleteSettings = (settings: SettingsService, selectedSettings: any) => {
mappings.retrieveAutoCompleteInfo(settings, selectedSettings);
};

const fetchAutocompleteSettingsIfNeeded = (
settings: SettingsService,
newSettings: DevToolsSettings,
prevSettings: DevToolsSettings
) => {
Expand All @@ -60,10 +61,10 @@ const fetchAutocompleteSettingsIfNeeded = (
},
{}
);
mappings.retrieveAutoCompleteInfo(changedSettings.autocomplete);
} else if (isPollingChanged) {
mappings.retrieveAutoCompleteInfo(settings, changedSettings);
} else if (isPollingChanged && newSettings.polling) {
// If the user has turned polling on, then we'll fetch all selected autocomplete settings.
mappings.retrieveAutoCompleteInfo();
mappings.retrieveAutoCompleteInfo(settings, settings.getAutocomplete());
}
}
};
Expand All @@ -81,7 +82,7 @@ export function Settings({ onClose }: Props) {

const onSaveSettings = (newSettings: DevToolsSettings) => {
const prevSettings = settings.toJSON();
fetchAutocompleteSettingsIfNeeded(newSettings, prevSettings);
fetchAutocompleteSettingsIfNeeded(settings, newSettings, prevSettings);

// Update the new settings in localStorage
settings.updateSettings(newSettings);
Expand All @@ -98,7 +99,9 @@ export function Settings({ onClose }: Props) {
<DevToolsSettingsModal
onClose={onClose}
onSaveSettings={onSaveSettings}
refreshAutocompleteSettings={refreshAutocompleteSettings}
refreshAutocompleteSettings={(selectedSettings: any) =>
refreshAutocompleteSettings(settings, selectedSettings)
}
settings={settings.toJSON()}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { SenseEditor } from '../../models/sense_editor';

export class EditorRegistry {
inputEditor: SenseEditor | undefined;
private inputEditor: SenseEditor | undefined;

setInputEditor(inputEditor: SenseEditor) {
this.inputEditor = inputEditor;
Expand Down
Loading

0 comments on commit f958e89

Please sign in to comment.