Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix-missing-licen…
Browse files Browse the repository at this point in the history
…se-in-maps-embeddables
  • Loading branch information
Aaron Caldwell committed Mar 3, 2020
2 parents 25d7e59 + a5e5122 commit f0c8fbe
Show file tree
Hide file tree
Showing 258 changed files with 8,369 additions and 2,290 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
30 changes: 30 additions & 0 deletions packages/kbn-test/src/ci_parallel_process_prefix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.
*/

const job = process.env.JOB ? `job-${process.env.JOB}-` : '';
const num = process.env.CI_PARALLEL_PROCESS_NUMBER
? `worker-${process.env.CI_PARALLEL_PROCESS_NUMBER}-`
: '';

/**
* A prefix string that is unique for each parallel CI process that
* is an empty string outside of CI, so it can be safely injected
* into strings as a prefix
*/
export const CI_PARALLEL_PROCESS_PREFIX = `${job}${num}`;
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ export async function runElasticsearch({ config, options }) {
esFrom: esFrom || config.get('esTestCluster.from'),
dataArchive: config.get('esTestCluster.dataArchive'),
esArgs,
esEnvVars,
ssl,
});

await cluster.start(esArgs, esEnvVars);
await cluster.start();

if (isSecurityEnabled) {
await setupUsers({
Expand Down
8 changes: 2 additions & 6 deletions packages/kbn-test/src/junit_report_path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@
*/

import { resolve } from 'path';

const job = process.env.JOB ? `job-${process.env.JOB}-` : '';
const num = process.env.CI_PARALLEL_PROCESS_NUMBER
? `worker-${process.env.CI_PARALLEL_PROCESS_NUMBER}-`
: '';
import { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix';

export function makeJunitReportPath(rootDirectory: string, reportName: string) {
return resolve(
rootDirectory,
'target/junit',
process.env.JOB || '.',
`TEST-${job}${num}${reportName}.xml`
`TEST-${CI_PARALLEL_PROCESS_PREFIX}${reportName}.xml`
);
}
30 changes: 16 additions & 14 deletions packages/kbn-test/src/legacy_es/legacy_es_test_cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { format } from 'url';
import { get } from 'lodash';
import toPath from 'lodash/internal/toPath';
import { Cluster } from '@kbn/es';
import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix';
import { esTestConfig } from './es_test_config';

import { KIBANA_ROOT } from '../';
Expand All @@ -38,14 +39,22 @@ export function createLegacyEsTestCluster(options = {}) {
basePath = resolve(KIBANA_ROOT, '.es'),
esFrom = esTestConfig.getBuildFrom(),
dataArchive,
esArgs,
esArgs: customEsArgs = [],
esEnvVars,
clusterName: customClusterName = 'es-test-cluster',
ssl,
} = options;

const randomHash = Math.random()
.toString(36)
.substring(2);
const clusterName = `test-${randomHash}`;
const clusterName = `${CI_PARALLEL_PROCESS_PREFIX}${customClusterName}`;

const esArgs = [
`cluster.name=${clusterName}`,
`http.port=${port}`,
'discovery.type=single-node',
`transport.port=${esTestConfig.getTransportPort()}`,
...customEsArgs,
];

const config = {
version: esTestConfig.getVersion(),
installPath: resolve(basePath, clusterName),
Expand All @@ -55,7 +64,6 @@ export function createLegacyEsTestCluster(options = {}) {
basePath,
esArgs,
};
const transportPort = esTestConfig.getTransportPort();

const cluster = new Cluster({ log, ssl });

Expand All @@ -67,7 +75,7 @@ export function createLegacyEsTestCluster(options = {}) {
return esFrom === 'snapshot' ? 3 * minute : 6 * minute;
}

async start(esArgs = [], esEnvVars) {
async start() {
let installPath;

if (esFrom === 'source') {
Expand All @@ -86,13 +94,7 @@ export function createLegacyEsTestCluster(options = {}) {

await cluster.start(installPath, {
password: config.password,
esArgs: [
`cluster.name=${clusterName}`,
`http.port=${port}`,
'discovery.type=single-node',
`transport.port=${transportPort}`,
...esArgs,
],
esArgs,
esEnvVars,
});
}
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 @@ -49,7 +49,7 @@ export function ToolBarPagerButtons(props: Props) {
disabled={!props.hasNextPage}
data-test-subj="btnNextPage"
aria-label={i18n.translate(
'kbn.ddiscover.docTable.pager.toolbarPagerButtons.nextButtonAriaLabel',
'kbn.discover.docTable.pager.toolbarPagerButtons.nextButtonAriaLabel',
{
defaultMessage: 'Next page in table',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,17 @@ export class VegaBaseView {
*/
async removeFilterHandler(query, index) {
const indexId = await this._findIndex(index);
const filter = esFilters.buildQueryFilter(query, indexId);
const filterToRemove = esFilters.buildQueryFilter(query, indexId);

const currentFilters = this._filterManager.getFilters();
const existingFilter = currentFilters.find(filter =>
esFilters.compareFilters(filter, filterToRemove)
);

if (!existingFilter) return;

try {
this._filterManager.removeFilter(filter);
this._filterManager.removeFilter(existingFilter);
} catch (err) {
this.onError(err);
}
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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 { notificationServiceMock } from '../../../../../core/public/mocks';
import { HistoryMock } from '../../services/history.mock';
import { SettingsMock } from '../../services/settings.mock';
import { StorageMock } from '../../services/storage.mock';

import { ContextValue } from './services_context';

export const serviceContextMock = {
create: (): ContextValue => {
const storage = new StorageMock({} as any, 'test');
(storage.keys as jest.Mock).mockImplementation(() => []);
return {
elasticsearchUrl: 'test',
services: {
trackUiMetric: { count: () => {}, load: () => {} },
storage,
settings: new SettingsMock(storage),
history: new HistoryMock(storage),
notifications: notificationServiceMock.createSetupContract(),
objectStorageClient: {} as any,
},
docLinkVersion: 'NA',
};
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function ServicesContextProvider({ children, value }: ContextProps) {
export const useServicesContext = () => {
const context = useContext(ServicesContext);
if (context === undefined) {
throw new Error('useAppContext must be used inside the AppContextProvider.');
throw new Error('useServicesContext must be used inside the ServicesContextProvider.');
}
return context;
};
Loading

0 comments on commit f0c8fbe

Please sign in to comment.