(queryLanguage ? getQueryLog(uiSettings!, storage, appName, queryLanguage) : undefined),
- [queryLanguage]
+ () =>
+ queryLanguage && uiSettings && storage && appName
+ ? getQueryLog(uiSettings!, storage, appName, queryLanguage)
+ : undefined,
+ [appName, queryLanguage, uiSettings, storage]
);
function onClickSubmitButton(event: React.MouseEvent) {
@@ -298,7 +305,7 @@ function QueryBarTopRowUI(props: Props) {
id: 'data.query.queryBar.luceneSyntaxWarningTitle',
defaultMessage: 'Lucene syntax warning',
}),
- text: (
+ text: toMountPoint(
;
@@ -73,6 +76,7 @@ export interface SearchBarOwnProps {
// Show when user has privileges to save
showSaveQuery?: boolean;
savedQuery?: SavedQuery;
+ onQueryChange?: (payload: { dateRange: TimeRange; query?: Query }) => void;
onQuerySubmit?: (payload: { dateRange: TimeRange; query?: Query }) => void;
// User has saved the current state as a saved query
onSaved?: (savedQuery: SavedQuery) => void;
@@ -207,6 +211,18 @@ class SearchBarUI extends Component {
);
}
+ /*
+ * This Function is here to show the toggle in saved query form
+ * in case you the date range (from/to)
+ */
+ private shouldRenderTimeFilterInSavedQueryForm() {
+ const { dateRangeFrom, dateRangeTo, showDatePicker } = this.props;
+ return (
+ showDatePicker ||
+ (!showDatePicker && dateRangeFrom !== undefined && dateRangeTo !== undefined)
+ );
+ }
+
public setFilterBarHeight = () => {
requestAnimationFrame(() => {
const height =
@@ -300,6 +316,9 @@ class SearchBarUI extends Component {
dateRangeFrom: queryAndDateRange.dateRange.from,
dateRangeTo: queryAndDateRange.dateRange.to,
});
+ if (this.props.onQueryChange) {
+ this.props.onQueryChange(queryAndDateRange);
+ }
};
public onQueryBarSubmit = (queryAndDateRange: { dateRange?: TimeRange; query?: Query }) => {
@@ -441,7 +460,7 @@ class SearchBarUI extends Component {
onSave={this.onSave}
onClose={() => this.setState({ showSaveQueryModal: false })}
showFilterOption={this.props.showFilterBar}
- showTimeFilterOption={this.props.showDatePicker}
+ showTimeFilterOption={this.shouldRenderTimeFilterInSavedQueryForm()}
/>
) : null}
{this.state.showSaveNewQueryModal ? (
@@ -450,7 +469,7 @@ class SearchBarUI extends Component {
onSave={savedQueryMeta => this.onSave(savedQueryMeta, true)}
onClose={() => this.setState({ showSaveNewQueryModal: false })}
showFilterOption={this.props.showFilterBar}
- showTimeFilterOption={this.props.showDatePicker}
+ showTimeFilterOption={this.shouldRenderTimeFilterInSavedQueryForm()}
/>
) : null}
diff --git a/src/legacy/core_plugins/data/public/search/search_bar/index.tsx b/src/legacy/core_plugins/data/public/search/search_bar/index.tsx
index ebde9d60b0b51..f369bf997c1a9 100644
--- a/src/legacy/core_plugins/data/public/search/search_bar/index.tsx
+++ b/src/legacy/core_plugins/data/public/search/search_bar/index.tsx
@@ -17,9 +17,7 @@
* under the License.
*/
-import { RefreshInterval, TimeRange } from 'src/plugins/data/public';
-import { Query } from '../../query/query_bar';
-import { esFilters } from '../../../../../../plugins/data/public';
+import { RefreshInterval, TimeRange, Query, esFilters } from 'src/plugins/data/public';
export * from './components';
diff --git a/src/legacy/core_plugins/expressions/public/np_ready/public/types.ts b/src/legacy/core_plugins/expressions/public/np_ready/public/types.ts
index 9d7b4fb6d0480..c8870b9f97957 100644
--- a/src/legacy/core_plugins/expressions/public/np_ready/public/types.ts
+++ b/src/legacy/core_plugins/expressions/public/np_ready/public/types.ts
@@ -17,9 +17,8 @@
* under the License.
*/
-import { TimeRange } from '../../../../../../plugins/data/public';
import { Adapters } from '../../../../../../plugins/inspector/public';
-import { Query } from '../../../../../../plugins/data/public';
+import { TimeRange, Query } from '../../../../../../plugins/data/public';
export { TimeRange, Adapters, Query };
export * from '../../../../../../plugins/expressions/public';
diff --git a/src/legacy/core_plugins/input_control_vis/public/components/editor/list_control_editor.test.js b/src/legacy/core_plugins/input_control_vis/public/components/editor/list_control_editor.test.js
index 96c0802d3772a..ea029af9e4890 100644
--- a/src/legacy/core_plugins/input_control_vis/public/components/editor/list_control_editor.test.js
+++ b/src/legacy/core_plugins/input_control_vis/public/components/editor/list_control_editor.test.js
@@ -236,7 +236,7 @@ test('handleCheckboxOptionChange - multiselect', async () => {
component.update();
const checkbox = findTestSubject(component, 'listControlMultiselectInput');
- checkbox.simulate('change', { target: { checked: true } });
+ checkbox.simulate('click');
sinon.assert.notCalled(handleFieldNameChange);
sinon.assert.notCalled(handleIndexPatternChange);
sinon.assert.notCalled(handleNumberOptionChange);
@@ -247,7 +247,9 @@ test('handleCheckboxOptionChange - multiselect', async () => {
expectedControlIndex,
expectedOptionName,
sinon.match((evt) => {
- if (evt.target.checked === true) {
+ // Synthetic `evt.target.checked` does not get altered by EuiSwitch,
+ // but its aria attribute is correctly updated
+ if (evt.target.getAttribute('aria-checked') === 'true') {
return true;
}
return false;
diff --git a/src/legacy/core_plugins/input_control_vis/public/components/editor/options_tab.test.js b/src/legacy/core_plugins/input_control_vis/public/components/editor/options_tab.test.js
index 39f5f6a50a5a6..8784f0e79ca8d 100644
--- a/src/legacy/core_plugins/input_control_vis/public/components/editor/options_tab.test.js
+++ b/src/legacy/core_plugins/input_control_vis/public/components/editor/options_tab.test.js
@@ -47,8 +47,8 @@ describe('OptionsTab', () => {
it('should update updateFiltersOnChange', () => {
const component = mountWithIntl();
- const checkbox = component.find('[data-test-subj="inputControlEditorUpdateFiltersOnChangeCheckbox"] input[type="checkbox"]');
- checkbox.simulate('change', { target: { checked: true } });
+ const checkbox = component.find('[data-test-subj="inputControlEditorUpdateFiltersOnChangeCheckbox"] button');
+ checkbox.simulate('click');
expect(props.setValue).toHaveBeenCalledTimes(1);
expect(props.setValue).toHaveBeenCalledWith('updateFiltersOnChange', true);
@@ -56,8 +56,8 @@ describe('OptionsTab', () => {
it('should update useTimeFilter', () => {
const component = mountWithIntl();
- const checkbox = component.find('[data-test-subj="inputControlEditorUseTimeFilterCheckbox"] input[type="checkbox"]');
- checkbox.simulate('change', { target: { checked: true } });
+ const checkbox = component.find('[data-test-subj="inputControlEditorUseTimeFilterCheckbox"] button');
+ checkbox.simulate('click');
expect(props.setValue).toHaveBeenCalledTimes(1);
expect(props.setValue).toHaveBeenCalledWith('useTimeFilter', true);
@@ -65,8 +65,8 @@ describe('OptionsTab', () => {
it('should update pinFilters', () => {
const component = mountWithIntl();
- const checkbox = component.find('[data-test-subj="inputControlEditorPinFiltersCheckbox"] input[type="checkbox"]');
- checkbox.simulate('change', { target: { checked: true } });
+ const checkbox = component.find('[data-test-subj="inputControlEditorPinFiltersCheckbox"] button');
+ checkbox.simulate('click');
expect(props.setValue).toHaveBeenCalledTimes(1);
expect(props.setValue).toHaveBeenCalledWith('pinFilters', true);
diff --git a/src/legacy/core_plugins/interpreter/public/renderers/visualization.tsx b/src/legacy/core_plugins/interpreter/public/renderers/visualization.tsx
index 9de6cdeaf5ec3..f15cdf23fe15b 100644
--- a/src/legacy/core_plugins/interpreter/public/renderers/visualization.tsx
+++ b/src/legacy/core_plugins/interpreter/public/renderers/visualization.tsx
@@ -21,7 +21,7 @@ import chrome from 'ui/chrome';
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
// @ts-ignore
-import { VisProvider } from '../../../../ui/public/visualize/loader/vis';
+import { Vis } from '../../../../ui/public/visualize/loader/vis';
import { Visualization } from '../../../../ui/public/visualize/components';
export const visualization = () => ({
@@ -33,8 +33,6 @@ export const visualization = () => ({
const visType = config.visType || visConfig.type;
const $injector = await chrome.dangerouslyGetActiveInjector();
const $rootScope = $injector.get('$rootScope') as any;
- const Private = $injector.get('Private') as any;
- const Vis = Private(VisProvider);
if (handlers.vis) {
// special case in visualize, we need to render first (without executing the expression), for maps to work
diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/components/options/metrics_axes/index.tsx b/src/legacy/core_plugins/kbn_vislib_vis_types/public/components/options/metrics_axes/index.tsx
index c7ada18f9e1f2..2ca4ed1e2343d 100644
--- a/src/legacy/core_plugins/kbn_vislib_vis_types/public/components/options/metrics_axes/index.tsx
+++ b/src/legacy/core_plugins/kbn_vislib_vis_types/public/components/options/metrics_axes/index.tsx
@@ -83,9 +83,11 @@ function MetricsAxisOptions(props: ValidationVisOptionsProps)
// stores previous aggs' custom labels
const [lastCustomLabels, setLastCustomLabels] = useState({} as { [key: string]: string });
// stores previous aggs' field and type
- const [lastSeriesAgg, setLastSeriesAgg] = useState({} as {
- [key: string]: { type: string; field: string };
- });
+ const [lastSeriesAgg, setLastSeriesAgg] = useState(
+ {} as {
+ [key: string]: { type: string; field: string };
+ }
+ );
const updateAxisTitle = () => {
const axes = cloneDeep(stateParams.valueAxes);
diff --git a/src/legacy/core_plugins/kibana/index.js b/src/legacy/core_plugins/kibana/index.js
index 24cd436912395..c7cda8aec0165 100644
--- a/src/legacy/core_plugins/kibana/index.js
+++ b/src/legacy/core_plugins/kibana/index.js
@@ -62,7 +62,7 @@ export default function (kibana) {
uiExports: {
hacks: [
- 'plugins/kibana/dev_tools/hacks/hide_empty_tools',
+ 'plugins/kibana/dev_tools',
],
fieldFormats: ['plugins/kibana/field_formats/register'],
savedObjectTypes: [
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.tsx b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.tsx
index 5fa3a938ed9df..d5da4ba51e55b 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.tsx
+++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.tsx
@@ -26,26 +26,22 @@ import { IInjector } from 'ui/chrome';
// @ts-ignore
import * as filterActions from 'plugins/kibana/discover/doc_table/actions/filter';
-// @ts-ignore
-import { getFilterGenerator } from 'ui/filter_manager';
-
import {
AppStateClass as TAppStateClass,
AppState as TAppState,
} from 'ui/state_management/app_state';
import { KbnUrl } from 'ui/url/kbn_url';
-import { TimeRange } from 'src/plugins/data/public';
import { IndexPattern } from 'ui/index_patterns';
import { IPrivate } from 'ui/private';
-import { StaticIndexPattern, Query, SavedQuery } from 'plugins/data';
+import { StaticIndexPattern, SavedQuery } from 'plugins/data';
import moment from 'moment';
import { Subscription } from 'rxjs';
import { ViewMode } from '../../../embeddable_api/public/np_ready/public';
import { SavedObjectDashboard } from './saved_dashboard/saved_dashboard';
import { DashboardAppState, SavedDashboardPanel, ConfirmModalFn } from './types';
-import { esFilters } from '../../../../../../src/plugins/data/public';
+import { TimeRange, Query, esFilters } from '../../../../../../src/plugins/data/public';
import { DashboardAppController } from './dashboard_app_controller';
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx
index 548a66297a3f9..d82b89339b0d0 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx
+++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx
@@ -50,12 +50,13 @@ import {
import { KbnUrl } from 'ui/url/kbn_url';
import { IndexPattern } from 'ui/index_patterns';
import { IPrivate } from 'ui/private';
-import { Query, SavedQuery } from 'src/legacy/core_plugins/data/public';
+import { SavedQuery } from 'src/legacy/core_plugins/data/public';
import { SaveOptions } from 'ui/saved_objects/saved_object';
import { capabilities } from 'ui/capabilities';
import { Subscription } from 'rxjs';
import { npStart } from 'ui/new_platform';
import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder';
+import { Query } from '../../../../../plugins/data/public';
import { start as data } from '../../../data/public/legacy';
import {
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state_manager.ts b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state_manager.ts
index 8ffabe5add1c3..d5af4c93d0e0c 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state_manager.ts
+++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state_manager.ts
@@ -28,8 +28,7 @@ import { Moment } from 'moment';
import { DashboardContainer } from 'src/legacy/core_plugins/dashboard_embeddable_container/public/np_ready/public';
import { ViewMode } from '../../../../../../src/plugins/embeddable/public';
-import { esFilters } from '../../../../../../src/plugins/data/public';
-import { Query } from '../../../data/public';
+import { Query, esFilters } from '../../../../../../src/plugins/data/public';
import { getAppStateDefaults, migrateAppState } from './lib';
import { convertPanelStateToSavedDashboardPanel } from './lib/embeddable_saved_object_converters';
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/migrations/move_filters_to_query.ts b/src/legacy/core_plugins/kibana/public/dashboard/migrations/move_filters_to_query.ts
index 8522495b9dedb..e82fc58670e39 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/migrations/move_filters_to_query.ts
+++ b/src/legacy/core_plugins/kibana/public/dashboard/migrations/move_filters_to_query.ts
@@ -17,8 +17,7 @@
* under the License.
*/
-import { Query } from 'src/legacy/core_plugins/data/public';
-import { esFilters } from '../../../../../../plugins/data/public';
+import { esFilters, Query } from '../../../../../../plugins/data/public';
export interface Pre600FilterQuery {
// pre 6.0.0 global query:queryString:options were stored per dashboard and would
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.d.ts b/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.d.ts
index 5b860b0a2cc7c..5b24aa13f4f77 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.d.ts
+++ b/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.d.ts
@@ -19,9 +19,7 @@
import { SearchSource } from 'ui/courier';
import { SavedObject } from 'ui/saved_objects/saved_object';
-import { RefreshInterval } from 'src/plugins/data/public';
-import { Query } from 'src/legacy/core_plugins/data/public';
-import { esFilters } from '../../../../../../plugins/data/public';
+import { esFilters, Query, RefreshInterval } from '../../../../../../plugins/data/public';
export interface SavedObjectDashboard extends SavedObject {
id?: string;
diff --git a/src/legacy/core_plugins/kibana/public/dashboard/types.ts b/src/legacy/core_plugins/kibana/public/dashboard/types.ts
index 5aaca7b62094f..3c2c87a502da4 100644
--- a/src/legacy/core_plugins/kibana/public/dashboard/types.ts
+++ b/src/legacy/core_plugins/kibana/public/dashboard/types.ts
@@ -18,7 +18,6 @@
*/
import { AppState } from 'ui/state_management/app_state';
-import { Query } from 'src/legacy/core_plugins/data/public';
import { AppState as TAppState } from 'ui/state_management/app_state';
import { ViewMode } from 'src/plugins/embeddable/public';
import {
@@ -29,7 +28,7 @@ import {
RawSavedDashboardPanel640To720,
RawSavedDashboardPanel730ToLatest,
} from './migrations/types';
-import { esFilters } from '../../../../../plugins/data/public';
+import { Query, esFilters } from '../../../../../plugins/data/public';
export type NavAction = (anchorElement?: any) => void;
diff --git a/src/legacy/core_plugins/kibana/public/dev_tools/_index.scss b/src/legacy/core_plugins/kibana/public/dev_tools/_index.scss
index 563b140fd2ead..2e88d2e1285e3 100644
--- a/src/legacy/core_plugins/kibana/public/dev_tools/_index.scss
+++ b/src/legacy/core_plugins/kibana/public/dev_tools/_index.scss
@@ -16,3 +16,6 @@
}
}
+.devApp {
+ height: 100%;
+}
diff --git a/src/legacy/core_plugins/kibana/public/dev_tools/application.tsx b/src/legacy/core_plugins/kibana/public/dev_tools/application.tsx
new file mode 100644
index 0000000000000..3945d8d8dc856
--- /dev/null
+++ b/src/legacy/core_plugins/kibana/public/dev_tools/application.tsx
@@ -0,0 +1,184 @@
+/*
+ * 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 { I18nProvider } from '@kbn/i18n/react';
+import { i18n } from '@kbn/i18n';
+import { EuiTab, EuiTabs, EuiToolTip } from '@elastic/eui';
+import { HashRouter as Router, Switch, Route, Redirect } from 'react-router-dom';
+import * as React from 'react';
+import ReactDOM from 'react-dom';
+import { useEffect, useRef } from 'react';
+
+import { AppMountContext } from 'kibana/public';
+import { DevTool } from '../../../../../plugins/dev_tools/public';
+
+interface DevToolsWrapperProps {
+ devTools: readonly DevTool[];
+ activeDevTool: DevTool;
+ appMountContext: AppMountContext;
+ updateRoute: (newRoute: string) => void;
+}
+
+interface MountedDevToolDescriptor {
+ devTool: DevTool;
+ mountpoint: HTMLElement;
+ unmountHandler: () => void;
+}
+
+function DevToolsWrapper({
+ devTools,
+ activeDevTool,
+ appMountContext,
+ updateRoute,
+}: DevToolsWrapperProps) {
+ const mountedTool = useRef(null);
+
+ useEffect(
+ () => () => {
+ if (mountedTool.current) {
+ mountedTool.current.unmountHandler();
+ }
+ },
+ []
+ );
+
+ return (
+
+
+ {devTools.map(currentDevTool => (
+
+ {
+ if (!currentDevTool.disabled) {
+ updateRoute(`/dev_tools/${currentDevTool.id}`);
+ }
+ }}
+ >
+ {currentDevTool.title}
+
+
+ ))}
+
+ {
+ if (
+ element &&
+ (mountedTool.current === null ||
+ mountedTool.current.devTool !== activeDevTool ||
+ mountedTool.current.mountpoint !== element)
+ ) {
+ if (mountedTool.current) {
+ mountedTool.current.unmountHandler();
+ }
+ const unmountHandler = await activeDevTool.mount(appMountContext, {
+ element,
+ appBasePath: '',
+ });
+ mountedTool.current = {
+ devTool: activeDevTool,
+ mountpoint: element,
+ unmountHandler,
+ };
+ }
+ }}
+ />
+
+ );
+}
+
+function redirectOnMissingCapabilities(appMountContext: AppMountContext) {
+ if (!appMountContext.core.application.capabilities.dev_tools.show) {
+ window.location.hash = '/home';
+ return true;
+ }
+ return false;
+}
+
+function setBadge(appMountContext: AppMountContext) {
+ if (appMountContext.core.application.capabilities.dev_tools.save) {
+ return;
+ }
+ appMountContext.core.chrome.setBadge({
+ text: i18n.translate('kbn.devTools.badge.readOnly.text', {
+ defaultMessage: 'Read only',
+ }),
+ tooltip: i18n.translate('kbn.devTools.badge.readOnly.tooltip', {
+ defaultMessage: 'Unable to save',
+ }),
+ iconType: 'glasses',
+ });
+}
+
+function setBreadcrumbs(appMountContext: AppMountContext) {
+ appMountContext.core.chrome.setBreadcrumbs([
+ {
+ text: i18n.translate('kbn.devTools.k7BreadcrumbsDevToolsLabel', {
+ defaultMessage: 'Dev Tools',
+ }),
+ href: '#/dev_tools',
+ },
+ ]);
+}
+
+export function renderApp(
+ element: HTMLElement,
+ appMountContext: AppMountContext,
+ basePath: string,
+ devTools: readonly DevTool[]
+) {
+ if (redirectOnMissingCapabilities(appMountContext)) {
+ return () => {};
+ }
+ setBadge(appMountContext);
+ setBreadcrumbs(appMountContext);
+ ReactDOM.render(
+
+
+
+ {devTools.map(devTool => (
+ (
+
+ )}
+ />
+ ))}
+
+
+
+
+
+ ,
+ element
+ );
+
+ return () => ReactDOM.unmountComponentAtNode(element);
+}
diff --git a/src/legacy/core_plugins/kibana/public/dev_tools/hacks/__tests__/hide_empty_tools.js b/src/legacy/core_plugins/kibana/public/dev_tools/hacks/__tests__/hide_empty_tools.js
deleted file mode 100644
index 25c7b945b9dfb..0000000000000
--- a/src/legacy/core_plugins/kibana/public/dev_tools/hacks/__tests__/hide_empty_tools.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 expect from '@kbn/expect';
-import sinon from 'sinon';
-
-import { hideEmptyDevTools } from '../hide_empty_tools';
-import { npStart } from 'ui/new_platform';
-
-describe('hide dev tools', function () {
- let updateNavLink;
-
- function PrivateWithoutTools() {
- return [];
- }
-
- function PrivateWithTools() {
- return ['tool1', 'tool2'];
- }
-
- function isHidden() {
- return updateNavLink.calledWith('kibana:dev_tools', { hidden: true });
- }
-
- beforeEach(function () {
- const coreNavLinks = npStart.core.chrome.navLinks;
- updateNavLink = sinon.spy(coreNavLinks, 'update');
- });
-
- it('should hide the app if there are no dev tools', function () {
- hideEmptyDevTools(PrivateWithTools);
- expect(isHidden()).to.be(false);
- });
-
- it('should not hide the app if there are tools', function () {
- hideEmptyDevTools(PrivateWithoutTools);
- expect(isHidden()).to.be(true);
- });
-
- afterEach(function () {
- updateNavLink.restore();
- });
-});
diff --git a/src/legacy/core_plugins/kibana/public/dev_tools/index.js b/src/legacy/core_plugins/kibana/public/dev_tools/index.js
deleted file mode 100644
index e36e75f6837ab..0000000000000
--- a/src/legacy/core_plugins/kibana/public/dev_tools/index.js
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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 uiRoutes from 'ui/routes';
-import { i18n } from '@kbn/i18n';
-import { DevToolsRegistryProvider } from 'ui/registry/dev_tools';
-import { FeatureCatalogueRegistryProvider, FeatureCatalogueCategory } from 'ui/registry/feature_catalogue';
-import 'ui/directives/kbn_href';
-import './directives/dev_tools_app';
-
-uiRoutes
- .when('/dev_tools', {
- resolve: {
- redirect(Private, kbnUrl) {
- const items = Private(DevToolsRegistryProvider).inOrder;
- kbnUrl.redirect(items[0].url.substring(1));
- }
- }
- });
-
-uiRoutes.defaults(/^\/dev_tools(\/|$)/, {
- badge: uiCapabilities => {
- if (uiCapabilities.dev_tools.save) {
- return undefined;
- }
-
- return {
- text: i18n.translate('kbn.devTools.badge.readOnly.text', {
- defaultMessage: 'Read only',
- }),
- tooltip: i18n.translate('kbn.devTools.badge.readOnly.tooltip', {
- defaultMessage: 'Unable to save',
- }),
- iconType: 'glasses'
- };
- },
- k7Breadcrumbs: () => [
- {
- text: i18n.translate('kbn.devTools.k7BreadcrumbsDevToolsLabel', {
- defaultMessage: 'Dev Tools'
- }),
- href: '#/dev_tools'
- }
- ]
-});
-
-FeatureCatalogueRegistryProvider.register(() => {
- return {
- id: 'console',
- title: i18n.translate('kbn.devTools.consoleTitle', {
- defaultMessage: 'Console'
- }),
- description: i18n.translate('kbn.devTools.consoleDescription', {
- defaultMessage: 'Skip cURL and use this JSON interface to work with your data directly.'
- }),
- icon: 'consoleApp',
- path: '/app/kibana#/dev_tools/console',
- showOnHomePage: true,
- category: FeatureCatalogueCategory.ADMIN
- };
-});
diff --git a/src/legacy/core_plugins/telemetry/server/telemetry_collection/get_stats.ts b/src/legacy/core_plugins/kibana/public/dev_tools/index.ts
similarity index 68%
rename from src/legacy/core_plugins/telemetry/server/telemetry_collection/get_stats.ts
rename to src/legacy/core_plugins/kibana/public/dev_tools/index.ts
index b739b20545678..74708e36a98aa 100644
--- a/src/legacy/core_plugins/telemetry/server/telemetry_collection/get_stats.ts
+++ b/src/legacy/core_plugins/kibana/public/dev_tools/index.ts
@@ -17,12 +17,18 @@
* under the License.
*/
-// @ts-ignore
-import { getLocalStats } from './get_local_stats';
-import { StatsGetter, getStatsCollectionConfig } from '../collection_manager';
+import { npSetup, npStart } from 'ui/new_platform';
-export const getStats: StatsGetter = async function(config) {
- const { callCluster, server } = getStatsCollectionConfig(config, 'data');
+import { DevToolsPlugin } from './plugin';
+import { localApplicationService } from '../local_application_service';
- return [await getLocalStats({ callCluster, server })];
-};
+const instance = new DevToolsPlugin();
+
+instance.setup(npSetup.core, {
+ __LEGACY: {
+ localApplicationService,
+ },
+});
+instance.start(npStart.core, {
+ newPlatformDevTools: npStart.plugins.devTools,
+});
diff --git a/src/legacy/core_plugins/kibana/public/dev_tools/partials/dev_tools_app.html b/src/legacy/core_plugins/kibana/public/dev_tools/partials/dev_tools_app.html
deleted file mode 100644
index 6c076092c76d5..0000000000000
--- a/src/legacy/core_plugins/kibana/public/dev_tools/partials/dev_tools_app.html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
diff --git a/src/legacy/core_plugins/kibana/public/dev_tools/plugin.ts b/src/legacy/core_plugins/kibana/public/dev_tools/plugin.ts
new file mode 100644
index 0000000000000..ec9af1a6acd92
--- /dev/null
+++ b/src/legacy/core_plugins/kibana/public/dev_tools/plugin.ts
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+// This import makes sure dev tools are registered before the app is.
+import 'uiExports/devTools';
+
+import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
+
+import { LocalApplicationService } from '../local_application_service';
+import { DevTool, DevToolsStart } from '../../../../../plugins/dev_tools/public';
+
+export interface DevToolsPluginSetupDependencies {
+ __LEGACY: {
+ localApplicationService: LocalApplicationService;
+ };
+}
+
+export interface DevToolsPluginStartDependencies {
+ newPlatformDevTools: DevToolsStart;
+}
+
+export class DevToolsPlugin implements Plugin {
+ private getSortedDevTools: (() => readonly DevTool[]) | null = null;
+
+ public setup(
+ core: CoreSetup,
+ { __LEGACY: { localApplicationService } }: DevToolsPluginSetupDependencies
+ ) {
+ localApplicationService.register({
+ id: 'dev_tools',
+ title: 'Dev Tools',
+ mount: async (appMountContext, params) => {
+ if (!this.getSortedDevTools) {
+ throw new Error('not started yet');
+ }
+ const { renderApp } = await import('./application');
+ return renderApp(
+ params.element,
+ appMountContext,
+ params.appBasePath,
+ this.getSortedDevTools()
+ );
+ },
+ });
+ }
+
+ public start(core: CoreStart, { newPlatformDevTools }: DevToolsPluginStartDependencies) {
+ this.getSortedDevTools = newPlatformDevTools.getSortedDevTools;
+ if (this.getSortedDevTools().length === 0) {
+ core.chrome.navLinks.update('kibana:dev_tools', {
+ hidden: true,
+ });
+ }
+ }
+}
diff --git a/src/legacy/core_plugins/kibana/public/discover/angular/context/api/__tests__/_stubs.js b/src/legacy/core_plugins/kibana/public/discover/angular/context/api/__tests__/_stubs.js
index f472ff9250eb5..b3d37083b37f7 100644
--- a/src/legacy/core_plugins/kibana/public/discover/angular/context/api/__tests__/_stubs.js
+++ b/src/legacy/core_plugins/kibana/public/discover/angular/context/api/__tests__/_stubs.js
@@ -26,7 +26,8 @@ export function createIndexPatternsStub() {
get: sinon.spy(indexPatternId =>
Promise.resolve({
id: indexPatternId,
- isTimeNanosBased: () => false
+ isTimeNanosBased: () => false,
+ popularizeField: () => {},
})
),
};
diff --git a/src/legacy/core_plugins/kibana/public/discover/angular/context/query_parameters/__tests__/action_add_filter.js b/src/legacy/core_plugins/kibana/public/discover/angular/context/query_parameters/__tests__/action_add_filter.js
index b136b03bd500b..5a445a65939ed 100644
--- a/src/legacy/core_plugins/kibana/public/discover/angular/context/query_parameters/__tests__/action_add_filter.js
+++ b/src/legacy/core_plugins/kibana/public/discover/angular/context/query_parameters/__tests__/action_add_filter.js
@@ -19,32 +19,33 @@
import expect from '@kbn/expect';
import ngMock from 'ng_mock';
-import sinon from 'sinon';
import { getServices } from '../../../../kibana_services';
import { createStateStub } from './_utils';
import { QueryParameterActionsProvider } from '../actions';
-
+import { createIndexPatternsStub } from '../../api/__tests__/_stubs';
+import { npStart } from 'ui/new_platform';
describe('context app', function () {
beforeEach(ngMock.module('kibana'));
+ beforeEach(ngMock.module(function createServiceStubs($provide) {
+ $provide.value('indexPatterns', createIndexPatternsStub());
+ }));
+
describe('action addFilter', function () {
- let filterManagerStub;
let addFilter;
beforeEach(ngMock.inject(function createPrivateStubs(Private) {
- filterManagerStub = createQueryFilterStub();
- Private.stub(getServices().FilterBarQueryFilterProvider, filterManagerStub);
-
+ Private.stub(getServices().FilterBarQueryFilterProvider);
addFilter = Private(QueryParameterActionsProvider).addFilter;
}));
it('should pass the given arguments to the filterManager', function () {
const state = createStateStub();
+ const filterManagerAddStub = npStart.plugins.data.query.filterManager.addFilters;
addFilter(state)('FIELD_NAME', 'FIELD_VALUE', 'FILTER_OPERATION');
- const filterManagerAddStub = filterManagerStub.addFilters;
//get the generated filter
const generatedFilter = filterManagerAddStub.firstCall.args[0][0];
const queryKeys = Object.keys(generatedFilter.query.match_phrase);
@@ -55,20 +56,12 @@ describe('context app', function () {
it('should pass the index pattern id to the filterManager', function () {
const state = createStateStub();
+ const filterManagerAddStub = npStart.plugins.data.query.filterManager.addFilters;
addFilter(state)('FIELD_NAME', 'FIELD_VALUE', 'FILTER_OPERATION');
- const filterManagerAddStub = filterManagerStub.addFilters;
const generatedFilter = filterManagerAddStub.firstCall.args[0][0];
- expect(filterManagerAddStub.calledOnce).to.be(true);
expect(generatedFilter.meta.index).to.eql('INDEX_PATTERN_ID');
});
});
});
-
-function createQueryFilterStub() {
- return {
- addFilters: sinon.stub(),
- getAppFilters: sinon.stub(),
- };
-}
diff --git a/src/legacy/core_plugins/kibana/public/discover/angular/context/query_parameters/actions.js b/src/legacy/core_plugins/kibana/public/discover/angular/context/query_parameters/actions.js
index 9f7b180e8fe7d..10fe6c0e2eda1 100644
--- a/src/legacy/core_plugins/kibana/public/discover/angular/context/query_parameters/actions.js
+++ b/src/legacy/core_plugins/kibana/public/discover/angular/context/query_parameters/actions.js
@@ -18,7 +18,8 @@
*/
import _ from 'lodash';
-import { getServices, getFilterGenerator } from '../../../kibana_services';
+import { generateFilters } from '../../../../../../../../plugins/data/public';
+import { npStart } from 'ui/new_platform';
import {
MAX_CONTEXT_SIZE,
@@ -27,9 +28,8 @@ import {
} from './constants';
-export function QueryParameterActionsProvider(indexPatterns, Private) {
- const queryFilter = Private(getServices().FilterBarQueryFilterProvider);
- const filterGen = getFilterGenerator(queryFilter);
+export function QueryParameterActionsProvider(indexPatterns) {
+ const { filterManager } = npStart.plugins.data.query;
const setPredecessorCount = (state) => (predecessorCount) => (
state.queryParameters.predecessorCount = clamp(
@@ -55,13 +55,13 @@ export function QueryParameterActionsProvider(indexPatterns, Private) {
);
const updateFilters = () => filters => {
- queryFilter.setFilters(filters);
+ filterManager.setFilters(filters);
};
const addFilter = (state) => async (field, values, operation) => {
const indexPatternId = state.queryParameters.indexPatternId;
- const newFilters = filterGen.generate(field, values, operation, indexPatternId);
- queryFilter.addFilters(newFilters);
+ const newFilters = generateFilters(filterManager, field, values, operation, indexPatternId);
+ filterManager.addFilters(newFilters);
const indexPattern = await indexPatterns.get(indexPatternId);
indexPattern.popularizeField(field.name, 1);
};
diff --git a/src/legacy/core_plugins/kibana/public/discover/angular/discover.js b/src/legacy/core_plugins/kibana/public/discover/angular/discover.js
index ed5049aa912e0..8ee23bfb005a2 100644
--- a/src/legacy/core_plugins/kibana/public/discover/angular/discover.js
+++ b/src/legacy/core_plugins/kibana/public/discover/angular/discover.js
@@ -31,7 +31,6 @@ import './doc_table';
import { getSort } from './doc_table/lib/get_sort';
import { getSortForSearchSource } from './doc_table/lib/get_sort_for_search_source';
import * as columnActions from './doc_table/actions/columns';
-import * as filterActions from './doc_table/actions/filter';
import indexTemplate from './discover.html';
import { showOpenSearchPanel } from '../top_nav/show_open_search_panel';
@@ -41,7 +40,6 @@ import { getPainlessError } from './get_painless_error';
import {
angular,
buildVislibDimensions,
- getFilterGenerator,
getRequestInspectorStats,
getResponseInspectorStats,
getServices,
@@ -57,7 +55,7 @@ import {
subscribeWithScope,
tabifyAggResponse,
vislibSeriesResponseHandlerProvider,
- VisProvider,
+ Vis,
SavedObjectSaveModal,
} from '../kibana_services';
@@ -76,7 +74,7 @@ const {
import { getRootBreadcrumbs, getSavedSearchBreadcrumbs } from '../breadcrumbs';
import { extractTimeFilter, changeTimeFilter } from '../../../../data/public';
import { start as data } from '../../../../data/public/legacy';
-
+import { generateFilters } from '../../../../../../plugins/data/public';
const { savedQueryService } = data.search.services;
@@ -190,13 +188,11 @@ function discoverController(
localStorage,
uiCapabilities
) {
- const Vis = Private(VisProvider);
const responseHandler = vislibSeriesResponseHandlerProvider().handler;
const getUnhashableStates = Private(getUnhashableStatesProvider);
const shareContextMenuExtensions = Private(ShareContextMenuExtensionsRegistryProvider);
const queryFilter = Private(FilterBarQueryFilterProvider);
- const filterGen = getFilterGenerator(queryFilter);
const inspectorAdapters = {
requests: new RequestAdapter()
@@ -901,7 +897,8 @@ function discoverController(
// TODO: On array fields, negating does not negate the combination, rather all terms
$scope.filterQuery = function (field, values, operation) {
$scope.indexPattern.popularizeField(field, 1);
- filterActions.addFilter(field, values, operation, $scope.indexPattern.id, $scope.state, filterGen);
+ const newFilters = generateFilters(queryFilter, field, values, operation, $scope.indexPattern.id);
+ return queryFilter.addFilters(newFilters);
};
$scope.addColumn = function addColumn(columnName) {
diff --git a/src/legacy/core_plugins/kibana/public/discover/angular/doc_table/__tests__/actions/filter.js b/src/legacy/core_plugins/kibana/public/discover/angular/doc_table/__tests__/actions/filter.js
deleted file mode 100644
index 1f5db791469b9..0000000000000
--- a/src/legacy/core_plugins/kibana/public/discover/angular/doc_table/__tests__/actions/filter.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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 { addFilter } from '../../actions/filter';
-import StubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
-import NoDigestPromises from 'test_utils/no_digest_promises';
-import expect from '@kbn/expect';
-import ngMock from 'ng_mock';
-import sinon from 'sinon';
-
-function getFilterGeneratorStub() {
- return {
- add: sinon.stub()
- };
-}
-
-describe('doc table filter actions', function () {
- NoDigestPromises.activateForSuite();
-
- let filterGen;
- let indexPattern;
-
- beforeEach(ngMock.module(
- 'kibana',
- function ($provide) {
- $provide.service('indexPatterns', require('fixtures/mock_index_patterns'));
- }
- ));
-
- beforeEach(ngMock.inject(function (Private) {
- indexPattern = Private(StubbedLogstashIndexPatternProvider);
- filterGen = getFilterGeneratorStub();
- }));
-
- describe('add', function () {
-
- it('should defer to the FilterManager when dealing with a lucene query', function () {
- const state = {
- query: { query: 'foo', language: 'lucene' }
- };
- const args = ['foo', ['bar'], '+', indexPattern, ];
- addFilter('foo', ['bar'], '+', indexPattern, state, filterGen);
- expect(filterGen.add.calledOnce).to.be(true);
- expect(filterGen.add.calledWith(...args)).to.be(true);
- });
-
- });
-
-
-});
diff --git a/src/legacy/core_plugins/kibana/public/discover/angular/doc_table/_doc_table.scss b/src/legacy/core_plugins/kibana/public/discover/angular/doc_table/_doc_table.scss
index c0bcc3ab8a614..8b754d23f9604 100644
--- a/src/legacy/core_plugins/kibana/public/discover/angular/doc_table/_doc_table.scss
+++ b/src/legacy/core_plugins/kibana/public/discover/angular/doc_table/_doc_table.scss
@@ -62,6 +62,15 @@ doc-table {
margin: $euiSizeXS $euiSizeXS 0;
}
+.kbnDocTable__bar--footer {
+ position: relative;
+ margin: -($euiSize * 3) $euiSizeXS 0;
+}
+
+.kbnDocTable__padBottom {
+ padding-bottom: $euiSizeXL;
+}
+
.kbnDocTable__error {
display: flex;
flex-direction: column;
diff --git a/src/legacy/core_plugins/kibana/public/discover/angular/doc_table/doc_table.html b/src/legacy/core_plugins/kibana/public/discover/angular/doc_table/doc_table.html
index b6ac1d3fd8b4a..61bb5cbf39cbe 100644
--- a/src/legacy/core_plugins/kibana/public/discover/angular/doc_table/doc_table.html
+++ b/src/legacy/core_plugins/kibana/public/discover/angular/doc_table/doc_table.html
@@ -1,5 +1,4 @@
@@ -26,32 +25,34 @@
>
-
+
-