From 1a1e2e7b2e3d535339a8b7c486e189e7936f02cf Mon Sep 17 00:00:00 2001 From: Daniil Suleiman <31325372+sulemanof@users.noreply.github.com> Date: Fri, 20 Mar 2020 18:39:44 +0300 Subject: [PATCH 01/42] [NP] Remove `ui/agg_types` dependencies and move paginated table to kibana_legacy (#60276) * fix agg type shims and move paginated table to kibana_legacy * fix types * fix i18n ids * fix unit tests * Update imports * Remove ui/agg_types imports * Clean up vis_default_editor plugin * Remove agg_types imports in vis_type_table * Clean up x-pack * Clean up vis_type_vislib * Last cleanups * Update docs * Mock Schemas in vis_type_metric * Use data plugin mocks * Remove ui/directives/paginate reference * Remove snapshot * Remove shallow Co-authored-by: Joe Reuter Co-authored-by: Elastic Machine --- ...in-plugins-data-public.querystringinput.md | 2 +- ...na-plugin-plugins-data-public.searchbar.md | 4 +- src/dev/jest/config.js | 2 - .../np_ready/dashboard_state.test.ts | 7 - .../kibana/public/discover/kibana_services.ts | 1 - .../discover/np_ready/angular/discover.js | 4 +- .../core_plugins/kibana/public/kibana.js | 1 - .../region_map/public/region_map_type.js | 2 +- .../tile_map/public/tile_map_type.js | 2 +- .../public/directives/saved_object_finder.js | 534 +++++++++--------- .../__snapshots__/agg_params.test.tsx.snap | 70 --- .../public/components/agg.test.tsx | 5 +- .../public/components/agg.tsx | 2 +- .../public/components/agg_add.tsx | 2 +- .../public/components/agg_common_props.ts | 2 +- .../public/components/agg_group.test.tsx | 13 +- .../public/components/agg_group.tsx | 4 +- .../components/agg_group_helper.test.ts | 2 +- .../public/components/agg_group_helper.tsx | 2 +- .../public/components/agg_group_state.tsx | 2 +- .../public/components/agg_param_props.ts | 3 +- .../public/components/agg_params.test.tsx | 24 +- .../public/components/agg_params.tsx | 39 +- .../components/agg_params_helper.test.ts | 49 +- .../public/components/agg_params_helper.ts | 37 +- .../public/components/agg_params_map.ts | 7 +- .../public/components/agg_select.tsx | 3 +- .../components/controls/agg_control_props.tsx | 2 +- .../components/controls/agg_utils.test.tsx | 2 +- .../controls/components/mask_list.tsx | 4 +- .../public/components/controls/field.test.tsx | 3 +- .../public/components/controls/field.tsx | 3 +- .../public/components/controls/filter.tsx | 3 +- .../controls/has_extended_bounds.tsx | 4 +- .../components/controls/metric_agg.test.tsx | 2 +- .../components/controls/missing_bucket.tsx | 4 +- .../public/components/controls/order.tsx | 2 +- .../components/controls/order_agg.test.tsx | 2 - .../public/components/controls/order_agg.tsx | 2 +- .../public/components/controls/order_by.tsx | 3 +- .../components/controls/percentiles.test.tsx | 2 +- .../public/components/controls/sub_agg.tsx | 2 +- .../public/components/controls/sub_metric.tsx | 2 +- .../public/components/controls/test_utils.ts | 2 +- .../components/controls/time_interval.tsx | 6 +- .../controls/top_aggregate.test.tsx | 2 +- .../components/controls/top_aggregate.tsx | 2 +- .../components/controls/utils/agg_utils.ts | 2 +- .../components/controls/utils/use_handlers.ts | 2 +- .../public/components/sidebar/data_tab.tsx | 8 +- .../public/components/sidebar/sidebar.tsx | 2 +- .../components/sidebar/state/actions.ts | 2 +- .../public/components/sidebar/state/index.ts | 11 +- .../components/sidebar/state/reducers.ts | 10 +- .../public/legacy_imports.ts | 47 -- .../vis_default_editor/public/types.ts | 24 + .../vis_default_editor/public/utils.test.ts | 4 +- .../public/vis_options_props.tsx | 2 +- .../public/vis_type_agg_filter.ts | 4 +- .../vis_type_metric/public/legacy_imports.ts | 1 - .../public/metric_vis_fn.test.ts | 17 +- .../public/metric_vis_type.test.ts | 17 +- .../vis_type_metric/public/metric_vis_type.ts | 3 +- .../public/agg_table/__tests__/agg_table.js | 5 +- .../agg_table/__tests__/agg_table_group.js | 5 +- .../public/components/table_vis_options.tsx | 4 +- .../public/get_inner_angular.ts | 6 +- .../vis_type_table/public/legacy_imports.ts | 13 - .../public/table_vis_controller.test.ts | 9 +- .../vis_type_table/public/table_vis_type.ts | 3 +- .../public/legacy_imports.ts | 1 - .../public/tag_cloud_type.ts | 2 +- .../vis_type_vislib/public/area.ts | 3 +- .../components/options/gauge/style_panel.tsx | 2 +- .../options/metrics_axes/index.test.tsx | 3 +- .../components/options/metrics_axes/index.tsx | 2 +- .../vis_type_vislib/public/gauge.ts | 4 +- .../vis_type_vislib/public/goal.ts | 3 +- .../vis_type_vislib/public/heatmap.ts | 4 +- .../vis_type_vislib/public/histogram.ts | 4 +- .../vis_type_vislib/public/horizontal_bar.ts | 4 +- .../vis_type_vislib/public/legacy_imports.ts | 1 - .../vis_type_vislib/public/line.ts | 3 +- .../vis_type_vislib/public/pie.ts | 3 +- src/legacy/ui/public/agg_types/index.ts | 85 --- .../common/field_formats/utils/serialize.ts | 2 +- src/plugins/data/public/public.api.md | 6 +- src/plugins/kibana_legacy/public/index.ts | 1 + .../public/paginate/paginate.d.ts | 21 + .../public/paginate}/paginate.js | 17 +- .../public/paginate}/paginate_controls.html | 4 +- .../dashboard_mode/public/dashboard_viewer.js | 1 - .../operations/definitions/date_histogram.tsx | 9 +- x-pack/legacy/plugins/rollup/public/legacy.ts | 6 +- .../plugins/rollup/public/legacy_imports.ts | 3 +- x-pack/legacy/plugins/rollup/public/plugin.ts | 18 +- .../translations/translations/ja-JP.json | 6 +- .../translations/translations/zh-CN.json | 6 +- 98 files changed, 575 insertions(+), 729 deletions(-) delete mode 100644 src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg_params.test.tsx.snap delete mode 100644 src/legacy/core_plugins/vis_default_editor/public/legacy_imports.ts create mode 100644 src/legacy/core_plugins/vis_default_editor/public/types.ts delete mode 100644 src/legacy/ui/public/agg_types/index.ts create mode 100644 src/plugins/kibana_legacy/public/paginate/paginate.d.ts rename src/{legacy/ui/public/directives => plugins/kibana_legacy/public/paginate}/paginate.js (93%) rename src/{legacy/ui/public/directives/partials => plugins/kibana_legacy/public/paginate}/paginate_controls.html (96%) diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.querystringinput.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.querystringinput.md index 58690300b3bd6..d0d4cc491e142 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.querystringinput.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.querystringinput.md @@ -7,5 +7,5 @@ Signature: ```typescript -QueryStringInput: React.FC> +QueryStringInput: React.FC> ``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md index 5cdf938a9e47f..89c5ca800a4d4 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md @@ -7,7 +7,7 @@ Signature: ```typescript -SearchBar: React.ComponentClass, "query" | "isLoading" | "indexPatterns" | "filters" | "onQueryChange" | "customSubmitButton" | "screenTitle" | "dataTestSubj" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "refreshInterval" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "onRefresh" | "timeHistory" | "onFiltersUpdated" | "onRefreshChange">, any> & { - WrappedComponent: React.ComponentType & ReactIntl.InjectedIntlProps>; +SearchBar: React.ComponentClass, "query" | "isLoading" | "indexPatterns" | "filters" | "refreshInterval" | "screenTitle" | "dataTestSubj" | "customSubmitButton" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "onRefresh" | "timeHistory" | "onFiltersUpdated" | "onRefreshChange">, any> & { + WrappedComponent: React.ComponentType & ReactIntl.InjectedIntlProps>; } ``` diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js index 8078c32b10646..a941735c7840e 100644 --- a/src/dev/jest/config.js +++ b/src/dev/jest/config.js @@ -49,8 +49,6 @@ export default { '!packages/kbn-ui-framework/src/services/**/*/index.js', 'src/legacy/core_plugins/**/*.{js,jsx,ts,tsx}', '!src/legacy/core_plugins/**/{__test__,__snapshots__}/**/*', - 'src/legacy/ui/public/{agg_types,vis}/**/*.{ts,tsx}', - '!src/legacy/ui/public/{agg_types,vis}/**/*.d.ts', ], moduleNameMapper: { '@elastic/eui$': '/node_modules/@elastic/eui/test-env', diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_state.test.ts b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_state.test.ts index 60ea14dad19e1..08ccc1e0d1e89 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_state.test.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_state.test.ts @@ -25,13 +25,6 @@ import { InputTimeRange, TimefilterContract, TimeRange } from 'src/plugins/data/ import { ViewMode } from 'src/plugins/embeddable/public'; import { createKbnUrlStateStorage } from 'src/plugins/kibana_utils/public'; -jest.mock('ui/agg_types', () => ({ - aggTypes: { - metrics: [], - buckets: [], - }, -})); - describe('DashboardState', function() { let dashboardState: DashboardStateManager; const savedDashboard = getSavedDashboardMock(); diff --git a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts index 725e94f16e2e8..cf76a9355e384 100644 --- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts @@ -53,7 +53,6 @@ export { wrapInI18nContext } from 'ui/i18n'; import { search } from '../../../../../plugins/data/public'; export const { getRequestInspectorStats, getResponseInspectorStats, tabifyAggResponse } = search; // @ts-ignore -export { intervalOptions } from 'ui/agg_types'; // @ts-ignore export { timezoneProvider } from 'ui/vis/lib/timezone'; export { diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js index 2857f8720d8dc..e45ab2a7d7675 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js @@ -44,7 +44,6 @@ import { getRequestInspectorStats, getResponseInspectorStats, getServices, - intervalOptions, unhashUrl, subscribeWithScope, tabifyAggResponse, @@ -76,6 +75,7 @@ import { connectToQueryState, syncQueryStateWithUrl, getDefaultQuery, + search, } from '../../../../../../../plugins/data/public'; import { getIndexPatternId } from '../helpers/get_index_pattern_id'; import { addFatalError } from '../../../../../../../plugins/kibana_legacy/public'; @@ -285,7 +285,7 @@ function discoverController( mode: 'absolute', }); }; - $scope.intervalOptions = intervalOptions; + $scope.intervalOptions = search.aggs.intervalOptions; $scope.minimumVisibleRows = 50; $scope.fetchStatus = fetchStatuses.UNINITIALIZED; $scope.showSaveQuery = uiCapabilities.discover.saveQuery; diff --git a/src/legacy/core_plugins/kibana/public/kibana.js b/src/legacy/core_plugins/kibana/public/kibana.js index 04eaf2cbe2679..df6b08ef76556 100644 --- a/src/legacy/core_plugins/kibana/public/kibana.js +++ b/src/legacy/core_plugins/kibana/public/kibana.js @@ -48,7 +48,6 @@ import './dashboard/legacy'; import './management'; import './dev_tools'; import 'ui/agg_response'; -import 'ui/agg_types'; import { showAppRedirectNotification } from '../../../../plugins/kibana_legacy/public'; import 'leaflet'; import { localApplicationService } from './local_application_service'; diff --git a/src/legacy/core_plugins/region_map/public/region_map_type.js b/src/legacy/core_plugins/region_map/public/region_map_type.js index a03fbe4b291e2..9a1a76362e094 100644 --- a/src/legacy/core_plugins/region_map/public/region_map_type.js +++ b/src/legacy/core_plugins/region_map/public/region_map_type.js @@ -18,12 +18,12 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { Schemas } from 'ui/agg_types'; import { mapToLayerWithId } from './util'; import { createRegionMapVisualization } from './region_map_visualization'; import { Status } from '../../visualizations/public'; import { RegionMapOptions } from './components/region_map_options'; import { truncatedColorSchemas } from '../../../../plugins/charts/public'; +import { Schemas } from '../../vis_default_editor/public'; // TODO: reference to TILE_MAP plugin should be removed import { ORIGIN } from '../../tile_map/common/origin'; diff --git a/src/legacy/core_plugins/tile_map/public/tile_map_type.js b/src/legacy/core_plugins/tile_map/public/tile_map_type.js index 544b63abe82c7..0809bf6ecbab6 100644 --- a/src/legacy/core_plugins/tile_map/public/tile_map_type.js +++ b/src/legacy/core_plugins/tile_map/public/tile_map_type.js @@ -21,8 +21,8 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { convertToGeoJson } from 'ui/vis/map/convert_to_geojson'; -import { Schemas } from 'ui/agg_types'; +import { Schemas } from '../../vis_default_editor/public'; import { Status } from '../../visualizations/public'; import { createTileMapVisualization } from './tile_map_visualization'; import { TileMapOptions } from './components/tile_map_options'; diff --git a/src/legacy/core_plugins/timelion/public/directives/saved_object_finder.js b/src/legacy/core_plugins/timelion/public/directives/saved_object_finder.js index 111db0a83ffc4..fb54c36df27d7 100644 --- a/src/legacy/core_plugins/timelion/public/directives/saved_object_finder.js +++ b/src/legacy/core_plugins/timelion/public/directives/saved_object_finder.js @@ -21,287 +21,295 @@ import _ from 'lodash'; import rison from 'rison-node'; import { uiModules } from 'ui/modules'; import 'ui/directives/input_focus'; -import 'ui/directives/paginate'; import savedObjectFinderTemplate from './saved_object_finder.html'; import { savedSheetLoader } from '../services/saved_sheets'; import { keyMap } from 'ui/directives/key_map'; +import { + PaginateControlsDirectiveProvider, + PaginateDirectiveProvider, +} from '../../../../../plugins/kibana_legacy/public'; const module = uiModules.get('kibana'); -module.directive('savedObjectFinder', function($location, kbnUrl, Private, config) { - return { - restrict: 'E', - scope: { - type: '@', - // optional make-url attr, sets the userMakeUrl in our scope - userMakeUrl: '=?makeUrl', - // optional on-choose attr, sets the userOnChoose in our scope - userOnChoose: '=?onChoose', - // optional useLocalManagement attr, removes link to management section - useLocalManagement: '=?useLocalManagement', - /** - * @type {function} - an optional function. If supplied an `Add new X` button is shown - * and this function is called when clicked. - */ - onAddNew: '=', - /** - * @{type} boolean - set this to true, if you don't want the search box above the - * table to automatically gain focus once loaded - */ - disableAutoFocus: '=', - }, - template: savedObjectFinderTemplate, - controllerAs: 'finder', - controller: function($scope, $element) { - const self = this; - - // the text input element - const $input = $element.find('input[ng-model=filter]'); - - // The number of items to show in the list - $scope.perPage = config.get('savedObjects:perPage'); - - // the list that will hold the suggestions - const $list = $element.find('ul'); - - // the current filter string, used to check that returned results are still useful - let currentFilter = $scope.filter; - - // the most recently entered search/filter - let prevSearch; - - // the list of hits, used to render display - self.hits = []; - - self.service = savedSheetLoader; - self.properties = self.service.loaderProperties; - - filterResults(); - - /** - * Boolean that keeps track of whether hits are sorted ascending (true) - * or descending (false) by title - * @type {Boolean} - */ - self.isAscending = true; - - /** - * Sorts saved object finder hits either ascending or descending - * @param {Array} hits Array of saved finder object hits - * @return {Array} Array sorted either ascending or descending - */ - self.sortHits = function(hits) { - self.isAscending = !self.isAscending; - self.hits = self.isAscending ? _.sortBy(hits, 'title') : _.sortBy(hits, 'title').reverse(); - }; - - /** - * Passed the hit objects and will determine if the - * hit should have a url in the UI, returns it if so - * @return {string|null} - the url or nothing - */ - self.makeUrl = function(hit) { - if ($scope.userMakeUrl) { - return $scope.userMakeUrl(hit); - } - - if (!$scope.userOnChoose) { - return hit.url; - } +module + .directive('paginate', PaginateDirectiveProvider) + .directive('paginateControls', PaginateControlsDirectiveProvider) + .directive('savedObjectFinder', function($location, kbnUrl, Private, config) { + return { + restrict: 'E', + scope: { + type: '@', + // optional make-url attr, sets the userMakeUrl in our scope + userMakeUrl: '=?makeUrl', + // optional on-choose attr, sets the userOnChoose in our scope + userOnChoose: '=?onChoose', + // optional useLocalManagement attr, removes link to management section + useLocalManagement: '=?useLocalManagement', + /** + * @type {function} - an optional function. If supplied an `Add new X` button is shown + * and this function is called when clicked. + */ + onAddNew: '=', + /** + * @{type} boolean - set this to true, if you don't want the search box above the + * table to automatically gain focus once loaded + */ + disableAutoFocus: '=', + }, + template: savedObjectFinderTemplate, + controllerAs: 'finder', + controller: function($scope, $element) { + const self = this; + + // the text input element + const $input = $element.find('input[ng-model=filter]'); + + // The number of items to show in the list + $scope.perPage = config.get('savedObjects:perPage'); + + // the list that will hold the suggestions + const $list = $element.find('ul'); + + // the current filter string, used to check that returned results are still useful + let currentFilter = $scope.filter; + + // the most recently entered search/filter + let prevSearch; + + // the list of hits, used to render display + self.hits = []; + + self.service = savedSheetLoader; + self.properties = self.service.loaderProperties; - return '#'; - }; + filterResults(); - self.preventClick = function($event) { - $event.preventDefault(); - }; + /** + * Boolean that keeps track of whether hits are sorted ascending (true) + * or descending (false) by title + * @type {Boolean} + */ + self.isAscending = true; + + /** + * Sorts saved object finder hits either ascending or descending + * @param {Array} hits Array of saved finder object hits + * @return {Array} Array sorted either ascending or descending + */ + self.sortHits = function(hits) { + self.isAscending = !self.isAscending; + self.hits = self.isAscending + ? _.sortBy(hits, 'title') + : _.sortBy(hits, 'title').reverse(); + }; + + /** + * Passed the hit objects and will determine if the + * hit should have a url in the UI, returns it if so + * @return {string|null} - the url or nothing + */ + self.makeUrl = function(hit) { + if ($scope.userMakeUrl) { + return $scope.userMakeUrl(hit); + } - /** - * Called when a hit object is clicked, can override the - * url behavior if necessary. - */ - self.onChoose = function(hit, $event) { - if ($scope.userOnChoose) { - $scope.userOnChoose(hit, $event); - } + if (!$scope.userOnChoose) { + return hit.url; + } - const url = self.makeUrl(hit); - if (!url || url === '#' || url.charAt(0) !== '#') return; + return '#'; + }; - $event.preventDefault(); + self.preventClick = function($event) { + $event.preventDefault(); + }; - // we want the '/path', not '#/path' - kbnUrl.change(url.substr(1)); - }; + /** + * Called when a hit object is clicked, can override the + * url behavior if necessary. + */ + self.onChoose = function(hit, $event) { + if ($scope.userOnChoose) { + $scope.userOnChoose(hit, $event); + } - $scope.$watch('filter', function(newFilter) { - // ensure that the currentFilter changes from undefined to '' - // which triggers - currentFilter = newFilter || ''; - filterResults(); - }); - - $scope.pageFirstItem = 0; - $scope.pageLastItem = 0; - $scope.onPageChanged = page => { - $scope.pageFirstItem = page.firstItem; - $scope.pageLastItem = page.lastItem; - }; - - //manages the state of the keyboard selector - self.selector = { - enabled: false, - index: -1, - }; - - self.getLabel = function() { - return _.words(self.properties.nouns) - .map(_.capitalize) - .join(' '); - }; - - //key handler for the filter text box - self.filterKeyDown = function($event) { - switch (keyMap[$event.keyCode]) { - case 'enter': - if (self.hitCount !== 1) return; - - const hit = self.hits[0]; - if (!hit) return; - - self.onChoose(hit, $event); - $event.preventDefault(); - break; - } - }; + const url = self.makeUrl(hit); + if (!url || url === '#' || url.charAt(0) !== '#') return; - //key handler for the list items - self.hitKeyDown = function($event, page, paginate) { - switch (keyMap[$event.keyCode]) { - case 'tab': - if (!self.selector.enabled) break; + $event.preventDefault(); - self.selector.index = -1; - self.selector.enabled = false; + // we want the '/path', not '#/path' + kbnUrl.change(url.substr(1)); + }; - //if the user types shift-tab return to the textbox - //if the user types tab, set the focus to the currently selected hit. - if ($event.shiftKey) { - $input.focus(); - } else { - $list.find('li.active a').focus(); - } + $scope.$watch('filter', function(newFilter) { + // ensure that the currentFilter changes from undefined to '' + // which triggers + currentFilter = newFilter || ''; + filterResults(); + }); - $event.preventDefault(); - break; - case 'down': - if (!self.selector.enabled) break; + $scope.pageFirstItem = 0; + $scope.pageLastItem = 0; + $scope.onPageChanged = page => { + $scope.pageFirstItem = page.firstItem; + $scope.pageLastItem = page.lastItem; + }; + + //manages the state of the keyboard selector + self.selector = { + enabled: false, + index: -1, + }; + + self.getLabel = function() { + return _.words(self.properties.nouns) + .map(_.capitalize) + .join(' '); + }; + + //key handler for the filter text box + self.filterKeyDown = function($event) { + switch (keyMap[$event.keyCode]) { + case 'enter': + if (self.hitCount !== 1) return; + + const hit = self.hits[0]; + if (!hit) return; + + self.onChoose(hit, $event); + $event.preventDefault(); + break; + } + }; + + //key handler for the list items + self.hitKeyDown = function($event, page, paginate) { + switch (keyMap[$event.keyCode]) { + case 'tab': + if (!self.selector.enabled) break; + + self.selector.index = -1; + self.selector.enabled = false; + + //if the user types shift-tab return to the textbox + //if the user types tab, set the focus to the currently selected hit. + if ($event.shiftKey) { + $input.focus(); + } else { + $list.find('li.active a').focus(); + } + + $event.preventDefault(); + break; + case 'down': + if (!self.selector.enabled) break; + + if (self.selector.index + 1 < page.length) { + self.selector.index += 1; + } + $event.preventDefault(); + break; + case 'up': + if (!self.selector.enabled) break; + + if (self.selector.index > 0) { + self.selector.index -= 1; + } + $event.preventDefault(); + break; + case 'right': + if (!self.selector.enabled) break; + + if (page.number < page.count) { + paginate.goToPage(page.number + 1); + self.selector.index = 0; + selectTopHit(); + } + $event.preventDefault(); + break; + case 'left': + if (!self.selector.enabled) break; + + if (page.number > 1) { + paginate.goToPage(page.number - 1); + self.selector.index = 0; + selectTopHit(); + } + $event.preventDefault(); + break; + case 'escape': + if (!self.selector.enabled) break; - if (self.selector.index + 1 < page.length) { - self.selector.index += 1; - } - $event.preventDefault(); - break; - case 'up': - if (!self.selector.enabled) break; + $input.focus(); + $event.preventDefault(); + break; + case 'enter': + if (!self.selector.enabled) break; + + const hitIndex = (page.number - 1) * paginate.perPage + self.selector.index; + const hit = self.hits[hitIndex]; + if (!hit) break; + + self.onChoose(hit, $event); + $event.preventDefault(); + break; + case 'shift': + break; + default: + $input.focus(); + break; + } + }; + + self.hitBlur = function() { + self.selector.index = -1; + self.selector.enabled = false; + }; + + self.manageObjects = function(type) { + $location.url('/management/kibana/objects?_a=' + rison.encode({ tab: type })); + }; + + self.hitCountNoun = function() { + return (self.hitCount === 1 ? self.properties.noun : self.properties.nouns).toLowerCase(); + }; + + function selectTopHit() { + setTimeout(function() { + //triggering a focus event kicks off a new angular digest cycle. + $list.find('a:first').focus(); + }, 0); + } - if (self.selector.index > 0) { - self.selector.index -= 1; - } - $event.preventDefault(); - break; - case 'right': - if (!self.selector.enabled) break; - - if (page.number < page.count) { - paginate.goToPage(page.number + 1); - self.selector.index = 0; - selectTopHit(); - } - $event.preventDefault(); - break; - case 'left': - if (!self.selector.enabled) break; - - if (page.number > 1) { - paginate.goToPage(page.number - 1); - self.selector.index = 0; - selectTopHit(); + function filterResults() { + if (!self.service) return; + if (!self.properties) return; + + // track the filter that we use for this search, + // but ensure that we don't search for the same + // thing twice. This is called from multiple places + // and needs to be smart about when it actually searches + const filter = currentFilter; + if (prevSearch === filter) return; + + prevSearch = filter; + + const isLabsEnabled = config.get('visualize:enableLabs'); + self.service.find(filter).then(function(hits) { + hits.hits = hits.hits.filter( + hit => isLabsEnabled || _.get(hit, 'type.stage') !== 'experimental' + ); + hits.total = hits.hits.length; + + // ensure that we don't display old results + // as we can't really cancel requests + if (currentFilter === filter) { + self.hitCount = hits.total; + self.hits = _.sortBy(hits.hits, 'title'); } - $event.preventDefault(); - break; - case 'escape': - if (!self.selector.enabled) break; - - $input.focus(); - $event.preventDefault(); - break; - case 'enter': - if (!self.selector.enabled) break; - - const hitIndex = (page.number - 1) * paginate.perPage + self.selector.index; - const hit = self.hits[hitIndex]; - if (!hit) break; - - self.onChoose(hit, $event); - $event.preventDefault(); - break; - case 'shift': - break; - default: - $input.focus(); - break; + }); } - }; - - self.hitBlur = function() { - self.selector.index = -1; - self.selector.enabled = false; - }; - - self.manageObjects = function(type) { - $location.url('/management/kibana/objects?_a=' + rison.encode({ tab: type })); - }; - - self.hitCountNoun = function() { - return (self.hitCount === 1 ? self.properties.noun : self.properties.nouns).toLowerCase(); - }; - - function selectTopHit() { - setTimeout(function() { - //triggering a focus event kicks off a new angular digest cycle. - $list.find('a:first').focus(); - }, 0); - } - - function filterResults() { - if (!self.service) return; - if (!self.properties) return; - - // track the filter that we use for this search, - // but ensure that we don't search for the same - // thing twice. This is called from multiple places - // and needs to be smart about when it actually searches - const filter = currentFilter; - if (prevSearch === filter) return; - - prevSearch = filter; - - const isLabsEnabled = config.get('visualize:enableLabs'); - self.service.find(filter).then(function(hits) { - hits.hits = hits.hits.filter( - hit => isLabsEnabled || _.get(hit, 'type.stage') !== 'experimental' - ); - hits.total = hits.hits.length; - - // ensure that we don't display old results - // as we can't really cancel requests - if (currentFilter === filter) { - self.hitCount = hits.total; - self.hits = _.sortBy(hits.hits, 'title'); - } - }); - } - }, - }; -}); + }, + }; + }); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg_params.test.tsx.snap b/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg_params.test.tsx.snap deleted file mode 100644 index 028d0b8016693..0000000000000 --- a/src/legacy/core_plugins/vis_default_editor/public/components/__snapshots__/agg_params.test.tsx.snap +++ /dev/null @@ -1,70 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`DefaultEditorAggParams component should init with the default set of params 1`] = ` - - - - - - - - - -`; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx index 22e0ebb3d30dc..7e715be25bff3 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg.test.tsx @@ -21,17 +21,14 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import { act } from 'react-dom/test-utils'; -import { IndexPattern } from 'src/plugins/data/public'; +import { IndexPattern, IAggType, AggGroupNames } from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggType, AggGroupNames } from '../legacy_imports'; import { DefaultEditorAgg, DefaultEditorAggProps } from './agg'; import { DefaultEditorAggParams } from './agg_params'; import { AGGS_ACTION_KEYS } from './agg_group_state'; import { Schema } from '../schemas'; -jest.mock('ui/new_platform'); - jest.mock('./agg_params', () => ({ DefaultEditorAggParams: () => null, })); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg.tsx index 30ccd4f0b6cae..2a45273207623 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg.tsx @@ -28,7 +28,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { IAggConfig } from '../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { DefaultEditorAggParams } from './agg_params'; import { DefaultEditorAggCommonProps } from './agg_common_props'; import { AGGS_ACTION_KEYS, AggsAction } from './agg_group_state'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_add.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_add.tsx index 24cb83498d4d0..9df4ea58e0f07 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_add.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_add.tsx @@ -29,7 +29,7 @@ import { } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; -import { IAggConfig, AggGroupNames } from '../legacy_imports'; +import { IAggConfig, AggGroupNames } from '../../../../../plugins/data/public'; import { Schema } from '../schemas'; interface DefaultEditorAggAddProps { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts index 1a97cc5c4d967..ec92f511b6eee 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_common_props.ts @@ -18,7 +18,7 @@ */ import { VisState, VisParams } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggType, IAggConfig, IAggGroupNames } from '../legacy_imports'; +import { IAggType, IAggConfig, IAggGroupNames } from 'src/plugins/data/public'; import { Schema } from '../schemas'; type AggId = IAggConfig['id']; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx index ec467480539ab..63f5e696c99f4 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx @@ -21,7 +21,7 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import { act } from 'react-dom/test-utils'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggConfigs, IAggConfig } from '../legacy_imports'; +import { IAggConfigs, IAggConfig } from 'src/plugins/data/public'; import { DefaultEditorAggGroup, DefaultEditorAggGroupProps } from './agg_group'; import { DefaultEditorAgg } from './agg'; import { DefaultEditorAggAdd } from './agg_add'; @@ -36,17 +36,6 @@ jest.mock('@elastic/eui', () => ({ EuiPanel: 'eui-panel', })); -jest.mock('../legacy_imports', () => ({ - aggGroupNamesMap: () => ({ - metrics: 'Metrics', - buckets: 'Buckets', - }), - AggGroupNames: { - Metrics: 'metrics', - Buckets: 'buckets', - }, -})); - jest.mock('./agg', () => ({ DefaultEditorAgg: () =>
, })); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.tsx index a15a98d4983ce..600612f2cf9d8 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group.tsx @@ -30,7 +30,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { IAggConfig, aggGroupNamesMap, AggGroupNames } from '../legacy_imports'; +import { AggGroupNames, search, IAggConfig } from '../../../../../plugins/data/public'; import { DefaultEditorAgg } from './agg'; import { DefaultEditorAggAdd } from './agg_add'; import { AddSchema, ReorderAggs, DefaultEditorAggCommonProps } from './agg_common_props'; @@ -68,7 +68,7 @@ function DefaultEditorAggGroup({ setTouched, setValidity, }: DefaultEditorAggGroupProps) { - const groupNameLabel = (aggGroupNamesMap() as any)[groupName]; + const groupNameLabel = (search.aggs.aggGroupNamesMap() as any)[groupName]; // e.g. buckets can have no aggs const schemaNames = getSchemasByGroup(schemas, groupName).map(s => s.name); const group: IAggConfig[] = useMemo( diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.test.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.test.ts index aebece29e7ae6..3693f1b1e3091 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.test.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.test.ts @@ -17,7 +17,7 @@ * under the License. */ -import { IAggConfig } from '../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { isAggRemovable, calcAggIsTooLow, diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.tsx index 0a8c5c3077ada..9a4cca940baea 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_helper.tsx @@ -18,7 +18,7 @@ */ import { findIndex, isEmpty } from 'lodash'; -import { IAggConfig } from '../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { AggsState } from './agg_group_state'; import { Schema, getSchemaByName } from '../schemas'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_state.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_state.tsx index d022297ae72b3..bfd5bec339b1f 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_state.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_group_state.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { IAggConfig } from '../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; export enum AGGS_ACTION_KEYS { TOUCHED = 'aggsTouched', diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts index cdc5a4c8f8a77..7c2852798b403 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_param_props.ts @@ -17,9 +17,8 @@ * under the License. */ -import { IndexPatternField } from 'src/plugins/data/public'; +import { IAggConfig, AggParam, IndexPatternField } from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggConfig, AggParam } from '../legacy_imports'; import { ComboBoxGroupedOptions } from '../utils'; import { EditorConfig } from './utils'; import { Schema } from '../schemas'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx index d2821566fcb37..cd6486b6a1532 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.test.tsx @@ -18,12 +18,16 @@ */ import React from 'react'; -import { mount, shallow } from 'enzyme'; +import { mount } from 'enzyme'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { IndexPattern } from 'src/plugins/data/public'; -import { DefaultEditorAggParams, DefaultEditorAggParamsProps } from './agg_params'; -import { IAggConfig, AggGroupNames } from '../legacy_imports'; +import { IndexPattern, IAggConfig, AggGroupNames } from 'src/plugins/data/public'; +import { + DefaultEditorAggParams as PureDefaultEditorAggParams, + DefaultEditorAggParamsProps, +} from './agg_params'; +import { KibanaContextProvider } from '../../../../../plugins/kibana_react/public'; +import { dataPluginMock } from '../../../../../plugins/data/public/mocks'; const mockEditorConfig = { useNormalizedEsInterval: { hidden: false, fixedValue: false }, @@ -34,8 +38,12 @@ const mockEditorConfig = { timeBase: '1m', }, }; +const DefaultEditorAggParams = (props: DefaultEditorAggParamsProps) => ( + + + +); -jest.mock('ui/new_platform'); jest.mock('./utils', () => ({ getEditorConfig: jest.fn(() => mockEditorConfig), })); @@ -109,12 +117,6 @@ describe('DefaultEditorAggParams component', () => { }; }); - it('should init with the default set of params', () => { - const comp = shallow(); - - expect(comp).toMatchSnapshot(); - }); - it('should reset the validity to true when destroyed', () => { const comp = mount(); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx index 510c21af95da1..b1555b76500d0 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params.tsx @@ -22,8 +22,7 @@ import { EuiForm, EuiAccordion, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import useUnmount from 'react-use/lib/useUnmount'; -import { IndexPattern } from 'src/plugins/data/public'; -import { IAggConfig, AggGroupNames } from '../legacy_imports'; +import { IAggConfig, IndexPattern, AggGroupNames } from '../../../../../plugins/data/public'; import { DefaultEditorAggSelect } from './agg_select'; import { DefaultEditorAggParam } from './agg_param'; @@ -41,6 +40,8 @@ import { import { DefaultEditorCommonProps } from './agg_common_props'; import { EditorParamConfig, TimeIntervalParam, FixedParam, getEditorConfig } from './utils'; import { Schema, getSchemaByName } from '../schemas'; +import { useKibana } from '../../../../../plugins/kibana_react/public'; +import { VisDefaultEditorKibanaServices } from '../types'; const FIXED_VALUE_PROP = 'fixedValue'; const DEFAULT_PROP = 'default'; @@ -83,18 +84,24 @@ function DefaultEditorAggParams({ allowedAggs = [], hideCustomLabel = false, }: DefaultEditorAggParamsProps) { - const schema = getSchemaByName(schemas, agg.schema); - const { title } = schema; - const aggFilter = [...allowedAggs, ...(schema.aggFilter || [])]; + const schema = useMemo(() => getSchemaByName(schemas, agg.schema), [agg.schema, schemas]); + const aggFilter = useMemo(() => [...allowedAggs, ...(schema.aggFilter || [])], [ + allowedAggs, + schema.aggFilter, + ]); + const { services } = useKibana(); + const aggTypes = useMemo(() => services.data.search.aggs.types.getAll(), [ + services.data.search.aggs.types, + ]); const groupedAggTypeOptions = useMemo( - () => getAggTypeOptions(agg, indexPattern, groupName, aggFilter), - [agg, indexPattern, groupName, aggFilter] + () => getAggTypeOptions(aggTypes, agg, indexPattern, groupName, aggFilter), + [aggTypes, agg, indexPattern, groupName, aggFilter] ); const error = aggIsTooLow ? i18n.translate('visDefaultEditor.aggParams.errors.aggWrongRunOrderErrorMessage', { defaultMessage: '"{schema}" aggs must run before all other buckets!', - values: { schema: title }, + values: { schema: schema.title }, }) : ''; const aggTypeName = agg.type?.name; @@ -105,8 +112,20 @@ function DefaultEditorAggParams({ fieldName, ]); const params = useMemo( - () => getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas, hideCustomLabel }), - [agg, editorConfig, metricAggs, state, schemas, hideCustomLabel] + () => + getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas, hideCustomLabel }, + services.data.search.__LEGACY.aggTypeFieldFilters + ), + [ + agg, + editorConfig, + metricAggs, + state, + schemas, + hideCustomLabel, + services.data.search.__LEGACY.aggTypeFieldFilters, + ] ); const allParams = [...params.basic, ...params.advanced]; const [paramsState, onChangeParamsState] = useReducer( diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts index 047467750794b..f2ebbdc87a60a 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.test.ts @@ -17,9 +17,15 @@ * under the License. */ -import { IndexPattern } from 'src/plugins/data/public'; +import { + AggGroupNames, + BUCKET_TYPES, + IAggConfig, + IAggType, + IndexPattern, + IndexPatternField, +} from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggConfig, IAggType, AggGroupNames, BUCKET_TYPES } from '../legacy_imports'; import { getAggParamsToRender, getAggTypeOptions, @@ -33,7 +39,11 @@ jest.mock('../utils', () => ({ groupAndSortBy: jest.fn(() => ['indexedFields']), })); -jest.mock('ui/new_platform'); +const mockFilter: any = { + filter(fields: IndexPatternField[]): IndexPatternField[] { + return fields; + }, +}; describe('DefaultEditorAggParams helpers', () => { describe('getAggParamsToRender', () => { @@ -62,14 +72,20 @@ describe('DefaultEditorAggParams helpers', () => { }, schema: 'metric', } as IAggConfig; - const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas }); + const params = getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas }, + mockFilter + ); expect(params).toEqual(emptyParams); }); it('should not create any param if there is no agg type', () => { agg = { schema: 'metric' } as IAggConfig; - const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas }); + const params = getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas }, + mockFilter + ); expect(params).toEqual(emptyParams); }); @@ -85,7 +101,10 @@ describe('DefaultEditorAggParams helpers', () => { hidden: true, }, }; - const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas }); + const params = getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas }, + mockFilter + ); expect(params).toEqual(emptyParams); }); @@ -97,7 +116,10 @@ describe('DefaultEditorAggParams helpers', () => { }, schema: 'metric2', } as any) as IAggConfig; - const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas }); + const params = getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas }, + mockFilter + ); expect(params).toEqual(emptyParams); }); @@ -136,7 +158,10 @@ describe('DefaultEditorAggParams helpers', () => { field: 'field', }, } as any) as IAggConfig; - const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state, schemas }); + const params = getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas }, + mockFilter + ); expect(params).toEqual({ basic: [ @@ -172,7 +197,13 @@ describe('DefaultEditorAggParams helpers', () => { describe('getAggTypeOptions', () => { it('should return agg type options grouped by subtype', () => { const indexPattern = {} as IndexPattern; - const aggs = getAggTypeOptions({} as IAggConfig, indexPattern, 'metrics', []); + const aggs = getAggTypeOptions( + { metrics: [] }, + {} as IAggConfig, + indexPattern, + 'metrics', + [] + ); expect(aggs).toEqual(['indexedFields']); }); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts index 520ff6ffc5ff5..e07bf81697579 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_helper.ts @@ -19,23 +19,23 @@ import { get, isEmpty } from 'lodash'; -import { IndexPattern, IndexPatternField } from 'src/plugins/data/public'; -import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { groupAndSortBy, ComboBoxGroupedOptions } from '../utils'; -import { AggTypeState, AggParamsState } from './agg_params_state'; -import { AggParamEditorProps } from './agg_param_props'; -import { aggParamsMap } from './agg_params_map'; import { - aggTypeFilters, - aggTypeFieldFilters, - aggTypes, + AggTypeFieldFilters, IAggConfig, AggParam, IFieldParamType, IAggType, -} from '../legacy_imports'; + IndexPattern, + IndexPatternField, +} from 'src/plugins/data/public'; +import { VisState } from 'src/legacy/core_plugins/visualizations/public'; +import { groupAndSortBy, ComboBoxGroupedOptions } from '../utils'; +import { AggTypeState, AggParamsState } from './agg_params_state'; +import { AggParamEditorProps } from './agg_param_props'; +import { aggParamsMap } from './agg_params_map'; import { EditorConfig } from './utils'; import { Schema, getSchemaByName } from '../schemas'; +import { search } from '../../../../../plugins/data/public'; interface ParamInstanceBase { agg: IAggConfig; @@ -53,14 +53,10 @@ export interface ParamInstance extends ParamInstanceBase { value: unknown; } -function getAggParamsToRender({ - agg, - editorConfig, - metricAggs, - state, - schemas, - hideCustomLabel, -}: ParamInstanceBase) { +function getAggParamsToRender( + { agg, editorConfig, metricAggs, state, schemas, hideCustomLabel }: ParamInstanceBase, + aggTypeFieldFilters: AggTypeFieldFilters +) { const params = { basic: [] as ParamInstance[], advanced: [] as ParamInstance[], @@ -136,13 +132,14 @@ function getAggParamsToRender({ } function getAggTypeOptions( + aggTypes: any, agg: IAggConfig, indexPattern: IndexPattern, groupName: string, allowedAggs: string[] ): ComboBoxGroupedOptions { - const aggTypeOptions = aggTypeFilters.filter( - (aggTypes as any)[groupName], + const aggTypeOptions = search.aggs.aggTypeFilters.filter( + aggTypes[groupName], indexPattern, agg, allowedAggs diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_map.ts b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_map.ts index 7caa775dd4fa4..4517313b6fd6e 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_map.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_params_map.ts @@ -22,11 +22,12 @@ import { AggGroupNames, BUCKET_TYPES, METRIC_TYPES, - siblingPipelineType, - parentPipelineType, -} from '../legacy_imports'; + search, +} from '../../../../../plugins/data/public'; import { wrapWithInlineComp } from './controls/utils'; +const { siblingPipelineType, parentPipelineType } = search.aggs; + const buckets = { [BUCKET_TYPES.DATE_HISTOGRAM]: { scaleMetricValues: controls.ScaleMetricsParamEditor, diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/agg_select.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/agg_select.tsx index 4d969a2d8ec6c..7ee432946f3c8 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/agg_select.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/agg_select.tsx @@ -23,9 +23,8 @@ import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow, EuiLink, EuiText } fr import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { IndexPattern } from 'src/plugins/data/public'; +import { IAggType, IndexPattern } from 'src/plugins/data/public'; import { useKibana } from '../../../../../plugins/kibana_react/public'; -import { IAggType } from '../legacy_imports'; import { ComboBoxGroupedOptions } from '../utils'; import { AGG_TYPE_ACTION_KEYS, AggTypeAction } from './agg_params_state'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_control_props.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_control_props.tsx index 7f04b851902de..98540d3414f2d 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_control_props.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_control_props.tsx @@ -18,7 +18,7 @@ */ import { VisParams } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggConfig } from '../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { DefaultEditorAggCommonProps } from '../agg_common_props'; export interface AggControlProps { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_utils.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_utils.test.tsx index 0b847e3747b30..0c1e93bc1e646 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_utils.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/agg_utils.test.tsx @@ -20,7 +20,7 @@ import React, { FunctionComponent } from 'react'; import { mount, ReactWrapper } from 'enzyme'; -import { IAggConfig } from '../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { safeMakeLabel, useAvailableOptions, diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/components/mask_list.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/components/mask_list.tsx index 625b09b05d28f..f6edecbbcbd70 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/components/mask_list.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/components/mask_list.tsx @@ -22,7 +22,7 @@ import { EuiFieldText, EuiFlexItem } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { InputList, InputListConfig, InputObject, InputModel, InputItem } from './input_list'; -import { CidrMask } from '../../../legacy_imports'; +import { search } from '../../../../../../../plugins/data/public'; const EMPTY_STRING = ''; @@ -47,7 +47,7 @@ function MaskList({ showValidation, onBlur, ...rest }: MaskListProps) { defaultValue: { mask: { model: '0.0.0.0/1', value: '0.0.0.0/1', isInvalid: false }, }, - validateClass: CidrMask, + validateClass: search.aggs.CidrMask, getModelValue: (item: MaskObject = {}) => ({ mask: { model: item.mask || EMPTY_STRING, diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx index 186738d0f551c..1043431475494 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.test.tsx @@ -22,11 +22,10 @@ import { act } from 'react-dom/test-utils'; import { mount, shallow, ReactWrapper } from 'enzyme'; import { EuiComboBoxProps, EuiComboBox } from '@elastic/eui'; -import { IndexPatternField } from 'src/plugins/data/public'; +import { IAggConfig, IndexPatternField } from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; import { ComboBoxGroupedOptions } from '../../utils'; import { FieldParamEditor, FieldParamEditorProps } from './field'; -import { IAggConfig } from '../../legacy_imports'; function callComboBoxOnChange(comp: ReactWrapper, value: any = []) { const comboBoxProps = comp.find(EuiComboBox).props() as EuiComboBoxProps; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.tsx index 0ec00ab6f20f0..59642ae4c25f7 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/field.tsx @@ -23,8 +23,7 @@ import React, { useEffect, useState, useCallback } from 'react'; import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { IndexPatternField } from 'src/plugins/data/public'; -import { AggParam, IAggConfig, IFieldParamType } from '../../legacy_imports'; +import { AggParam, IAggConfig, IFieldParamType, IndexPatternField } from 'src/plugins/data/public'; import { formatListAsProse, parseCommaSeparatedList, useValidation } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; import { ComboBoxGroupedOptions } from '../../utils'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/filter.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/filter.tsx index 3622b27bad403..e2e7c2895093e 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/filter.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/filter.tsx @@ -21,8 +21,7 @@ import React, { useState } from 'react'; import { EuiForm, EuiButtonIcon, EuiFieldText, EuiFormRow, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { Query, QueryStringInput } from '../../../../../../plugins/data/public'; -import { IAggConfig } from '../../legacy_imports'; +import { IAggConfig, Query, QueryStringInput } from '../../../../../../plugins/data/public'; interface FilterRowProps { id: string; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/has_extended_bounds.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/has_extended_bounds.tsx index 416f925da8c1e..90b7cb03b7a5b 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/has_extended_bounds.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/has_extended_bounds.tsx @@ -20,10 +20,12 @@ import React, { useEffect } from 'react'; import { i18n } from '@kbn/i18n'; +import { search } from '../../../../../../plugins/data/public'; import { SwitchParamEditor } from './switch'; -import { isType } from '../../legacy_imports'; import { AggParamEditorProps } from '../agg_param_props'; +const { isType } = search.aggs; + function HasExtendedBoundsParamEditor(props: AggParamEditorProps) { useEffect(() => { props.setValue(props.value && props.agg.params.min_doc_count); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/metric_agg.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/metric_agg.test.tsx index cf7af1aa5cb3a..c53e7a8beb831 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/metric_agg.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/metric_agg.test.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; -import { IAggConfig } from '../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { DEFAULT_OPTIONS, aggFilter, MetricAggParamEditor } from './metric_agg'; jest.mock('./utils', () => ({ diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/missing_bucket.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/missing_bucket.tsx index 8d22ab283f3a1..7010f0d53e569 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/missing_bucket.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/missing_bucket.tsx @@ -21,11 +21,11 @@ import React, { useEffect } from 'react'; import { i18n } from '@kbn/i18n'; import { SwitchParamEditor } from './switch'; -import { isStringType } from '../../legacy_imports'; +import { search } from '../../../../../../plugins/data/public'; import { AggParamEditorProps } from '../agg_param_props'; function MissingBucketParamEditor(props: AggParamEditorProps) { - const fieldTypeIsNotString = !isStringType(props.agg); + const fieldTypeIsNotString = !search.aggs.isStringType(props.agg); useEffect(() => { if (fieldTypeIsNotString) { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order.tsx index f40143251e46a..8f63662d928c1 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order.tsx @@ -21,7 +21,7 @@ import React, { useEffect } from 'react'; import { EuiFormRow, EuiSelect } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { OptionedValueProp, OptionedParamEditorProps } from '../../legacy_imports'; +import { OptionedValueProp, OptionedParamEditorProps } from 'src/plugins/data/public'; import { AggParamEditorProps } from '../agg_param_props'; function OrderParamEditor({ diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.test.tsx index 01f5ed9b6a2f1..4c843791153b0 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.test.tsx @@ -21,8 +21,6 @@ import React from 'react'; import { mount } from 'enzyme'; import { OrderByParamEditor } from './order_by'; -jest.mock('ui/new_platform'); - describe('OrderAggParamEditor component', () => { let setValue: jest.Mock; let setValidity: jest.Mock; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.tsx index 8c020c668b3c6..41672bc192fab 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_agg.tsx @@ -20,7 +20,7 @@ import React, { useEffect } from 'react'; import { EuiSpacer } from '@elastic/eui'; -import { AggParamType, IAggConfig, AggGroupNames } from '../../legacy_imports'; +import { AggParamType, IAggConfig, AggGroupNames } from '../../../../../../plugins/data/public'; import { useSubAggParamsHandlers } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; import { DefaultEditorAggParams } from '../agg_params'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_by.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_by.tsx index c0391358ec6e2..9f1aaa54a8ca3 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_by.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/order_by.tsx @@ -28,8 +28,9 @@ import { useValidation, } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; -import { termsAggFilter } from '../../legacy_imports'; +import { search } from '../../../../../../plugins/data/public'; +const { termsAggFilter } = search.aggs; const DEFAULT_VALUE = '_key'; const DEFAULT_OPTIONS = [ { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/percentiles.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/percentiles.test.tsx index 0eaf9bcc987c1..76eb12af8c4e2 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/percentiles.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/percentiles.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { AggParamEditorProps } from '../agg_param_props'; -import { IAggConfig } from '../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; import { mount } from 'enzyme'; import { PercentilesEditor } from './percentiles'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_agg.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_agg.tsx index 5bc94bd4af226..c9f53a68b3e83 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_agg.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_agg.tsx @@ -20,7 +20,7 @@ import React, { useEffect } from 'react'; import { EuiSpacer } from '@elastic/eui'; -import { AggParamType, IAggConfig, AggGroupNames } from '../../legacy_imports'; +import { AggParamType, IAggConfig, AggGroupNames } from '../../../../../../plugins/data/public'; import { useSubAggParamsHandlers } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; import { DefaultEditorAggParams } from '../agg_params'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_metric.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_metric.tsx index 9d48b1c964a27..ead3f8bb00623 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_metric.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/sub_metric.tsx @@ -21,7 +21,7 @@ import React, { useEffect } from 'react'; import { EuiFormLabel, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { AggParamType, IAggConfig, AggGroupNames } from '../../legacy_imports'; +import { AggParamType, IAggConfig, AggGroupNames } from '../../../../../../plugins/data/public'; import { useSubAggParamsHandlers } from './utils'; import { AggParamEditorProps } from '../agg_param_props'; import { DefaultEditorAggParams } from '../agg_params'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts b/src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts index 8a21114999cd6..b816e61cce355 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/test_utils.ts @@ -18,7 +18,7 @@ */ import { VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggConfig, AggParam } from '../../legacy_imports'; +import { IAggConfig, AggParam } from 'src/plugins/data/public'; import { EditorConfig } from '../utils'; export const aggParamCommonPropsMock = { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/time_interval.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/time_interval.tsx index ee3666b2ed441..de0059f5467ad 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/time_interval.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/time_interval.tsx @@ -23,7 +23,7 @@ import { EuiFormRow, EuiIconTip, EuiComboBox, EuiComboBoxOptionOption } from '@e import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { isValidInterval, AggParamOption } from '../../legacy_imports'; +import { search, AggParamOption } from '../../../../../../plugins/data/public'; import { AggParamEditorProps } from '../agg_param_props'; interface ComboBoxOption extends EuiComboBoxOptionOption { @@ -59,7 +59,7 @@ function TimeIntervalParamEditor({ if (value) { definedOption = find(options, { key: value }); selectedOptions = definedOption ? [definedOption] : [{ label: value, key: 'custom' }]; - isValid = !!(definedOption || isValidInterval(value, timeBase)); + isValid = !!(definedOption || search.aggs.isValidInterval(value, timeBase)); } const interval = get(agg, 'buckets.getInterval') && (agg as any).buckets.getInterval(); @@ -100,7 +100,7 @@ function TimeIntervalParamEditor({ const normalizedCustomValue = customValue.trim(); setValue(normalizedCustomValue); - if (normalizedCustomValue && isValidInterval(normalizedCustomValue, timeBase)) { + if (normalizedCustomValue && search.aggs.isValidInterval(normalizedCustomValue, timeBase)) { agg.write(); } }; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx index 4ce0712040bd5..74dab1a3b551a 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx @@ -25,7 +25,7 @@ import { TopAggregateParamEditorProps, } from './top_aggregate'; import { aggParamCommonPropsMock } from './test_utils'; -import { IAggConfig } from '../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; describe('TopAggregateParamEditor', () => { let agg: IAggConfig; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.tsx index 346dfc0156f07..bab20d18c8fc0 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/top_aggregate.tsx @@ -28,7 +28,7 @@ import { OptionedValueProp, OptionedParamEditorProps, OptionedParamType, -} from '../../legacy_imports'; +} from 'src/plugins/data/public'; import { AggParamEditorProps } from '../agg_param_props'; export interface AggregateValueProp extends OptionedValueProp { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts b/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts index 8aeae488942cd..f4c0814748ebc 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts @@ -20,7 +20,7 @@ import { useEffect, useCallback, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; -import { IAggConfig } from '../../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; type AggFilter = string[]; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/use_handlers.ts b/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/use_handlers.ts index c7816d5a9d305..4dadef79b1204 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/use_handlers.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/controls/utils/use_handlers.ts @@ -19,7 +19,7 @@ import { useCallback } from 'react'; -import { IAggConfig, AggParamType } from '../../../legacy_imports'; +import { IAggConfig, AggParamType } from 'src/plugins/data/public'; type SetValue = (value?: IAggConfig) => void; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/data_tab.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/data_tab.tsx index 1c1f9d57d8b90..6f92c27e90ec1 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/data_tab.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/data_tab.tsx @@ -23,11 +23,11 @@ import { EuiSpacer } from '@elastic/eui'; import { VisState } from 'src/legacy/core_plugins/visualizations/public'; import { - IAggConfig, AggGroupNames, - parentPipelineType, + IAggConfig, IMetricAggType, -} from '../../legacy_imports'; + search, +} from '../../../../../../plugins/data/public'; import { DefaultEditorAggGroup } from '../agg_group'; import { EditorAction, @@ -67,7 +67,7 @@ function DefaultEditorDataTab({ () => findLast( metricAggs, - ({ type }: { type: IMetricAggType }) => type.subtype === parentPipelineType + ({ type }: { type: IMetricAggType }) => type.subtype === search.aggs.parentPipelineType ), [metricAggs] ); diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx index 1efd8dae8178b..2508ef3a55537 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx @@ -23,7 +23,6 @@ import { i18n } from '@kbn/i18n'; import { keyCodes, EuiButtonIcon, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { Vis } from 'src/legacy/core_plugins/visualizations/public'; -import { AggGroupNames } from '../../legacy_imports'; import { DefaultEditorNavBar, OptionTab } from './navbar'; import { DefaultEditorControls } from './controls'; import { setStateParamValue, useEditorReducer, useEditorFormState, discardChanges } from './state'; @@ -31,6 +30,7 @@ import { DefaultEditorAggCommonProps } from '../agg_common_props'; import { SidebarTitle } from './sidebar_title'; import { PersistedState } from '../../../../../../plugins/visualizations/public'; import { SavedSearch } from '../../../../../../plugins/discover/public'; +import { AggGroupNames } from '../../../../../../plugins/data/public'; import { getSchemasByGroup } from '../../schemas'; interface DefaultEditorSideBarProps { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/actions.ts b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/actions.ts index f9915bedc8878..e3577218b7e25 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/actions.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/actions.ts @@ -18,7 +18,7 @@ */ import { Vis, VisParams } from 'src/legacy/core_plugins/visualizations/public'; -import { IAggConfig } from '../../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { EditorStateActionTypes } from './constants'; import { Schema } from '../../../schemas'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/index.ts b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/index.ts index df5ba3f6121c7..6383ac866dcfc 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/index.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/index.ts @@ -21,15 +21,22 @@ import { useEffect, useReducer, useCallback } from 'react'; import { isEqual } from 'lodash'; import { Vis, VisState, VisParams } from 'src/legacy/core_plugins/visualizations/public'; -import { editorStateReducer, initEditorState } from './reducers'; +import { createEditorStateReducer, initEditorState } from './reducers'; import { EditorStateActionTypes } from './constants'; import { EditorAction, updateStateParams } from './actions'; +import { useKibana } from '../../../../../../../plugins/kibana_react/public'; +import { VisDefaultEditorKibanaServices } from '../../../types'; export * from './editor_form_state'; export * from './actions'; export function useEditorReducer(vis: Vis): [VisState, React.Dispatch] { - const [state, dispatch] = useReducer(editorStateReducer, vis, initEditorState); + const { services } = useKibana(); + const [state, dispatch] = useReducer( + createEditorStateReducer(services.data.search), + vis, + initEditorState + ); useEffect(() => { const handleVisUpdate = (params: VisParams) => { diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts index 73675e75cbe36..67220fd9fd91b 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/state/reducers.ts @@ -20,7 +20,7 @@ import { cloneDeep } from 'lodash'; import { Vis, VisState } from 'src/legacy/core_plugins/visualizations/public'; -import { createAggConfigs, AggGroupNames } from '../../../legacy_imports'; +import { AggGroupNames, DataPublicPluginStart } from '../../../../../../../plugins/data/public'; import { EditorStateActionTypes } from './constants'; import { getEnabledMetricAggsCount } from '../../agg_group_helper'; import { EditorAction } from './actions'; @@ -29,7 +29,9 @@ function initEditorState(vis: Vis) { return vis.copyCurrentState(true); } -function editorStateReducer(state: VisState, action: EditorAction): VisState { +const createEditorStateReducer = ({ + aggs: { createAggConfigs }, +}: DataPublicPluginStart['search']) => (state: VisState, action: EditorAction): VisState => { switch (action.type) { case EditorStateActionTypes.ADD_NEW_AGG: { const { schema } = action.payload; @@ -181,6 +183,6 @@ function editorStateReducer(state: VisState, action: EditorAction): VisState { }; } } -} +}; -export { editorStateReducer, initEditorState }; +export { createEditorStateReducer, initEditorState }; diff --git a/src/legacy/core_plugins/vis_default_editor/public/legacy_imports.ts b/src/legacy/core_plugins/vis_default_editor/public/legacy_imports.ts deleted file mode 100644 index 50028d8c970f4..0000000000000 --- a/src/legacy/core_plugins/vis_default_editor/public/legacy_imports.ts +++ /dev/null @@ -1,47 +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. - */ - -/* `ui/agg_types` dependencies */ -export { BUCKET_TYPES, METRIC_TYPES } from '../../../../plugins/data/public'; -export { - AggGroupNames, - aggGroupNamesMap, - AggParam, - AggParamType, - AggType, - aggTypes, - createAggConfigs, - FieldParamType, - IAggConfig, - IAggConfigs, - IAggGroupNames, - IAggType, - IFieldParamType, - termsAggFilter, -} from 'ui/agg_types'; -export { aggTypeFilters, propFilter } from 'ui/agg_types'; -export { aggTypeFieldFilters } from 'ui/agg_types'; -export { MetricAggType, IMetricAggType } from 'ui/agg_types'; -export { parentPipelineType } from 'ui/agg_types'; -export { siblingPipelineType } from 'ui/agg_types'; -export { isType, isStringType } from 'ui/agg_types'; -export { OptionedValueProp, OptionedParamEditorProps, OptionedParamType } from 'ui/agg_types'; -export { isValidInterval } from 'ui/agg_types'; -export { AggParamOption } from 'ui/agg_types'; -export { CidrMask } from 'ui/agg_types'; diff --git a/src/legacy/core_plugins/vis_default_editor/public/types.ts b/src/legacy/core_plugins/vis_default_editor/public/types.ts new file mode 100644 index 0000000000000..22fc24005994d --- /dev/null +++ b/src/legacy/core_plugins/vis_default_editor/public/types.ts @@ -0,0 +1,24 @@ +/* + * 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 { DataPublicPluginStart } from 'src/plugins/data/public'; + +export interface VisDefaultEditorKibanaServices { + data: DataPublicPluginStart; +} diff --git a/src/legacy/core_plugins/vis_default_editor/public/utils.test.ts b/src/legacy/core_plugins/vis_default_editor/public/utils.test.ts index b050979b7b338..f3912450ba670 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/utils.test.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/utils.test.ts @@ -18,9 +18,7 @@ */ import { groupAndSortBy } from './utils'; -import { AggGroupNames } from './legacy_imports'; - -jest.mock('ui/new_platform'); +import { AggGroupNames } from 'src/plugins/data/public'; const aggs = [ { diff --git a/src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx b/src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx index 18fbba1b039b5..2e8f20946c73a 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/vis_options_props.tsx @@ -17,8 +17,8 @@ * under the License. */ +import { IAggConfigs } from 'src/plugins/data/public'; import { PersistedState } from '../../../../plugins/visualizations/public'; -import { IAggConfigs } from './legacy_imports'; import { Vis } from '../../visualizations/public'; export interface VisOptionsProps { diff --git a/src/legacy/core_plugins/vis_default_editor/public/vis_type_agg_filter.ts b/src/legacy/core_plugins/vis_default_editor/public/vis_type_agg_filter.ts index fcb06f73513b0..3ff212c43e6e8 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/vis_type_agg_filter.ts +++ b/src/legacy/core_plugins/vis_default_editor/public/vis_type_agg_filter.ts @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -import { IndexPattern } from 'src/plugins/data/public'; -import { IAggType, IAggConfig, aggTypeFilters, propFilter } from './legacy_imports'; +import { IAggType, IAggConfig, IndexPattern, search } from '../../../../plugins/data/public'; +const { aggTypeFilters, propFilter } = search.aggs; const filterByName = propFilter('name'); /** diff --git a/src/legacy/core_plugins/vis_type_metric/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_metric/public/legacy_imports.ts index b769030a04fb1..cd7a8e740d85d 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_metric/public/legacy_imports.ts @@ -18,4 +18,3 @@ */ export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; -export { AggGroupNames, Schemas } from 'ui/agg_types'; diff --git a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.test.ts b/src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.test.ts index 3bddc94929cf5..22c32895d6803 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.test.ts +++ b/src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.test.ts @@ -23,21 +23,8 @@ import { functionWrapper } from '../../../../plugins/expressions/common/expressi jest.mock('ui/new_platform'); -jest.mock('../../vis_default_editor/public/legacy_imports', () => ({ - propFilter: jest.fn(), - AggGroupNames: { - Buckets: 'buckets', - Metrics: 'metrics', - }, - aggTypeFilters: { - addFilter: jest.fn(), - }, - BUCKET_TYPES: { - DATE_HISTOGRAM: 'date_histogram', - }, - METRIC_TYPES: { - TOP_HITS: 'top_hits', - }, +jest.mock('../../vis_default_editor/public', () => ({ + Schemas: class {}, })); describe('interpreter/functions#metric', () => { diff --git a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.test.ts b/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.test.ts index 5813465cc3f00..cce5864aa50a1 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.test.ts +++ b/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.test.ts @@ -36,21 +36,8 @@ import { createMetricVisTypeDefinition } from './metric_vis_type'; jest.mock('ui/new_platform'); -jest.mock('../../vis_default_editor/public/legacy_imports', () => ({ - propFilter: jest.fn(), - AggGroupNames: { - Buckets: 'buckets', - Metrics: 'metrics', - }, - aggTypeFilters: { - addFilter: jest.fn(), - }, - BUCKET_TYPES: { - DATE_HISTOGRAM: 'date_histogram', - }, - METRIC_TYPES: { - TOP_HITS: 'top_hits', - }, +jest.mock('../../vis_default_editor/public', () => ({ + Schemas: class {}, })); describe('metric_vis - createMetricVisTypeDefinition', () => { diff --git a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.ts b/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.ts index 0b8d9b17659f4..f29164f7e540d 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.ts +++ b/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.ts @@ -22,8 +22,9 @@ import { i18n } from '@kbn/i18n'; import { MetricVisComponent } from './components/metric_vis_component'; import { MetricVisOptions } from './components/metric_vis_options'; import { ColorModes } from '../../vis_type_vislib/public'; -import { Schemas, AggGroupNames } from './legacy_imports'; import { ColorSchemas, colorSchemas } from '../../../../plugins/charts/public'; +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; export const createMetricVisTypeDefinition = () => ({ name: 'metric', diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js b/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js index 91581923b05cb..8edef2ea16353 100644 --- a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js +++ b/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js @@ -27,7 +27,8 @@ import { oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative, } from 'fixtures/fake_hierarchical_data'; import sinon from 'sinon'; -import { tabifyAggResponse, npStart } from '../../legacy_imports'; +import { npStart } from '../../legacy_imports'; +import { search } from '../../../../../../plugins/data/public'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; import { round } from 'lodash'; import { tableVisTypeDefinition } from '../../table_vis_type'; @@ -39,6 +40,8 @@ import { getAngularModule } from '../../get_inner_angular'; import { initTableVisLegacyModule } from '../../table_vis_legacy_module'; import { tableVisResponseHandler } from '../../table_vis_response_handler'; +const { tabifyAggResponse } = search; + describe('Table Vis - AggTable Directive', function() { let $rootScope; let $compile; diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js b/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js index 4d62551dcf396..89900d2144030 100644 --- a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js +++ b/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js @@ -21,13 +21,16 @@ import $ from 'jquery'; import ngMock from 'ng_mock'; import expect from '@kbn/expect'; import { metricOnly, threeTermBuckets } from 'fixtures/fake_hierarchical_data'; -import { tabifyAggResponse, npStart } from '../../legacy_imports'; +import { npStart } from '../../legacy_imports'; +import { search } from '../../../../../../plugins/data/public'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; import { getAngularModule } from '../../get_inner_angular'; import { initTableVisLegacyModule } from '../../table_vis_legacy_module'; import { tableVisResponseHandler } from '../../table_vis_response_handler'; import { start as visualizationsStart } from '../../../../visualizations/public/np_ready/public/legacy'; +const { tabifyAggResponse } = search; + describe('Table Vis - AggTableGroup Directive', function() { let $rootScope; let $compile; diff --git a/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx b/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx index 8cc0ca2456867..30a9526273166 100644 --- a/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx +++ b/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx @@ -24,11 +24,13 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { VisOptionsProps } from 'src/legacy/core_plugins/vis_default_editor/public'; -import { tabifyGetColumns } from '../legacy_imports'; +import { search } from '../../../../../plugins/data/public'; import { NumberInputOption, SwitchOption, SelectOption } from '../../../vis_type_vislib/public'; import { TableVisParams } from '../types'; import { totalAggregations } from './utils'; +const { tabifyGetColumns } = search; + function TableOptions({ aggs, stateParams, diff --git a/src/legacy/core_plugins/vis_type_table/public/get_inner_angular.ts b/src/legacy/core_plugins/vis_type_table/public/get_inner_angular.ts index 6fb5658d8e815..6208e358b4184 100644 --- a/src/legacy/core_plugins/vis_type_table/public/get_inner_angular.ts +++ b/src/legacy/core_plugins/vis_type_table/public/get_inner_angular.ts @@ -25,14 +25,14 @@ import 'angular-recursion'; import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular'; import { CoreStart, LegacyCoreStart, IUiSettingsClient } from 'kibana/public'; import { - PrivateProvider, + initAngularBootstrap, PaginateDirectiveProvider, PaginateControlsDirectiveProvider, + PrivateProvider, watchMultiDecorator, KbnAccessibleClickProvider, configureAppAngularModule, -} from './legacy_imports'; -import { initAngularBootstrap } from '../../../../plugins/kibana_legacy/public'; +} from '../../../../plugins/kibana_legacy/public'; initAngularBootstrap(); diff --git a/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts index 7b584f8069338..287b6c172ffd9 100644 --- a/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts @@ -19,16 +19,3 @@ export { npSetup, npStart } from 'ui/new_platform'; export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; -export { IAggConfig, AggGroupNames, Schemas } from 'ui/agg_types'; -// @ts-ignore -export { PaginateDirectiveProvider } from 'ui/directives/paginate'; -// @ts-ignore -export { PaginateControlsDirectiveProvider } from 'ui/directives/paginate'; -import { search } from '../../../../plugins/data/public'; -export const { tabifyAggResponse, tabifyGetColumns } = search; -export { - configureAppAngularModule, - KbnAccessibleClickProvider, - PrivateProvider, - watchMultiDecorator, -} from '../../../../plugins/kibana_legacy/public'; diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts b/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts index 6d4e94c6292a6..327a47093f535 100644 --- a/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts +++ b/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts @@ -34,8 +34,13 @@ import { stubFields } from '../../../../plugins/data/public/stubs'; import { tableVisResponseHandler } from './table_vis_response_handler'; import { coreMock } from '../../../../core/public/mocks'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { createAggConfigs } from 'ui/agg_types'; -import { tabifyAggResponse, IAggConfig } from './legacy_imports'; +import { npStart } from './legacy_imports'; +import { IAggConfig, search } from '../../../../plugins/data/public'; + +// should be mocked once get rid of 'ui/new_platform' legacy imports +const { createAggConfigs } = npStart.plugins.data.search.aggs; + +const { tabifyAggResponse } = search; jest.mock('ui/new_platform'); jest.mock('../../../../plugins/kibana_legacy/public/angular/angular_config', () => ({ diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis_type.ts b/src/legacy/core_plugins/vis_type_table/public/table_vis_type.ts index 970bf1ba7ce64..e70b09904253f 100644 --- a/src/legacy/core_plugins/vis_type_table/public/table_vis_type.ts +++ b/src/legacy/core_plugins/vis_type_table/public/table_vis_type.ts @@ -18,7 +18,8 @@ */ import { i18n } from '@kbn/i18n'; -import { AggGroupNames, Schemas } from './legacy_imports'; +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; import { Vis } from '../../visualizations/public'; import { tableVisResponseHandler } from './table_vis_response_handler'; // @ts-ignore diff --git a/src/legacy/core_plugins/vis_type_tagcloud/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_tagcloud/public/legacy_imports.ts index 0d76bc5d8b68b..cd7a8e740d85d 100644 --- a/src/legacy/core_plugins/vis_type_tagcloud/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_tagcloud/public/legacy_imports.ts @@ -17,5 +17,4 @@ * under the License. */ -export { Schemas } from 'ui/agg_types'; export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; diff --git a/src/legacy/core_plugins/vis_type_tagcloud/public/tag_cloud_type.ts b/src/legacy/core_plugins/vis_type_tagcloud/public/tag_cloud_type.ts index 34d15287169c0..9a522fe6e648e 100644 --- a/src/legacy/core_plugins/vis_type_tagcloud/public/tag_cloud_type.ts +++ b/src/legacy/core_plugins/vis_type_tagcloud/public/tag_cloud_type.ts @@ -19,7 +19,7 @@ import { i18n } from '@kbn/i18n'; -import { Schemas } from './legacy_imports'; +import { Schemas } from '../../vis_default_editor/public'; import { Status } from '../../visualizations/public'; import { TagCloudOptions } from './components/tag_cloud_options'; diff --git a/src/legacy/core_plugins/vis_type_vislib/public/area.ts b/src/legacy/core_plugins/vis_type_vislib/public/area.ts index 71027d7db5af8..e79555470298b 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/area.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/area.ts @@ -23,7 +23,8 @@ import { palettes } from '@elastic/eui/lib/services'; // @ts-ignore import { euiPaletteColorBlind } from '@elastic/eui/lib/services'; -import { Schemas, AggGroupNames } from './legacy_imports'; +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; import { Positions, ChartTypes, diff --git a/src/legacy/core_plugins/vis_type_vislib/public/components/options/gauge/style_panel.tsx b/src/legacy/core_plugins/vis_type_vislib/public/components/options/gauge/style_panel.tsx index 4c936c93a4c8a..9254c3c18347c 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/components/options/gauge/style_panel.tsx +++ b/src/legacy/core_plugins/vis_type_vislib/public/components/options/gauge/style_panel.tsx @@ -24,7 +24,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { SelectOption } from '../../common'; import { GaugeOptionsInternalProps } from '.'; -import { AggGroupNames } from '../../../legacy_imports'; +import { AggGroupNames } from '../../../../../../../plugins/data/public'; function StylePanel({ aggs, setGaugeValue, stateParams, vis }: GaugeOptionsInternalProps) { const diasableAlignment = diff --git a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.test.tsx b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.test.tsx index f172a4344c940..032dd10cf11d2 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.test.tsx +++ b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.test.tsx @@ -20,6 +20,7 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; +import { IAggConfig, IAggType } from 'src/plugins/data/public'; import { MetricsAxisOptions } from './index'; import { BasicVislibParams, SeriesParam, ValueAxis } from '../../../types'; import { ValidationVisOptionsProps } from '../../common'; @@ -27,10 +28,8 @@ import { Positions } from '../../../utils/collections'; import { ValueAxesPanel } from './value_axes_panel'; import { CategoryAxisPanel } from './category_axis_panel'; import { ChartTypes } from '../../../utils/collections'; -import { IAggConfig, IAggType } from '../../../legacy_imports'; import { defaultValueAxisId, valueAxis, seriesParam, categoryAxis } from './mocks'; -jest.mock('ui/new_platform'); jest.mock('./series_panel', () => ({ SeriesPanel: () => 'SeriesPanel', })); diff --git a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx index 82b64e4185ed2..a6f4a967d9c76 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx +++ b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx @@ -21,7 +21,7 @@ import React, { useState, useEffect, useCallback, useMemo } from 'react'; import { cloneDeep, uniq, get } from 'lodash'; import { EuiSpacer } from '@elastic/eui'; -import { IAggConfig } from '../../../legacy_imports'; +import { IAggConfig } from 'src/plugins/data/public'; import { BasicVislibParams, ValueAxis, SeriesParam, Axis } from '../../../types'; import { ValidationVisOptionsProps } from '../../common'; import { SeriesPanel } from './series_panel'; diff --git a/src/legacy/core_plugins/vis_type_vislib/public/gauge.ts b/src/legacy/core_plugins/vis_type_vislib/public/gauge.ts index c78925d5316b0..4610bd37db5f1 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/gauge.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/gauge.ts @@ -19,8 +19,8 @@ import { i18n } from '@kbn/i18n'; -import { RangeValues } from '../../vis_default_editor/public'; -import { Schemas, AggGroupNames } from './legacy_imports'; +import { RangeValues, Schemas } from '../../vis_default_editor/public'; +import { AggGroupNames } from '../../../../plugins/data/public'; import { GaugeOptions } from './components/options'; import { getGaugeCollections, Alignments, ColorModes, GaugeTypes } from './utils/collections'; import { createVislibVisController } from './vis_controller'; diff --git a/src/legacy/core_plugins/vis_type_vislib/public/goal.ts b/src/legacy/core_plugins/vis_type_vislib/public/goal.ts index d2fdb9543d827..c918128d01f11 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/goal.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/goal.ts @@ -19,12 +19,13 @@ import { i18n } from '@kbn/i18n'; -import { Schemas, AggGroupNames } from './legacy_imports'; import { GaugeOptions } from './components/options'; import { getGaugeCollections, GaugeTypes, ColorModes } from './utils/collections'; import { createVislibVisController } from './vis_controller'; import { VisTypeVislibDependencies } from './plugin'; import { ColorSchemas } from '../../../../plugins/charts/public'; +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; export const createGoalVisTypeDefinition = (deps: VisTypeVislibDependencies) => ({ name: 'goal', diff --git a/src/legacy/core_plugins/vis_type_vislib/public/heatmap.ts b/src/legacy/core_plugins/vis_type_vislib/public/heatmap.ts index c8ce335f09e78..39a583f3c9641 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/heatmap.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/heatmap.ts @@ -19,8 +19,8 @@ import { i18n } from '@kbn/i18n'; -import { RangeValues } from '../../vis_default_editor/public'; -import { Schemas, AggGroupNames } from './legacy_imports'; +import { RangeValues, Schemas } from '../../vis_default_editor/public'; +import { AggGroupNames } from '../../../../plugins/data/public'; import { AxisTypes, getHeatmapCollections, Positions, ScaleTypes } from './utils/collections'; import { HeatmapOptions } from './components/options'; import { createVislibVisController } from './vis_controller'; diff --git a/src/legacy/core_plugins/vis_type_vislib/public/histogram.ts b/src/legacy/core_plugins/vis_type_vislib/public/histogram.ts index 7b9b008481c40..15ef369e5150e 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/histogram.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/histogram.ts @@ -23,8 +23,8 @@ import { palettes } from '@elastic/eui/lib/services'; // @ts-ignore import { euiPaletteColorBlind } from '@elastic/eui/lib/services'; -import { Schemas, AggGroupNames } from './legacy_imports'; - +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; import { Positions, ChartTypes, diff --git a/src/legacy/core_plugins/vis_type_vislib/public/horizontal_bar.ts b/src/legacy/core_plugins/vis_type_vislib/public/horizontal_bar.ts index eca26b4f55f60..8b5811628855c 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/horizontal_bar.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/horizontal_bar.ts @@ -23,8 +23,8 @@ import { palettes } from '@elastic/eui/lib/services'; // @ts-ignore import { euiPaletteColorBlind } from '@elastic/eui/lib/services'; -import { Schemas, AggGroupNames } from './legacy_imports'; - +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; import { Positions, ChartTypes, diff --git a/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts index 343fda44340d1..2b177bff98d56 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/legacy_imports.ts @@ -19,7 +19,6 @@ import { npStart } from 'ui/new_platform'; export const { createFiltersFromEvent } = npStart.plugins.data.actions; -export { AggType, AggGroupNames, IAggConfig, IAggType, Schemas } from 'ui/agg_types'; export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; import { search } from '../../../../plugins/data/public'; export const { tabifyAggResponse, tabifyGetColumns } = search; diff --git a/src/legacy/core_plugins/vis_type_vislib/public/line.ts b/src/legacy/core_plugins/vis_type_vislib/public/line.ts index 7aaad52ed8841..ac4cda869fe29 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/line.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/line.ts @@ -23,7 +23,8 @@ import { palettes } from '@elastic/eui/lib/services'; // @ts-ignore import { euiPaletteColorBlind } from '@elastic/eui/lib/services'; -import { Schemas, AggGroupNames } from './legacy_imports'; +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; import { Positions, ChartTypes, diff --git a/src/legacy/core_plugins/vis_type_vislib/public/pie.ts b/src/legacy/core_plugins/vis_type_vislib/public/pie.ts index b56dba659ffc8..0f1bd93f5b5bd 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/pie.ts +++ b/src/legacy/core_plugins/vis_type_vislib/public/pie.ts @@ -19,7 +19,8 @@ import { i18n } from '@kbn/i18n'; -import { Schemas, AggGroupNames } from './legacy_imports'; +import { AggGroupNames } from '../../../../plugins/data/public'; +import { Schemas } from '../../vis_default_editor/public'; import { PieOptions } from './components/options'; import { getPositions, Positions } from './utils/collections'; import { createVislibVisController } from './vis_controller'; diff --git a/src/legacy/ui/public/agg_types/index.ts b/src/legacy/ui/public/agg_types/index.ts deleted file mode 100644 index 75c2cd4317872..0000000000000 --- a/src/legacy/ui/public/agg_types/index.ts +++ /dev/null @@ -1,85 +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. - */ - -/** - * Nothing to see here! - * - * Agg Types have moved to the new platform, and are being - * re-exported from ui/agg_types for backwards compatibility. - */ - -import { npStart } from 'ui/new_platform'; - -// runtime contracts -const { types } = npStart.plugins.data.search.aggs; -export const aggTypes = types.getAll(); -export const { createAggConfigs } = npStart.plugins.data.search.aggs; -export const { - AggConfig, - AggType, - aggTypeFieldFilters, - FieldParamType, - MetricAggType, - parentPipelineAggHelper, - siblingPipelineAggHelper, -} = npStart.plugins.data.search.__LEGACY; - -// types -export { - AggGroupNames, - AggParam, - AggParamOption, - AggParamType, - AggTypeFieldFilters, - AggTypeFilters, - BUCKET_TYPES, - DateRangeKey, - IAggConfig, - IAggConfigs, - IAggGroupNames, - IAggType, - IFieldParamType, - IMetricAggType, - IpRangeKey, - METRIC_TYPES, - OptionedParamEditorProps, - OptionedParamType, - OptionedValueProp, -} from '../../../../plugins/data/public'; - -// static code -import { search } from '../../../../plugins/data/public'; -export const { - aggGroupNamesMap, - aggTypeFilters, - CidrMask, - convertDateRangeToString, - convertIPRangeToString, - intervalOptions, - isDateHistogramBucketAggConfig, - isStringType, - isType, - isValidInterval, - parentPipelineType, - propFilter, - siblingPipelineType, - termsAggFilter, -} = search.aggs; - -export { ISchemas, Schemas, Schema } from '../../../core_plugins/vis_default_editor/public/schemas'; diff --git a/src/plugins/data/common/field_formats/utils/serialize.ts b/src/plugins/data/common/field_formats/utils/serialize.ts index 9931f55c30a9e..1092c90d19451 100644 --- a/src/plugins/data/common/field_formats/utils/serialize.ts +++ b/src/plugins/data/common/field_formats/utils/serialize.ts @@ -17,7 +17,7 @@ * under the License. */ -import { IAggConfig } from '../../../../../legacy/ui/public/agg_types'; +import { IAggConfig } from 'src/plugins/data/public'; import { SerializedFieldFormat } from '../../../../expressions/common/types'; export const serializeFieldFormat = (agg: IAggConfig): SerializedFieldFormat => { diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 07d8d302bc18c..45ac5a3e12531 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -1322,7 +1322,7 @@ export interface QueryState { // Warning: (ae-missing-release-tag) "QueryStringInput" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const QueryStringInput: React.FC>; +export const QueryStringInput: React.FC>; // @public (undocumented) export type QuerySuggestion = QuerySuggestionBasic | QuerySuggestionField; @@ -1531,8 +1531,8 @@ export const search: { // Warning: (ae-missing-release-tag) "SearchBar" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const SearchBar: React.ComponentClass, "query" | "isLoading" | "indexPatterns" | "filters" | "onQueryChange" | "customSubmitButton" | "screenTitle" | "dataTestSubj" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "refreshInterval" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "onRefresh" | "timeHistory" | "onFiltersUpdated" | "onRefreshChange">, any> & { - WrappedComponent: React.ComponentType & ReactIntl.InjectedIntlProps>; +export const SearchBar: React.ComponentClass, "query" | "isLoading" | "indexPatterns" | "filters" | "refreshInterval" | "screenTitle" | "dataTestSubj" | "customSubmitButton" | "showQueryBar" | "showQueryInput" | "showFilterBar" | "showDatePicker" | "showAutoRefreshOnly" | "isRefreshPaused" | "dateRangeFrom" | "dateRangeTo" | "showSaveQuery" | "savedQuery" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated" | "onClearSavedQuery" | "onRefresh" | "timeHistory" | "onFiltersUpdated" | "onRefreshChange">, any> & { + WrappedComponent: React.ComponentType & ReactIntl.InjectedIntlProps>; }; // Warning: (ae-forgotten-export) The symbol "SearchBarOwnProps" needs to be exported by the entry point index.d.ts diff --git a/src/plugins/kibana_legacy/public/index.ts b/src/plugins/kibana_legacy/public/index.ts index 18f01854de259..75e81b0505747 100644 --- a/src/plugins/kibana_legacy/public/index.ts +++ b/src/plugins/kibana_legacy/public/index.ts @@ -27,6 +27,7 @@ export * from './plugin'; export { kbnBaseUrl } from '../common/kbn_base_url'; export { initAngularBootstrap } from './angular_bootstrap'; +export { PaginateDirectiveProvider, PaginateControlsDirectiveProvider } from './paginate/paginate'; export * from './angular'; export * from './notify'; export * from './utils'; diff --git a/src/plugins/kibana_legacy/public/paginate/paginate.d.ts b/src/plugins/kibana_legacy/public/paginate/paginate.d.ts new file mode 100644 index 0000000000000..a40b869b2ccbb --- /dev/null +++ b/src/plugins/kibana_legacy/public/paginate/paginate.d.ts @@ -0,0 +1,21 @@ +/* + * 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 PaginateDirectiveProvider($parse: any, $compile: any): any; +export function PaginateControlsDirectiveProvider(): any; diff --git a/src/legacy/ui/public/directives/paginate.js b/src/plugins/kibana_legacy/public/paginate/paginate.js similarity index 93% rename from src/legacy/ui/public/directives/paginate.js rename to src/plugins/kibana_legacy/public/paginate/paginate.js index 802aaaf453751..f7e623cdabd86 100644 --- a/src/legacy/ui/public/directives/paginate.js +++ b/src/plugins/kibana_legacy/public/paginate/paginate.js @@ -19,8 +19,7 @@ import _ from 'lodash'; import { i18n } from '@kbn/i18n'; -import { uiModules } from '../modules'; -import paginateControlsTemplate from './partials/paginate_controls.html'; +import paginateControlsTemplate from './paginate_controls.html'; export function PaginateDirectiveProvider($parse, $compile) { return { @@ -61,12 +60,9 @@ export function PaginateDirectiveProvider($parse, $compile) { controller: function($scope, $document) { const self = this; const ALL = 0; - const allSizeTitle = i18n.translate( - 'common.ui.directives.paginate.size.allDropDownOptionLabel', - { - defaultMessage: 'All', - } - ); + const allSizeTitle = i18n.translate('kibana_legacy.paginate.size.allDropDownOptionLabel', { + defaultMessage: 'All', + }); self.sizeOptions = [ { title: '10', value: 10 }, @@ -229,8 +225,3 @@ export function PaginateControlsDirectiveProvider() { template: paginateControlsTemplate, }; } - -uiModules - .get('kibana') - .directive('paginate', PaginateDirectiveProvider) - .directive('paginateControls', PaginateControlsDirectiveProvider); diff --git a/src/legacy/ui/public/directives/partials/paginate_controls.html b/src/plugins/kibana_legacy/public/paginate/paginate_controls.html similarity index 96% rename from src/legacy/ui/public/directives/partials/paginate_controls.html rename to src/plugins/kibana_legacy/public/paginate/paginate_controls.html index c40021507c233..a553bc2231720 100644 --- a/src/legacy/ui/public/directives/partials/paginate_controls.html +++ b/src/plugins/kibana_legacy/public/paginate/paginate_controls.html @@ -3,7 +3,7 @@ ng-if="linkToTop" ng-click="paginate.goToTop()" data-test-subj="paginateControlsLinkToTop" - i18n-id="common.ui.paginateControls.scrollTopButtonLabel" + i18n-id="kibana_legacy.paginate.controls.scrollTopButtonLabel" i18n-default-message="Scroll to top" > @@ -86,7 +86,7 @@
+ +
+ +
@@ -1384,26 +1345,21 @@ Array [
-
-
- - - +

+ Name +

@@ -1462,27 +1418,22 @@ Array [
-
-
+
-
- - - +

+ Connection mode +

@@ -1665,27 +1616,22 @@ Array [
-
-
+
-
- - - +

+ Make remote cluster optional +

@@ -1762,7 +1708,7 @@ Array [
-
+
,
{ private renderDeleteButton = () => { const { selectedJobs } = this.state; - if (selectedJobs.length === 0) return null; + if (selectedJobs.length === 0) return undefined; const performDelete = async () => { for (const record of selectedJobs) { diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/common.ts b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/common.ts index a6d69dd655c0c..f42c9afb7ed00 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/common.ts +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/common.ts @@ -4,18 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -export interface Clause { - type: string; - value: string; - match: string; -} +import { Query, Ast } from '@elastic/eui'; -export interface Query { - ast: { - clauses: Clause[]; - }; - text: string; - syntax: any; -} +export { Query }; +export type Clause = Parameters[0]; + +type ExtractClauseType = T extends (x: any) => x is infer Type ? Type : never; +export type TermClause = ExtractClauseType; +export type FieldClause = ExtractClauseType; +export type Value = Parameters[0]; export type ItemIdToExpandedRowMap = Record; diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.tsx index 3393aada8b69d..6736a79d62a3f 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/transform_list.tsx @@ -18,6 +18,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiInMemoryTable, + EuiSearchBarProps, EuiPopover, EuiTitle, } from '@elastic/eui'; @@ -39,7 +40,7 @@ import { DeleteAction } from './action_delete'; import { StartAction } from './action_start'; import { StopAction } from './action_stop'; -import { ItemIdToExpandedRowMap, Query, Clause } from './common'; +import { ItemIdToExpandedRowMap, Clause, TermClause, FieldClause, Value } from './common'; import { getColumns } from './columns'; import { ExpandedRow } from './expanded_row'; @@ -56,7 +57,7 @@ function getItemIdToExpandedRowMap( }, {} as ItemIdToExpandedRowMap); } -function stringMatch(str: string | undefined, substr: string) { +function stringMatch(str: string | undefined, substr: any) { return ( typeof str === 'string' && typeof substr === 'string' && @@ -104,7 +105,10 @@ export const TransformList: FC = ({ !capabilities.canPreviewTransform || !capabilities.canStartStopTransform; - const onQueryChange = ({ query, error }: { query: Query; error: any }) => { + const onQueryChange = ({ + query, + error, + }: Parameters>[0]) => { if (error) { setSearchError(error.message); } else { @@ -114,7 +118,7 @@ export const TransformList: FC = ({ } if (clauses.length > 0) { setFilterActive(true); - filterTransforms(clauses); + filterTransforms(clauses as Array); } else { setFilterActive(false); } @@ -122,7 +126,7 @@ export const TransformList: FC = ({ } }; - const filterTransforms = (clauses: Clause[]) => { + const filterTransforms = (clauses: Array) => { setIsLoading(true); // keep count of the number of matches we make as we're looping over the clauses // we only want to return transforms which match all clauses, i.e. each search term is ANDed @@ -161,7 +165,7 @@ export const TransformList: FC = ({ // filter other clauses, i.e. the mode and status filters if (Array.isArray(c.value)) { // the status value is an array of string(s) e.g. ['failed', 'stopped'] - ts = transforms.filter(transform => c.value.includes(transform.stats.state)); + ts = transforms.filter(transform => (c.value as Value[]).includes(transform.stats.state)); } else { ts = transforms.filter(transform => transform.mode === c.value); } diff --git a/x-pack/plugins/watcher/public/application/sections/watch_list/components/watch_list.tsx b/x-pack/plugins/watcher/public/application/sections/watch_list/components/watch_list.tsx index 54f4209a137b9..5be17ab2d7ed2 100644 --- a/x-pack/plugins/watcher/public/application/sections/watch_list/components/watch_list.tsx +++ b/x-pack/plugins/watcher/public/application/sections/watch_list/components/watch_list.tsx @@ -380,27 +380,30 @@ export const WatchList = () => { box: { incremental: true, }, - toolsLeft: selection.length && ( - { - setWatchesToDelete(selection.map((selected: any) => selected.id)); - }} - color="danger" - > - {selection.length > 1 ? ( - - ) : ( - - )} - - ), + toolsLeft: + selection.length > 0 ? ( + { + setWatchesToDelete(selection.map((selected: any) => selected.id)); + }} + color="danger" + > + {selection.length > 1 ? ( + + ) : ( + + )} + + ) : ( + undefined + ), toolsRight: createWatchContextMenu, }; diff --git a/x-pack/test/functional/services/machine_learning/data_frame_analytics.ts b/x-pack/test/functional/services/machine_learning/data_frame_analytics.ts index eed7db48af460..bada1d42b564a 100644 --- a/x-pack/test/functional/services/machine_learning/data_frame_analytics.ts +++ b/x-pack/test/functional/services/machine_learning/data_frame_analytics.ts @@ -7,7 +7,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; import { MlApi } from './api'; -import { DATA_FRAME_TASK_STATE } from '../../../../plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/common'; +import { DATA_FRAME_TASK_STATE } from '../../../../plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/data_frame_task_state'; export function MachineLearningDataFrameAnalyticsProvider( { getService }: FtrProviderContext, diff --git a/x-pack/typings/@elastic/eui/index.d.ts b/x-pack/typings/@elastic/eui/index.d.ts index ea7a81fa986ce..7306f1f1af138 100644 --- a/x-pack/typings/@elastic/eui/index.d.ts +++ b/x-pack/typings/@elastic/eui/index.d.ts @@ -6,10 +6,6 @@ // TODO: Remove once typescript definitions are in EUI -declare module '@elastic/eui' { - export const Query: any; -} - declare module '@elastic/eui/lib/services' { export const RIGHT_ALIGNMENT: any; } diff --git a/yarn.lock b/yarn.lock index 30fadce11c26f..e2b8082877cd2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1951,10 +1951,10 @@ tabbable "^1.1.0" uuid "^3.1.0" -"@elastic/eui@20.0.2": - version "20.0.2" - resolved "https://registry.yarnpkg.com/@elastic/eui/-/eui-20.0.2.tgz#c64b16fef15da6aa9e627d45cdd372f1fc676359" - integrity sha512-8TtazI7RO1zJH4Qkl6TZKvAxaFG9F8BEdwyGmbGhyvXOJbkvttRzoaEg9jSQpKr+z7w2vsjGNbza/fEAE41HOA== +"@elastic/eui@21.0.1": + version "21.0.1" + resolved "https://registry.yarnpkg.com/@elastic/eui/-/eui-21.0.1.tgz#7cf6846ed88032aebd72f75255298df2fbe26554" + integrity sha512-Hf8ZGRI265qpOKwnnqhZkaMQvali+Xg6FAaNZSskkpXvdLhwGtUGC4YU7HW2vb7svq6IpNUuz+5XWrMLLzVY9w== dependencies: "@types/chroma-js" "^1.4.3" "@types/enzyme" "^3.1.13" @@ -5036,14 +5036,7 @@ dependencies: "@types/react" "*" -"@types/react-dom@*": - version "16.9.4" - resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.4.tgz#0b58df09a60961dcb77f62d4f1832427513420df" - integrity sha512-fya9xteU/n90tda0s+FtN5Ym4tbgxpq/hb/Af24dvs6uYnYn+fspaxw5USlw0R8apDNwxsqumdRoCoKitckQqw== - dependencies: - "@types/react" "*" - -"@types/react-dom@^16.9.5": +"@types/react-dom@*", "@types/react-dom@^16.9.5": version "16.9.5" resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.5.tgz#5de610b04a35d07ffd8f44edad93a71032d9aaa7" integrity sha512-BX6RQ8s9D+2/gDhxrj8OW+YD4R+8hj7FEM/OJHGNR0KipE1h1mSsf39YeyC81qafkq+N3rU3h3RFbLSwE5VqUg== @@ -5158,9 +5151,9 @@ "@types/react" "*" "@types/react@*", "@types/react@^16.8.23", "@types/react@^16.9.19": - version "16.9.19" - resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.19.tgz#c842aa83ea490007d29938146ff2e4d9e4360c40" - integrity sha512-LJV97//H+zqKWMms0kvxaKYJDG05U2TtQB3chRLF8MPNs+MQh/H1aGlyDUxjaHvu08EAGerdX2z4LTBc7ns77A== + version "16.9.23" + resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.23.tgz#1a66c6d468ba11a8943ad958a8cb3e737568271c" + integrity sha512-SsGVT4E7L2wLN3tPYLiF20hmZTPGuzaayVunfgXzUn1x4uHVsKH6QDJQ/TdpHqwsTLd4CwrmQ2vOgxN7gE24gw== dependencies: "@types/prop-types" "*" csstype "^2.2.0" From ca55db53c1dbbcd91b8cdf7cf8a970a27e727e19 Mon Sep 17 00:00:00 2001 From: Catherine Liu Date: Fri, 20 Mar 2020 13:32:01 -0700 Subject: [PATCH 18/42] =?UTF-8?q?[Canvas]=20Switch=20to=20using=20EUI=20Su?= =?UTF-8?q?perDatePicker=20in=20time=20filter=20el=E2=80=A6=20(#59249)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Replaced custom custom time filter component with EuiSuperDatePicker * Added advanced settings dateFormat and timepicker:quickRanges to time filter * Round up end date in time filter * Updated snapshots * Fixed timefilter function * Fixed import * reduce margin between datepicker and selection border (#59498) * Added time_filter renderer stories * Updated storyshots * Updated timefilter element thumbnail * Updated snapshots * Used Filter type instead of any * Renamed timefilter components folder * Removed unused time range i18n strings * Updated translations * BROKEN * Updated snapshots * Revert "BROKEN" This reverts commit e3b8bd7865c98d366f98a691a78bde2572f81720. * Fix time-filter element preview image * Upated time filter preview image * Fix time-filter renderer * fixed storybook tests * Fixed time filter renderer --- .../elements/time_filter/header.png | Bin 33515 -> 18970 bytes .../functions/common/timefilter.ts | 10 +- .../functions/common/timefilterControl.ts | 1 + .../time_filter.examples.storyshot | 134 +++++ .../time_filter.stories.storyshot | 521 ++++++++++++++++++ .../__examples__/time_filter.stories.tsx | 66 +++ .../datetime_calendar.stories.storyshot | 335 ----------- .../datetime_calendar.stories.tsx | 55 -- .../datetime_calendar/datetime_calendar.scss | 6 - .../datetime_calendar/datetime_calendar.tsx | 65 --- .../components/datetime_calendar/index.ts | 7 - .../datetime_input.stories.storyshot | 67 --- .../__examples__/datetime_input.stories.tsx | 20 - .../datetime_input/datetime_input.tsx | 60 -- .../components/datetime_input/index.ts | 40 -- .../datetime_quick_list.stories.storyshot | 249 --------- .../datetime_quick_list.stories.tsx | 21 - .../datetime_quick_list.tsx | 60 -- .../components/datetime_quick_list/index.ts | 7 - .../datetime_range_absolute.stories.storyshot | 122 ---- .../datetime_range_absolute.stories.tsx | 18 - .../datetime_range_absolute.scss | 7 - .../datetime_range_absolute.tsx | 74 --- .../datetime_range_absolute/index.ts | 7 - .../time_filter/components/index.tsx | 25 + .../pretty_duration.stories.storyshot | 13 - .../__examples__/pretty_duration.stories.tsx | 13 - .../components/pretty_duration/index.ts | 10 - .../pretty_duration/lib/format_duration.ts | 59 -- .../pretty_duration/lib/quick_ranges.ts | 53 -- .../pretty_duration/pretty_duration.tsx | 25 - .../time_filter/components/time_filter.tsx | 87 +++ .../time_filter.examples.storyshot | 283 ---------- .../__examples__/time_filter.examples.tsx | 25 - .../components/time_filter/index.ts | 7 - .../components/time_filter/time_filter.tsx | 58 -- .../time_picker.stories.storyshot | 256 --------- .../__examples__/time_picker.stories.tsx | 18 - .../components/time_picker/index.ts | 7 - .../components/time_picker/time_picker.scss | 7 - .../components/time_picker/time_picker.tsx | 99 ---- .../time_picker_popover.examples.storyshot | 28 - .../time_picker_popover.examples.tsx | 18 - .../components/time_picker_popover/index.ts | 7 - .../time_picker_popover.scss | 19 - .../time_picker_popover.tsx | 63 --- .../renderers/time_filter/index.js | 2 +- .../renderers/time_filter/time_filter.scss | 11 + x-pack/legacy/plugins/canvas/i18n/units.ts | 92 +--- .../plugins/canvas/public/style/index.scss | 5 +- .../translations/translations/ja-JP.json | 21 - .../translations/translations/zh-CN.json | 21 - 52 files changed, 856 insertions(+), 2428 deletions(-) create mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/__examples__/__snapshots__/time_filter.examples.storyshot create mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/__examples__/__snapshots__/time_filter.stories.storyshot create mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/__examples__/time_filter.stories.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/__examples__/__snapshots__/datetime_calendar.stories.storyshot delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/__examples__/datetime_calendar.stories.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.scss delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/index.ts delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/__snapshots__/datetime_input.stories.storyshot delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/datetime_input.stories.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/datetime_input.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/index.ts delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/__snapshots__/datetime_quick_list.stories.storyshot delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/datetime_quick_list.stories.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/datetime_quick_list.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/index.ts delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/__snapshots__/datetime_range_absolute.stories.storyshot delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/datetime_range_absolute.stories.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.scss delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/index.ts create mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/index.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/__snapshots__/pretty_duration.stories.storyshot delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/pretty_duration.stories.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/index.ts delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/format_duration.ts delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/quick_ranges.ts delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/pretty_duration.tsx create mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/__snapshots__/time_filter.examples.storyshot delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/time_filter.examples.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/index.ts delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/__snapshots__/time_picker.stories.storyshot delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/time_picker.stories.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/index.ts delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.scss delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/__snapshots__/time_picker_popover.examples.storyshot delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/time_picker_popover.examples.tsx delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/index.ts delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.scss delete mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.tsx create mode 100644 x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/time_filter.scss diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/elements/time_filter/header.png b/x-pack/legacy/plugins/canvas/canvas_plugin_src/elements/time_filter/header.png index 2fbfabd61a41bb9749cd940632c4e4efa2c40648..d36b4cc97e5b13c542cfb59e53013e179532e741 100644 GIT binary patch literal 18970 zcmeIYbyU>P7dH+_NC|>~G@_Kmk|GUK(hAbu-JMGah?I10W0Pkhh${rCIpIp=ZDdB@Joy)$#?#_P_!V_v8$5);r6U|?VnD?OLf#K5@4g@J+T zavS%i#4;>*90P+$-d-cg8S3 z&memi%fzG&zMCxlEQasFo0&9uoM|3rGg)2vd&Y!JKD*X0cdyN5Dt6jm(- z?gwrl*B7O1M=mr5<^ydpzE}QKDix{V!Dvku*EjOxb@Wnx9D8z~2?OWe(;>g0)>L|0 zTAad@1vJM#NY;^E*C^GfdjzcuCBMBEgz--A%{Y!n2+x;5%%0eDO??IoIoFEj{9HEe zpC3tS`^~~hRnnen#mA;THI9d9Kf!mWd((VNy6n)eP8FkpwkSVsbo90OobUsmwA)|E zFueLn@ebt0F~8g;B^eyftN8N$&eQkko|Frck&_U020%SymE%i%5jn1m^@Fmj0{Hn- za!$!+tT`T@+N0PvT2n+wAAvxN_hjQtd#Udg`=qN$4i!I2Ta)l9Q*bboO`cV7n2v-= z+){mGjMMS%`5UzdcT!g66zxy8sDJYEd~u5`#Q7=i68_D%>jeW1=tp(3T3qbbXKMaC zhAW1BDV0AT!!_9J$Y*I#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o~Ng0*y^77Ytcy5UL=bEUQz_Dbr_z5kz=fM_aLCeUx5&Qf!B#V z9#WW=mUd0^Cw=%e$=PtOs2uM1z!yEMKcRjq)?_^<)%g)AYa0g;GI=Ww@31ukc` zzrMqG6B~?0xq^SZ>y{C5Yaw-oqUqzX@LhKb@Al8+{o&2zveR-KuB0@91b&LVie%)D z>*}>`O}`XroGE1weXM#7&8SqZ#jI%RwwcAQlh{gt7nw z1*W@oT=hdaEtH@H6AOU&IEMkmCrgsV0%8HNKxhkO4LH~U{{sUaX?noLYVQC5002ov JPDHLkV1icSlym?9 diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/timefilter.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/timefilter.ts index 8afa6eb04ad69..249faf6141b46 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/timefilter.ts +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/timefilter.ts @@ -58,14 +58,14 @@ export function timefilter(): ExpressionFunctionDefinition< } const { from, to, column } = args; - const filter = { + const filter: Filter = { type: 'time', column, and: [], }; - function parseAndValidate(str: string): string { - const moment = dateMath.parse(str); + function parseAndValidate(str: string, { roundUp }: { roundUp: boolean }): string { + const moment = dateMath.parse(str, { roundUp }); if (!moment || !moment.isValid()) { throw errors.invalidString(str); @@ -75,11 +75,11 @@ export function timefilter(): ExpressionFunctionDefinition< } if (!!to) { - (filter as any).to = parseAndValidate(to); + filter.to = parseAndValidate(to, { roundUp: true }); } if (!!from) { - (filter as any).from = parseAndValidate(from); + filter.from = parseAndValidate(from, { roundUp: false }); } return { ...input, and: [...input.and, filter] }; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/timefilterControl.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/timefilterControl.ts index 5b6c0cb97b0fd..2f7f5c26ad0b7 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/timefilterControl.ts +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/timefilterControl.ts @@ -34,6 +34,7 @@ export function timefilterControl(): ExpressionFunctionDefinition< help: argHelp.column, default: '@timestamp', }, + // TODO: remove this deprecated arg compact: { types: ['boolean'], help: argHelp.compact, diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/__examples__/__snapshots__/time_filter.examples.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/__examples__/__snapshots__/time_filter.examples.storyshot new file mode 100644 index 0000000000000..d555fbbe0ce92 --- /dev/null +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/__examples__/__snapshots__/time_filter.examples.storyshot @@ -0,0 +1,134 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Storyshots renderers/TimeFilter default 1`] = ` +
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+ → +
+
+
+
+ +
+
+
+
+
+
+
+
+`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/__examples__/__snapshots__/time_filter.stories.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/__examples__/__snapshots__/time_filter.stories.storyshot new file mode 100644 index 0000000000000..2973103d421a9 --- /dev/null +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/__examples__/__snapshots__/time_filter.stories.storyshot @@ -0,0 +1,521 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Storyshots renderers/TimeFilter default 1`] = ` +
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+`; + +exports[`Storyshots renderers/TimeFilter with absolute time bounds 1`] = ` +
+
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+ → +
+
+
+
+ +
+
+
+
+
+
+
+
+
+`; + +exports[`Storyshots renderers/TimeFilter with commonlyUsedRanges 1`] = ` +
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+`; + +exports[`Storyshots renderers/TimeFilter with dateFormat 1`] = ` +
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+`; + +exports[`Storyshots renderers/TimeFilter with relative time bounds 1`] = ` +
+
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+ → +
+
+
+
+ +
+
+
+
+
+
+
+
+
+`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/__examples__/time_filter.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/__examples__/time_filter.stories.tsx new file mode 100644 index 0000000000000..c854ea8267bf5 --- /dev/null +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/__examples__/time_filter.stories.tsx @@ -0,0 +1,66 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { action } from '@storybook/addon-actions'; +import { storiesOf } from '@storybook/react'; +import React from 'react'; +import { TimeFilter } from '../time_filter'; + +const timeRanges = [ + { start: 'now/d', end: 'now/d', label: 'Today' }, + { start: 'now/w', end: 'now/w', label: 'This week' }, + { start: 'now-15m', end: 'now', label: 'Last 15 minutes' }, + { start: 'now-30m', end: 'now', label: 'Last 30 minutes' }, + { start: 'now-1h', end: 'now', label: 'Last 1 hour' }, + { start: 'now-24h', end: 'now', label: 'Last 24 hours' }, + { start: 'now-7d', end: 'now', label: 'Last 7 days' }, + { start: 'now-30d', end: 'now', label: 'Last 30 days' }, + { start: 'now-90d', end: 'now', label: 'Last 90 days' }, + { start: 'now-1y', end: 'now', label: 'Last 1 year' }, +]; + +storiesOf('renderers/TimeFilter', module) + .addDecorator(story => ( +
+ {story()} +
+ )) + .add('default', () => ( + + )) + .add('with relative time bounds', () => ( + + )) + .add('with absolute time bounds', () => ( + + )) + .add('with dateFormat', () => ( + + )) + .add('with commonlyUsedRanges', () => ( + + )); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/__examples__/__snapshots__/datetime_calendar.stories.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/__examples__/__snapshots__/datetime_calendar.stories.storyshot deleted file mode 100644 index f6b14e98b5fad..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/__examples__/__snapshots__/datetime_calendar.stories.storyshot +++ /dev/null @@ -1,335 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/DatetimeCalendar default 1`] = ` -
-
-
- -
-
- - -
-
- -
-
-
-
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeCalendar invalid date 1`] = ` -
-
-
- -
-
- - -
-
- -
-
-
-
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeCalendar with max date 1`] = ` -
-
-
- -
-
- - -
-
- -
-
-
-
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeCalendar with min date 1`] = ` -
-
-
- -
-
- - -
-
- -
-
-
-
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeCalendar with start and end date 1`] = ` -
-
-
- -
-
- - -
-
- -
-
-
-
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeCalendar with value 1`] = ` -
-
-
- -
-
- - -
-
- -
-
-
-
-
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/__examples__/datetime_calendar.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/__examples__/datetime_calendar.stories.tsx deleted file mode 100644 index 19004e6fdcc5a..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/__examples__/datetime_calendar.stories.tsx +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import moment from 'moment'; -import React from 'react'; -import { DatetimeCalendar } from '..'; - -const startDate = moment.utc('2019-06-27'); -const endDate = moment.utc('2019-07-04'); - -storiesOf('renderers/TimeFilter/components/DatetimeCalendar', module) - .add('default', () => ( - - )) - .add('with value', () => ( - - )) - .add('with start and end date', () => ( - - )) - .add('with min date', () => ( - - )) - .add('with max date', () => ( - - )) - .add('invalid date', () => ( - - )); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.scss b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.scss deleted file mode 100644 index 6133b9184d1c5..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.scss +++ /dev/null @@ -1,6 +0,0 @@ -.canvasDateTimeCal { - display: inline-grid; - height: 100%; - border: $euiBorderThin; - grid-template-rows: $euiSizeXL 1fr; -} diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.tsx deleted file mode 100644 index 8c189682c959c..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.tsx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { FunctionComponent } from 'react'; -import PropTypes from 'prop-types'; -import { Moment } from 'moment'; -import { momentObj } from 'react-moment-proptypes'; -import { EuiDatePicker } from '@elastic/eui'; -import { DatetimeInput } from '../datetime_input'; - -export interface Props { - /** Selected date (Moment date object) */ - value?: Moment; - /** Function invoked when a date is selected from the datepicker */ - onSelect: (date: Moment | null) => void; - /** Function invoked when the date text input changes */ - onValueChange: (moment: Moment) => void; // Called with a moment - /** Start date of selected date range (Moment date object) */ - startDate?: Moment; - /** End date of selected date range (Moment date object) */ - endDate?: Moment; - /** Earliest selectable date (Moment date object) */ - minDate?: Moment; - /** Latest selectable date (Moment date object) */ - maxDate?: Moment; -} - -export const DatetimeCalendar: FunctionComponent = ({ - value, - onValueChange, - onSelect, - startDate, - endDate, - minDate, - maxDate, -}) => ( -
- - -
-); - -DatetimeCalendar.propTypes = { - value: PropTypes.oneOfType([momentObj, PropTypes.object]), // Handle both valid and invalid moment objects - onSelect: PropTypes.func.isRequired, - onValueChange: PropTypes.func.isRequired, // Called with a moment - startDate: momentObj, - endDate: momentObj, - minDate: momentObj, - maxDate: momentObj, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/index.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/index.ts deleted file mode 100644 index 7f64e2b89df03..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_calendar/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { DatetimeCalendar } from './datetime_calendar'; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/__snapshots__/datetime_input.stories.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/__snapshots__/datetime_input.stories.storyshot deleted file mode 100644 index 1bda4b5246991..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/__snapshots__/datetime_input.stories.storyshot +++ /dev/null @@ -1,67 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/DatetimeInput default 1`] = ` -
-
- -
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeInput invalid date 1`] = ` -
-
- -
-
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeInput with date 1`] = ` -
-
- -
-
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/datetime_input.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/datetime_input.stories.tsx deleted file mode 100644 index 060f04da88f99..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/__examples__/datetime_input.stories.tsx +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import moment from 'moment'; -import React from 'react'; -import { DatetimeInput } from '..'; - -storiesOf('renderers/TimeFilter/components/DatetimeInput', module) - .add('default', () => ) - .add('with date', () => ( - - )) - .add('invalid date', () => ( - - )); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/datetime_input.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/datetime_input.tsx deleted file mode 100644 index 32bdcde5ddda0..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/datetime_input.tsx +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { FunctionComponent, ChangeEvent } from 'react'; -import PropTypes from 'prop-types'; -import { EuiFieldText } from '@elastic/eui'; -import moment, { Moment } from 'moment'; - -export interface Props { - /** Selected string value of input */ - strValue: string; - /** Function invoked with string when input is changed */ - setStrValue: (value: string) => void; - /** Function invoked with moment when input is changed with valid datetime */ - setMoment: (value: Moment) => void; - /** Boolean denotes whether current input value is valid date */ - valid: boolean; - /** Function invoked with value validity when input is changed */ - setValid: (valid: boolean) => void; -} - -export const DatetimeInput: FunctionComponent = ({ - strValue, - setStrValue, - setMoment, - valid, - setValid, -}) => { - function check(e: ChangeEvent) { - const parsed = moment(e.target.value, 'YYYY-MM-DD HH:mm:ss', true); - if (parsed.isValid()) { - setMoment(parsed); - setValid(true); - } else { - setValid(false); - } - setStrValue(e.target.value); - } - - return ( - - ); -}; - -DatetimeInput.propTypes = { - setMoment: PropTypes.func, - strValue: PropTypes.string, - setStrValue: PropTypes.func, - valid: PropTypes.bool, - setValid: PropTypes.func, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/index.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/index.ts deleted file mode 100644 index ff0e52580b421..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_input/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { Moment } from 'moment'; -import { compose, withState, lifecycle } from 'recompose'; -import { DatetimeInput as Component, Props as ComponentProps } from './datetime_input'; - -export interface Props { - /** Input value (Moment date object) */ - moment?: Moment; - /** Function to invoke when the input changes */ - setMoment: (m: Moment) => void; -} - -export const DatetimeInput = compose( - withState('valid', 'setValid', () => true), - withState('strValue', 'setStrValue', ({ moment }) => - moment ? moment.format('YYYY-MM-DD HH:mm:ss') : '' - ), - lifecycle({ - componentDidUpdate(prevProps) { - const prevMoment = prevProps.moment; - - // If we don't have a current moment, do nothing - if (!this.props.moment) return; - - // If we previously had a moment and it's the same as the current moment, do nothing - if (prevMoment && prevMoment.isSame(this.props.moment)) { - return; - } - - // Set the string value of the current moment and mark as valid - this.props.setStrValue(this.props.moment.format('YYYY-MM-DD HH:mm:ss')); - this.props.setValid(true); - }, - }) -)(Component); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/__snapshots__/datetime_quick_list.stories.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/__snapshots__/datetime_quick_list.stories.storyshot deleted file mode 100644 index b3ec64fa55a07..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/__snapshots__/datetime_quick_list.stories.storyshot +++ /dev/null @@ -1,249 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/DatetimeQuickList with children 1`] = ` -
- - - - - - - - -
-`; - -exports[`Storyshots renderers/TimeFilter/components/DatetimeQuickList with start and end dates 1`] = ` -
- - - - - - - -
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/datetime_quick_list.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/datetime_quick_list.stories.tsx deleted file mode 100644 index 68ef3cf1300bc..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/__examples__/datetime_quick_list.stories.tsx +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { EuiButtonEmpty } from '@elastic/eui'; -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import React from 'react'; -import { DatetimeQuickList } from '..'; - -storiesOf('renderers/TimeFilter/components/DatetimeQuickList', module) - .add('with start and end dates', () => ( - - )) - .add('with children', () => ( - - Apply - - )); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/datetime_quick_list.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/datetime_quick_list.tsx deleted file mode 100644 index 9d5a3893dbcb8..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/datetime_quick_list.tsx +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { ReactNode, FunctionComponent } from 'react'; -import PropTypes from 'prop-types'; -import { EuiButton, EuiButtonEmpty } from '@elastic/eui'; -import 'react-datetime/css/react-datetime.css'; -import { UnitStrings } from '../../../../../i18n/units'; - -const { quickRanges: strings } = UnitStrings; - -interface Props { - /** Initial start date string */ - from: string; - /** Initial end date string */ - to: string; - - /** Function invoked when a date range is clicked */ - onSelect: (from: string, to: string) => void; - - /** Nodes to display under the date range buttons */ - children?: ReactNode; -} - -const quickRanges = [ - { from: 'now/d', to: 'now', display: strings.getTodayLabel() }, - { from: 'now-24h', to: 'now', display: strings.getLast24HoursLabel() }, - { from: 'now-7d', to: 'now', display: strings.getLast7DaysLabel() }, - { from: 'now-14d', to: 'now', display: strings.getLast2WeeksLabel() }, - { from: 'now-30d', to: 'now', display: strings.getLast30DaysLabel() }, - { from: 'now-90d', to: 'now', display: strings.getLast90DaysLabel() }, - { from: 'now-1y', to: 'now', display: strings.getLast1YearLabel() }, -]; - -export const DatetimeQuickList: FunctionComponent = ({ from, to, onSelect, children }) => ( -
- {quickRanges.map((range, i) => - from === range.from && to === range.to ? ( - onSelect(range.from, range.to)}> - {range.display} - - ) : ( - onSelect(range.from, range.to)}> - {range.display} - - ) - )} - {children} -
-); - -DatetimeQuickList.propTypes = { - from: PropTypes.string.isRequired, - to: PropTypes.string.isRequired, - onSelect: PropTypes.func.isRequired, - children: PropTypes.node, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/index.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/index.ts deleted file mode 100644 index 5780f0f89c00a..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_quick_list/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { DatetimeQuickList } from './datetime_quick_list'; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/__snapshots__/datetime_range_absolute.stories.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/__snapshots__/datetime_range_absolute.stories.storyshot deleted file mode 100644 index 7bf08c3d6f24e..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/__snapshots__/datetime_range_absolute.stories.storyshot +++ /dev/null @@ -1,122 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/DatetimeRangeAbsolute default 1`] = ` -
-
-
-
-
- -
-
- - -
-
- -
-
-
-
-
-
-
-
-
-
- -
-
- - -
-
- -
-
-
-
-
-
-
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/datetime_range_absolute.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/datetime_range_absolute.stories.tsx deleted file mode 100644 index 01d2fe49e29e8..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/__examples__/datetime_range_absolute.stories.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import moment from 'moment'; -import React from 'react'; -import { DatetimeRangeAbsolute } from '..'; - -const startDate = moment.utc('2019-06-21'); -const endDate = moment.utc('2019-07-05'); - -storiesOf('renderers/TimeFilter/components/DatetimeRangeAbsolute', module).add('default', () => ( - -)); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.scss b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.scss deleted file mode 100644 index 706bd90ad1edf..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.scss +++ /dev/null @@ -1,7 +0,0 @@ -.canvasDateTimeRangeAbsolute { - display: flex; - - > div:not(:last-child) { - margin-right: $euiSizeS; - } -} diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.tsx deleted file mode 100644 index ddd755b4a12f4..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.tsx +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { FunctionComponent } from 'react'; -import PropTypes from 'prop-types'; -import { Moment } from 'moment'; -import { momentObj } from 'react-moment-proptypes'; -import { DatetimeCalendar } from '../datetime_calendar'; - -interface Props { - /** Optional initial start date moment */ - from?: Moment; - /** Optional initial end date moment */ - to?: Moment; - - /** Function invoked when a date is selected from the datetime calendar */ - onSelect: (from?: Moment, to?: Moment) => void; -} - -export const DatetimeRangeAbsolute: FunctionComponent = ({ from, to, onSelect }) => ( -
-
- onSelect(val, to)} - onSelect={val => { - if (!val || !from) { - return; - } - - // sets the time to start of day if only the date was selected - if (from.format('hh:mm:ss a') === val.format('hh:mm:ss a')) { - onSelect(val.startOf('day'), to); - } else { - onSelect(val, to); - } - }} - /> -
-
- onSelect(from, val)} - onSelect={val => { - if (!val || !to) { - return; - } - - // set the time to end of day if only the date was selected - if (to.format('hh:mm:ss a') === val.format('hh:mm:ss a')) { - onSelect(from, val.endOf('day')); - } else { - onSelect(from, val); - } - }} - /> -
-
-); - -DatetimeRangeAbsolute.propTypes = { - from: momentObj, - to: momentObj, - onSelect: PropTypes.func.isRequired, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/index.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/index.ts deleted file mode 100644 index c6e5a77ca8af8..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { DatetimeRangeAbsolute } from './datetime_range_absolute'; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/index.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/index.tsx new file mode 100644 index 0000000000000..e2e9358bf99c6 --- /dev/null +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/index.tsx @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { AdvancedSettings } from '../../../../public/lib/kibana_advanced_settings'; +import { TimeFilter as Component, Props } from './time_filter'; + +export const TimeFilter = (props: Props) => { + const customQuickRanges = (AdvancedSettings.get('timepicker:quickRanges') || []).map( + ({ from, to, display }: { from: string; to: string; display: string }) => ({ + start: from, + end: to, + label: display, + }) + ); + + const customDateFormat = AdvancedSettings.get('dateFormat'); + + return ( + + ); +}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/__snapshots__/pretty_duration.stories.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/__snapshots__/pretty_duration.stories.storyshot deleted file mode 100644 index 3730cfb5f4e5c..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/__snapshots__/pretty_duration.stories.storyshot +++ /dev/null @@ -1,13 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/PrettyDuration with absolute dates 1`] = ` - - ~ 5 months ago to ~ 4 months ago - -`; - -exports[`Storyshots renderers/TimeFilter/components/PrettyDuration with relative dates 1`] = ` - - Last 7 days - -`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/pretty_duration.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/pretty_duration.stories.tsx deleted file mode 100644 index 951776f8a9558..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/__examples__/pretty_duration.stories.tsx +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { storiesOf } from '@storybook/react'; -import React from 'react'; -import { PrettyDuration } from '..'; - -storiesOf('renderers/TimeFilter/components/PrettyDuration', module) - .add('with relative dates', () => ) - .add('with absolute dates', () => ); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/index.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/index.ts deleted file mode 100644 index a35a4aba66487..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { pure } from 'recompose'; -import { PrettyDuration as Component } from './pretty_duration'; - -export const PrettyDuration = pure(Component); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/format_duration.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/format_duration.ts deleted file mode 100644 index b713eb4d7cd5e..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/format_duration.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import dateMath from '@elastic/datemath'; -import moment, { Moment } from 'moment'; -import { quickRanges, QuickRange } from './quick_ranges'; -import { timeUnits, TimeUnit } from '../../../../../../common/lib/time_units'; - -const lookupByRange: { [key: string]: QuickRange } = {}; -quickRanges.forEach(frame => { - lookupByRange[`${frame.from} to ${frame.to}`] = frame; -}); - -function formatTime(time: string | Moment, roundUp = false) { - if (moment.isMoment(time)) { - return time.format('lll'); - } else { - if (time === 'now') { - return 'now'; - } else { - const tryParse = dateMath.parse(time, { roundUp }); - return moment.isMoment(tryParse) ? '~ ' + tryParse.fromNow() : time; - } - } -} - -function cantLookup(from: string, to: string) { - return `${formatTime(from)} to ${formatTime(to)}`; -} - -export function formatDuration(from: string, to: string) { - // If both parts are date math, try to look up a reasonable string - if (from && to && !moment.isMoment(from) && !moment.isMoment(to)) { - const tryLookup = lookupByRange[`${from.toString()} to ${to.toString()}`]; - if (tryLookup) { - return tryLookup.display; - } else { - const fromParts = from.toString().split('-'); - if (to.toString() === 'now' && fromParts[0] === 'now' && fromParts[1]) { - const rounded = fromParts[1].split('/'); - let text = `Last ${rounded[0]}`; - if (rounded[1]) { - const unit = rounded[1] as TimeUnit; - text = `${text} rounded to the ${timeUnits[unit]}`; - } - - return text; - } else { - return cantLookup(from, to); - } - } - // If at least one part is a moment, try to make pretty strings by parsing date math - } else { - return cantLookup(from, to); - } -} diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/quick_ranges.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/quick_ranges.ts deleted file mode 100644 index 1c436d3630b53..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/lib/quick_ranges.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { UnitStrings } from '../../../../../../i18n/units'; - -export interface QuickRange { - /** Start date string of range */ - from: string; - /** Start date string of range */ - to: string; - /** Display name describing date range */ - display: string; -} - -const { quickRanges: strings } = UnitStrings; - -export const quickRanges: QuickRange[] = [ - { from: 'now/d', to: 'now/d', display: strings.getTodayLabel() }, - { from: 'now/w', to: 'now/w', display: strings.getThisWeekLabel() }, - { from: 'now/M', to: 'now/M', display: strings.getThisMonthLabel() }, - { from: 'now/y', to: 'now/y', display: strings.getThisYearLabel() }, - { from: 'now/d', to: 'now', display: strings.getTheDaySoFarLabel() }, - { from: 'now/w', to: 'now', display: strings.getWeekToDateLabel() }, - { from: 'now/M', to: 'now', display: strings.getMonthToDateLabel() }, - { from: 'now/y', to: 'now', display: strings.getYearToDateLabel() }, - - { from: 'now-1d/d', to: 'now-1d/d', display: strings.getYesterdayLabel() }, - { from: 'now-2d/d', to: 'now-2d/d', display: strings.getDayBeforeYesterdayLabel() }, - { from: 'now-7d/d', to: 'now-7d/d', display: strings.getThisDayLastWeek() }, - { from: 'now-1w/w', to: 'now-1w/w', display: strings.getPreviousWeekLabel() }, - { from: 'now-1M/M', to: 'now-1M/M', display: strings.getPreviousMonthLabel() }, - { from: 'now-1y/y', to: 'now-1y/y', display: strings.getPreviousYearLabel() }, - - { from: 'now-15m', to: 'now', display: strings.getLast15MinutesLabel() }, - { from: 'now-30m', to: 'now', display: strings.getLast30MinutesLabel() }, - { from: 'now-1h', to: 'now', display: strings.getLast1HourLabel() }, - { from: 'now-4h', to: 'now', display: strings.getLast4HoursLabel() }, - { from: 'now-12h', to: 'now', display: strings.getLast12HoursLabel() }, - { from: 'now-24h', to: 'now', display: strings.getLast24HoursLabel() }, - { from: 'now-7d', to: 'now', display: strings.getLast7DaysLabel() }, - { from: 'now-14d', to: 'now', display: strings.getLast2WeeksLabel() }, - - { from: 'now-30d', to: 'now', display: strings.getLast30DaysLabel() }, - { from: 'now-60d', to: 'now', display: strings.getLast60DaysLabel() }, - { from: 'now-90d', to: 'now', display: strings.getLast90DaysLabel() }, - { from: 'now-6M', to: 'now', display: strings.getLast6MonthsLabel() }, - { from: 'now-1y', to: 'now', display: strings.getLast1YearLabel() }, - { from: 'now-2y', to: 'now', display: strings.getLast2YearsLabel() }, - { from: 'now-5y', to: 'now', display: strings.getLast5YearsLabel() }, -]; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/pretty_duration.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/pretty_duration.tsx deleted file mode 100644 index f1b65c586ff0c..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/pretty_duration/pretty_duration.tsx +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { FunctionComponent } from 'react'; -import PropTypes from 'prop-types'; -import { formatDuration } from './lib/format_duration'; - -interface Props { - /** Initial start date string */ - from: string; - /** Initial end date string */ - to: string; -} - -export const PrettyDuration: FunctionComponent = ({ from, to }) => ( - {formatDuration(from, to)} -); - -PrettyDuration.propTypes = { - from: PropTypes.string.isRequired, - to: PropTypes.string.isRequired, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter.tsx new file mode 100644 index 0000000000000..8d28287b32066 --- /dev/null +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter.tsx @@ -0,0 +1,87 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { EuiSuperDatePicker, OnTimeChangeProps, EuiSuperDatePickerCommonRange } from '@elastic/eui'; +import React from 'react'; +import PropTypes from 'prop-types'; +import { get } from 'lodash'; +import { fromExpression } from '@kbn/interpreter/common'; +import { UnitStrings } from '../../../../i18n/units'; + +const { quickRanges: strings } = UnitStrings; + +const defaultQuickRanges: EuiSuperDatePickerCommonRange[] = [ + { start: 'now-1d/d', end: 'now-1d/d', label: strings.getYesterdayLabel() }, + { start: 'now/d', end: 'now', label: strings.getTodayLabel() }, + { start: 'now-24h', end: 'now', label: strings.getLast24HoursLabel() }, + { start: 'now-7d', end: 'now', label: strings.getLast7DaysLabel() }, + { start: 'now-14d', end: 'now', label: strings.getLast2WeeksLabel() }, + { start: 'now-30d', end: 'now', label: strings.getLast30DaysLabel() }, + { start: 'now-90d', end: 'now', label: strings.getLast90DaysLabel() }, + { start: 'now-1y', end: 'now', label: strings.getLast1YearLabel() }, +]; + +export interface FilterMeta { + /** Name of datetime column to be filtered */ + column: string; + /** Start date string of filtered date range */ + start: string; + /** End date string of filtered date range */ + end: string; +} + +function getFilterMeta(filter: string): FilterMeta { + const ast = fromExpression(filter); + const column = get(ast, 'chain[0].arguments.column[0]'); + const start = get(ast, 'chain[0].arguments.from[0]'); + const end = get(ast, 'chain[0].arguments.to[0]'); + return { column, start, end }; +} + +export interface Props { + /** Initial value of the filter */ + filter: string; + /** Function invoked when the filter changes */ + commit: (filter: string) => void; + /** Elastic datemath format string */ + dateFormat?: string; + /** Array of time ranges */ + commonlyUsedRanges?: EuiSuperDatePickerCommonRange[]; +} + +export const TimeFilter = ({ filter, commit, dateFormat, commonlyUsedRanges = [] }: Props) => { + const setFilter = (column: string) => ({ start, end }: OnTimeChangeProps) => { + commit(`timefilter from="${start}" to=${end} column=${column}`); + }; + + const { column, start, end } = getFilterMeta(filter); + + return ( +
+ +
+ ); +}; + +TimeFilter.propTypes = { + filter: PropTypes.string.isRequired, + commit: PropTypes.func.isRequired, // Canvas filter + dateFormat: PropTypes.string, + commonlyUsedRanges: PropTypes.arrayOf( + PropTypes.shape({ + start: PropTypes.string.isRequired, + end: PropTypes.string.isRequired, + label: PropTypes.string.isRequired, + }) + ), +}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/__snapshots__/time_filter.examples.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/__snapshots__/time_filter.examples.storyshot deleted file mode 100644 index 9c070dded5810..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/__snapshots__/time_filter.examples.storyshot +++ /dev/null @@ -1,283 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter compact mode 1`] = ` -
-
- -
-
-`; - -exports[`Storyshots renderers/TimeFilter default 1`] = ` -
-
-
-
-
-
- -
-
- - -
-
- -
-
-
-
-
-
-
-
-
-
- -
-
- - -
-
- -
-
-
-
-
-
-
-
- - - - - - - - -
-
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/time_filter.examples.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/time_filter.examples.tsx deleted file mode 100644 index b6b94bf3e4a05..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/__examples__/time_filter.examples.tsx +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import React from 'react'; -import { TimeFilter } from '..'; - -storiesOf('renderers/TimeFilter', module) - .add('default', () => ( - - )) - .add('compact mode', () => ( - - )); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/index.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/index.ts deleted file mode 100644 index cdea7d6591592..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { TimeFilter } from './time_filter'; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.tsx deleted file mode 100644 index cbe9793c806e1..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.tsx +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import { get } from 'lodash'; -import { fromExpression } from '@kbn/interpreter/common'; -import { TimePicker } from '../time_picker'; -import { TimePickerPopover } from '../time_picker_popover'; - -export interface FilterMeta { - /** Name of datetime column to be filtered */ - column: string; - /** Start date string of filtered date range */ - from: string; - /** End date string of filtered date range */ - to: string; -} - -function getFilterMeta(filter: string): FilterMeta { - const ast = fromExpression(filter); - const column = get(ast, 'chain[0].arguments.column[0]'); - const from = get(ast, 'chain[0].arguments.from[0]'); - const to = get(ast, 'chain[0].arguments.to[0]'); - return { column, from, to }; -} - -export interface Props { - /** Initial value of the filter */ - filter: string; - /** Function invoked when the filter changes */ - commit: (filter: string) => void; - /** Determines if compact or full-sized time picker is displayed */ - compact?: boolean; -} - -export const TimeFilter = ({ filter, commit, compact }: Props) => { - const setFilter = (column: string) => (from: string, to: string) => { - commit(`timefilter from="${from}" to=${to} column=${column}`); - }; - - const { column, from, to } = getFilterMeta(filter); - - if (compact) { - return ; - } else { - return ; - } -}; - -TimeFilter.propTypes = { - filter: PropTypes.string.isRequired, - commit: PropTypes.func.isRequired, // Canvas filter - compact: PropTypes.bool, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/__snapshots__/time_picker.stories.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/__snapshots__/time_picker.stories.storyshot deleted file mode 100644 index 49ea8ccc5889e..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/__snapshots__/time_picker.stories.storyshot +++ /dev/null @@ -1,256 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/TimePicker default 1`] = ` -
-
-
-
-
-
- -
-
- - -
-
- -
-
-
-
-
-
-
-
-
-
- -
-
- - -
-
- -
-
-
-
-
-
-
-
- - - - - - - - -
-
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/time_picker.stories.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/time_picker.stories.tsx deleted file mode 100644 index e34d2d5f58561..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/__examples__/time_picker.stories.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import moment from 'moment'; -import React from 'react'; -import { TimePicker } from '..'; - -const startDate = moment.utc('2018-04-04').toISOString(); -const endDate = moment.utc('2019-04-04').toISOString(); - -storiesOf('renderers/TimeFilter/components/TimePicker', module).add('default', () => ( - -)); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/index.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/index.ts deleted file mode 100644 index a220bd5eebc21..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { TimePicker } from './time_picker'; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.scss b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.scss deleted file mode 100644 index 889db1fc8165d..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.scss +++ /dev/null @@ -1,7 +0,0 @@ -.canvasTimePicker { - display: flex; - - > div:not(:last-child) { - margin-right: $euiSizeS; - } -} diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.tsx deleted file mode 100644 index 599b15524ddda..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.tsx +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import dateMath from '@elastic/datemath'; -import { EuiButton } from '@elastic/eui'; -import moment from 'moment'; -import { DatetimeQuickList } from '../datetime_quick_list'; -import { DatetimeRangeAbsolute } from '../datetime_range_absolute'; -import { ComponentStrings } from '../../../../../i18n/components'; - -const { TimePicker: strings } = ComponentStrings; - -export interface Props { - /** Start date string */ - from: string; - /** End date string */ - to: string; - /** Function invoked when date range is changed */ - onSelect: (from: string, to: string) => void; -} - -export interface State { - range: { - /** Start date string of selected date range */ - from: string; - /** End date string of selected date range */ - to: string; - }; - /** Boolean denoting whether selected date range has been applied */ - isDirty: boolean; -} - -export class TimePicker extends Component { - static propTypes = { - from: PropTypes.string.isRequired, - to: PropTypes.string.isRequired, - onSelect: PropTypes.func.isRequired, - }; - - state = { - range: { from: this.props.from, to: this.props.to }, - isDirty: false, - }; - - componentDidUpdate(prevProps: Props) { - const { to, from } = this.props; - - if (prevProps.from !== from || prevProps.to !== to) { - this.setState({ - range: { from, to }, - isDirty: false, - }); - } - } - - _absoluteSelect = (from?: moment.Moment, to?: moment.Moment) => { - if (from && to) { - this.setState({ - range: { from: moment(from).toISOString(), to: moment(to).toISOString() }, - isDirty: true, - }); - } - }; - - render() { - const { onSelect } = this.props; - const { range, isDirty } = this.state; - const { from, to } = range; - - return ( -
- - - { - this.setState({ isDirty: false }); - onSelect(from, to); - }} - > - {strings.getApplyButtonLabel()} - - -
- ); - } -} diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/__snapshots__/time_picker_popover.examples.storyshot b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/__snapshots__/time_picker_popover.examples.storyshot deleted file mode 100644 index 7e2474dbfb79c..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/__snapshots__/time_picker_popover.examples.storyshot +++ /dev/null @@ -1,28 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Storyshots renderers/TimeFilter/components/TimePickerPopover default 1`] = ` -
-
- -
-
-`; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/time_picker_popover.examples.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/time_picker_popover.examples.tsx deleted file mode 100644 index 7555de1336b3e..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/__examples__/time_picker_popover.examples.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { action } from '@storybook/addon-actions'; -import { storiesOf } from '@storybook/react'; -import moment from 'moment'; -import React from 'react'; -import { TimePickerPopover } from '..'; - -const startDate = moment.utc('2019-05-04').toISOString(); -const endDate = moment.utc('2019-06-04').toISOString(); - -storiesOf('renderers/TimeFilter/components/TimePickerPopover', module).add('default', () => ( - -)); diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/index.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/index.ts deleted file mode 100644 index 482580ea2e367..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { TimePickerPopover } from './time_picker_popover'; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.scss b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.scss deleted file mode 100644 index 1703c2c721dc0..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.scss +++ /dev/null @@ -1,19 +0,0 @@ -.canvasTimePickerPopover { - width: 100%; - - .canvasTimePickerPopover__button { - width: 100%; - padding: $euiSizeXS; - border: $euiBorderThin; - border-radius: $euiBorderRadius; - background-color: $euiColorEmptyShade; - - &:hover { - background-color: $euiColorLightestShade; - } - } - - .canvasTimePickerPopover__anchor { - width: 100%; - } -} diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.tsx deleted file mode 100644 index 8f6061b688319..0000000000000 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.tsx +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { FunctionComponent, MouseEvent } from 'react'; -import PropTypes from 'prop-types'; -// @ts-ignore untyped local -import { Popover } from '../../../../../public/components/popover'; -import { PrettyDuration } from '../pretty_duration'; -import { formatDuration } from '../pretty_duration/lib/format_duration'; -import { TimePicker } from '../time_picker'; - -export interface Props { - /** Start date string */ - from: string; - /** End date string */ - to: string; - /** Function invoked when date range is changed */ - onSelect: (from: string, to: string) => void; -} - -export const TimePickerPopover: FunctionComponent = ({ from, to, onSelect }) => { - const button = (handleClick: (event: MouseEvent) => void) => ( - - ); - - return ( - - {({ closePopover }) => ( - { - onSelect(...args); - closePopover(); - }} - /> - )} - - ); -}; - -TimePickerPopover.propTypes = { - from: PropTypes.string.isRequired, - to: PropTypes.string.isRequired, - onSelect: PropTypes.func.isRequired, -}; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js index 7fd6e81752b3c..cbc514e218d74 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js @@ -9,7 +9,7 @@ import React from 'react'; import { toExpression } from '@kbn/interpreter/common'; import { syncFilterExpression } from '../../../public/lib/sync_filter_expression'; import { RendererStrings } from '../../../i18n'; -import { TimeFilter } from './components/time_filter'; +import { TimeFilter } from './components'; const { timeFilter: strings } = RendererStrings; diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/time_filter.scss b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/time_filter.scss new file mode 100644 index 0000000000000..442332697f318 --- /dev/null +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/time_filter.scss @@ -0,0 +1,11 @@ +.canvasTimeFilter .euiSuperDatePicker__flexWrapper { + width: 100%; + + &.euiFlexGroup--gutterSmall { + margin: 0; + + > .euiFlexItem { + margin: 0; + } + } +} \ No newline at end of file diff --git a/x-pack/legacy/plugins/canvas/i18n/units.ts b/x-pack/legacy/plugins/canvas/i18n/units.ts index 04b1fec9b1f8a..a105031e7edf7 100644 --- a/x-pack/legacy/plugins/canvas/i18n/units.ts +++ b/x-pack/legacy/plugins/canvas/i18n/units.ts @@ -72,6 +72,10 @@ export const UnitStrings = { }), }, quickRanges: { + getYesterdayLabel: () => + i18n.translate('xpack.canvas.units.quickRange.yesterday', { + defaultMessage: 'Yesterday', + }), getTodayLabel: () => i18n.translate('xpack.canvas.units.quickRange.today', { defaultMessage: 'Today', @@ -100,93 +104,5 @@ export const UnitStrings = { i18n.translate('xpack.canvas.units.quickRange.last1Year', { defaultMessage: 'Last 1 year', }), - getThisWeekLabel: () => - i18n.translate('xpack.canvas.units.quickRange.thisWeek', { - defaultMessage: 'This week', - }), - getThisMonthLabel: () => - i18n.translate('xpack.canvas.units.quickRange.thisMonth', { - defaultMessage: 'This month', - }), - getThisYearLabel: () => - i18n.translate('xpack.canvas.units.quickRange.thisYear', { - defaultMessage: 'This year', - }), - getTheDaySoFarLabel: () => - i18n.translate('xpack.canvas.units.quickRange.theDaySoFar', { - defaultMessage: 'The day so far', - }), - getWeekToDateLabel: () => - i18n.translate('xpack.canvas.units.quickRange.weekToDate', { - defaultMessage: 'Week to date', - }), - getMonthToDateLabel: () => - i18n.translate('xpack.canvas.units.quickRange.monthToDate', { - defaultMessage: 'Month to date', - }), - getYearToDateLabel: () => - i18n.translate('xpack.canvas.units.quickRange.yearToDate', { - defaultMessage: 'Year to date', - }), - getYesterdayLabel: () => - i18n.translate('xpack.canvas.units.quickRange.yesterday', { - defaultMessage: 'Yesterday', - }), - getDayBeforeYesterdayLabel: () => - i18n.translate('xpack.canvas.units.quickRange.dayBeforeYesterday', { - defaultMessage: 'Day before yesterday', - }), - getThisDayLastWeek: () => - i18n.translate('xpack.canvas.units.quickRange.thisDayLastWeek', { - defaultMessage: 'This day last week', - }), - getPreviousWeekLabel: () => - i18n.translate('xpack.canvas.units.quickRange.previousWeek', { - defaultMessage: 'Previous week', - }), - getPreviousMonthLabel: () => - i18n.translate('xpack.canvas.units.quickRange.previousMonth', { - defaultMessage: 'Previous month', - }), - getPreviousYearLabel: () => - i18n.translate('xpack.canvas.units.quickRange.previousYear', { - defaultMessage: 'Previous year', - }), - getLast15MinutesLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last15Minutes', { - defaultMessage: 'Last 15 minutes', - }), - getLast30MinutesLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last30Minutes', { - defaultMessage: 'Last 30 minutes', - }), - getLast1HourLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last1Hour', { - defaultMessage: 'Last 1 hour', - }), - getLast4HoursLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last4Hours', { - defaultMessage: 'Last 4 hours', - }), - getLast12HoursLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last12Hours', { - defaultMessage: 'Last 12 hours', - }), - getLast60DaysLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last60Days', { - defaultMessage: 'Last 60 days', - }), - getLast6MonthsLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last6Months', { - defaultMessage: 'Last 6 months', - }), - getLast2YearsLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last2Years', { - defaultMessage: 'Last 2 years', - }), - getLast5YearsLabel: () => - i18n.translate('xpack.canvas.units.quickRange.last5Years', { - defaultMessage: 'Last 5 years', - }), }, }; diff --git a/x-pack/legacy/plugins/canvas/public/style/index.scss b/x-pack/legacy/plugins/canvas/public/style/index.scss index 39e5903ff1d96..56f9ed8d18cbe 100644 --- a/x-pack/legacy/plugins/canvas/public/style/index.scss +++ b/x-pack/legacy/plugins/canvas/public/style/index.scss @@ -64,8 +64,5 @@ @import '../../canvas_plugin_src/renderers/embeddable/embeddable.scss'; @import '../../canvas_plugin_src/renderers/plot/plot.scss'; @import '../../canvas_plugin_src/renderers/reveal_image/reveal_image.scss'; -@import '../../canvas_plugin_src/renderers/time_filter/components/datetime_calendar/datetime_calendar.scss'; -@import '../../canvas_plugin_src/renderers/time_filter/components/datetime_range_absolute/datetime_range_absolute.scss'; -@import '../../canvas_plugin_src/renderers/time_filter/components/time_picker/time_picker.scss'; -@import '../../canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.scss'; +@import '../../canvas_plugin_src/renderers/time_filter/time_filter.scss'; @import '../../canvas_plugin_src/uis/arguments/image_upload/image_upload.scss'; diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 8c7ea95d713d7..bec3ffd147964 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -5140,34 +5140,13 @@ "xpack.canvas.uis.views.timefilter.args.filterGroupLabel": "選択されたグループ名をエレメントのフィルター関数に適用してこのフィルターをターゲットにする", "xpack.canvas.uis.views.timefilter.args.filterGroupTitle": "フィルターグループ名", "xpack.canvas.uis.views.timefilterTitle": "時間フィルター", - "xpack.canvas.units.quickRange.dayBeforeYesterday": "一昨日", - "xpack.canvas.units.quickRange.last12Hours": "過去 12 時間", - "xpack.canvas.units.quickRange.last15Minutes": "過去 15 分間", - "xpack.canvas.units.quickRange.last1Hour": "過去 1 時間", "xpack.canvas.units.quickRange.last1Year": "過去 1 年間", "xpack.canvas.units.quickRange.last24Hours": "過去 24 時間", "xpack.canvas.units.quickRange.last2Weeks": "過去 2 週間", - "xpack.canvas.units.quickRange.last2Years": "過去 2 年間", "xpack.canvas.units.quickRange.last30Days": "過去 30 日間", - "xpack.canvas.units.quickRange.last30Minutes": "過去 30 分間", - "xpack.canvas.units.quickRange.last4Hours": "過去 4 時間", - "xpack.canvas.units.quickRange.last5Years": "過去 5 年間", - "xpack.canvas.units.quickRange.last60Days": "過去 60 日間", - "xpack.canvas.units.quickRange.last6Months": "過去 6 か月間", "xpack.canvas.units.quickRange.last7Days": "過去 7 日間", "xpack.canvas.units.quickRange.last90Days": "過去 90 日間", - "xpack.canvas.units.quickRange.monthToDate": "月初めから今日まで", - "xpack.canvas.units.quickRange.previousMonth": "先月", - "xpack.canvas.units.quickRange.previousWeek": "先週", - "xpack.canvas.units.quickRange.previousYear": "昨年", - "xpack.canvas.units.quickRange.theDaySoFar": "本日現在まで", - "xpack.canvas.units.quickRange.thisDayLastWeek": "先週のこの曜日", - "xpack.canvas.units.quickRange.thisMonth": "今月", - "xpack.canvas.units.quickRange.thisWeek": "今週", - "xpack.canvas.units.quickRange.thisYear": "今年", "xpack.canvas.units.quickRange.today": "今日", - "xpack.canvas.units.quickRange.weekToDate": "週初めから今日まで", - "xpack.canvas.units.quickRange.yearToDate": "年度の頭から今日まで", "xpack.canvas.units.quickRange.yesterday": "昨日", "xpack.canvas.units.time.days": "{days, plural, one {# 日} other {# 日}}", "xpack.canvas.units.time.hours": "{hours, plural, one {# 時間} other {# 時間}}", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 34fff4d885eda..f472247232cb8 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -5140,34 +5140,13 @@ "xpack.canvas.uis.views.timefilter.args.filterGroupLabel": "将选定组名称应用到元素的筛选函数,以定位该筛选", "xpack.canvas.uis.views.timefilter.args.filterGroupTitle": "筛选组名称", "xpack.canvas.uis.views.timefilterTitle": "时间筛选", - "xpack.canvas.units.quickRange.dayBeforeYesterday": "前天", - "xpack.canvas.units.quickRange.last12Hours": "过去 12 小时", - "xpack.canvas.units.quickRange.last15Minutes": "过去 15 分钟", - "xpack.canvas.units.quickRange.last1Hour": "过去 1 小时", "xpack.canvas.units.quickRange.last1Year": "过去 1 年", "xpack.canvas.units.quickRange.last24Hours": "过去 24 小时", "xpack.canvas.units.quickRange.last2Weeks": "过去 2 周", - "xpack.canvas.units.quickRange.last2Years": "过去 2 年", "xpack.canvas.units.quickRange.last30Days": "过去 30 天", - "xpack.canvas.units.quickRange.last30Minutes": "过去 30 分钟", - "xpack.canvas.units.quickRange.last4Hours": "过去 4 小时", - "xpack.canvas.units.quickRange.last5Years": "过去 5 年", - "xpack.canvas.units.quickRange.last60Days": "过去 60 天", - "xpack.canvas.units.quickRange.last6Months": "过去 6 个月", "xpack.canvas.units.quickRange.last7Days": "过去 7 天", "xpack.canvas.units.quickRange.last90Days": "过去 90 天", - "xpack.canvas.units.quickRange.monthToDate": "本月迄今为止", - "xpack.canvas.units.quickRange.previousMonth": "上一月", - "xpack.canvas.units.quickRange.previousWeek": "上一周", - "xpack.canvas.units.quickRange.previousYear": "上一年", - "xpack.canvas.units.quickRange.theDaySoFar": "今天迄今为止", - "xpack.canvas.units.quickRange.thisDayLastWeek": "上周本日", - "xpack.canvas.units.quickRange.thisMonth": "本月", - "xpack.canvas.units.quickRange.thisWeek": "本周", - "xpack.canvas.units.quickRange.thisYear": "本年", "xpack.canvas.units.quickRange.today": "今日", - "xpack.canvas.units.quickRange.weekToDate": "本周迄今为止", - "xpack.canvas.units.quickRange.yearToDate": "本年迄今为止", "xpack.canvas.units.quickRange.yesterday": "昨天", "xpack.canvas.units.time.days": "{days, plural, one {# 天} other {# 天}}", "xpack.canvas.units.time.hours": "{hours, plural, one {# 小时} other {# 小时}}", From 7983d1dff73beac45d9719fe264391928982f373 Mon Sep 17 00:00:00 2001 From: Paul Tavares <56442535+paul-tavares@users.noreply.github.com> Date: Fri, 20 Mar 2020 16:32:55 -0400 Subject: [PATCH 19/42] [Endpoint] Integrate the Policy list with ingest datasources api (#60548) * Use ingest API to get endpoint datasources * Add `application` service to `KibanaContextProvider` * Adjust Policy list to show data available from API * Added ingest service + refactored middleware * handle api failures/errors * Removed policy list fake_data generator * Fix typing * Rename method + added explicit return type * move dispatch outside of try block * Removed unnecessary action * Added FIXME comments with link to issue * Skip some functional tests * added tests for ingest service * Policy list tests - turn it all off Co-authored-by: Elastic Machine --- .../public/applications/endpoint/index.tsx | 9 +- .../endpoint/services/ingest.test.ts | 53 ++++++++ .../applications/endpoint/services/ingest.ts | 62 +++++++++ .../store/policy_details/middleware.ts | 6 +- .../endpoint/store/policy_details/reducer.ts | 12 +- .../endpoint/store/policy_list/action.ts | 12 +- .../endpoint/store/policy_list/fake_data.ts | 63 --------- .../endpoint/store/policy_list/middleware.ts | 25 +++- .../endpoint/store/policy_list/reducer.ts | 10 ++ .../endpoint/store/policy_list/selectors.ts | 2 + .../public/applications/endpoint/types.ts | 19 +-- .../endpoint/view/policy/policy_list.tsx | 125 +++++++----------- .../apps/endpoint/policy_details.ts | 3 +- .../functional/apps/endpoint/policy_list.ts | 4 +- 14 files changed, 230 insertions(+), 175 deletions(-) create mode 100644 x-pack/plugins/endpoint/public/applications/endpoint/services/ingest.test.ts create mode 100644 x-pack/plugins/endpoint/public/applications/endpoint/services/ingest.ts delete mode 100644 x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/fake_data.ts diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx index 997113754f95d..884646369b4b1 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx @@ -50,13 +50,18 @@ interface RouterProps { } const AppRoot: React.FunctionComponent = React.memo( - ({ basename, store, coreStart: { http, notifications, uiSettings }, depsStart: { data } }) => { + ({ + basename, + store, + coreStart: { http, notifications, uiSettings, application }, + depsStart: { data }, + }) => { const isDarkMode = useObservable(uiSettings.get$('theme:darkMode')); return ( - + diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/services/ingest.test.ts b/x-pack/plugins/endpoint/public/applications/endpoint/services/ingest.test.ts new file mode 100644 index 0000000000000..a2c1dfbe09a48 --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/services/ingest.test.ts @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { httpServiceMock } from '../../../../../../../src/core/public/mocks'; +import { sendGetDatasource, sendGetEndpointSpecificDatasources } from './ingest'; + +describe('ingest service', () => { + let http: ReturnType; + + beforeEach(() => { + http = httpServiceMock.createStartContract(); + }); + + describe('sendGetEndpointSpecificDatasources()', () => { + it('auto adds kuery to api request', async () => { + await sendGetEndpointSpecificDatasources(http); + expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/datasources', { + query: { + kuery: 'datasources.package.name: endpoint', + }, + }); + }); + it('supports additional KQL to be defined on input for query params', async () => { + await sendGetEndpointSpecificDatasources(http, { + query: { kuery: 'someValueHere', page: 1, perPage: 10 }, + }); + expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/datasources', { + query: { + kuery: 'someValueHere and datasources.package.name: endpoint', + perPage: 10, + page: 1, + }, + }); + }); + }); + describe('sendGetDatasource()', () => { + it('builds correct API path', async () => { + await sendGetDatasource(http, '123'); + expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/datasources/123', undefined); + }); + it('supports http options', async () => { + await sendGetDatasource(http, '123', { query: { page: 1 } }); + expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/datasources/123', { + query: { + page: 1, + }, + }); + }); + }); +}); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/services/ingest.ts b/x-pack/plugins/endpoint/public/applications/endpoint/services/ingest.ts new file mode 100644 index 0000000000000..fbb92f8bbe915 --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/services/ingest.ts @@ -0,0 +1,62 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { HttpFetchOptions, HttpStart } from 'kibana/public'; +import { GetDatasourcesRequest } from '../../../../../ingest_manager/common/types/rest_spec'; +import { PolicyData } from '../types'; + +const INGEST_API_ROOT = `/api/ingest_manager`; +const INGEST_API_DATASOURCES = `${INGEST_API_ROOT}/datasources`; + +// FIXME: Import from ingest after - https://github.com/elastic/kibana/issues/60677 +export interface GetDatasourcesResponse { + items: PolicyData[]; + total: number; + page: number; + perPage: number; + success: boolean; +} + +// FIXME: Import from Ingest after - https://github.com/elastic/kibana/issues/60677 +export interface GetDatasourceResponse { + item: PolicyData; + success: boolean; +} + +/** + * Retrieves a list of endpoint specific datasources (those created with a `package.name` of + * `endpoint`) from Ingest + * @param http + * @param options + */ +export const sendGetEndpointSpecificDatasources = ( + http: HttpStart, + options: HttpFetchOptions & Partial = {} +): Promise => { + return http.get(INGEST_API_DATASOURCES, { + ...options, + query: { + ...options.query, + kuery: `${ + options?.query?.kuery ? options.query.kuery + ' and ' : '' + }datasources.package.name: endpoint`, + }, + }); +}; + +/** + * Retrieves a single datasource based on ID from ingest + * @param http + * @param datasourceId + * @param options + */ +export const sendGetDatasource = ( + http: HttpStart, + datasourceId: string, + options?: HttpFetchOptions +) => { + return http.get(`${INGEST_API_DATASOURCES}/${datasourceId}`, options); +}; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/middleware.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/middleware.ts index 92a1c036c0211..39d7eb93569e2 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/middleware.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/middleware.ts @@ -6,8 +6,11 @@ import { MiddlewareFactory, PolicyDetailsState } from '../../types'; import { selectPolicyIdFromParams, isOnPolicyDetailsPage } from './selectors'; +import { sendGetDatasource } from '../../services/ingest'; export const policyDetailsMiddlewareFactory: MiddlewareFactory = coreStart => { + const http = coreStart.http; + return ({ getState, dispatch }) => next => async action => { next(action); const state = getState(); @@ -15,8 +18,7 @@ export const policyDetailsMiddlewareFactory: MiddlewareFactory { return { - policyItem: { - name: '', - total: 0, - pending: 0, - failed: 0, - id: '', - created_by: '', - created: '', - updated_by: '', - updated: '', - }, + policyItem: undefined, isLoading: false, }; }; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/action.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/action.ts index 5ac2a4328b00a..3f4f3f39e9be0 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/action.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/action.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { PolicyData } from '../../types'; +import { PolicyData, ServerApiError } from '../../types'; interface ServerReturnedPolicyListData { type: 'serverReturnedPolicyListData'; @@ -16,6 +16,11 @@ interface ServerReturnedPolicyListData { }; } +interface ServerFailedToReturnPolicyListData { + type: 'serverFailedToReturnPolicyListData'; + payload: ServerApiError; +} + interface UserPaginatedPolicyListTable { type: 'userPaginatedPolicyListTable'; payload: { @@ -24,4 +29,7 @@ interface UserPaginatedPolicyListTable { }; } -export type PolicyListAction = ServerReturnedPolicyListData | UserPaginatedPolicyListTable; +export type PolicyListAction = + | ServerReturnedPolicyListData + | UserPaginatedPolicyListTable + | ServerFailedToReturnPolicyListData; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/fake_data.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/fake_data.ts deleted file mode 100644 index 2312d3397f7be..0000000000000 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/fake_data.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -// !!!! Should be deleted when https://github.com/elastic/endpoint-app-team/issues/150 -// is implemented - -const dateOffsets = [ - 0, - 1000, - 300000, // 5 minutes - 3.6e6, // 1 hour - 86340000, // 23h, 59m - 9e7, // 25h - 9e7 * 5, // 5d -]; - -const randomNumbers = [5, 50, 500, 5000, 50000]; - -const getRandomDateIsoString = () => { - const randomIndex = Math.floor(Math.random() * Math.floor(dateOffsets.length)); - return new Date(Date.now() - dateOffsets[randomIndex]).toISOString(); -}; - -const getRandomNumber = () => { - const randomIndex = Math.floor(Math.random() * Math.floor(randomNumbers.length)); - return randomNumbers[randomIndex]; -}; - -const policyItem = (id: string) => { - return { - name: `policy with some protections ${id}`, - total: getRandomNumber(), - pending: getRandomNumber(), - failed: getRandomNumber(), - id: `${id}`, - created_by: `admin ABC`, - created: getRandomDateIsoString(), - updated_by: 'admin 123', - updated: getRandomDateIsoString(), - }; -}; - -export const getFakeDatasourceApiResponse = async (page: number, pageSize: number) => { - await new Promise(resolve => setTimeout(resolve, 500)); - - // Emulates the API response - see PR: - // https://github.com/elastic/kibana/pull/56567/files#diff-431549a8739efe0c56763f164c32caeeR25 - return { - items: Array.from({ length: pageSize }, (x, i) => policyItem(`${i + 1}`)), - success: true, - total: pageSize * 10, - page, - perPage: pageSize, - }; -}; - -export const getFakeDatasourceDetailsApiResponse = async (id: string) => { - await new Promise(resolve => setTimeout(resolve, 500)); - return policyItem(id); -}; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/middleware.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/middleware.ts index f8e2b7d07c389..ebfee5dbe6a7e 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/middleware.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/middleware.ts @@ -5,8 +5,11 @@ */ import { MiddlewareFactory, PolicyListState } from '../../types'; +import { GetDatasourcesResponse, sendGetEndpointSpecificDatasources } from '../../services/ingest'; export const policyListMiddlewareFactory: MiddlewareFactory = coreStart => { + const http = coreStart.http; + return ({ getState, dispatch }) => next => async action => { next(action); @@ -26,10 +29,24 @@ export const policyListMiddlewareFactory: MiddlewareFactory = c pageIndex = state.pageIndex; } - // Need load data from API and remove fake data below - // Refactor tracked via: https://github.com/elastic/endpoint-app-team/issues/150 - const { getFakeDatasourceApiResponse } = await import('./fake_data'); - const { items: policyItems, total } = await getFakeDatasourceApiResponse(pageIndex, pageSize); + let response: GetDatasourcesResponse; + + try { + response = await sendGetEndpointSpecificDatasources(http, { + query: { + perPage: pageSize, + page: pageIndex + 1, + }, + }); + } catch (err) { + dispatch({ + type: 'serverFailedToReturnPolicyListData', + payload: err.body ?? err, + }); + return; + } + + const { items: policyItems, total } = response; dispatch({ type: 'serverReturnedPolicyListData', diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/reducer.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/reducer.ts index 77f536d413ae3..b964f4f023866 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/reducer.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/reducer.ts @@ -12,6 +12,7 @@ const initialPolicyListState = (): PolicyListState => { return { policyItems: [], isLoading: false, + apiError: undefined, pageIndex: 0, pageSize: 10, total: 0, @@ -30,12 +31,21 @@ export const policyListReducer: Reducer = ( }; } + if (action.type === 'serverFailedToReturnPolicyListData') { + return { + ...state, + apiError: action.payload, + isLoading: false, + }; + } + if ( action.type === 'userPaginatedPolicyListTable' || (action.type === 'userNavigatedToPage' && action.payload === 'policyListPage') ) { return { ...state, + apiError: undefined, isLoading: true, }; } diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/selectors.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/selectors.ts index b9c2edbf5d55b..7ca25e81ce75a 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/selectors.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/selectors.ts @@ -15,3 +15,5 @@ export const selectPageSize = (state: PolicyListState) => state.pageSize; export const selectTotal = (state: PolicyListState) => state.total; export const selectIsLoading = (state: PolicyListState) => state.isLoading; + +export const selectApiError = (state: PolicyListState) => state.apiError; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/types.ts b/x-pack/plugins/endpoint/public/applications/endpoint/types.ts index 3045f42a93fe2..dae2c93c9dd04 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/types.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/types.ts @@ -16,6 +16,7 @@ import { import { EndpointPluginStartDependencies } from '../../plugin'; import { AppAction } from './store/action'; import { CoreStart } from '../../../../../../src/core/public'; +import { Datasource } from '../../../../ingest_manager/common/types/models'; export { AppAction }; export type MiddlewareFactory = ( @@ -50,18 +51,10 @@ export interface ServerApiError { message: string; } -// REFACTOR to use Types from Ingest Manager - see: https://github.com/elastic/endpoint-app-team/issues/150 -export interface PolicyData { - name: string; - total: number; - pending: number; - failed: number; - id: string; - created_by: string; - created: string; - updated_by: string; - updated: string; -} +/** + * An Endpoint Policy. + */ +export type PolicyData = Datasource; /** * Policy list store state @@ -69,6 +62,8 @@ export interface PolicyData { export interface PolicyListState { /** Array of policy items */ policyItems: PolicyData[]; + /** API error if loading data failed */ + apiError?: ServerApiError; /** total number of policies */ total: number; /** Number of policies per page */ diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_list.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_list.tsx index e7ce53679bbe7..f949efa46a2bd 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_list.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_list.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useCallback, useMemo } from 'react'; +import React, { SyntheticEvent, useCallback, useEffect, useMemo } from 'react'; import { EuiPage, EuiPageBody, @@ -16,17 +16,15 @@ import { EuiBasicTable, EuiText, EuiTableFieldDataColumnType, - EuiToolTip, EuiLink, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { FormattedMessage, FormattedNumber } from '@kbn/i18n/react'; +import { FormattedMessage } from '@kbn/i18n/react'; import { useDispatch } from 'react-redux'; -import styled from 'styled-components'; import { useHistory } from 'react-router-dom'; import { usePageId } from '../use_page_id'; -import { FormattedDateAndTime } from '../formatted_date_time'; import { + selectApiError, selectIsLoading, selectPageIndex, selectPageSize, @@ -36,21 +34,12 @@ import { import { usePolicyListSelector } from './policy_hooks'; import { PolicyListAction } from '../../store/policy_list'; import { PolicyData } from '../../types'; -import { TruncateText } from '../../components/truncate_text'; +import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; interface TableChangeCallbackArguments { page: { index: number; size: number }; } -const TruncateTooltipText = styled(TruncateText)` - .euiToolTipAnchor { - display: block; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } -`; - const PolicyLink: React.FC<{ name: string; route: string }> = ({ name, route }) => { const history = useHistory(); @@ -70,29 +59,28 @@ const renderPolicyNameLink = (value: string, _item: PolicyData) => { return ; }; -const renderDate = (date: string, _item: PolicyData) => ( - - - - - -); - -const renderFormattedNumber = (value: number, _item: PolicyData) => ( - - - -); - export const PolicyList = React.memo(() => { usePageId('policyListPage'); + const { services, notifications } = useKibana(); + const dispatch = useDispatch<(action: PolicyListAction) => void>(); const policyItems = usePolicyListSelector(selectPolicyItems); const pageIndex = usePolicyListSelector(selectPageIndex); const pageSize = usePolicyListSelector(selectPageSize); const totalItemCount = usePolicyListSelector(selectTotal); const loading = usePolicyListSelector(selectIsLoading); + const apiError = usePolicyListSelector(selectApiError); + + useEffect(() => { + if (apiError) { + notifications.toasts.danger({ + title: apiError.error, + body: apiError.message, + toastLifeTimeMs: 10000, + }); + } + }, [apiError, dispatch, notifications.toasts]); const paginationSetup = useMemo(() => { return { @@ -128,67 +116,52 @@ export const PolicyList = React.memo(() => { truncateText: true, }, { - field: 'total', - name: i18n.translate('xpack.endpoint.policyList.totalField', { - defaultMessage: 'Total', + field: 'revision', + name: i18n.translate('xpack.endpoint.policyList.revisionField', { + defaultMessage: 'Revision', }), - render: renderFormattedNumber, dataType: 'number', - truncateText: true, - width: '15ch', }, { - field: 'pending', - name: i18n.translate('xpack.endpoint.policyList.pendingField', { - defaultMessage: 'Pending', + field: 'package', + name: i18n.translate('xpack.endpoint.policyList.versionField', { + defaultMessage: 'Version', }), - render: renderFormattedNumber, - dataType: 'number', - truncateText: true, - width: '15ch', - }, - { - field: 'failed', - name: i18n.translate('xpack.endpoint.policyList.failedField', { - defaultMessage: 'Failed', - }), - render: renderFormattedNumber, - dataType: 'number', - truncateText: true, - width: '15ch', - }, - { - field: 'created_by', - name: i18n.translate('xpack.endpoint.policyList.createdByField', { - defaultMessage: 'Created By', - }), - truncateText: true, - }, - { - field: 'created', - name: i18n.translate('xpack.endpoint.policyList.createdField', { - defaultMessage: 'Created', - }), - render: renderDate, - truncateText: true, + render(pkg) { + return `${pkg.title} v${pkg.version}`; + }, }, { - field: 'updated_by', - name: i18n.translate('xpack.endpoint.policyList.updatedByField', { - defaultMessage: 'Last Updated By', + field: 'description', + name: i18n.translate('xpack.endpoint.policyList.descriptionField', { + defaultMessage: 'Description', }), truncateText: true, }, { - field: 'updated', - name: i18n.translate('xpack.endpoint.policyList.updatedField', { - defaultMessage: 'Last Updated', + field: 'config_id', + name: i18n.translate('xpack.endpoint.policyList.agentConfigField', { + defaultMessage: 'Agent Configuration', }), - render: renderDate, - truncateText: true, + render(version: string) { + return ( + // eslint-disable-next-line @elastic/eui/href-or-on-click + { + ev.preventDefault(); + services.application.navigateToApp('ingestManager', { + path: `#/configs/${version}`, + }); + }} + > + {version} + + ); + }, }, ], - [] + [services.application] ); return ( diff --git a/x-pack/test/functional/apps/endpoint/policy_details.ts b/x-pack/test/functional/apps/endpoint/policy_details.ts index 39b6e7a9f4fb7..f251dcd93014e 100644 --- a/x-pack/test/functional/apps/endpoint/policy_details.ts +++ b/x-pack/test/functional/apps/endpoint/policy_details.ts @@ -10,7 +10,8 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { const pageObjects = getPageObjects(['common', 'endpoint']); const testSubjects = getService('testSubjects'); - describe('Endpoint Policy Details', function() { + // Skipped until we can figure out how to load data for Ingest + describe.skip('Endpoint Policy Details', function() { this.tags(['ciGroup7']); it('loads the Policy Details Page', async () => { diff --git a/x-pack/test/functional/apps/endpoint/policy_list.ts b/x-pack/test/functional/apps/endpoint/policy_list.ts index 382963bc2b0c7..c54eafdd8b787 100644 --- a/x-pack/test/functional/apps/endpoint/policy_list.ts +++ b/x-pack/test/functional/apps/endpoint/policy_list.ts @@ -10,8 +10,8 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { const pageObjects = getPageObjects(['common', 'endpoint']); const testSubjects = getService('testSubjects'); - // FLAKY: https://github.com/elastic/kibana/issues/57946 - describe('Endpoint Policy List', function() { + // FIXME: Skipped until we can figure out how to load data for Ingest + describe.skip('Endpoint Policy List', function() { this.tags(['ciGroup7']); before(async () => { await pageObjects.common.navigateToUrlWithBrowserHistory('endpoint', '/policy'); From 5efd59b43ffcc747d43222a08c772cb658650d5e Mon Sep 17 00:00:00 2001 From: Patrick Mueller Date: Fri, 20 Mar 2020 16:36:01 -0400 Subject: [PATCH 20/42] [Alerting]: harden APIs of built-in alert index-threshold (#60702) resolves https://github.com/elastic/kibana/issues/59889 The index threshold APIs - used by both the index threshold UI and the alert executor - were returning errors (500's from http endpoints) when getting errors from ES. These have been changed so that the error is logged as a warning, and the relevant API returns an "empty" result. Another 500 response was found while experimenting with this. Apparently the date_range agg requires a date format to be passed in if the date format in ES is not an ISO date. The repro on this was to select the `.security` alias (or it's index) within the index threshold alert UI, and then select one of it's date fields. --- .../index_threshold/lib/time_series_query.ts | 5 ++-- .../index_threshold/routes/fields.ts | 7 +++-- .../index_threshold/routes/indices.ts | 11 +++++--- .../routes/time_series_query.ts | 22 ++++++---------- .../common/lib/es_test_index_tool.ts | 4 +++ .../index_threshold/alert.ts | 9 ++++--- .../index_threshold/create_test_data.ts | 1 + .../index_threshold/fields_endpoint.ts | 6 +++++ .../index_threshold/indices_endpoint.ts | 6 +++++ .../time_series_query_endpoint.ts | 26 +++++++++++++++++++ 10 files changed, 72 insertions(+), 25 deletions(-) diff --git a/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/lib/time_series_query.ts b/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/lib/time_series_query.ts index 0382792dafb35..1d9cc1c98bc01 100644 --- a/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/lib/time_series_query.ts +++ b/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/lib/time_series_query.ts @@ -94,6 +94,7 @@ export async function timeSeriesQuery( dateAgg: { date_range: { field: timeField, + format: 'strict_date_time', ranges: dateRangeInfo.dateRanges, }, }, @@ -134,8 +135,8 @@ export async function timeSeriesQuery( esResult = await callCluster('search', esQuery); } catch (err) { // console.log('time_series_query.ts error\n', JSON.stringify(err, null, 4)); - logger.warn(`${logPrefix} error: ${JSON.stringify(err.message)}`); - throw new Error('error running search'); + logger.warn(`${logPrefix} error: ${err.message}`); + return { results: [] }; } // console.log('time_series_query.ts response\n', JSON.stringify(esResult, null, 4)); diff --git a/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/routes/fields.ts b/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/routes/fields.ts index c862d96828eb4..32d6409d9c9fb 100644 --- a/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/routes/fields.ts +++ b/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/routes/fields.ts @@ -53,8 +53,11 @@ export function createFieldsRoute(service: Service, router: IRouter, baseRoute: try { rawFields = await getRawFields(ctx.core.elasticsearch.dataClient, req.body.indexPatterns); } catch (err) { - service.logger.debug(`route ${path} error: ${err.message}`); - return res.internalError({ body: 'error getting field data' }); + const indexPatterns = req.body.indexPatterns.join(','); + service.logger.warn( + `route ${path} error getting fields from pattern "${indexPatterns}": ${err.message}` + ); + return res.ok({ body: { fields: [] } }); } const result = { fields: getFieldsFromRawFields(rawFields) }; diff --git a/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/routes/indices.ts b/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/routes/indices.ts index 760ed21078de2..c08450448b44c 100644 --- a/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/routes/indices.ts +++ b/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/routes/indices.ts @@ -54,15 +54,18 @@ export function createIndicesRoute(service: Service, router: IRouter, baseRoute: try { aliases = await getAliasesFromPattern(ctx.core.elasticsearch.dataClient, pattern); } catch (err) { - service.logger.debug(`route ${path} error: ${err.message}`); - return res.internalError({ body: 'error getting alias data' }); + service.logger.warn( + `route ${path} error getting aliases from pattern "${pattern}": ${err.message}` + ); } + let indices: string[] = []; try { indices = await getIndicesFromPattern(ctx.core.elasticsearch.dataClient, pattern); } catch (err) { - service.logger.debug(`route ${path} error: ${err.message}`); - return res.internalError({ body: 'error getting index data' }); + service.logger.warn( + `route ${path} error getting indices from pattern "${pattern}": ${err.message}` + ); } const result = { indices: uniqueCombined(aliases, indices, MAX_INDICES) }; diff --git a/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/routes/time_series_query.ts b/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/routes/time_series_query.ts index 16864d250a747..c8129c2428ee4 100644 --- a/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/routes/time_series_query.ts +++ b/x-pack/plugins/alerting_builtins/server/alert_types/index_threshold/routes/time_series_query.ts @@ -13,7 +13,7 @@ import { } from 'kibana/server'; import { Service } from '../../../types'; -import { TimeSeriesQuery, TimeSeriesQuerySchema, TimeSeriesResult } from '../lib/time_series_types'; +import { TimeSeriesQuery, TimeSeriesQuerySchema } from '../lib/time_series_types'; export { TimeSeriesQuery, TimeSeriesResult } from '../lib/time_series_types'; export function createTimeSeriesQueryRoute(service: Service, router: IRouter, baseRoute: string) { @@ -33,21 +33,15 @@ export function createTimeSeriesQueryRoute(service: Service, router: IRouter, ba req: KibanaRequest, res: KibanaResponseFactory ): Promise { - service.logger.debug(`route query_data request: ${JSON.stringify(req.body)}`); + service.logger.debug(`route ${path} request: ${JSON.stringify(req.body)}`); - let result: TimeSeriesResult; - try { - result = await service.indexThreshold.timeSeriesQuery({ - logger: service.logger, - callCluster: ctx.core.elasticsearch.dataClient.callAsCurrentUser, - query: req.body, - }); - } catch (err) { - service.logger.debug(`route query_data error: ${err.message}`); - return res.internalError({ body: 'error running time series query' }); - } + const result = await service.indexThreshold.timeSeriesQuery({ + logger: service.logger, + callCluster: ctx.core.elasticsearch.dataClient.callAsCurrentUser, + query: req.body, + }); - service.logger.debug(`route query_data response: ${JSON.stringify(result)}`); + service.logger.debug(`route ${path} response: ${JSON.stringify(result)}`); return res.ok({ body: result }); } } diff --git a/x-pack/test/alerting_api_integration/common/lib/es_test_index_tool.ts b/x-pack/test/alerting_api_integration/common/lib/es_test_index_tool.ts index 999a8686e0ee7..14a91325d1cc1 100644 --- a/x-pack/test/alerting_api_integration/common/lib/es_test_index_tool.ts +++ b/x-pack/test/alerting_api_integration/common/lib/es_test_index_tool.ts @@ -41,6 +41,10 @@ export class ESTestIndexTool { type: 'date', format: 'strict_date_time', }, + date_epoch_millis: { + type: 'date', + format: 'epoch_millis', + }, testedValue: { type: 'long', }, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/alert.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/alert.ts index 13f3a4971183c..87acbcf99d383 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/alert.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/alert.ts @@ -172,12 +172,14 @@ export default function alertTests({ getService }: FtrProviderContext) { // create some more documents in the first group createEsDocumentsInGroups(1); + // this never fires because of bad fields error await createAlert({ name: 'never fire', + timeField: 'source', // bad field for time aggType: 'avg', - aggField: 'testedValue', + aggField: 'source', // bad field for agg groupBy: 'all', - thresholdComparator: '<', + thresholdComparator: '>', threshold: [0], }); @@ -303,6 +305,7 @@ export default function alertTests({ getService }: FtrProviderContext) { name: string; aggType: string; aggField?: string; + timeField?: string; groupBy: 'all' | 'top'; termField?: string; termSize?: number; @@ -347,7 +350,7 @@ export default function alertTests({ getService }: FtrProviderContext) { actions: [action], params: { index: ES_TEST_INDEX_NAME, - timeField: 'date', + timeField: params.timeField || 'date', aggType: params.aggType, aggField: params.aggField, groupBy: params.groupBy, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/create_test_data.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/create_test_data.ts index 21f73ac9b9833..1a83f34f0fdfb 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/create_test_data.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/create_test_data.ts @@ -53,6 +53,7 @@ async function createEsDocument(es: any, epochMillis: number, testedValue: numbe source: DOCUMENT_SOURCE, reference: DOCUMENT_REFERENCE, date: new Date(epochMillis).toISOString(), + date_epoch_millis: epochMillis, testedValue, group, }; diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/fields_endpoint.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/fields_endpoint.ts index fa7aed2c035b9..c6f8f6d1b80b1 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/fields_endpoint.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/fields_endpoint.ts @@ -139,6 +139,12 @@ export default function fieldsEndpointTests({ getService }: FtrProviderContext) expect(field.name).to.eql('updated_at'); expect(field.type).to.eql('date'); }); + + // TODO: the pattern '*a:b,c:d*' throws an exception in dev, but not ci! + it('should handle no_such_remote_cluster', async () => { + const result = await runQueryExpect({ indexPatterns: ['*a:b,c:d*'] }, 200); + expect(result.fields.length).to.be(0); + }); }); function getFieldNamed(fields: any[], fieldName: string): any | undefined { diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/indices_endpoint.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/indices_endpoint.ts index 6908398deb57b..72484fa70f9cc 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/indices_endpoint.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/indices_endpoint.ts @@ -105,6 +105,12 @@ export default function indicesEndpointTests({ getService }: FtrProviderContext) expect(result.indices).to.be.an('array'); expect(result.indices.includes('.kibana')).to.be(true); }); + + // TODO: the pattern '*a:b,c:d*' throws an exception in dev, but not ci! + it('should handle no_such_remote_cluster', async () => { + const result = await runQueryExpect({ pattern: '*a:b,c:d*' }, 200); + expect(result.indices.length).to.be(0); + }); }); async function runQueryExpect(requestBody: any, status: number): Promise { diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/time_series_query_endpoint.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/time_series_query_endpoint.ts index c9b488da5dec5..932ffe3a7ce14 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/time_series_query_endpoint.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/time_series_query_endpoint.ts @@ -273,6 +273,32 @@ export default function timeSeriesQueryEndpointTests({ getService }: FtrProvider }; expect(await runQueryExpect(query, 400)).eql(expected); }); + + it('should handle epoch_millis time field', async () => { + const query = getQueryBody({ + dateStart: START_DATE, + dateEnd: START_DATE, + timeField: 'date_epoch_millis', + }); + const expected = { + results: [{ group: 'all documents', metrics: [[START_DATE, 6]] }], + }; + expect(await runQueryExpect(query, 200)).eql(expected); + }); + + it('should handle ES errors', async () => { + const query = getQueryBody({ + dateStart: START_DATE, + dateEnd: START_DATE, + timeField: 'source', // bad field for time + aggType: 'avg', + aggField: 'source', // bad field for agg + }); + const expected = { + results: [], + }; + expect(await runQueryExpect(query, 200)).eql(expected); + }); }); async function runQueryExpect(requestBody: TimeSeriesQuery, status: number): Promise { From 5d93a0890c436d11969c9757dfeb2ceb1cf41ec8 Mon Sep 17 00:00:00 2001 From: MadameSheema Date: Fri, 20 Mar 2020 21:52:26 +0100 Subject: [PATCH 21/42] increases loading timeout (#60788) --- x-pack/legacy/plugins/siem/cypress/tasks/login.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/login.ts b/x-pack/legacy/plugins/siem/cypress/tasks/login.ts index 883bdb2a4820a..3abf5a6930486 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/login.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/login.ts @@ -131,5 +131,5 @@ export const loginAndWaitForPageWithoutDateRange = (url: string) => { login(); cy.viewport('macbook-15'); cy.visit(url); - cy.contains('a', 'SIEM'); + cy.contains('a', 'SIEM', { timeout: 60000 }); }; From fc24febec9f25f31b8921ff7ad905fb7b520bb25 Mon Sep 17 00:00:00 2001 From: Wylie Conlon Date: Fri, 20 Mar 2020 17:03:59 -0400 Subject: [PATCH 22/42] [Lens] Resetting a layer generates new suggestions (#60674) * [Lens] Resetting a layer generates new suggestions * Include preview in tests --- .../editor_frame/layer_actions.test.ts | 32 +++++++++++++------ .../editor_frame/layer_actions.ts | 2 ++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_service/editor_frame/layer_actions.test.ts b/x-pack/legacy/plugins/lens/public/editor_frame_service/editor_frame/layer_actions.test.ts index 0fd38a8fdba65..3363e34a01568 100644 --- a/x-pack/legacy/plugins/lens/public/editor_frame_service/editor_frame/layer_actions.test.ts +++ b/x-pack/legacy/plugins/lens/public/editor_frame_service/editor_frame/layer_actions.test.ts @@ -28,19 +28,21 @@ function createTestArgs(initialLayerIds: string[]) { appendLayer: (layerIds: unknown, layerId: string) => [...(layerIds as string[]), layerId], }; + const datasourceStates = { + ds1: { + isLoading: false, + state: initialLayerIds.slice(0, 1), + }, + ds2: { + isLoading: false, + state: initialLayerIds.slice(1), + }, + }; + return { state: { activeDatasourceId: 'ds1', - datasourceStates: { - ds1: { - isLoading: false, - state: initialLayerIds.slice(0, 1), - }, - ds2: { - isLoading: false, - state: initialLayerIds.slice(1), - }, - }, + datasourceStates, title: 'foo', visualization: { activeId: 'vis1', @@ -53,6 +55,13 @@ function createTestArgs(initialLayerIds: string[]) { ds2: testDatasource('ds2'), }, trackUiEvent, + stagedPreview: { + visualization: { + activeId: 'vis1', + state: initialLayerIds, + }, + datasourceStates, + }, }; } @@ -70,6 +79,7 @@ describe('removeLayer', () => { expect(newState.visualization.state).toEqual(['vis_clear_layer1']); expect(newState.datasourceStates.ds1.state).toEqual(['ds1_clear_layer1']); expect(newState.datasourceStates.ds2.state).toEqual([]); + expect(newState.stagedPreview).not.toBeDefined(); expect(trackUiEvent).toHaveBeenCalledWith('layer_cleared'); }); @@ -89,6 +99,7 @@ describe('removeLayer', () => { expect(newState.visualization.state).toEqual(['layer2']); expect(newState.datasourceStates.ds1.state).toEqual([]); expect(newState.datasourceStates.ds2.state).toEqual(['layer2']); + expect(newState.stagedPreview).not.toBeDefined(); expect(trackUiEvent).toHaveBeenCalledWith('layer_removed'); }); }); @@ -110,6 +121,7 @@ describe('appendLayer', () => { expect(newState.visualization.state).toEqual(['layer1', 'layer2', 'foo']); expect(newState.datasourceStates.ds1.state).toEqual(['layer1', 'foo']); expect(newState.datasourceStates.ds2.state).toEqual(['layer2']); + expect(newState.stagedPreview).not.toBeDefined(); expect(trackUiEvent).toHaveBeenCalledWith('layer_added'); }); }); diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_service/editor_frame/layer_actions.ts b/x-pack/legacy/plugins/lens/public/editor_frame_service/editor_frame/layer_actions.ts index e0562e8ca8e11..cc2cbb172d23e 100644 --- a/x-pack/legacy/plugins/lens/public/editor_frame_service/editor_frame/layer_actions.ts +++ b/x-pack/legacy/plugins/lens/public/editor_frame_service/editor_frame/layer_actions.ts @@ -50,6 +50,7 @@ export function removeLayer(opts: RemoveLayerOptions): EditorFrameState { ? activeVisualization.clearLayer(state.visualization.state, layerId) : activeVisualization.removeLayer(state.visualization.state, layerId), }, + stagedPreview: undefined, }; } @@ -84,5 +85,6 @@ export function appendLayer({ ...state.visualization, state: activeVisualization.appendLayer(state.visualization.state, layerId), }, + stagedPreview: undefined, }; } From cf9b64eada5b0809dab7e69bfd356ba30e57755f Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Fri, 20 Mar 2020 15:14:09 -0600 Subject: [PATCH 23/42] [SIEM] [Cases] Create case from timeline (#60711) --- .../insert_timeline_popover/index.test.tsx | 60 +++++++++++++++++++ .../insert_timeline_popover/index.tsx | 33 +++++++++- .../timeline/properties/helpers.tsx | 37 ++++++++++++ .../components/timeline/properties/index.tsx | 1 + .../timeline/properties/properties_right.tsx | 12 +++- .../timeline/properties/translations.ts | 11 +++- .../components/timeline/timeline.test.tsx | 2 +- .../case/components/case_view/index.test.tsx | 11 ++++ .../pages/case/components/user_list/index.tsx | 2 +- 9 files changed, 162 insertions(+), 7 deletions(-) create mode 100644 x-pack/legacy/plugins/siem/public/components/timeline/insert_timeline_popover/index.test.tsx diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/insert_timeline_popover/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/insert_timeline_popover/index.test.tsx new file mode 100644 index 0000000000000..adac26a8ac92b --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/timeline/insert_timeline_popover/index.test.tsx @@ -0,0 +1,60 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { mount } from 'enzyme'; +/* eslint-disable @kbn/eslint/module_migration */ +import routeData from 'react-router'; +/* eslint-enable @kbn/eslint/module_migration */ +import { InsertTimelinePopoverComponent } from './'; + +const mockDispatch = jest.fn(); +jest.mock('react-redux', () => ({ + useDispatch: () => mockDispatch, +})); +const mockLocation = { + pathname: '/apath', + hash: '', + search: '', + state: '', +}; +const mockLocationWithState = { + ...mockLocation, + state: { + insertTimeline: { + timelineId: 'timeline-id', + timelineTitle: 'Timeline title', + }, + }, +}; + +const onTimelineChange = jest.fn(); +const defaultProps = { + isDisabled: false, + onTimelineChange, +}; + +describe('Insert timeline popover ', () => { + beforeEach(() => { + jest.resetAllMocks(); + }); + + it('should insert a timeline when passed in the router state', () => { + jest.spyOn(routeData, 'useLocation').mockReturnValue(mockLocationWithState); + mount(); + expect(mockDispatch).toBeCalledWith({ + payload: { id: 'timeline-id', show: false }, + type: 'x-pack/siem/local/timeline/SHOW_TIMELINE', + }); + expect(onTimelineChange).toBeCalledWith('Timeline title', 'timeline-id'); + }); + it('should do nothing when router state', () => { + jest.spyOn(routeData, 'useLocation').mockReturnValue(mockLocation); + mount(); + expect(mockDispatch).toHaveBeenCalledTimes(0); + expect(onTimelineChange).toHaveBeenCalledTimes(0); + }); +}); diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/insert_timeline_popover/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/insert_timeline_popover/index.tsx index 84bd8c1f302c3..fa474c4d601ad 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/insert_timeline_popover/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/insert_timeline_popover/index.tsx @@ -5,11 +5,14 @@ */ import { EuiButtonIcon, EuiPopover, EuiSelectableOption } from '@elastic/eui'; -import React, { memo, useCallback, useMemo, useState } from 'react'; +import React, { memo, useCallback, useEffect, useMemo, useState } from 'react'; +import { useLocation } from 'react-router-dom'; +import { useDispatch } from 'react-redux'; import { OpenTimelineResult } from '../../open_timeline/types'; import { SelectableTimeline } from '../selectable_timeline'; import * as i18n from '../translations'; +import { timelineActions } from '../../../store/timeline'; interface InsertTimelinePopoverProps { isDisabled: boolean; @@ -17,12 +20,37 @@ interface InsertTimelinePopoverProps { onTimelineChange: (timelineTitle: string, timelineId: string | null) => void; } -const InsertTimelinePopoverComponent: React.FC = ({ +interface RouterState { + insertTimeline: { + timelineId: string; + timelineTitle: string; + }; +} + +type Props = InsertTimelinePopoverProps; + +export const InsertTimelinePopoverComponent: React.FC = ({ isDisabled, hideUntitled = false, onTimelineChange, }) => { + const dispatch = useDispatch(); const [isPopoverOpen, setIsPopoverOpen] = useState(false); + const { state } = useLocation(); + const [routerState, setRouterState] = useState(state ?? null); + + useEffect(() => { + if (routerState && routerState.insertTimeline) { + dispatch( + timelineActions.showTimeline({ id: routerState.insertTimeline.timelineId, show: false }) + ); + onTimelineChange( + routerState.insertTimeline.timelineTitle, + routerState.insertTimeline.timelineId + ); + setRouterState(null); + } + }, [routerState]); const handleClosePopover = useCallback(() => { setIsPopoverOpen(false); @@ -65,6 +93,7 @@ const InsertTimelinePopoverComponent: React.FC = ({ return ( (({ timelineId, title, updateTitle }) = )); Name.displayName = 'Name'; +interface NewCaseProps { + onClosePopover: () => void; + timelineId: string; + timelineTitle: string; +} + +export const NewCase = React.memo(({ onClosePopover, timelineId, timelineTitle }) => { + const history = useHistory(); + const handleClick = useCallback(() => { + onClosePopover(); + history.push({ + pathname: `/${SiemPageName.case}/create`, + state: { + insertTimeline: { + timelineId, + timelineTitle: timelineTitle.length > 0 ? timelineTitle : i18n.UNTITLED_TIMELINE, + }, + }, + }); + }, [onClosePopover, history, timelineId, timelineTitle]); + + return ( + + {i18n.ATTACH_TIMELINE_TO_NEW_CASE} + + ); +}); +NewCase.displayName = 'NewCase'; + interface NewTimelineProps { createTimeline: CreateTimeline; onClosePopover: () => void; diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/properties/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/properties/index.tsx index 8549784b8ecd6..0080fcb1e6924 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/properties/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/properties/index.tsx @@ -141,6 +141,7 @@ export const Properties = React.memo( showTimelineModal={showTimelineModal} showUsersView={title.length > 0} timelineId={timelineId} + title={title} updateDescription={updateDescription} updateNote={updateNote} usersViewing={usersViewing} diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/properties/properties_right.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/properties/properties_right.tsx index b21ab5063441e..59d268487cca7 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/properties/properties_right.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/properties/properties_right.tsx @@ -14,7 +14,7 @@ import { EuiToolTip, EuiAvatar, } from '@elastic/eui'; -import { NewTimeline, Description, NotesButton } from './helpers'; +import { NewTimeline, Description, NotesButton, NewCase } from './helpers'; import { OpenTimelineModalButton } from '../../open_timeline/open_timeline_modal/open_timeline_modal_button'; import { OpenTimelineModal } from '../../open_timeline/open_timeline_modal'; import { InspectButton, InspectButtonContainer } from '../../inspect'; @@ -79,6 +79,7 @@ interface Props { onCloseTimelineModal: () => void; onOpenTimelineModal: () => void; showTimelineModal: boolean; + title: string; updateNote: UpdateNote; } @@ -104,6 +105,7 @@ const PropertiesRightComponent: React.FC = ({ showTimelineModal, onCloseTimelineModal, onOpenTimelineModal, + title, }) => ( @@ -135,6 +137,14 @@ const PropertiesRightComponent: React.FC = ({ + + + + { .find('[data-test-subj="timeline-title"]') .first() .props().placeholder - ).toContain('Untitled Timeline'); + ).toContain('Untitled timeline'); }); test('it renders the timeline table', () => { diff --git a/x-pack/legacy/plugins/siem/public/pages/case/components/case_view/index.test.tsx b/x-pack/legacy/plugins/siem/public/pages/case/components/case_view/index.test.tsx index 41100ec6d50f1..3f4a83d1bff33 100644 --- a/x-pack/legacy/plugins/siem/public/pages/case/components/case_view/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/case/components/case_view/index.test.tsx @@ -7,6 +7,9 @@ import React from 'react'; import { Router } from 'react-router-dom'; import { mount } from 'enzyme'; +/* eslint-disable @kbn/eslint/module_migration */ +import routeData from 'react-router'; +/* eslint-enable @kbn/eslint/module_migration */ import { CaseComponent } from './'; import { caseProps, caseClosedProps, data, dataClosed } from './__mock__'; import { TestProviders } from '../../../../mock'; @@ -35,6 +38,13 @@ const mockHistory = { listen: jest.fn(), }; +const mockLocation = { + pathname: '/welcome', + hash: '', + search: '', + state: '', +}; + describe('CaseView ', () => { const updateCaseProperty = jest.fn(); /* eslint-disable no-console */ @@ -59,6 +69,7 @@ describe('CaseView ', () => { beforeEach(() => { jest.resetAllMocks(); useUpdateCaseMock.mockImplementation(() => defaultUpdateCaseState); + jest.spyOn(routeData, 'useLocation').mockReturnValue(mockLocation); }); it('should render CaseComponent', () => { diff --git a/x-pack/legacy/plugins/siem/public/pages/case/components/user_list/index.tsx b/x-pack/legacy/plugins/siem/public/pages/case/components/user_list/index.tsx index 74a1b98c29eef..9ace36eea1e9e 100644 --- a/x-pack/legacy/plugins/siem/public/pages/case/components/user_list/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/case/components/user_list/index.tsx @@ -58,7 +58,7 @@ const renderUsers = ( From fda31966113068ee57faf2e85a47d1e22aeb4470 Mon Sep 17 00:00:00 2001 From: Kaarina Tungseth Date: Fri, 20 Mar 2020 16:33:20 -0500 Subject: [PATCH 24/42] [DOCS] Updates API requests and examples (#60695) * [DOCS] Updates API requests and examples * Review comments --- docs/api/dashboard/export-dashboard.asciidoc | 12 +- docs/api/dashboard/import-dashboard.asciidoc | 6 +- docs/api/features.asciidoc | 4 +- ...logstash-configuration-management.asciidoc | 6 +- .../create-logstash.asciidoc | 6 +- .../delete-pipeline.asciidoc | 7 +- .../list-pipeline.asciidoc | 6 +- .../retrieve-pipeline.asciidoc | 8 +- docs/api/role-management.asciidoc | 4 +- docs/api/role-management/delete.asciidoc | 13 +- docs/api/role-management/get-all.asciidoc | 16 +- docs/api/role-management/get.asciidoc | 14 +- docs/api/role-management/put.asciidoc | 44 ++-- docs/api/saved-objects/bulk_create.asciidoc | 10 +- docs/api/saved-objects/bulk_get.asciidoc | 10 +- docs/api/saved-objects/create.asciidoc | 12 +- docs/api/saved-objects/delete.asciidoc | 12 +- docs/api/saved-objects/export.asciidoc | 22 +- docs/api/saved-objects/find.asciidoc | 14 +- docs/api/saved-objects/get.asciidoc | 18 +- docs/api/saved-objects/import.asciidoc | 25 +- .../resolve_import_errors.asciidoc | 25 +- docs/api/saved-objects/update.asciidoc | 10 +- .../copy_saved_objects.asciidoc | 220 +++--------------- docs/api/spaces-management/delete.asciidoc | 12 +- docs/api/spaces-management/get.asciidoc | 10 +- docs/api/spaces-management/get_all.asciidoc | 8 +- docs/api/spaces-management/post.asciidoc | 16 +- docs/api/spaces-management/put.asciidoc | 26 +-- ...olve_copy_saved_objects_conflicts.asciidoc | 213 +++-------------- docs/api/upgrade-assistant.asciidoc | 4 +- .../upgrade-assistant/cancel_reindex.asciidoc | 6 +- .../check_reindex_status.asciidoc | 63 +++-- .../api/upgrade-assistant/reindexing.asciidoc | 18 +- docs/api/upgrade-assistant/status.asciidoc | 6 +- docs/api/url-shortening.asciidoc | 16 +- docs/api/using-api.asciidoc | 5 +- 37 files changed, 308 insertions(+), 619 deletions(-) diff --git a/docs/api/dashboard/export-dashboard.asciidoc b/docs/api/dashboard/export-dashboard.asciidoc index 7858b69d44c79..36c551dee84fc 100644 --- a/docs/api/dashboard/export-dashboard.asciidoc +++ b/docs/api/dashboard/export-dashboard.asciidoc @@ -9,7 +9,7 @@ experimental[] Export dashboards and corresponding saved objects. [[dashboard-api-export-request]] ==== Request -`GET /api/kibana/dashboards/export` +`GET :/api/kibana/dashboards/export` [[dashboard-api-export-params]] ==== Query parameters @@ -20,9 +20,9 @@ experimental[] Export dashboards and corresponding saved objects. [[dashboard-api-export-response-body]] ==== Response body -`objects`:: +`objects`:: (array) A top level property that includes the saved objects. The order of the objects is not guaranteed. Use the exact response body as the request body for the corresponding <>. - + [[dashboard-api-export-codes]] ==== Response code @@ -33,10 +33,10 @@ experimental[] Export dashboards and corresponding saved objects. [[dashboard-api-export-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -GET api/kibana/dashboards/export?dashboard=942dcef0-b2cd-11e8-ad8e-85441f0c2e5c <1> +$ curl -X GET "localhost:5601/api/kibana/dashboards/export?dashboard=942dcef0-b2cd-11e8-ad8e-85441f0c2e5c" <1> -------------------------------------------------- // KIBANA -<1> The dashboard ID is `942dcef0-b2cd-11e8-ad8e-85441f0c2e5c`. \ No newline at end of file +<1> The dashboard ID is `942dcef0-b2cd-11e8-ad8e-85441f0c2e5c`. diff --git a/docs/api/dashboard/import-dashboard.asciidoc b/docs/api/dashboard/import-dashboard.asciidoc index 14817719ec7ee..320859f78c617 100644 --- a/docs/api/dashboard/import-dashboard.asciidoc +++ b/docs/api/dashboard/import-dashboard.asciidoc @@ -9,7 +9,7 @@ experimental[] Import dashboards and corresponding saved objects. [[dashboard-api-import-request]] ==== Request -`POST /api/kibana/dashboards/import` +`POST :/api/kibana/dashboards/import` [[dashboard-api-import-params]] ==== Query parameters @@ -40,9 +40,9 @@ Use the complete response body from the <:/api/features` [float] [[features-api-get-codes]] @@ -23,7 +23,7 @@ experimental[] Retrieves all {kib} features. Features are used by spaces and sec The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "discover", diff --git a/docs/api/logstash-configuration-management.asciidoc b/docs/api/logstash-configuration-management.asciidoc index fbb45095c214b..621b6c61dad8a 100644 --- a/docs/api/logstash-configuration-management.asciidoc +++ b/docs/api/logstash-configuration-management.asciidoc @@ -2,9 +2,9 @@ [[logstash-configuration-management-api]] == Logstash configuration management APIs -Programmatically integrate with the Logstash configuration management feature. +Programmatically integrate with Logstash configuration management. -WARNING: Do not directly access the `.logstash` index. The structure of the `.logstash` index is subject to change, which could cause your integration to break. Instead, use the Logstash configuration management APIs. +WARNING: Do not directly access the `.logstash` index. The structure of the `.logstash` index is subject to change, which could cause your integration to break. Instead, use the Logstash configuration management APIs. The following Logstash configuration management APIs are available: @@ -20,5 +20,3 @@ include::logstash-configuration-management/delete-pipeline.asciidoc[] include::logstash-configuration-management/list-pipeline.asciidoc[] include::logstash-configuration-management/create-logstash.asciidoc[] include::logstash-configuration-management/retrieve-pipeline.asciidoc[] - - diff --git a/docs/api/logstash-configuration-management/create-logstash.asciidoc b/docs/api/logstash-configuration-management/create-logstash.asciidoc index 38e0ee12a0ebf..d6ad27fe44603 100644 --- a/docs/api/logstash-configuration-management/create-logstash.asciidoc +++ b/docs/api/logstash-configuration-management/create-logstash.asciidoc @@ -9,7 +9,7 @@ experimental[] Create a centrally-managed Logstash pipeline, or update an existi [[logstash-configuration-management-api-create-request]] ==== Request -`PUT /api/logstash/pipeline/` +`PUT :/api/logstash/pipeline/` [[logstash-configuration-management-api-create-params]] ==== Path parameters @@ -39,9 +39,9 @@ experimental[] Create a centrally-managed Logstash pipeline, or update an existi [[logstash-configuration-management-api-create-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -PUT api/logstash/pipeline/hello-world +$ curl -X PUT "localhost:5601/api/logstash/pipeline/hello-world" { "pipeline": "input { stdin {} } output { stdout {} }", "settings": { diff --git a/docs/api/logstash-configuration-management/delete-pipeline.asciidoc b/docs/api/logstash-configuration-management/delete-pipeline.asciidoc index 15d44034b46fe..e982619ee17f4 100644 --- a/docs/api/logstash-configuration-management/delete-pipeline.asciidoc +++ b/docs/api/logstash-configuration-management/delete-pipeline.asciidoc @@ -9,7 +9,7 @@ experimental[] Delete a centrally-managed Logstash pipeline. [[logstash-configuration-management-api-delete-request]] ==== Request -`DELETE /api/logstash/pipeline/` +`DELETE :/api/logstash/pipeline/` [[logstash-configuration-management-api-delete-params]] ==== Path parameters @@ -26,9 +26,8 @@ experimental[] Delete a centrally-managed Logstash pipeline. [[logstash-configuration-management-api-delete-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -DELETE api/logstash/pipeline/hello-world +$ curl -X DELETE "localhost:5601/api/logstash/pipeline/hello-world" -------------------------------------------------- // KIBANA - diff --git a/docs/api/logstash-configuration-management/list-pipeline.asciidoc b/docs/api/logstash-configuration-management/list-pipeline.asciidoc index 7140c35d89853..d875ea3d95b78 100644 --- a/docs/api/logstash-configuration-management/list-pipeline.asciidoc +++ b/docs/api/logstash-configuration-management/list-pipeline.asciidoc @@ -9,14 +9,14 @@ experimental[] List all centrally-managed Logstash pipelines. [[logstash-configuration-management-api-list-request]] ==== Request -`GET /api/logstash/pipelines` +`GET :/api/logstash/pipelines` [[logstash-configuration-management-api-list-example]] ==== Example The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "pipelines": [ @@ -35,4 +35,4 @@ The API returns the following: } -------------------------------------------------- -<1> The `username` property appears when security is enabled, and depends on when the pipeline was created or last updated. \ No newline at end of file +<1> The `username` property appears when security is enabled, and depends on when the pipeline was created or last updated. diff --git a/docs/api/logstash-configuration-management/retrieve-pipeline.asciidoc b/docs/api/logstash-configuration-management/retrieve-pipeline.asciidoc index 93a1ec3aa1da5..1eb380b71c62a 100644 --- a/docs/api/logstash-configuration-management/retrieve-pipeline.asciidoc +++ b/docs/api/logstash-configuration-management/retrieve-pipeline.asciidoc @@ -9,20 +9,20 @@ experimental[] Retrieve a centrally-managed Logstash pipeline. [[logstash-configuration-management-api-retrieve-request]] ==== Request -`GET /api/logstash/pipeline/` +`GET :/api/logstash/pipeline/` [[logstash-configuration-management-api-retrieve-path-params]] ==== Path parameters `id`:: (Required, string) The pipeline ID. - + [[logstash-configuration-management-api-retrieve-example]] ==== Example The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "hello-world", @@ -33,4 +33,4 @@ The API returns the following: "queue.type": "persistent" } } --------------------------------------------------- \ No newline at end of file +-------------------------------------------------- diff --git a/docs/api/role-management.asciidoc b/docs/api/role-management.asciidoc index 482d1a9b3cdd3..4c4620a23943a 100644 --- a/docs/api/role-management.asciidoc +++ b/docs/api/role-management.asciidoc @@ -2,9 +2,9 @@ [[role-management-api]] == {kib} role management APIs -Manage the roles that grant <>. +Manage the roles that grant <>. -WARNING: Do not use the {ref}/security-api.html#security-role-apis[{es} role management APIs] to manage {kib} roles. +WARNING: Do not use the {ref}/security-api.html#security-role-apis[{es} role management APIs] to manage {kib} roles. The following {kib} role management APIs are available: diff --git a/docs/api/role-management/delete.asciidoc b/docs/api/role-management/delete.asciidoc index acf2e4a3e3f1f..530e1e252ef8f 100644 --- a/docs/api/role-management/delete.asciidoc +++ b/docs/api/role-management/delete.asciidoc @@ -4,26 +4,23 @@ Delete role ++++ -Delete a {kib} role. - -experimental["The underlying mechanism of enforcing role-based access control is stable, but the APIs for managing the roles are experimental."] +experimental[] Delete a {kib} role. [[role-management-api-delete-prereqs]] -==== Prerequisite +==== Prerequisite To use the delete role API, you must have the `manage_security` cluster privilege. [[role-management-api-delete-request-body]] ==== Request -`DELETE /api/security/role/my_admin_role` +`DELETE :/api/security/role/my_admin_role` [[role-management-api-delete-response-codes]] ==== Response codes `204`:: Indicates a successful call. - + `404`:: - Indicates an unsuccessful call. - \ No newline at end of file + Indicates an unsuccessful call. diff --git a/docs/api/role-management/get-all.asciidoc b/docs/api/role-management/get-all.asciidoc index 4a3dbd7734d3a..888bf0c8a137c 100644 --- a/docs/api/role-management/get-all.asciidoc +++ b/docs/api/role-management/get-all.asciidoc @@ -4,32 +4,30 @@ Get all roles ++++ -Retrieve all {kib} roles. - -experimental["The underlying mechanism of enforcing role-based access control is stable, but the APIs for managing the roles are experimental."] +experimental[] Retrieve all {kib} roles. [[role-management-api-get-prereqs]] -==== Prerequisite +==== Prerequisite To use the get role API, you must have the `manage_security` cluster privilege. [[role-management-api-retrieve-all-request-body]] ==== Request -`GET /api/security/role` +`GET :/api/security/role` [[role-management-api-retrieve-all-response-codes]] ==== Response code -`200`:: +`200`:: Indicates a successful call. - + [[role-management-api-retrieve-all-example]] ==== Example The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- [ { @@ -77,4 +75,4 @@ The API returns the following: "kibana": [ ] } ] --------------------------------------------------- \ No newline at end of file +-------------------------------------------------- diff --git a/docs/api/role-management/get.asciidoc b/docs/api/role-management/get.asciidoc index 44423b01abe5b..d1e9d1e6afa83 100644 --- a/docs/api/role-management/get.asciidoc +++ b/docs/api/role-management/get.asciidoc @@ -4,32 +4,30 @@ Get specific role ++++ -Retrieve a specific role. - -experimental["The underlying mechanism of enforcing role-based access control is stable, but the APIs for managing the roles are experimental."] +experimental[] Retrieve a specific role. [[role-management-specific-api-get-prereqs]] -==== Prerequisite +==== Prerequisite To use the get specific role API, you must have the `manage_security` cluster privilege. [[role-management-specific-api-retrieve-all-request-body]] ===== Request -`GET /api/security/role/my_restricted_kibana_role` +`GET :/api/security/role/my_restricted_kibana_role` [[role-management-specific-api-retrieve-all-response-codes]] ==== Response code -`200`:: +`200`:: Indicates a successful call. - + [[role-management-specific-api-retrieve-all-example]] ===== Example The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "name": "my_restricted_kibana_role", diff --git a/docs/api/role-management/put.asciidoc b/docs/api/role-management/put.asciidoc index a00fedf7e7ac4..59e6bc8d37eec 100644 --- a/docs/api/role-management/put.asciidoc +++ b/docs/api/role-management/put.asciidoc @@ -4,15 +4,13 @@ Create or update role ++++ -Create a new {kib} role, or update the attributes of an existing role. {kib} roles are stored in the +experimental[] Create a new {kib} role, or update the attributes of an existing role. {kib} roles are stored in the {es} native realm. -experimental["The underlying mechanism of enforcing role-based access control is stable, but the APIs for managing the roles are experimental."] - [[role-management-api-put-request]] ==== Request -`PUT /api/security/role/my_kibana_role` +`PUT :/api/security/role/my_kibana_role` [[role-management-api-put-prereqs]] ==== Prerequisite @@ -22,45 +20,45 @@ To use the create or update role API, you must have the `manage_security` cluste [[role-management-api-response-body]] ==== Request body -`metadata`:: +`metadata`:: (Optional, object) In the `metadata` object, keys that begin with `_` are reserved for system usage. -`elasticsearch`:: - (Optional, object) {es} cluster and index privileges. Valid keys include +`elasticsearch`:: + (Optional, object) {es} cluster and index privileges. Valid keys include `cluster`, `indices`, and `run_as`. For more information, see {ref}/defining-roles.html[Defining roles]. -`kibana`:: +`kibana`:: (list) Objects that specify the <> for the role: -`base` ::: +`base` ::: (Optional, list) A base privilege. When specified, the base must be `["all"]` or `["read"]`. When the `base` privilege is specified, you are unable to use the `feature` section. "all" grants read/write access to all {kib} features for the specified spaces. "read" grants read-only access to all {kib} features for the specified spaces. -`feature` ::: +`feature` ::: (object) Contains privileges for specific features. When the `feature` privileges are specified, you are unable to use the `base` section. To retrieve a list of available features, use the <>. -`spaces` ::: +`spaces` ::: (list) The spaces to apply the privileges to. To grant access to all spaces, set to `["*"]`, or omit the value. [[role-management-api-put-response-codes]] ==== Response code -`204`:: +`204`:: Indicates a successful call. ===== Examples Grant access to various features in all spaces: -[source,js] +[source,sh] -------------------------------------------------- -PUT /api/security/role/my_kibana_role +$ curl -X PUT "localhost:5601/api/security/role/my_kibana_role" { "metadata" : { "version" : 1 @@ -127,9 +125,9 @@ PUT /api/security/role/my_kibana_role Grant dashboard-only access to only the Marketing space: -[source,js] +[source,sh] -------------------------------------------------- -PUT /api/security/role/my_kibana_role +$ curl -X PUT "localhost:5601/api/security/role/my_kibana_role" { "metadata" : { "version" : 1 @@ -155,9 +153,9 @@ PUT /api/security/role/my_kibana_role Grant full access to all features in the Default space: -[source,js] +[source,sh] -------------------------------------------------- -PUT /api/security/role/my_kibana_role +$ curl -X PUT "localhost:5601/api/security/role/my_kibana_role" { "metadata" : { "version" : 1 @@ -182,9 +180,9 @@ PUT /api/security/role/my_kibana_role Grant different access to different spaces: -[source,js] +[source,sh] -------------------------------------------------- -PUT /api/security/role/my_kibana_role +$ curl -X PUT "localhost:5601/api/security/role/my_kibana_role" { "metadata" : { "version" : 1 @@ -216,11 +214,11 @@ PUT /api/security/role/my_kibana_role -------------------------------------------------- // KIBANA -Grant access to {kib} and Elasticsearch: +Grant access to {kib} and {es}: -[source,js] +[source,sh] -------------------------------------------------- -PUT /api/security/role/my_kibana_role +$ curl -X PUT "localhost:5601/api/security/role/my_kibana_role" { "metadata" : { "version" : 1 diff --git a/docs/api/saved-objects/bulk_create.asciidoc b/docs/api/saved-objects/bulk_create.asciidoc index d649684bc30f2..9daba224b317c 100644 --- a/docs/api/saved-objects/bulk_create.asciidoc +++ b/docs/api/saved-objects/bulk_create.asciidoc @@ -9,9 +9,9 @@ experimental[] Create multiple {kib} saved objects. [[saved-objects-api-bulk-create-request]] ==== Request -`POST /api/saved_objects/_bulk_create` +`POST :/api/saved_objects/_bulk_create` -`POST /s//api/saved_objects/_bulk_create` +`POST :/s//api/saved_objects/_bulk_create` [[saved-objects-api-bulk-create-path-params]] @@ -63,9 +63,9 @@ Saved objects that are unable to persist are replaced with an error object. Create an index pattern with the `my-pattern` ID, and a dashboard with the `my-dashboard` ID: -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/_bulk_create +$ curl -X POST "localhost:5601/api/saved_objects/_bulk_create" [ { "type": "index-pattern", @@ -87,7 +87,7 @@ POST api/saved_objects/_bulk_create The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "saved_objects": [ diff --git a/docs/api/saved-objects/bulk_get.asciidoc b/docs/api/saved-objects/bulk_get.asciidoc index 3ef5823716d79..a6fdeb69ba925 100644 --- a/docs/api/saved-objects/bulk_get.asciidoc +++ b/docs/api/saved-objects/bulk_get.asciidoc @@ -9,9 +9,9 @@ experimental[] Retrieve multiple {kib} saved objects by ID. [[saved-objects-api-bulk-get-request]] ==== Request -`POST /api/saved_objects/_bulk_get` +`POST :/api/saved_objects/_bulk_get` -`POST /s//api/saved_objects/_bulk_get` +`POST :/s//api/saved_objects/_bulk_get` [[saved-objects-api-bulk-get-path-params]] ==== Path parameters @@ -50,9 +50,9 @@ Saved objects that are unable to persist are replaced with an error object. Retrieve an index pattern with the `my-pattern` ID, and a dashboard with the `my-dashboard` ID: -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/_bulk_get +$ curl -X POST "localhost:5601/api/saved_objects/_bulk_get" [ { "type": "index-pattern", @@ -68,7 +68,7 @@ POST api/saved_objects/_bulk_get The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "saved_objects": [ diff --git a/docs/api/saved-objects/create.asciidoc b/docs/api/saved-objects/create.asciidoc index 634c71bb4eefe..dc010c80fd012 100644 --- a/docs/api/saved-objects/create.asciidoc +++ b/docs/api/saved-objects/create.asciidoc @@ -9,11 +9,11 @@ experimental[] Create {kib} saved objects. [[saved-objects-api-create-request]] ==== Request -`POST /api/saved_objects/` + +`POST :/api/saved_objects/` + -`POST /api/saved_objects//` +`POST :/api/saved_objects//` -`POST /s//saved_objects/` +`POST :/s//saved_objects/` [[saved-objects-api-create-path-params]] ==== Path parameters @@ -55,9 +55,9 @@ any data that you send to the API is properly formed. [[saved-objects-api-create-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/index-pattern/my-pattern +$ curl -X POST "localhost:5601/api/saved_objects/index-pattern/my-pattern" { "attributes": { "title": "my-pattern-*" @@ -68,7 +68,7 @@ POST api/saved_objects/index-pattern/my-pattern The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "my-pattern", <1> diff --git a/docs/api/saved-objects/delete.asciidoc b/docs/api/saved-objects/delete.asciidoc index c34f9b67dfd22..65c955e15d360 100644 --- a/docs/api/saved-objects/delete.asciidoc +++ b/docs/api/saved-objects/delete.asciidoc @@ -4,16 +4,16 @@ Delete object ++++ -experimental[] Remove {kib} saved objects. +experimental[] Remove {kib} saved objects. WARNING: Once you delete a saved object, _it cannot be recovered_. [[saved-objects-api-delete-request]] ==== Request -`DELETE /api/saved_objects//` +`DELETE :/api/saved_objects//` -`DELETE /s//api/saved_objects//` +`DELETE :/s//api/saved_objects//` [[saved-objects-api-delete-path-params]] ==== Path parameters @@ -33,12 +33,12 @@ WARNING: Once you delete a saved object, _it cannot be recovered_. `200`:: Indicates a successful call. -==== Examples +==== Example Delete an index pattern object with the `my-pattern` ID: -[source,js] +[source,sh] -------------------------------------------------- -DELETE api/saved_objects/index-pattern/my-pattern +$ curl -X DELETE "localhost:5601/api/saved_objects/index-pattern/my-pattern" -------------------------------------------------- // KIBANA diff --git a/docs/api/saved-objects/export.asciidoc b/docs/api/saved-objects/export.asciidoc index 1b4f50dda2ddb..e8c762b9543a1 100644 --- a/docs/api/saved-objects/export.asciidoc +++ b/docs/api/saved-objects/export.asciidoc @@ -9,9 +9,9 @@ experimental[] Retrieve sets of saved objects that you want to import into {kib} [[saved-objects-api-export-request]] ==== Request -`POST /api/saved_objects/_export` +`POST :/api/saved_objects/_export` -`POST /s//api/saved_objects/_export` +`POST :/s//api/saved_objects/_export` [[saved-objects-api-export-path-params]] ==== Path parameters @@ -39,7 +39,7 @@ TIP: You must include `type` or `objects` in the request body. [[saved-objects-api-export-request-response-body]] ==== Response body -The format of the response body is newline delimited JSON. Each exported object is exported as a valid JSON record and separated by the newline character '\n'. +The format of the response body is newline delimited JSON. Each exported object is exported as a valid JSON record and separated by the newline character '\n'. When `excludeExportDetails=false` (the default) we append an export result details record at the end of the file after all the saved object records. The export result details object has the following format: @@ -66,9 +66,9 @@ When `excludeExportDetails=false` (the default) we append an export result detai Export all index pattern saved objects: -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/_export +$ curl -X POST "localhost:5601/api/saved_objects/_export" { "type": "index-pattern" } @@ -77,9 +77,9 @@ POST api/saved_objects/_export Export all index pattern saved objects and exclude the export summary from the stream: -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/_export +$ curl -X POST "localhost:5601/api/saved_objects/_export" { "type": "index-pattern", "excludeExportDetails": true @@ -89,9 +89,9 @@ POST api/saved_objects/_export Export a specific saved object: -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/_export +$ curl -X POST "localhost:5601/api/saved_objects/_export" { "objects": [ { @@ -105,9 +105,9 @@ POST api/saved_objects/_export Export a specific saved object and it's related objects : -[source,js] +[source,sh] -------------------------------------------------- -POST api/saved_objects/_export +$ curl -X POST "localhost:5601/api/saved_objects/_export" { "objects": [ { diff --git a/docs/api/saved-objects/find.asciidoc b/docs/api/saved-objects/find.asciidoc index 955c50922fde7..93e60be5d4923 100644 --- a/docs/api/saved-objects/find.asciidoc +++ b/docs/api/saved-objects/find.asciidoc @@ -9,9 +9,9 @@ experimental[] Retrieve a paginated set of {kib} saved objects by various condit [[saved-objects-api-find-request]] ==== Request -`GET /api/saved_objects/_find` +`GET :/api/saved_objects/_find` -`GET /s//api/saved_objects/_find` +`GET :/s//api/saved_objects/_find` [[saved-objects-api-find-path-params]] ==== Path parameters @@ -67,15 +67,15 @@ change. Use the find API for traditional paginated results, but avoid using it t Find index patterns with titles that start with `my`: -[source,js] +[source,sh] -------------------------------------------------- -GET api/saved_objects/_find?type=index-pattern&search_fields=title&search=my* +$ curl -X GET "localhost:5601/api/saved_objects/_find?type=index-pattern&search_fields=title&search=my*" -------------------------------------------------- // KIBANA The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "total": 1, @@ -95,8 +95,8 @@ The API returns the following: For parameters that accept multiple values (e.g. `fields`), repeat the query parameter for each value: -[source,js] +[source,sh] -------------------------------------------------- -GET api/saved_objects/_find?fields=id&fields=title +$ curl -X GET "localhost:5601/api/saved_objects/_find?fields=id&fields=title" -------------------------------------------------- // KIBANA diff --git a/docs/api/saved-objects/get.asciidoc b/docs/api/saved-objects/get.asciidoc index 29f8ef67e0a83..86b86795b534f 100644 --- a/docs/api/saved-objects/get.asciidoc +++ b/docs/api/saved-objects/get.asciidoc @@ -9,9 +9,9 @@ experimental[] Retrieve a single {kib} saved object by ID. [[saved-objects-api-get-request]] ==== Request -`GET /api/saved_objects//` +`GET :/api/saved_objects//` -`GET /s//api/saved_objects//` +`GET :/s//api/saved_objects//` [[saved-objects-api-get-params]] ==== Path parameters @@ -37,15 +37,15 @@ experimental[] Retrieve a single {kib} saved object by ID. Retrieve the index pattern object with the `my-pattern` ID: -[source,js] +[source,sh] -------------------------------------------------- -GET api/saved_objects/index-pattern/my-pattern +$ curl -X GET "localhost:5601/api/saved_objects/index-pattern/my-pattern" -------------------------------------------------- // KIBANA The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "my-pattern", @@ -57,17 +57,17 @@ The API returns the following: } -------------------------------------------------- -The following example retrieves a dashboard object in the `testspace` by id. +Retrieve a dashboard object in the `testspace` by ID: -[source,js] +[source,sh] -------------------------------------------------- -GET /s/testspace/api/saved_objects/dashboard/7adfa750-4c81-11e8-b3d7-01146121b73d +$ curl -X GET "localhost:5601/s/testspace/api/saved_objects/dashboard/7adfa750-4c81-11e8-b3d7-01146121b73d" -------------------------------------------------- // KIBANA The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "7adfa750-4c81-11e8-b3d7-01146121b73d", diff --git a/docs/api/saved-objects/import.asciidoc b/docs/api/saved-objects/import.asciidoc index 1a380830ed21a..b3e4c48696a17 100644 --- a/docs/api/saved-objects/import.asciidoc +++ b/docs/api/saved-objects/import.asciidoc @@ -9,9 +9,9 @@ experimental[] Create sets of {kib} saved objects from a file created by the exp [[saved-objects-api-import-request]] ==== Request -`POST /api/saved_objects/_import` +`POST :/api/saved_objects/_import` -`POST /s//api/saved_objects/_import` +`POST :/s//api/saved_objects/_import` [[saved-objects-api-import-path-params]] ==== Path parameters @@ -55,14 +55,15 @@ The request body must include the multipart/form-data type. Import an index pattern and dashboard: -[source,js] +[source,sh] -------------------------------------------------- $ curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form file=@file.ndjson -------------------------------------------------- +// KIBANA The `file.ndjson` file contains the following: -[source,js] +[source,sh] -------------------------------------------------- {"type":"index-pattern","id":"my-pattern","attributes":{"title":"my-pattern-*"}} {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"}} @@ -70,7 +71,7 @@ The `file.ndjson` file contains the following: The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "success": true, @@ -80,14 +81,15 @@ The API returns the following: Import an index pattern and dashboard that includes a conflict on the index pattern: -[source,js] +[source,sh] -------------------------------------------------- $ curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form file=@file.ndjson -------------------------------------------------- +// KIBANA The `file.ndjson` file contains the following: -[source,js] +[source,sh] -------------------------------------------------- {"type":"index-pattern","id":"my-pattern","attributes":{"title":"my-pattern-*"}} {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"}} @@ -95,7 +97,7 @@ The `file.ndjson` file contains the following: The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "success": false, @@ -115,14 +117,15 @@ The API returns the following: Import a visualization and dashboard with an index pattern for the visualization reference that doesn't exist: -[source,js] +[source,sh] -------------------------------------------------- $ curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form file=@file.ndjson -------------------------------------------------- +// KIBANA The `file.ndjson` file contains the following: -[source,js] +[source,sh] -------------------------------------------------- {"type":"visualization","id":"my-vis","attributes":{"title":"my-vis"},"references":[{"name":"ref_0","type":"index-pattern","id":"my-pattern-*"}]} {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"},"references":[{"name":"ref_0","type":"visualization","id":"my-vis"}]} @@ -130,7 +133,7 @@ The `file.ndjson` file contains the following: The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- "success": false, "successCount": 0, diff --git a/docs/api/saved-objects/resolve_import_errors.asciidoc b/docs/api/saved-objects/resolve_import_errors.asciidoc index b64e5deb361b2..ec03917390d36 100644 --- a/docs/api/saved-objects/resolve_import_errors.asciidoc +++ b/docs/api/saved-objects/resolve_import_errors.asciidoc @@ -17,9 +17,9 @@ To resolve errors, you can: [[saved-objects-api-resolve-import-errors-request]] ==== Request -`POST /api/saved_objects/_resolve_import_errors` +`POST :/api/saved_objects/_resolve_import_errors` -`POST /s//api/saved_objects/_resolve_import_errors` +`POST :/s//api/saved_objects/_resolve_import_errors` [[saved-objects-api-resolve-import-errors-path-params]] ==== Path parameters @@ -61,21 +61,22 @@ The request body must include the multipart/form-data type. Retry a dashboard import: -[source,js] +[source,sh] -------------------------------------------------- $ curl -X POST "localhost:5601/api/saved_objects/_resolve_import_errors" -H "kbn-xsrf: true" --form file=@file.ndjson --form retries='[{"type":"dashboard","id":"my-dashboard"}]' -------------------------------------------------- +// KIBANA The `file.ndjson` file contains the following: -[source,js] +[source,sh] -------------------------------------------------- {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"}} -------------------------------------------------- The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "success": true, @@ -85,14 +86,15 @@ The API returns the following: Resolve errors for a dashboard and overwrite the existing saved object: -[source,js] +[source,sh] -------------------------------------------------- $ curl -X POST "localhost:5601/api/saved_objects/_resolve_import_errors" -H "kbn-xsrf: true" --form file=@file.ndjson --form retries='[{"type":"dashboard","id":"my-dashboard","overwrite":true}]' -------------------------------------------------- +// KIBANA The `file.ndjson` file contains the following: -[source,js] +[source,sh] -------------------------------------------------- {"type":"index-pattern","id":"my-pattern","attributes":{"title":"my-pattern-*"}} {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"}} @@ -100,7 +102,7 @@ The `file.ndjson` file contains the following: The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "success": true, @@ -110,21 +112,22 @@ The API returns the following: Resolve errors for a visualization by replacing the index pattern with another: -[source,js] +[source,sh] -------------------------------------------------- $ curl -X POST "localhost:5601/api/saved_objects/_resolve_import_errors" -H "kbn-xsrf: true" --form file=@file.ndjson --form retries='[{"type":"visualization","id":"my-vis","replaceReferences":[{"type":"index-pattern","from":"missing","to":"existing"}]}]' -------------------------------------------------- +// KIBANA The `file.ndjson` file contains the following: -[source,js] +[source,sh] -------------------------------------------------- {"type":"visualization","id":"my-vis","attributes":{"title":"Look at my visualization"},"references":[{"name":"ref_0","type":"index-pattern","id":"missing"}]} -------------------------------------------------- The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "success": true, diff --git a/docs/api/saved-objects/update.asciidoc b/docs/api/saved-objects/update.asciidoc index 99a9bd4ad15bb..62f4104debc77 100644 --- a/docs/api/saved-objects/update.asciidoc +++ b/docs/api/saved-objects/update.asciidoc @@ -9,9 +9,9 @@ experimental[] Update the attributes for existing {kib} saved objects. [[saved-objects-api-update-request]] ==== Request -`PUT /api/saved_objects//` +`PUT :/api/saved_objects//` -`PUT /s//api/saved_objects//` +`PUT :/s//api/saved_objects//` [[saved-objects-api-update-path-params]] ==== Path parameters @@ -47,9 +47,9 @@ WARNING: When you update, attributes are not validated, which allows you to pass Update an existing index pattern object,`my-pattern`, with a different title: -[source,js] +[source,sh] -------------------------------------------------- -PUT api/saved_objects/index-pattern/my-pattern +$ curl -X PUT "localhost:5601/api/saved_objects/index-pattern/my-pattern" { "attributes": { "title": "some-other-pattern-*" @@ -60,7 +60,7 @@ PUT api/saved_objects/index-pattern/my-pattern The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "my-pattern", diff --git a/docs/api/spaces-management/copy_saved_objects.asciidoc b/docs/api/spaces-management/copy_saved_objects.asciidoc index c07b5f35efe09..e23a137485b2d 100644 --- a/docs/api/spaces-management/copy_saved_objects.asciidoc +++ b/docs/api/spaces-management/copy_saved_objects.asciidoc @@ -5,225 +5,75 @@ Copy saved objects to space ++++ -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] - -//// -Use the appropriate heading levels for your book. -Add anchors for each section. -FYI: The section titles use attributes in case those terms change. -//// - -[[spaces-api-copy-saved-objects-request]] -==== {api-request-title} -//// -This section show the basic endpoint, without the body or optional parameters. -Variables should use <...> syntax. -If an API supports both PUT and POST, include both here. -//// - -`POST /api/spaces/_copy_saved_objects` - -`POST /s//api/spaces/_copy_saved_objects` - - -//// -[[spaces-api-copy-saved-objects-prereqs]] -==== {api-prereq-title} -//// -//// -Optional list of prerequisites. - -For example: - -* A snapshot of an index created in 5.x can be restored to 6.x. You must... -* If the {es} {security-features} are enabled, you must have `write`, `monitor`, -and `manage_follow_index` index privileges... -//// - - -[[spaces-api-copy-saved-objects-desc]] -==== {api-description-title} - -Copy saved objects between spaces. +experimental[] Copy saved objects between spaces. It also allows you to automatically copy related objects, so when you copy a `dashboard`, this can automatically copy over the associated visualizations, index patterns, and saved searches, as required. -You can request to overwrite any objects that already exist in the target space if they share an ID, or you can use the +You can request to overwrite any objects that already exist in the target space if they share an ID, or you can use the <> to do this on a per-object basis. -//// -Add a more detailed description the context. -Link to related APIs if appropriate. +[[spaces-api-copy-saved-objects-request]] +==== {api-request-title} -Guidelines for parameter documentation -*************************************** -* Use a definition list. -* End each definition with a period. -* Include whether the parameter is Optional or Required and the data type. -* Include default values as the last sentence of the first paragraph. -* Include a range of valid values, if applicable. -* If the parameter requires a specific delimiter for multiple values, say so. -* If the parameter supports wildcards, ditto. -* For large or nested objects, consider linking to a separate definition list. -*************************************** -//// +`POST :/api/spaces/_copy_saved_objects` +`POST :/s//api/spaces/_copy_saved_objects` [[spaces-api-copy-saved-objects-path-params]] ==== {api-path-parms-title} -//// -A list of all the parameters within the path of the endpoint (before the query string (?)). -For example: -``:: -(Required, string) Name of the follower index -//// `space_id`:: -(Optional, string) Identifies the source space from which saved objects will be copied. If `space_id` is not specified in the URL, the default space is used. - -//// -[[spaces-api-copy-saved-objects-params]] -==== {api-query-parms-title} -//// -//// -A list of the parameters in the query string of the endpoint (after the ?). - -For example: -`wait_for_active_shards`:: -(Optional, integer) Specifies the number of shards to wait on being active before -responding. A shard must be restored from the leader index being active. -Restoring a follower shard requires transferring all the remote Lucene segment -files to the follower index. The default is `0`, which means waiting on none of -the shards to be active. -//// +(Optional, string) The ID of the space that contains the saved objects you want to copy. When `space_id` is unspecified in the URL, the default space is used. [[spaces-api-copy-saved-objects-request-body]] ==== {api-request-body-title} -//// -A list of the properties you can specify in the body of the request. -For example: -`remote_cluster`:: -(Required, string) The <> that contains -the leader index. +`spaces`:: + (Required, string array) The IDs of the spaces where you want to copy the specified objects. -`leader_index`:: -(Required, string) The name of the index in the leader cluster to follow. -//// -`spaces` :: - (Required, string array) The ids of the spaces the specified object(s) will be copied into. - -`objects` :: +`objects`:: (Required, object array) The saved objects to copy. - `type` ::: + `type`::: (Required, string) The saved object type. - `id` ::: - (Required, string) The saved object id. + `id`::: + (Required, string) The saved object ID. -`includeReferences` :: +`includeReferences`:: (Optional, boolean) When set to `true`, all saved objects related to the specified saved objects will also be copied into the target spaces. The default value is `false`. -`overwrite` :: - (Optional, boolean) When set to `true`, all conflicts will be automatically overidden. If a saved object with a matching `type` and `id` exists in the target space, then that version will be replaced with the version from the source space. The default value is `false`. +`overwrite`:: + (Optional, boolean) When set to `true`, all conflicts are automatically overidden. When a saved object with a matching `type` and `id` exists in the target space, that version is replaced with the version from the source space. The default value is `false`. [[spaces-api-copy-saved-objects-response-body]] ==== {api-response-body-title} -//// -Response body is only required for detailed responses. - -For example: -`auto_follow_stats`:: - (object) An object representing stats for the auto-follow coordinator. This - object consists of the following fields: - -`auto_follow_stats.number_of_successful_follow_indices`::: - (long) the number of indices that the auto-follow coordinator successfully - followed -... - -//// ``:: - (object) Specifies the dynamic keys that are included in the response. An object describing the result of the copy operation for this particular space. + (object) An object that describes the result of the copy operation for the space. Includes the dynamic keys in the response. `success`::: - (boolean) Indicates if the copy operation was successful. Note that some objects may have been copied even if this is set to `false`. Consult the `successCount` and `errors` properties of the response for additional information. + (boolean) The copy operation was successful. When set to `false`, some objects may have been copied. For additional information, refer to the `successCount` and `errors` properties. `successCount`::: - (number) The number of objects that were successfully copied. + (number) The number of objects that successfully copied. `errors`::: - (Optional, array) Collection of any errors that were encountered during the copy operation. If any errors are reported, then the `success` flag will be set to `false`. + (Optional, array) The errors that occurred during the copy operation. When errors are reported, the `success` flag is set to `false`.v `id`:::: - (string) The saved object id which failed to copy. + (string) The saved object ID that failed to copy. `type`:::: - (string) The type of saved object which failed to copy. + (string) The type of saved object that failed to copy. `error`:::: - (object) The error which caused the copy operation to fail. + (object) The error that caused the copy operation to fail. `type`::::: - (string) Indicates the type of error. May be one of: `conflict`, `unsupported_type`, `missing_references`, `unknown`. Errors marked as `conflict` may be resolved by using the <>. - -//// -[[spaces-api-copy-saved-objects-response-codes]] -==== {api-response-codes-title} -//// -//// -Response codes are only required when needed to understand the response body. - -For example: -`200`:: -Indicates all listed indices or index aliases exist. - - `404`:: -Indicates one or more listed indices or index aliases **do not** exist. -//// - + (string) The type of error. For example, `unsupported_type`, `missing_references`, or `unknown`. Errors marked as `conflict` may be resolved by using the <>. [[spaces-api-copy-saved-objects-example]] ==== {api-examples-title} -//// -Optional brief example. -Use an 'Examples' heading if you include multiple examples. +Copy a dashboard with the `my-dashboard` ID, including all references from the `default` space to the `marketing` and `sales` spaces: -[source,js] +[source,sh] ---- -PUT /follower_index/_ccr/follow?wait_for_active_shards=1 -{ - "remote_cluster" : "remote_cluster", - "leader_index" : "leader_index", - "max_read_request_operation_count" : 1024, - "max_outstanding_read_requests" : 16, - "max_read_request_size" : "1024k", - "max_write_request_operation_count" : 32768, - "max_write_request_size" : "16k", - "max_outstanding_write_requests" : 8, - "max_write_buffer_count" : 512, - "max_write_buffer_size" : "512k", - "max_retry_delay" : "10s", - "read_poll_timeout" : "30s" -} ----- -// CONSOLE -// TEST[setup:remote_cluster_and_leader_index] - -The API returns the following result: - -[source,js] ----- -{ - "follow_index_created" : true, - "follow_index_shards_acked" : true, - "index_following_started" : true -} ----- -// TESTRESPONSE -//// - -The following example attempts to copy a dashboard with id `my-dashboard`, including all references from the `default` space to the `marketing` and `sales` spaces. The `marketing` space succeeds, while the `sales` space fails due to a conflict on the underlying index pattern: - -[source,js] ----- -POST /api/spaces/_copy_saved_objects +$ curl -X POST "localhost:5601/api/spaces/_copy_saved_objects" { "objects": [{ "type": "dashboard", @@ -235,9 +85,9 @@ POST /api/spaces/_copy_saved_objects ---- // KIBANA -The API returns the following result: +The API returns the following: -[source,js] +[source,sh] ---- { "marketing": { @@ -258,11 +108,13 @@ The API returns the following result: } ---- -The following example successfully copies a visualization with id `my-viz` from the `marketing` space to the `default` space: +The `marketing` space succeeds, but the `sales` space fails due to a conflict in the index pattern. + +Copy a visualization with the `my-viz` ID from the `marketing` space to the `default` space: -[source,js] +[source,sh] ---- -POST /s/marketing/api/spaces/_copy_saved_objects +$ curl -X POST "localhost:5601/s/marketing/api/spaces/_copy_saved_objects" { "objects": [{ "type": "visualization", @@ -273,9 +125,9 @@ POST /s/marketing/api/spaces/_copy_saved_objects ---- // KIBANA -The API returns the following result: +The API returns the following: -[source,js] +[source,sh] ---- { "default": { diff --git a/docs/api/spaces-management/delete.asciidoc b/docs/api/spaces-management/delete.asciidoc index c66307ea3070f..5b4db78c056dd 100644 --- a/docs/api/spaces-management/delete.asciidoc +++ b/docs/api/spaces-management/delete.asciidoc @@ -4,22 +4,20 @@ Delete space ++++ -Delete a {kib} space. +experimental[] Delete a {kib} space. -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] - -WARNING: When you delete a space, all saved objects that belong to the space are automatically deleted, which is permanent and cannot be undone. +WARNING: When you delete a space, all saved objects that belong to the space are automatically deleted, which is permanent and cannot be undone. [[spaces-api-delete-request]] ==== Request -`DELETE /api/spaces/space/marketing` +`DELETE :/api/spaces/space/marketing` [[spaces-api-delete-errors-codes]] ==== Response codes -`204`:: +`204`:: Indicates a successful call. - + `404`:: Indicates that the request failed. diff --git a/docs/api/spaces-management/get.asciidoc b/docs/api/spaces-management/get.asciidoc index 49119d7602b20..48245b7786604 100644 --- a/docs/api/spaces-management/get.asciidoc +++ b/docs/api/spaces-management/get.asciidoc @@ -4,14 +4,12 @@ Get space ++++ -Retrieve a specified {kib} space. - -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] +experimental[] Retrieve a specified {kib} space. [[spaces-api-get-request]] ==== Request -`GET /api/spaces/space/marketing` +`GET :/api/spaces/space/marketing` [[spaces-api-get-response-codes]] ==== Response code @@ -24,7 +22,7 @@ experimental["The underlying Spaces concepts are stable, but the APIs for managi The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "id": "marketing", @@ -35,4 +33,4 @@ The API returns the following: "disabledFeatures": [], "imageUrl": "" } --------------------------------------------------- \ No newline at end of file +-------------------------------------------------- diff --git a/docs/api/spaces-management/get_all.asciidoc b/docs/api/spaces-management/get_all.asciidoc index f7fb92baa165f..8f7ba86f332de 100644 --- a/docs/api/spaces-management/get_all.asciidoc +++ b/docs/api/spaces-management/get_all.asciidoc @@ -4,14 +4,12 @@ Get all spaces ++++ -Retrieve all {kib} spaces. - -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] +experimental[] Retrieve all {kib} spaces. [[spaces-api-get-all-request]] ==== Request -`GET /api/spaces/space` +`GET :/api/spaces/space` [[spaces-api-get-all-response-codes]] ==== Response code @@ -24,7 +22,7 @@ experimental["The underlying Spaces concepts are stable, but the APIs for managi The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- [ { diff --git a/docs/api/spaces-management/post.asciidoc b/docs/api/spaces-management/post.asciidoc index 4d4627e98899e..b96fbe6364c34 100644 --- a/docs/api/spaces-management/post.asciidoc +++ b/docs/api/spaces-management/post.asciidoc @@ -4,14 +4,12 @@ Create space ++++ -Create a {kib} space. - -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] +experimental[] Create a {kib} space. [[spaces-api-post-request]] ==== Request -`POST /api/spaces/space` +`POST :/api/spaces/space` [[spaces-api-post-request-body]] ==== Request body @@ -29,13 +27,13 @@ experimental["The underlying Spaces concepts are stable, but the APIs for managi (Optional, string array) The list of disabled features for the space. To get a list of available feature IDs, use the <>. `initials`:: - (Optional, string) Specifies the initials shown in the space avatar. By default, the initials are automatically generated from the space name. Initials must be 1 or 2 characters. + (Optional, string) The initials shown in the space avatar. By default, the initials are automatically generated from the space name. Initials must be 1 or 2 characters. `color`:: - (Optional, string) Specifies the hexadecimal color code used in the space avatar. By default, the color is automatically generated from the space name. + (Optional, string) The hexadecimal color code used in the space avatar. By default, the color is automatically generated from the space name. `imageUrl`:: - (Optional, string) Specifies the data-url encoded image to display in the space avatar. If specified, `initials` will not be displayed, and the `color` will be visible as the background color for transparent images. + (Optional, string) The data-URL encoded image to display in the space avatar. If specified, `initials` will not be displayed, and the `color` will be visible as the background color for transparent images. For best results, your image should be 64x64. Images will not be optimized by this API call, so care should be taken when using custom images. [[spaces-api-post-response-codes]] @@ -47,9 +45,9 @@ experimental["The underlying Spaces concepts are stable, but the APIs for managi [[spaces-api-post-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -POST /api/spaces/space +$ curl -X POST "localhost:5601/api/spaces/space" { "id": "marketing", "name": "Marketing", diff --git a/docs/api/spaces-management/put.asciidoc b/docs/api/spaces-management/put.asciidoc index 586818707c76f..f405d57975a70 100644 --- a/docs/api/spaces-management/put.asciidoc +++ b/docs/api/spaces-management/put.asciidoc @@ -4,37 +4,35 @@ Update space ++++ -Update an existing {kib} space. - -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] +experimental[] Update an existing {kib} space. [[spaces-api-put-api-request]] ==== Request -`PUT /api/spaces/space/` +`PUT :/api/spaces/space/` [[spaces-api-put-request-body]] ==== Request body -`id`:: +`id`:: (Required, string) The space ID that is part of the {kib} URL when inside the space. You are unable to change the ID with the update operation. -`name`:: +`name`:: (Required, string) The display name for the space. -`description`:: +`description`:: (Optional, string) The description for the space. -`disabledFeatures`:: +`disabledFeatures`:: (Optional, string array) The list of disabled features for the space. To get a list of available feature IDs, use the <>. -`initials`:: +`initials`:: (Optional, string) Specifies the initials shown in the space avatar. By default, the initials are automatically generated from the space name. Initials must be 1 or 2 characters. -`color`:: +`color`:: (Optional, string) Specifies the hexadecimal color code used in the space avatar. By default, the color is automatically generated from the space name. -`imageUrl`:: +`imageUrl`:: (Optional, string) Specifies the data-url encoded image to display in the space avatar. If specified, `initials` will not be displayed, and the `color` will be visible as the background color for transparent images. For best results, your image should be 64x64. Images will not be optimized by this API call, so care should be taken when using custom images. @@ -43,13 +41,13 @@ experimental["The underlying Spaces concepts are stable, but the APIs for managi `200`:: Indicates a successful call. - + [[sample-api-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -PUT /api/spaces/space/marketing +$ curl -X PUT "localhost:5601/api/spaces/space/marketing" { "id": "marketing", "name": "Marketing", diff --git a/docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc b/docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc index 7b52125599c05..8e874bb9f94e5 100644 --- a/docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc +++ b/docs/api/spaces-management/resolve_copy_saved_objects_conflicts.asciidoc @@ -5,227 +5,80 @@ Resolve copy to space conflicts ++++ -Overwrite specific saved objects that were returned as errors from the <>. - -experimental["The underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental."] - -//// -Use the appropriate heading levels for your book. -Add anchors for each section. -FYI: The section titles use attributes in case those terms change. -//// +experimental[] Overwrite saved objects that are returned as errors from the <>. [[spaces-api-resolve-copy-saved-objects-conflicts-request]] ==== {api-request-title} -//// -This section show the basic endpoint, without the body or optional parameters. -Variables should use <...> syntax. -If an API supports both PUT and POST, include both here. -//// - -`POST /api/spaces/_resolve_copy_saved_objects_errors` - -`POST /s//api/spaces/_resolve_copy_saved_objects_errors` +`POST :/api/spaces/_resolve_copy_saved_objects_errors` +`POST :/s//api/spaces/_resolve_copy_saved_objects_errors` [[spaces-api-resolve-copy-saved-objects-conflicts-prereqs]] ==== {api-prereq-title} -//// -Optional list of prerequisites. - -For example: - -* A snapshot of an index created in 5.x can be restored to 6.x. You must... -* If the {es} {security-features} are enabled, you must have `write`, `monitor`, -and `manage_follow_index` index privileges... -//// -* Executed the <>, which returned one or more `conflict` errors that you wish to resolve. - -//// -[[spaces-api-resolve-copy-saved-objects-conflicts-desc]] -==== {api-description-title} - -Allows saved objects to be selectively overridden in the target spaces. -//// - -//// -Add a more detailed description the context. -Link to related APIs if appropriate. - -Guidelines for parameter documentation -*************************************** -* Use a definition list. -* End each definition with a period. -* Include whether the parameter is Optional or Required and the data type. -* Include default values as the last sentence of the first paragraph. -* Include a range of valid values, if applicable. -* If the parameter requires a specific delimiter for multiple values, say so. -* If the parameter supports wildcards, ditto. -* For large or nested objects, consider linking to a separate definition list. -*************************************** -//// +Execute the <>, which returns the errors for you to resolve. [[spaces-api-resolve-copy-saved-objects-conflicts-path-params]] ==== {api-path-parms-title} -//// -A list of all the parameters within the path of the endpoint (before the query string (?)). -For example: -``:: -(Required, string) Name of the follower index -//// `space_id`:: -(Optional, string) Identifies the source space from which saved objects will be copied. If `space_id` is not specified in the URL, the default space is used. Must be the same value that was used during the failed <> operation. - -//// -[[spaces-api-resolve-copy-saved-objects-conflicts-request-params]] -==== {api-query-parms-title} -//// -//// -A list of the parameters in the query string of the endpoint (after the ?). - -For example: -`wait_for_active_shards`:: -(Optional, integer) Specifies the number of shards to wait on being active before -responding. A shard must be restored from the leader index being active. -Restoring a follower shard requires transferring all the remote Lucene segment -files to the follower index. The default is `0`, which means waiting on none of -the shards to be active. -//// +(Optional, string) The ID of the space that contains the saved objects you want to copy. When `space_id` is unspecified in the URL, the default space is used. The `space_id` must be the same value used during the failed <> operation. [[spaces-api-resolve-copy-saved-objects-conflicts-request-body]] ==== {api-request-body-title} -//// -A list of the properties you can specify in the body of the request. - -For example: -`remote_cluster`:: -(Required, string) The <> that contains -the leader index. -`leader_index`:: -(Required, string) The name of the index in the leader cluster to follow. -//// -`objects` :: - (Required, object array) The saved objects to copy. Must be the same value that was used during the failed <> operation. - `type` ::: +`objects`:: + (Required, object array) The saved objects to copy. The `objects` must be the same values used during the failed <> operation. + `type`::: (Required, string) The saved object type. - `id` ::: - (Required, string) The saved object id. + `id`::: + (Required, string) The saved object ID. -`includeReferences` :: - (Optional, boolean) When set to `true`, all saved objects related to the specified saved objects will also be copied into the target spaces. You must set this to the same value that you used when executing the <>. The default value is `false`. +`includeReferences`:: + (Optional, boolean) When set to `true`, all saved objects related to the specified saved objects are copied into the target spaces. The `includeReferences` must be the same values used during the failed <> operation. The default value is `false`. `retries`:: - (Required, object) The retry operations to attempt. Object keys represent the target space ids. - `` ::: - (Required, array) The the conflicts to resolve for the indicated ``. - `type` :::: + (Required, object) The retry operations to attempt. Object keys represent the target space IDs. + ``::: + (Required, array) The errors to resolve for the specified ``. + `type`:::: (Required, string) The saved object type. - `id` :::: - (Required, string) The saved object id. - `overwrite` :::: - (Required, boolean) when set to `true`, the saved object from the source space (desigated by the <>) will overwrite the the conflicting object in the destination space. When `false`, this does nothing. + `id`:::: + (Required, string) The saved object ID. + `overwrite`:::: + (Required, boolean) When set to `true`, the saved object from the source space (desigated by the <>) overwrites the conflicting object in the destination space. When set to `false`, this does nothing. [[spaces-api-resolve-copy-saved-objects-conflicts-response-body]] ==== {api-response-body-title} -//// -Response body is only required for detailed responses. - -For example: -`auto_follow_stats`:: - (object) An object representing stats for the auto-follow coordinator. This - object consists of the following fields: - -`auto_follow_stats.number_of_successful_follow_indices`::: - (long) the number of indices that the auto-follow coordinator successfully - followed -... - -//// ``:: - (object) Specifies the dynamic keys that are included in the response. An object describing the result of the copy operation for this particular space. + (object) An object that describes the result of the copy operation for the space. Includes the dynamic keys in the response. `success`::: - (boolean) Indicates if the copy operation was successful. Note that some objects may have been copied even if this is set to `false`. Consult the `successCount` and `errors` properties of the response for additional information. + (boolean) The copy operation was successful. When set to `false`, some objects may have been copied. For additional information, refer to the `successCount` and `errors` properties. `successCount`::: - (number) The number of objects that were successfully copied. + (number) The number of objects that successfully copied. `errors`::: - (Optional, array) Collection of any errors that were encountered during the copy operation. If any errors are reported, then the `success` flag will be set to `false`. + (Optional, array) The errors that occurred during the copy operation. When errors are reported, the `success` flag is set to `false`. `id`:::: - (string) The saved object id which failed to copy. + (string) The saved object ID that failed to copy. `type`:::: - (string) The type of saved object which failed to copy. + (string) The type of saved object that failed to copy. `error`:::: - (object) The error which caused the copy operation to fail. + (object) The error that caused the copy operation to fail. `type`::::: - (string) Indicates the type of error. May be one of: `unsupported_type`, `missing_references`, `unknown`. - -//// -[[spaces-api-resolve-copy-saved-objects-conflicts-response-codes]] -==== {api-response-codes-title} -//// -//// -Response codes are only required when needed to understand the response body. - -For example: -`200`:: -Indicates all listed indices or index aliases exist. - - `404`:: -Indicates one or more listed indices or index aliases **do not** exist. -//// + (string) The type of error. For example, `unsupported_type`, `missing_references`, or `unknown`. [[spaces-api-resolve-copy-saved-objects-conflicts-example]] ==== {api-examples-title} -//// -Optional brief example. -Use an 'Examples' heading if you include multiple examples. - - -[source,js] ----- -PUT /follower_index/_ccr/follow?wait_for_active_shards=1 -{ - "remote_cluster" : "remote_cluster", - "leader_index" : "leader_index", - "max_read_request_operation_count" : 1024, - "max_outstanding_read_requests" : 16, - "max_read_request_size" : "1024k", - "max_write_request_operation_count" : 32768, - "max_write_request_size" : "16k", - "max_outstanding_write_requests" : 8, - "max_write_buffer_count" : 512, - "max_write_buffer_size" : "512k", - "max_retry_delay" : "10s", - "read_poll_timeout" : "30s" -} ----- -// CONSOLE -// TEST[setup:remote_cluster_and_leader_index] - -The API returns the following result: - -[source,js] ----- -{ - "follow_index_created" : true, - "follow_index_shards_acked" : true, - "index_following_started" : true -} ----- -// TESTRESPONSE -//// -The following example overwrites an index pattern in the marketing space, and a visualization in the sales space. +Overwrite an index pattern in the `marketing` space, and a visualization in the `sales` space: -[source,js] +[source,sh] ---- -POST api/spaces/_resolve_copy_saved_objects_errors +$ curl -X POST "localhost:5601/api/spaces/_resolve_copy_saved_objects_errors" { "objects": [{ "type": "dashboard", @@ -248,9 +101,9 @@ POST api/spaces/_resolve_copy_saved_objects_errors ---- // KIBANA -The API returns the following result: +The API returns the following: -[source,js] +[source,sh] ---- { "marketing": { diff --git a/docs/api/upgrade-assistant.asciidoc b/docs/api/upgrade-assistant.asciidoc index 3e9c416b292cf..15d87fbd0dc9d 100644 --- a/docs/api/upgrade-assistant.asciidoc +++ b/docs/api/upgrade-assistant.asciidoc @@ -2,7 +2,7 @@ [[upgrade-assistant-api]] == Upgrade assistant APIs -Check the upgrade status of your Elasticsearch cluster and reindex indices that were created in the previous major version. The assistant helps you prepare for the next major version of Elasticsearch. +Check the upgrade status of your {es} cluster and reindex indices that were created in the previous major version. The assistant helps you prepare for the next major version of {es}. The following upgrade assistant APIs are available: @@ -16,7 +16,7 @@ The following upgrade assistant APIs are available: * <> to check the status of the reindex operation -* <> to cancel reindexes that are waiting for the Elasticsearch reindex task to complete +* <> to cancel reindexes that are waiting for the {es} reindex task to complete include::upgrade-assistant/status.asciidoc[] include::upgrade-assistant/reindexing.asciidoc[] diff --git a/docs/api/upgrade-assistant/cancel_reindex.asciidoc b/docs/api/upgrade-assistant/cancel_reindex.asciidoc index d31894cd06a05..04ab3bdde35fc 100644 --- a/docs/api/upgrade-assistant/cancel_reindex.asciidoc +++ b/docs/api/upgrade-assistant/cancel_reindex.asciidoc @@ -4,14 +4,14 @@ Cancel reindex ++++ -experimental["The underlying Upgrade Assistant concepts are stable, but the APIs for managing Upgrade Assistant are experimental."] +experimental[] Cancel reindexes that are waiting for the {es} reindex task to complete. For example, `lastCompletedStep` set to `40`. Cancel reindexes that are waiting for the Elasticsearch reindex task to complete. For example, `lastCompletedStep` set to `40`. [[cancel-reindex-request]] ==== Request -`POST /api/upgrade_assistant/reindex/myIndex/cancel` +`POST :/api/upgrade_assistant/reindex/myIndex/cancel` [[cancel-reindex-response-codes]] ==== Response codes @@ -24,7 +24,7 @@ Cancel reindexes that are waiting for the Elasticsearch reindex task to complete The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "acknowledged": true diff --git a/docs/api/upgrade-assistant/check_reindex_status.asciidoc b/docs/api/upgrade-assistant/check_reindex_status.asciidoc index c422e5764c69f..00801f201d1e1 100644 --- a/docs/api/upgrade-assistant/check_reindex_status.asciidoc +++ b/docs/api/upgrade-assistant/check_reindex_status.asciidoc @@ -4,27 +4,27 @@ Check reindex status ++++ -experimental["The underlying Upgrade Assistant concepts are stable, but the APIs for managing Upgrade Assistant are experimental."] +experimental[] Check the status of the reindex operation. Check the status of the reindex operation. [[check-reindex-status-request]] ==== Request -`GET /api/upgrade_assistant/reindex/myIndex` +`GET :/api/upgrade_assistant/reindex/myIndex` [[check-reindex-status-response-codes]] ==== Response codes `200`:: Indicates a successful call. - + [[check-reindex-status-example]] ==== Example The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "reindexOp": { @@ -53,59 +53,58 @@ The API returns the following: [[status-code]] ==== Status codes -`0`:: +`0`:: In progress -`1`:: +`1`:: Completed -`2`:: +`2`:: Failed - -`3`:: + +`3`:: Paused NOTE: If the {kib} node that started the reindex is shutdown or restarted, the reindex goes into a paused state after some time. To resume the reindex, you must submit a new POST request to the `/api/upgrade_assistant/reindex/` endpoint. -`4`:: +`4`:: Cancelled [[step-code]] ==== Step codes -`0`:: +`0`:: The reindex operation has been created in Kibana. - -`10`:: + +`10`:: The index group services stopped. Only applies to some system indices. - -`20`:: - The index is set to `readonly`. - -`30`:: + +`20`:: + The index is set to `readonly`. + +`30`:: The new destination index has been created. - -`40`:: + +`40`:: The reindex task in Elasticsearch has started. - -`50`:: + +`50`:: The reindex task in Elasticsearch has completed. - -`60`:: + +`60`:: Aliases were created to point to the new index, and the old index has been deleted. - -`70`:: + +`70`:: The index group services have resumed. Only applies to some system indices. [[warning-code]] ==== Warning codes -`0`:: +`0`:: Specifies to remove the `_all` meta field. - -`1`:: + +`1`:: Specifies to convert any coerced boolean values in the source document. For example, `yes`, `1`, and `off`. - -`2`:: - Specifies to convert documents to support Elastic Common Schema. Only applies to APM indices created in 6.x. +`2`:: + Specifies to convert documents to support Elastic Common Schema. Only applies to APM indices created in 6.x. diff --git a/docs/api/upgrade-assistant/reindexing.asciidoc b/docs/api/upgrade-assistant/reindexing.asciidoc index 51e7b917b67ac..ce5670822e5ad 100644 --- a/docs/api/upgrade-assistant/reindexing.asciidoc +++ b/docs/api/upgrade-assistant/reindexing.asciidoc @@ -4,14 +4,14 @@ Start or resume reindex ++++ -experimental["The underlying Upgrade Assistant concepts are stable, but the APIs for managing Upgrade Assistant are experimental."] +experimental[] Start a new reindex or resume a paused reindex. Start a new reindex or resume a paused reindex. [[start-resume-reindex-request]] ==== Request -`POST /api/upgrade_assistant/reindex/myIndex` +`POST :/api/upgrade_assistant/reindex/myIndex` [[start-resume-reindex-codes]] ==== Response code @@ -24,7 +24,7 @@ Start a new reindex or resume a paused reindex. The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "indexName": ".ml-state", @@ -37,9 +37,9 @@ The API returns the following: } -------------------------------------------------- -<1> Name of the new index that is being created. -<2> Current status of the reindex. For details, see <>. -<3> Last successfully completed step of the reindex. For details, see <> table. -<4> Task ID of the reindex task in Elasticsearch. Only present if reindexing has started. -<5> Percentage of how far the reindexing task in Elasticsearch has progressed, in decimal from from 0 to 1. -<6> Error that caused the reindex to fail, if it failed. +<1> The name of the new index. +<2> The reindex status. For more information, refer to <>. +<3> The last successfully completed step of the reindex. For more information, refer to <>. +<4> The task ID of the reindex task in {es}. Appears when the reindexing starts. +<5> The progress of the reindexing task in {es}. Appears in decimal form, from 0 to 1. +<6> The error that caused the reindex to fail, if it failed. diff --git a/docs/api/upgrade-assistant/status.asciidoc b/docs/api/upgrade-assistant/status.asciidoc index b087a66fa3bcd..42030061c4289 100644 --- a/docs/api/upgrade-assistant/status.asciidoc +++ b/docs/api/upgrade-assistant/status.asciidoc @@ -4,14 +4,14 @@ Upgrade readiness status ++++ -experimental["The underlying Upgrade Assistant concepts are stable, but the APIs for managing Upgrade Assistant are experimental."] +experimental[] Check the status of your cluster. Check the status of your cluster. [[upgrade-assistant-api-status-request]] ==== Request -`GET /api/upgrade_assistant/status` +`GET :/api/upgrade_assistant/status` [[upgrade-assistant-api-status-response-codes]] ==== Response codes @@ -24,7 +24,7 @@ Check the status of your cluster. The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "readyForUpgrade": false, diff --git a/docs/api/url-shortening.asciidoc b/docs/api/url-shortening.asciidoc index 8bc701a3d5d12..a62529e11a9ba 100644 --- a/docs/api/url-shortening.asciidoc +++ b/docs/api/url-shortening.asciidoc @@ -12,18 +12,18 @@ Short URLs are designed to make sharing {kib} URLs easier. [[url-shortening-api-request]] ==== Request -`POST /api/shorten_url` +`POST :/api/shorten_url` [[url-shortening-api-request-body]] ==== Request body `url`:: - (Required, string) The {kib} URL that you want to shorten, Relative to `/app/kibana`. + (Required, string) The {kib} URL that you want to shorten, relative to `/app/kibana`. [[url-shortening-api-response-body]] ==== Response body -urlId:: A top level property that contains the shortened URL token for the provided request body. +urlId:: A top-level property that contains the shortened URL token for the provided request body. [[url-shortening-api-codes]] ==== Response code @@ -31,21 +31,21 @@ urlId:: A top level property that contains the shortened URL token for the provi `200`:: Indicates a successful call. -[[url-shortening-api-example]] +[[url-shortening-api-example]] ==== Example -[source,js] +[source,sh] -------------------------------------------------- -POST api/shorten_url +$ curl -X POST "localhost:5601/api/shorten_url" { "url": "/app/kibana#/dashboard?_g=()&_a=(description:'',filters:!(),fullScreenMode:!f,options:(hidePanelTitles:!f,useMargins:!t),panels:!((embeddableConfig:(),gridData:(h:15,i:'1',w:24,x:0,y:0),id:'8f4d0c00-4c86-11e8-b3d7-01146121b73d',panelIndex:'1',type:visualization,version:'7.0.0-alpha1')),query:(language:lucene,query:''),timeRestore:!f,title:'New%20Dashboard',viewMode:edit)" } -------------------------------------------------- // KIBANA -The API returns the following result: +The API returns the following: -[source,js] +[source,sh] -------------------------------------------------- { "urlId": "f73b295ff92718b26bc94edac766d8e3" diff --git a/docs/api/using-api.asciidoc b/docs/api/using-api.asciidoc index 37c5315025dc4..aba65f2e921c2 100644 --- a/docs/api/using-api.asciidoc +++ b/docs/api/using-api.asciidoc @@ -33,6 +33,7 @@ For example, the following `curl` command exports a dashboard: -- curl -X POST -u $USER:$PASSWORD "localhost:5601/api/kibana/dashboards/export?dashboard=942dcef0-b2cd-11e8-ad8e-85441f0c2e5c" -- +// KIBANA [float] [[api-request-headers]] @@ -43,14 +44,14 @@ For all APIs, you must use a request header. The {kib} APIs support the `kbn-xsr `kbn-xsrf: true`:: By default, you must use `kbn-xsrf` for all API calls, except in the following scenarios: -* The API endpoint uses the `GET` or `HEAD` methods +* The API endpoint uses the `GET` or `HEAD` operations * The path is whitelisted using the <> setting * XSRF protections are disabled using the `server.xsrf.disableProtection` setting `Content-Type: application/json`:: - Applicable only when you send a payload in the API request. {kib} API requests and responses use JSON. Typically, if you include the `kbn-xsrf` header, you must also include the `Content-Type` header. + Applicable only when you send a payload in the API request. {kib} API requests and responses use JSON. Typically, if you include the `kbn-xsrf` header, you must also include the `Content-Type` header. Request header example: From 0bf199757fbfb6b3f21f6a61edc78c8127cf7059 Mon Sep 17 00:00:00 2001 From: Brittany Joiner Date: Fri, 20 Mar 2020 17:05:46 -0500 Subject: [PATCH 25/42] Change "url" to "urls" in APM agent instructions (#60790) --- .../apm/server/tutorial/instructions/apm_agent_instructions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/apm/server/tutorial/instructions/apm_agent_instructions.ts b/x-pack/plugins/apm/server/tutorial/instructions/apm_agent_instructions.ts index 54dab4d13845e..d076008da9d8e 100644 --- a/x-pack/plugins/apm/server/tutorial/instructions/apm_agent_instructions.ts +++ b/x-pack/plugins/apm/server/tutorial/instructions/apm_agent_instructions.ts @@ -689,7 +689,7 @@ Do **not** add the agent as a dependency to your application.', ), commands: `java -javaagent:/path/to/elastic-apm-agent-.jar \\ -Delastic.apm.service_name=my-application \\ - -Delastic.apm.server_url=${apmServerUrl || 'http://localhost:8200'} \\ + -Delastic.apm.server_urls=${apmServerUrl || 'http://localhost:8200'} \\ -Delastic.apm.secret_token=${secretToken} \\ -Delastic.apm.application_packages=org.example \\ -jar my-application.jar`.split('\n'), From 677055f3adda7839193c010dc00b64d535bbd75c Mon Sep 17 00:00:00 2001 From: kqualters-elastic <56408403+kqualters-elastic@users.noreply.github.com> Date: Fri, 20 Mar 2020 18:07:41 -0400 Subject: [PATCH 26/42] Flatten child api response for resolver (#60810) --- .../embeddables/resolver/store/middleware.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/endpoint/public/embeddables/resolver/store/middleware.ts b/x-pack/plugins/endpoint/public/embeddables/resolver/store/middleware.ts index 23e4a4fe7d7ed..4e57212e5c0c2 100644 --- a/x-pack/plugins/endpoint/public/embeddables/resolver/store/middleware.ts +++ b/x-pack/plugins/endpoint/public/embeddables/resolver/store/middleware.ts @@ -16,6 +16,19 @@ type MiddlewareFactory = ( ) => ( api: MiddlewareAPI, S> ) => (next: Dispatch) => (action: ResolverAction) => unknown; +interface Lifecycle { + lifecycle: ResolverEvent[]; +} +type ChildResponse = [Lifecycle]; + +function flattenEvents(events: ChildResponse): ResolverEvent[] { + return events + .map((child: Lifecycle) => child.lifecycle) + .reduce( + (accumulator: ResolverEvent[], value: ResolverEvent[]) => accumulator.concat(value), + [] + ); +} export const resolverMiddlewareFactory: MiddlewareFactory = context => { return api => next => async (action: ResolverAction) => { @@ -47,7 +60,7 @@ export const resolverMiddlewareFactory: MiddlewareFactory = context => { query: { legacyEndpointID }, }), ]); - childEvents = children.length > 0 ? children.map((child: any) => child.lifecycle) : []; + childEvents = children.length > 0 ? flattenEvents(children) : []; } else { const uniquePid = action.payload.selectedEvent.process.entity_id; const ppid = action.payload.selectedEvent.process.parent?.entity_id; @@ -67,7 +80,7 @@ export const resolverMiddlewareFactory: MiddlewareFactory = context => { getAncestors(ppid), ]); } - childEvents = children.length > 0 ? children.map((child: any) => child.lifecycle) : []; + childEvents = children.length > 0 ? flattenEvents(children) : []; response = [...lifecycle, ...childEvents, ...relatedEvents, ...ancestors]; api.dispatch({ type: 'serverReturnedResolverData', From 74ceceb324e9e6cc677218725a94f9e80113666b Mon Sep 17 00:00:00 2001 From: Frank Hassanabad Date: Fri, 20 Mar 2020 17:33:09 -0600 Subject: [PATCH 27/42] [SIEM][Detection Engine] Adds test scripts for machine learning feature ## Summary * Adds ad-hoc testing scripts for machine learning feature ## Testing ```ts ./post_rule.sh ./rules/queries/query_with_machine_learning.json ./update_rule.sh ./rules/updates/update_machine_learning.json ./patch_rule.sh ./rules/patches/update_machine_learning.json ``` --- .../scripts/rules/patches/update_machine_learning.json | 4 ++++ .../rules/queries/query_with_machine_learning.json | 10 ++++++++++ .../scripts/rules/updates/update_machine_learning.json | 10 ++++++++++ 3 files changed, 24 insertions(+) create mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_machine_learning.json create mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_machine_learning.json create mode 100644 x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_machine_learning.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_machine_learning.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_machine_learning.json new file mode 100644 index 0000000000000..638c2a35c2a65 --- /dev/null +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_machine_learning.json @@ -0,0 +1,4 @@ +{ + "rule_id": "machine-learning", + "anomaly_threshold": 10 +} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_machine_learning.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_machine_learning.json new file mode 100644 index 0000000000000..db2664978807e --- /dev/null +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_machine_learning.json @@ -0,0 +1,10 @@ +{ + "name": "Query with a machine learning job", + "description": "Query with a machine learning job", + "rule_id": "machine-learning", + "risk_score": 1, + "severity": "high", + "type": "machine_learning", + "machine_learning_job_id": "linux_anomalous_network_activity_ecs", + "anomaly_threshold": 50 +} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_machine_learning.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_machine_learning.json new file mode 100644 index 0000000000000..dfa82c337a68b --- /dev/null +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_machine_learning.json @@ -0,0 +1,10 @@ +{ + "name": "Query with a machine learning job", + "description": "Query with a machine learning job", + "rule_id": "machine-learning", + "risk_score": 1, + "severity": "high", + "type": "machine_learning", + "machine_learning_job_id": "linux_anomalous_network_activity_ecs", + "anomaly_threshold": 100 +} From e73159281e72d92a7139dd0886d8c8a549bdd251 Mon Sep 17 00:00:00 2001 From: Patrick Mueller Date: Fri, 20 Mar 2020 20:00:47 -0400 Subject: [PATCH 28/42] [Alerting] fix flaky test for index threshold grouping (#60792) resolves https://github.com/elastic/kibana/issues/60744 This is a fairly complex test, with alerts that run actions that write to an index which we then do queries over. The tests didn't account for some slop in all that async activity, but now should be about as flake-free as they can be. --- .../builtin_alert_types/index_threshold/alert.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/alert.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/alert.ts index 87acbcf99d383..8f161cfa37c93 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/alert.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/alert.ts @@ -135,7 +135,8 @@ export default function alertTests({ getService }: FtrProviderContext) { } // there should be 2 docs in group-0, rando split between others - expect(inGroup0).to.be(2); + // allow for some flakiness ... + expect(inGroup0).to.be.greaterThan(0); }); it('runs correctly: sum all between', async () => { @@ -238,7 +239,8 @@ export default function alertTests({ getService }: FtrProviderContext) { } // there should be 2 docs in group-2, rando split between others - expect(inGroup2).to.be(2); + // allow for some flakiness ... + expect(inGroup2).to.be.greaterThan(0); }); it('runs correctly: min grouped', async () => { @@ -279,7 +281,8 @@ export default function alertTests({ getService }: FtrProviderContext) { } // there should be 2 docs in group-0, rando split between others - expect(inGroup0).to.be(2); + // allow for some flakiness ... + expect(inGroup0).to.be.greaterThan(0); }); async function createEsDocumentsInGroups(groups: number) { From 9de2d815fc2f162469f2390628b9055eb5946c9c Mon Sep 17 00:00:00 2001 From: Oliver Gupte Date: Fri, 20 Mar 2020 18:56:08 -0700 Subject: [PATCH 29/42] [APM] Service Map - Separate overlapping edges by rotating nodes (#60477) * Adds rotation transform which does the top->bottom to left->right transformation + an extra 5 degrees which results in taxi edges separating when rendered. * PR feedback to reduce edge width on hover, and assure that connected edges are highlighted when node is selected/focused * update disabled kuery bar placeholder text for service map --- .../components/app/ServiceMap/Cytoscape.tsx | 62 ++++++++++++++----- .../app/ServiceMap/cytoscapeOptions.ts | 9 ++- .../components/shared/KueryBar/index.tsx | 2 +- 3 files changed, 55 insertions(+), 18 deletions(-) diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx b/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx index 3197c269fd90c..e0a188b4915a2 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx @@ -57,6 +57,20 @@ function useCytoscape(options: cytoscape.CytoscapeOptions) { return [ref, cy] as [React.MutableRefObject, cytoscape.Core | undefined]; } +function rotatePoint( + { x, y }: { x: number; y: number }, + degreesRotated: number +) { + const radiansPerDegree = Math.PI / 180; + const θ = radiansPerDegree * degreesRotated; + const cosθ = Math.cos(θ); + const sinθ = Math.sin(θ); + return { + x: x * cosθ - y * sinθ, + y: x * sinθ + y * cosθ + }; +} + function getLayoutOptions( selectedRoots: string[], height: number, @@ -71,10 +85,11 @@ function getLayoutOptions( animate: true, animationEasing: animationOptions.easing, animationDuration: animationOptions.duration, - // Rotate nodes from top -> bottom to display left -> right // @ts-ignore - transform: (node: any, { x, y }: cytoscape.Position) => ({ x: y, y: -x }), - // swap width/height of boundingBox to compensation for the rotation + // Rotate nodes counter-clockwise to transform layout from top→bottom to left→right. + // The extra 5° achieves the effect of separating overlapping taxi-styled edges. + transform: (node: any, pos: cytoscape.Position) => rotatePoint(pos, -95), + // swap width/height of boundingBox to compensate for the rotation boundingBox: { x1: 0, y1: 0, w: height, h: width } }; } @@ -109,20 +124,31 @@ export function Cytoscape({ // is required and can trigger rendering when changed. const divStyle = { ...style, height }; - const dataHandler = useCallback( - event => { + const resetConnectedEdgeStyle = useCallback( + (node?: cytoscape.NodeSingular) => { if (cy) { cy.edges().removeClass('highlight'); - if (serviceName) { - const focusedNode = cy.getElementById(serviceName); - focusedNode.connectedEdges().addClass('highlight'); + if (node) { + node.connectedEdges().addClass('highlight'); } + } + }, + [cy] + ); - // Add the "primary" class to the node if its id matches the serviceName. - if (cy.nodes().length > 0 && serviceName) { - cy.nodes().removeClass('primary'); - cy.getElementById(serviceName).addClass('primary'); + const dataHandler = useCallback( + event => { + if (cy) { + if (serviceName) { + resetConnectedEdgeStyle(cy.getElementById(serviceName)); + // Add the "primary" class to the node if its id matches the serviceName. + if (cy.nodes().length > 0) { + cy.nodes().removeClass('primary'); + cy.getElementById(serviceName).addClass('primary'); + } + } else { + resetConnectedEdgeStyle(); } if (event.cy.elements().length > 0) { const selectedRoots = selectRoots(event.cy); @@ -141,7 +167,7 @@ export function Cytoscape({ } } }, - [cy, serviceName, height, width] + [cy, resetConnectedEdgeStyle, serviceName, height, width] ); // Trigger a custom "data" event when data changes @@ -162,12 +188,20 @@ export function Cytoscape({ event.target.removeClass('hover'); event.target.connectedEdges().removeClass('nodeHover'); }; + const selectHandler: cytoscape.EventHandler = event => { + resetConnectedEdgeStyle(event.target); + }; + const unselectHandler: cytoscape.EventHandler = event => { + resetConnectedEdgeStyle(); + }; if (cy) { cy.on('data', dataHandler); cy.ready(dataHandler); cy.on('mouseover', 'edge, node', mouseoverHandler); cy.on('mouseout', 'edge, node', mouseoutHandler); + cy.on('select', 'node', selectHandler); + cy.on('unselect', 'node', unselectHandler); } return () => { @@ -181,7 +215,7 @@ export function Cytoscape({ cy.removeListener('mouseout', 'edge, node', mouseoutHandler); } }; - }, [cy, dataHandler, serviceName]); + }, [cy, dataHandler, resetConnectedEdgeStyle, serviceName]); return ( diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts b/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts index 30b36b58cb001..e19cb8ae4b646 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts +++ b/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts @@ -121,15 +121,18 @@ const style: cytoscape.Stylesheet[] = [ { selector: 'edge.nodeHover', style: { - width: 4, + width: 2, // @ts-ignore - 'z-index': zIndexEdgeHover + 'z-index': zIndexEdgeHover, + 'line-color': theme.euiColorDarkShade, + 'source-arrow-color': theme.euiColorDarkShade, + 'target-arrow-color': theme.euiColorDarkShade } }, { selector: 'node.hover', style: { - 'border-width': 4 + 'border-width': 2 } }, { diff --git a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/index.tsx b/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/index.tsx index bea1de18384a3..dba31822dd23e 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/index.tsx @@ -79,7 +79,7 @@ export function KueryBar() { const disabled = /\/service-map$/.test(location.pathname); const disabledPlaceholder = i18n.translate( 'xpack.apm.kueryBar.disabledPlaceholder', - { defaultMessage: 'Search is not available for service maps' } + { defaultMessage: 'Search is not available for service map' } ); async function onChange(inputValue: string, selectionStart: number) { From 9e911469a3e45bc6c9a1b1f28221e022591c19c8 Mon Sep 17 00:00:00 2001 From: Ryland Herrick Date: Fri, 20 Mar 2020 21:32:51 -0500 Subject: [PATCH 30/42] [SIEM] Fix patching of ML Rules (#60830) * Allow ML Rules to be patched * Test passing of params from our patch routes to our helpers Since patchRules accepts a partial there's no way to verify this in typescript, we need regression tests instead. * Update lists when importing with overwrite This was simply missed earlier. Co-authored-by: Elastic Machine --- .../routes/rules/import_rules_route.ts | 1 + .../rules/patch_rules_bulk_route.test.ts | 26 +++++++++++++++++++ .../routes/rules/patch_rules_bulk_route.ts | 4 +++ .../routes/rules/patch_rules_route.test.ts | 24 +++++++++++++++++ .../routes/rules/patch_rules_route.ts | 4 +++ 5 files changed, 59 insertions(+) diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts index 72a6e70cbb14a..4a5ea33025d49 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts @@ -234,6 +234,7 @@ export const importRulesRoute = (router: IRouter, config: LegacyServices['config references, note, version, + lists, anomalyThreshold, machineLearningJobId, }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.test.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.test.ts index 4c980c8cc60d2..4c00cfa51c8ee 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.test.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.test.ts @@ -56,6 +56,32 @@ describe('patch_rules_bulk', () => { ]); }); + test('allows ML Params to be patched', async () => { + const request = requestMock.create({ + method: 'patch', + path: `${DETECTION_ENGINE_RULES_URL}/bulk_update`, + body: [ + { + rule_id: 'my-rule-id', + anomaly_threshold: 4, + machine_learning_job_id: 'some_job_id', + }, + ], + }); + await server.inject(request, context); + + expect(clients.alertsClient.update).toHaveBeenCalledWith( + expect.objectContaining({ + data: expect.objectContaining({ + params: expect.objectContaining({ + anomalyThreshold: 4, + machineLearningJobId: 'some_job_id', + }), + }), + }) + ); + }); + test('returns 404 if alertClient is not available on the route', async () => { context.alerting!.getAlertsClient = jest.fn(); const response = await server.inject(getPatchBulkRequest(), context); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.ts index 698f58438a5e6..a80f3fee6b433 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.ts @@ -75,6 +75,8 @@ export const patchRulesBulkRoute = (router: IRouter) => { references, note, version, + anomaly_threshold: anomalyThreshold, + machine_learning_job_id: machineLearningJobId, } = payloadRule; const idOrRuleIdOrUnknown = id ?? ruleId ?? '(unknown id)'; try { @@ -111,6 +113,8 @@ export const patchRulesBulkRoute = (router: IRouter) => { references, note, version, + anomalyThreshold, + machineLearningJobId, }); if (rule != null) { const ruleStatuses = await savedObjectsClient.find< diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.test.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.test.ts index b92c18827557c..07519733db291 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.test.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.test.ts @@ -85,6 +85,30 @@ describe('patch_rules', () => { status_code: 500, }); }); + + test('allows ML Params to be patched', async () => { + const request = requestMock.create({ + method: 'patch', + path: DETECTION_ENGINE_RULES_URL, + body: { + rule_id: 'my-rule-id', + anomaly_threshold: 4, + machine_learning_job_id: 'some_job_id', + }, + }); + await server.inject(request, context); + + expect(clients.alertsClient.update).toHaveBeenCalledWith( + expect.objectContaining({ + data: expect.objectContaining({ + params: expect.objectContaining({ + anomalyThreshold: 4, + machineLearningJobId: 'some_job_id', + }), + }), + }) + ); + }); }); describe('request validation', () => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.ts index 4493bb380d03d..c5ecb109f4595 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.ts @@ -59,6 +59,8 @@ export const patchRulesRoute = (router: IRouter) => { references, note, version, + anomaly_threshold: anomalyThreshold, + machine_learning_job_id: machineLearningJobId, } = request.body; const siemResponse = buildSiemResponse(response); @@ -108,6 +110,8 @@ export const patchRulesRoute = (router: IRouter) => { references, note, version, + anomalyThreshold, + machineLearningJobId, }); if (rule != null) { const ruleStatuses = await savedObjectsClient.find< From 0390251f6972009b11d178041456240d6187b81b Mon Sep 17 00:00:00 2001 From: Yuliia Naumenko Date: Fri, 20 Mar 2020 21:29:06 -0700 Subject: [PATCH 31/42] Fixed UI/UX issues: alerts delete confirmation, combobox behaviors (#60703) * Fixed UI/UX issues: alerts delete confirmation * Fixed 4. Popover disappears when clearing the field selector * Fixed tests * Fixed due to comments * fixed tests * Fixed test --- .../components/delete_connectors_modal.tsx | 91 --------------- .../components/delete_modal_confirmation.tsx | 105 ++++++++++++++++++ .../public/application/lib/alert_api.test.ts | 16 +-- .../public/application/lib/alert_api.ts | 18 ++- .../components/actions_connectors_list.tsx | 53 +++++---- .../alerts_list/components/alerts_list.tsx | 46 +++++++- .../components/collapsed_item_actions.tsx | 8 +- .../components/alert_quick_edit_buttons.tsx | 5 +- .../with_bulk_alert_api_operations.test.tsx | 4 +- .../with_bulk_alert_api_operations.tsx | 17 ++- .../public/common/expression_items/of.tsx | 4 +- .../apps/triggers_actions_ui/alerts.ts | 21 +++- .../apps/triggers_actions_ui/connectors.ts | 12 +- 13 files changed, 242 insertions(+), 158 deletions(-) delete mode 100644 x-pack/plugins/triggers_actions_ui/public/application/components/delete_connectors_modal.tsx create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/components/delete_modal_confirmation.tsx diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/delete_connectors_modal.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/delete_connectors_modal.tsx deleted file mode 100644 index b7d1a4ffe2966..0000000000000 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/delete_connectors_modal.tsx +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -import { EuiConfirmModal, EuiOverlayMask } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; -import React from 'react'; -import { useAppDependencies } from '../app_context'; -import { deleteActions } from '../lib/action_connector_api'; - -export const DeleteConnectorsModal = ({ - connectorsToDelete, - callback, -}: { - connectorsToDelete: string[]; - callback: (deleted?: string[]) => void; -}) => { - const { http, toastNotifications } = useAppDependencies(); - const numConnectorsToDelete = connectorsToDelete.length; - if (!numConnectorsToDelete) { - return null; - } - const confirmModalText = i18n.translate( - 'xpack.triggersActionsUI.deleteSelectedConnectorsConfirmModal.descriptionText', - { - defaultMessage: - "You can't recover {numConnectorsToDelete, plural, one {a deleted connector} other {deleted connectors}}.", - values: { numConnectorsToDelete }, - } - ); - const confirmButtonText = i18n.translate( - 'xpack.triggersActionsUI.deleteSelectedConnectorsConfirmModal.deleteButtonLabel', - { - defaultMessage: - 'Delete {numConnectorsToDelete, plural, one {connector} other {# connectors}} ', - values: { numConnectorsToDelete }, - } - ); - const cancelButtonText = i18n.translate( - 'xpack.triggersActionsUI.deleteSelectedConnectorsConfirmModal.cancelButtonLabel', - { - defaultMessage: 'Cancel', - } - ); - return ( - - callback()} - onConfirm={async () => { - const { successes, errors } = await deleteActions({ ids: connectorsToDelete, http }); - const numSuccesses = successes.length; - const numErrors = errors.length; - callback(successes); - if (numSuccesses > 0) { - toastNotifications.addSuccess( - i18n.translate( - 'xpack.triggersActionsUI.sections.connectorsList.deleteSelectedConnectorsSuccessNotification.descriptionText', - { - defaultMessage: - 'Deleted {numSuccesses, number} {numSuccesses, plural, one {connector} other {connectors}}', - values: { numSuccesses }, - } - ) - ); - } - - if (numErrors > 0) { - toastNotifications.addDanger( - i18n.translate( - 'xpack.triggersActionsUI.sections.connectorsList.deleteSelectedConnectorsErrorNotification.descriptionText', - { - defaultMessage: - 'Failed to delete {numErrors, number} {numErrors, plural, one {connector} other {connectors}}', - values: { numErrors }, - } - ) - ); - } - }} - cancelButtonText={cancelButtonText} - confirmButtonText={confirmButtonText} - > - {confirmModalText} - - - ); -}; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/delete_modal_confirmation.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/delete_modal_confirmation.tsx new file mode 100644 index 0000000000000..80b59e15644ec --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/delete_modal_confirmation.tsx @@ -0,0 +1,105 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { EuiConfirmModal, EuiOverlayMask } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import React from 'react'; +import { HttpSetup } from 'kibana/public'; +import { useAppDependencies } from '../app_context'; + +export const DeleteModalConfirmation = ({ + idsToDelete, + apiDeleteCall, + onDeleted, + onCancel, + singleTitle, + multipleTitle, +}: { + idsToDelete: string[]; + apiDeleteCall: ({ + ids, + http, + }: { + ids: string[]; + http: HttpSetup; + }) => Promise<{ successes: string[]; errors: string[] }>; + onDeleted: (deleted: string[]) => void; + onCancel: () => void; + singleTitle: string; + multipleTitle: string; +}) => { + const { http, toastNotifications } = useAppDependencies(); + const numIdsToDelete = idsToDelete.length; + if (!numIdsToDelete) { + return null; + } + const confirmModalText = i18n.translate( + 'xpack.triggersActionsUI.deleteSelectedIdsConfirmModal.descriptionText', + { + defaultMessage: + "You can't recover {numIdsToDelete, plural, one {a deleted {singleTitle}} other {deleted {multipleTitle}}}.", + values: { numIdsToDelete, singleTitle, multipleTitle }, + } + ); + const confirmButtonText = i18n.translate( + 'xpack.triggersActionsUI.deleteSelectedIdsConfirmModal.deleteButtonLabel', + { + defaultMessage: + 'Delete {numIdsToDelete, plural, one {{singleTitle}} other {# {multipleTitle}}} ', + values: { numIdsToDelete, singleTitle, multipleTitle }, + } + ); + const cancelButtonText = i18n.translate( + 'xpack.triggersActionsUI.deleteSelectedIdsConfirmModal.cancelButtonLabel', + { + defaultMessage: 'Cancel', + } + ); + return ( + + onCancel()} + onConfirm={async () => { + const { successes, errors } = await apiDeleteCall({ ids: idsToDelete, http }); + const numSuccesses = successes.length; + const numErrors = errors.length; + onDeleted(successes); + if (numSuccesses > 0) { + toastNotifications.addSuccess( + i18n.translate( + 'xpack.triggersActionsUI.components.deleteSelectedIdsSuccessNotification.descriptionText', + { + defaultMessage: + 'Deleted {numSuccesses, number} {numSuccesses, plural, one {{singleTitle}} other {{multipleTitle}}}', + values: { numSuccesses, singleTitle, multipleTitle }, + } + ) + ); + } + + if (numErrors > 0) { + toastNotifications.addDanger( + i18n.translate( + 'xpack.triggersActionsUI.components.deleteSelectedIdsErrorNotification.descriptionText', + { + defaultMessage: + 'Failed to delete {numErrors, number} {numErrors, plural, one {{singleTitle}} other {{multipleTitle}}}', + values: { numErrors, singleTitle, multipleTitle }, + } + ) + ); + } + }} + cancelButtonText={cancelButtonText} + confirmButtonText={confirmButtonText} + > + {confirmModalText} + + + ); +}; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.test.ts index 0555823d0245e..453fbc4a9eb4f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.test.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.test.ts @@ -8,7 +8,6 @@ import { Alert, AlertType } from '../../types'; import { httpServiceMock } from '../../../../../../src/core/public/mocks'; import { createAlert, - deleteAlert, deleteAlerts, disableAlerts, enableAlerts, @@ -347,24 +346,11 @@ describe('loadAlerts', () => { }); }); -describe('deleteAlert', () => { - test('should call delete API for alert', async () => { - const id = '1'; - const result = await deleteAlert({ http, id }); - expect(result).toEqual(undefined); - expect(http.delete.mock.calls[0]).toMatchInlineSnapshot(` - Array [ - "/api/alert/1", - ] - `); - }); -}); - describe('deleteAlerts', () => { test('should call delete API for each alert', async () => { const ids = ['1', '2', '3']; const result = await deleteAlerts({ http, ids }); - expect(result).toEqual(undefined); + expect(result).toEqual({ errors: [], successes: [undefined, undefined, undefined] }); expect(http.delete.mock.calls).toMatchInlineSnapshot(` Array [ Array [ diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.ts index 1b18460ba11cb..359c48850549a 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.ts @@ -93,18 +93,24 @@ export async function loadAlerts({ }); } -export async function deleteAlert({ id, http }: { id: string; http: HttpSetup }): Promise { - await http.delete(`${BASE_ALERT_API_PATH}/${id}`); -} - export async function deleteAlerts({ ids, http, }: { ids: string[]; http: HttpSetup; -}): Promise { - await Promise.all(ids.map(id => deleteAlert({ http, id }))); +}): Promise<{ successes: string[]; errors: string[] }> { + const successes: string[] = []; + const errors: string[] = []; + await Promise.all(ids.map(id => http.delete(`${BASE_ALERT_API_PATH}/${id}`))).then( + function(fulfilled) { + successes.push(...fulfilled); + }, + function(rejected) { + errors.push(...rejected); + } + ); + return { successes, errors }; } export async function createAlert({ diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx index c023f9087d70e..8c2565538f718 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx @@ -20,10 +20,10 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { useAppDependencies } from '../../../app_context'; -import { loadAllActions, loadActionTypes } from '../../../lib/action_connector_api'; +import { loadAllActions, loadActionTypes, deleteActions } from '../../../lib/action_connector_api'; import { ConnectorAddFlyout, ConnectorEditFlyout } from '../../action_connector_form'; import { hasDeleteActionsCapability, hasSaveActionsCapability } from '../../../lib/capabilities'; -import { DeleteConnectorsModal } from '../../../components/delete_connectors_modal'; +import { DeleteModalConfirmation } from '../../../components/delete_modal_confirmation'; import { ActionsConnectorsContextProvider } from '../../../context/actions_connectors_context'; import { checkActionTypeEnabled } from '../../../lib/check_action_type_enabled'; import './actions_connectors_list.scss'; @@ -378,29 +378,38 @@ export const ActionsConnectorsList: React.FunctionComponent = () => { return (
- { - if (deleted) { - if (selectedItems.length === 0 || selectedItems.length === deleted.length) { - const updatedActions = actions.filter( - action => action.id && !connectorsToDelete.includes(action.id) - ); - setActions(updatedActions); - setSelectedItems([]); - } else { - toastNotifications.addDanger({ - title: i18n.translate( - 'xpack.triggersActionsUI.sections.actionsConnectorsList.failedToDeleteActionsMessage', - { defaultMessage: 'Failed to delete action(s)' } - ), - }); - // Refresh the actions from the server, some actions may have beend deleted - loadActions(); - } + { + if (selectedItems.length === 0 || selectedItems.length === deleted.length) { + const updatedActions = actions.filter( + action => action.id && !connectorsToDelete.includes(action.id) + ); + setActions(updatedActions); + setSelectedItems([]); } setConnectorsToDelete([]); }} - connectorsToDelete={connectorsToDelete} + onCancel={async () => { + toastNotifications.addDanger({ + title: i18n.translate( + 'xpack.triggersActionsUI.sections.actionsConnectorsList.failedToDeleteActionsMessage', + { defaultMessage: 'Failed to delete action(s)' } + ), + }); + // Refresh the actions from the server, some actions may have beend deleted + await loadActions(); + setConnectorsToDelete([]); + }} + apiDeleteCall={deleteActions} + idsToDelete={connectorsToDelete} + singleTitle={i18n.translate( + 'xpack.triggersActionsUI.sections.actionsConnectorsList.singleTitle', + { defaultMessage: 'connector' } + )} + multipleTitle={i18n.translate( + 'xpack.triggersActionsUI.sections.actionsConnectorsList.multipleTitle', + { defaultMessage: 'connectors' } + )} /> {/* Render the view based on if there's data or if they can save */} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx index 18e79a1d93a10..84e4d5794859c 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx @@ -31,10 +31,11 @@ import { AlertQuickEditButtonsWithApi as AlertQuickEditButtons } from '../../com import { CollapsedItemActionsWithApi as CollapsedItemActions } from './collapsed_item_actions'; import { TypeFilter } from './type_filter'; import { ActionTypeFilter } from './action_type_filter'; -import { loadAlerts, loadAlertTypes } from '../../../lib/alert_api'; +import { loadAlerts, loadAlertTypes, deleteAlerts } from '../../../lib/alert_api'; import { loadActionTypes } from '../../../lib/action_connector_api'; import { hasDeleteAlertsCapability, hasSaveAlertsCapability } from '../../../lib/capabilities'; import { routeToAlertDetails, DEFAULT_SEARCH_PAGE_SIZE } from '../../../constants'; +import { DeleteModalConfirmation } from '../../../components/delete_modal_confirmation'; const ENTER_KEY = 13; @@ -85,6 +86,7 @@ export const AlertsList: React.FunctionComponent = () => { }); const [editedAlertItem, setEditedAlertItem] = useState(undefined); const [editFlyoutVisible, setEditFlyoutVisibility] = useState(false); + const [alertsToDelete, setAlertsToDelete] = useState([]); useEffect(() => { loadAlertsData(); @@ -242,7 +244,12 @@ export const AlertsList: React.FunctionComponent = () => { width: '40px', render(item: AlertTableItem) { return ( - loadAlertsData()} /> + loadAlertsData()} + setAlertsToDelete={setAlertsToDelete} + /> ); }, }, @@ -338,6 +345,7 @@ export const AlertsList: React.FunctionComponent = () => { loadAlertsData(); setIsPerformingAction(false); }} + setAlertsToDelete={setAlertsToDelete} /> @@ -422,6 +430,40 @@ export const AlertsList: React.FunctionComponent = () => { return (
+ { + if (selectedIds.length === 0 || selectedIds.length === deleted.length) { + const updatedAlerts = alertsState.data.filter( + alert => alert.id && !alertsToDelete.includes(alert.id) + ); + setAlertsState({ + isLoading: false, + data: updatedAlerts, + totalItemCount: alertsState.totalItemCount - deleted.length, + }); + setSelectedIds([]); + } + setAlertsToDelete([]); + }} + onCancel={async () => { + toastNotifications.addDanger({ + title: i18n.translate( + 'xpack.triggersActionsUI.sections.alertsList.failedToDeleteAlertsMessage', + { defaultMessage: 'Failed to delete alert(s)' } + ), + }); + // Refresh the alerts from the server, some alerts may have beend deleted + await loadAlertsData(); + }} + apiDeleteCall={deleteAlerts} + idsToDelete={alertsToDelete} + singleTitle={i18n.translate('xpack.triggersActionsUI.sections.alertsList.singleTitle', { + defaultMessage: 'alert', + })} + multipleTitle={i18n.translate('xpack.triggersActionsUI.sections.alertsList.multipleTitle', { + defaultMessage: 'alerts', + })} + /> {loadedItems.length || isFilterApplied ? ( table diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/collapsed_item_actions.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/collapsed_item_actions.tsx index 2bac159ed79ed..694f99251d26b 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/collapsed_item_actions.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/collapsed_item_actions.tsx @@ -27,6 +27,7 @@ import { export type ComponentOpts = { item: AlertTableItem; onAlertChanged: () => void; + setAlertsToDelete: React.Dispatch>; } & BulkOperationsComponentOpts; export const CollapsedItemActions: React.FunctionComponent = ({ @@ -36,7 +37,7 @@ export const CollapsedItemActions: React.FunctionComponent = ({ enableAlert, unmuteAlert, muteAlert, - deleteAlert, + setAlertsToDelete, }: ComponentOpts) => { const { capabilities } = useAppDependencies(); @@ -116,10 +117,7 @@ export const CollapsedItemActions: React.FunctionComponent = ({ iconType="trash" color="text" data-test-subj="deleteAlert" - onClick={async () => { - await deleteAlert(item); - onAlertChanged(); - }} + onClick={() => setAlertsToDelete([item.id])} > void; onActionPerformed?: () => void; + setAlertsToDelete: React.Dispatch>; } & BulkOperationsComponentOpts; export const AlertQuickEditButtons: React.FunctionComponent = ({ @@ -30,7 +31,7 @@ export const AlertQuickEditButtons: React.FunctionComponent = ({ unmuteAlerts, enableAlerts, disableAlerts, - deleteAlerts, + setAlertsToDelete, }: ComponentOpts) => { const { toastNotifications } = useAppDependencies(); @@ -129,7 +130,7 @@ export const AlertQuickEditButtons: React.FunctionComponent = ({ onPerformingAction(); setIsDeletingAlerts(true); try { - await deleteAlerts(selectedItems); + setAlertsToDelete(selectedItems.map((selected: any) => selected.id)); } catch (e) { toastNotifications.addDanger({ title: i18n.translate( diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/with_bulk_alert_api_operations.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/with_bulk_alert_api_operations.test.tsx index 30a065479ce33..074e2d5147b5e 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/with_bulk_alert_api_operations.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/with_bulk_alert_api_operations.test.tsx @@ -125,8 +125,8 @@ describe('with_bulk_alert_api_operations', () => { const component = mount(); component.find('button').simulate('click'); - expect(alertApi.deleteAlert).toHaveBeenCalledTimes(1); - expect(alertApi.deleteAlert).toHaveBeenCalledWith({ id: alert.id, http }); + expect(alertApi.deleteAlerts).toHaveBeenCalledTimes(1); + expect(alertApi.deleteAlerts).toHaveBeenCalledWith({ ids: [alert.id], http }); }); // bulk alerts diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/with_bulk_alert_api_operations.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/with_bulk_alert_api_operations.tsx index 4b348b85fe5bc..0ba590ab462a7 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/with_bulk_alert_api_operations.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/with_bulk_alert_api_operations.tsx @@ -14,7 +14,6 @@ import { enableAlerts, muteAlerts, unmuteAlerts, - deleteAlert, disableAlert, enableAlert, muteAlert, @@ -31,14 +30,24 @@ export interface ComponentOpts { unmuteAlerts: (alerts: Alert[]) => Promise; enableAlerts: (alerts: Alert[]) => Promise; disableAlerts: (alerts: Alert[]) => Promise; - deleteAlerts: (alerts: Alert[]) => Promise; + deleteAlerts: ( + alerts: Alert[] + ) => Promise<{ + successes: string[]; + errors: string[]; + }>; muteAlert: (alert: Alert) => Promise; unmuteAlert: (alert: Alert) => Promise; muteAlertInstance: (alert: Alert, alertInstanceId: string) => Promise; unmuteAlertInstance: (alert: Alert, alertInstanceId: string) => Promise; enableAlert: (alert: Alert) => Promise; disableAlert: (alert: Alert) => Promise; - deleteAlert: (alert: Alert) => Promise; + deleteAlert: ( + alert: Alert + ) => Promise<{ + successes: string[]; + errors: string[]; + }>; loadAlert: (id: Alert['id']) => Promise; loadAlertState: (id: Alert['id']) => Promise; loadAlertTypes: () => Promise; @@ -102,7 +111,7 @@ export function withBulkAlertOperations( return disableAlert({ http, id: alert.id }); } }} - deleteAlert={async (alert: Alert) => deleteAlert({ http, id: alert.id })} + deleteAlert={async (alert: Alert) => deleteAlerts({ http, ids: [alert.id] })} loadAlert={async (alertId: Alert['id']) => loadAlert({ http, alertId })} loadAlertState={async (alertId: Alert['id']) => loadAlertState({ http, alertId })} loadAlertTypes={async () => loadAlertTypes({ http })} diff --git a/x-pack/plugins/triggers_actions_ui/public/common/expression_items/of.tsx b/x-pack/plugins/triggers_actions_ui/public/common/expression_items/of.tsx index 954e584d52a87..fdf68cc49572f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/common/expression_items/of.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/common/expression_items/of.tsx @@ -125,7 +125,9 @@ export const OfExpression = ({ onChangeSelectedAggField( selectedOptions.length === 1 ? selectedOptions[0].label : undefined ); - setAggFieldPopoverOpen(false); + if (selectedOptions.length > 0) { + setAggFieldPopoverOpen(false); + } }} /> diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts index b4dd3bb5baa51..7e5825d88ec13 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts @@ -332,6 +332,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); it('should delete single alert', async () => { + await createAlert(); const createdAlert = await createAlert(); await pageObjects.common.navigateToApp('triggersActions'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); @@ -339,8 +340,16 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('collapsedItemActions'); await testSubjects.click('deleteAlert'); + await testSubjects.existOrFail('deleteIdsConfirmation'); + await testSubjects.click('deleteIdsConfirmation > confirmModalConfirmButton'); + await testSubjects.missingOrFail('deleteIdsConfirmation'); - expect(await pageObjects.triggersActionsUI.isAnEmptyAlertsListDisplayed()).to.be(true); + const toastTitle = await pageObjects.common.closeToast(); + expect(toastTitle).to.eql('Deleted 1 alert'); + await pageObjects.common.navigateToApp('triggersActions'); + await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); + const searchResultsAfterDelete = await pageObjects.triggersActionsUI.getAlertsList(); + expect(searchResultsAfterDelete.length).to.eql(0); }); it('should mute all selection', async () => { @@ -449,8 +458,16 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('bulkAction'); await testSubjects.click('deleteAll'); + await testSubjects.existOrFail('deleteIdsConfirmation'); + await testSubjects.click('deleteIdsConfirmation > confirmModalConfirmButton'); + await testSubjects.missingOrFail('deleteIdsConfirmation'); - expect(await pageObjects.triggersActionsUI.isAnEmptyAlertsListDisplayed()).to.be(true); + await pageObjects.common.closeToast(); + + await pageObjects.common.navigateToApp('triggersActions'); + await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); + const searchResultsAfterDelete = await pageObjects.triggersActionsUI.getAlertsList(); + expect(searchResultsAfterDelete.length).to.eql(0); }); }); }; diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts index 9d656b08a3abd..c2013ba3502e2 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts @@ -123,9 +123,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { expect(searchResultsBeforeDelete.length).to.eql(1); await testSubjects.click('deleteConnector'); - await testSubjects.existOrFail('deleteConnectorsConfirmation'); - await testSubjects.click('deleteConnectorsConfirmation > confirmModalConfirmButton'); - await testSubjects.missingOrFail('deleteConnectorsConfirmation'); + await testSubjects.existOrFail('deleteIdsConfirmation'); + await testSubjects.click('deleteIdsConfirmation > confirmModalConfirmButton'); + await testSubjects.missingOrFail('deleteIdsConfirmation'); const toastTitle = await pageObjects.common.closeToast(); expect(toastTitle).to.eql('Deleted 1 connector'); @@ -164,9 +164,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await find.clickByCssSelector('.euiTableRowCellCheckbox .euiCheckbox__input'); await testSubjects.click('bulkDelete'); - await testSubjects.existOrFail('deleteConnectorsConfirmation'); - await testSubjects.click('deleteConnectorsConfirmation > confirmModalConfirmButton'); - await testSubjects.missingOrFail('deleteConnectorsConfirmation'); + await testSubjects.existOrFail('deleteIdsConfirmation'); + await testSubjects.click('deleteIdsConfirmation > confirmModalConfirmButton'); + await testSubjects.missingOrFail('deleteIdsConfirmation'); const toastTitle = await pageObjects.common.closeToast(); expect(toastTitle).to.eql('Deleted 1 connector'); From 8ccaa2e62fdeafd94dae292eed9622e5658fc3a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Sat, 21 Mar 2020 17:01:01 +0100 Subject: [PATCH 32/42] [Index management] Re-enable index template tests (#60780) --- .../client_integration/helpers/constants.ts | 32 ++ .../helpers/home.helpers.ts | 173 ++++++ .../helpers/http_requests.ts | 96 ++++ .../client_integration/helpers/index.ts | 21 + .../helpers/setup_environment.tsx | 57 ++ .../helpers/template_clone.helpers.ts | 24 + .../helpers/template_create.helpers.ts | 26 + .../helpers/template_edit.helpers.ts | 24 + .../helpers/template_form.helpers.ts | 241 +++++++++ .../__jest__/client_integration/home.test.ts | 508 ++++++++++++++++++ .../template_clone.test.tsx | 123 +++++ .../template_create.test.tsx | 387 +++++++++++++ .../client_integration/template_edit.test.tsx | 210 ++++++++ 13 files changed, 1922 insertions(+) create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/helpers/constants.ts create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/helpers/home.helpers.ts create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/helpers/http_requests.ts create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/helpers/index.ts create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/helpers/setup_environment.tsx create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/helpers/template_clone.helpers.ts create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/helpers/template_create.helpers.ts create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/helpers/template_edit.helpers.ts create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/helpers/template_form.helpers.ts create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/home.test.ts create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/template_clone.test.tsx create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/template_create.test.tsx create mode 100644 x-pack/plugins/index_management/__jest__/client_integration/template_edit.test.tsx diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/constants.ts b/x-pack/plugins/index_management/__jest__/client_integration/helpers/constants.ts new file mode 100644 index 0000000000000..3f6e5d7d4dab2 --- /dev/null +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/constants.ts @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const TEMPLATE_NAME = 'my_template'; + +export const INDEX_PATTERNS = ['my_index_pattern']; + +export const SETTINGS = { + number_of_shards: 1, + index: { + lifecycle: { + name: 'my_policy', + }, + }, +}; + +export const ALIASES = { + alias: { + filter: { + term: { user: 'my_user' }, + }, + }, +}; + +export const MAPPINGS = { + _source: {}, + _meta: {}, + properties: {}, +}; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/home.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/helpers/home.helpers.ts new file mode 100644 index 0000000000000..7e3e1fba9c44a --- /dev/null +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/home.helpers.ts @@ -0,0 +1,173 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ReactWrapper } from 'enzyme'; +import { act } from 'react-dom/test-utils'; +import { + registerTestBed, + TestBed, + TestBedConfig, + findTestSubject, + nextTick, +} from '../../../../../test_utils'; +import { IndexManagementHome } from '../../../public/application/sections/home'; // eslint-disable-line @kbn/eslint/no-restricted-paths +import { BASE_PATH } from '../../../common/constants'; +import { indexManagementStore } from '../../../public/application/store'; // eslint-disable-line @kbn/eslint/no-restricted-paths +import { Template } from '../../../common/types'; +import { WithAppDependencies, services } from './setup_environment'; + +const testBedConfig: TestBedConfig = { + store: () => indexManagementStore(services as any), + memoryRouter: { + initialEntries: [`${BASE_PATH}indices`], + componentRoutePath: `${BASE_PATH}:section(indices|templates)`, + }, + doMountAsync: true, +}; + +const initTestBed = registerTestBed(WithAppDependencies(IndexManagementHome), testBedConfig); + +export interface IdxMgmtHomeTestBed extends TestBed { + findAction: (action: 'edit' | 'clone' | 'delete') => ReactWrapper; + actions: { + selectHomeTab: (tab: 'indicesTab' | 'templatesTab') => void; + selectDetailsTab: (tab: 'summary' | 'settings' | 'mappings' | 'aliases') => void; + clickReloadButton: () => void; + clickTemplateAction: (name: Template['name'], action: 'edit' | 'clone' | 'delete') => void; + clickTemplateAt: (index: number) => void; + clickCloseDetailsButton: () => void; + clickActionMenu: (name: Template['name']) => void; + }; +} + +export const setup = async (): Promise => { + const testBed = await initTestBed(); + + /** + * Additional helpers + */ + const findAction = (action: 'edit' | 'clone' | 'delete') => { + const actions = ['edit', 'clone', 'delete']; + const { component } = testBed; + + return component.find('.euiContextMenuItem').at(actions.indexOf(action)); + }; + + /** + * User Actions + */ + + const selectHomeTab = (tab: 'indicesTab' | 'templatesTab') => { + testBed.find(tab).simulate('click'); + }; + + const selectDetailsTab = (tab: 'summary' | 'settings' | 'mappings' | 'aliases') => { + const tabs = ['summary', 'settings', 'mappings', 'aliases']; + + testBed + .find('templateDetails.tab') + .at(tabs.indexOf(tab)) + .simulate('click'); + }; + + const clickReloadButton = () => { + const { find } = testBed; + find('reloadButton').simulate('click'); + }; + + const clickActionMenu = async (templateName: Template['name']) => { + const { component } = testBed; + + // When a table has > 2 actions, EUI displays an overflow menu with an id "-actions" + // The template name may contain a period (.) so we use bracket syntax for selector + component.find(`div[id="${templateName}-actions"] button`).simulate('click'); + }; + + const clickTemplateAction = ( + templateName: Template['name'], + action: 'edit' | 'clone' | 'delete' + ) => { + const actions = ['edit', 'clone', 'delete']; + const { component } = testBed; + + clickActionMenu(templateName); + + component + .find('.euiContextMenuItem') + .at(actions.indexOf(action)) + .simulate('click'); + }; + + const clickTemplateAt = async (index: number) => { + const { component, table, router } = testBed; + const { rows } = table.getMetaData('templateTable'); + const templateLink = findTestSubject(rows[index].reactWrapper, 'templateDetailsLink'); + + await act(async () => { + const { href } = templateLink.props(); + router.navigateTo(href!); + await nextTick(); + component.update(); + }); + }; + + const clickCloseDetailsButton = () => { + const { find } = testBed; + + find('closeDetailsButton').simulate('click'); + }; + + return { + ...testBed, + findAction, + actions: { + selectHomeTab, + selectDetailsTab, + clickReloadButton, + clickTemplateAction, + clickTemplateAt, + clickCloseDetailsButton, + clickActionMenu, + }, + }; +}; + +type IdxMgmtTestSubjects = TestSubjects; + +export type TestSubjects = + | 'aliasesTab' + | 'appTitle' + | 'cell' + | 'closeDetailsButton' + | 'createTemplateButton' + | 'deleteSystemTemplateCallOut' + | 'deleteTemplateButton' + | 'deleteTemplatesConfirmation' + | 'documentationLink' + | 'emptyPrompt' + | 'manageTemplateButton' + | 'mappingsTab' + | 'noAliasesCallout' + | 'noMappingsCallout' + | 'noSettingsCallout' + | 'indicesList' + | 'indicesTab' + | 'reloadButton' + | 'row' + | 'sectionError' + | 'sectionLoading' + | 'settingsTab' + | 'summaryTab' + | 'summaryTitle' + | 'systemTemplatesSwitch' + | 'templateDetails' + | 'templateDetails.manageTemplateButton' + | 'templateDetails.sectionLoading' + | 'templateDetails.tab' + | 'templateDetails.title' + | 'templateList' + | 'templateTable' + | 'templatesTab'; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/http_requests.ts b/x-pack/plugins/index_management/__jest__/client_integration/helpers/http_requests.ts new file mode 100644 index 0000000000000..e5bce31ee6de1 --- /dev/null +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/http_requests.ts @@ -0,0 +1,96 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import sinon, { SinonFakeServer } from 'sinon'; +import { API_BASE_PATH } from '../../../common/constants'; + +type HttpResponse = Record | any[]; + +// Register helpers to mock HTTP Requests +const registerHttpRequestMockHelpers = (server: SinonFakeServer) => { + const setLoadTemplatesResponse = (response: HttpResponse = []) => { + server.respondWith('GET', `${API_BASE_PATH}/templates`, [ + 200, + { 'Content-Type': 'application/json' }, + JSON.stringify(response), + ]); + }; + + const setLoadIndicesResponse = (response: HttpResponse = []) => { + server.respondWith('GET', `${API_BASE_PATH}/indices`, [ + 200, + { 'Content-Type': 'application/json' }, + JSON.stringify(response), + ]); + }; + + const setDeleteTemplateResponse = (response: HttpResponse = []) => { + server.respondWith('DELETE', `${API_BASE_PATH}/templates`, [ + 200, + { 'Content-Type': 'application/json' }, + JSON.stringify(response), + ]); + }; + + const setLoadTemplateResponse = (response?: HttpResponse, error?: any) => { + const status = error ? error.status || 400 : 200; + const body = error ? error.body : response; + + server.respondWith('GET', `${API_BASE_PATH}/templates/:id`, [ + status, + { 'Content-Type': 'application/json' }, + JSON.stringify(body), + ]); + }; + + const setCreateTemplateResponse = (response?: HttpResponse, error?: any) => { + const status = error ? error.body.status || 400 : 200; + const body = error ? JSON.stringify(error.body) : JSON.stringify(response); + + server.respondWith('PUT', `${API_BASE_PATH}/templates`, [ + status, + { 'Content-Type': 'application/json' }, + body, + ]); + }; + + const setUpdateTemplateResponse = (response?: HttpResponse, error?: any) => { + const status = error ? error.status || 400 : 200; + const body = error ? JSON.stringify(error.body) : JSON.stringify(response); + + server.respondWith('PUT', `${API_BASE_PATH}/templates/:name`, [ + status, + { 'Content-Type': 'application/json' }, + body, + ]); + }; + + return { + setLoadTemplatesResponse, + setLoadIndicesResponse, + setDeleteTemplateResponse, + setLoadTemplateResponse, + setCreateTemplateResponse, + setUpdateTemplateResponse, + }; +}; + +export const init = () => { + const server = sinon.fakeServer.create(); + server.respondImmediately = true; + + // Define default response for unhandled requests. + // We make requests to APIs which don't impact the component under test, e.g. UI metric telemetry, + // and we can mock them all with a 200 instead of mocking each one individually. + server.respondWith([200, {}, 'DefaultSinonMockServerResponse']); + + const httpRequestsMockHelpers = registerHttpRequestMockHelpers(server); + + return { + server, + httpRequestsMockHelpers, + }; +}; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/index_management/__jest__/client_integration/helpers/index.ts new file mode 100644 index 0000000000000..66021b531919a --- /dev/null +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/index.ts @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { setup as homeSetup } from './home.helpers'; +import { setup as templateCreateSetup } from './template_create.helpers'; +import { setup as templateCloneSetup } from './template_clone.helpers'; +import { setup as templateEditSetup } from './template_edit.helpers'; + +export { nextTick, getRandomString, findTestSubject, TestBed } from '../../../../../test_utils'; + +export { setupEnvironment } from './setup_environment'; + +export const pageHelpers = { + home: { setup: homeSetup }, + templateCreate: { setup: templateCreateSetup }, + templateClone: { setup: templateCloneSetup }, + templateEdit: { setup: templateEditSetup }, +}; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/setup_environment.tsx b/x-pack/plugins/index_management/__jest__/client_integration/helpers/setup_environment.tsx new file mode 100644 index 0000000000000..1eaf7efd17395 --- /dev/null +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/setup_environment.tsx @@ -0,0 +1,57 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +/* eslint-disable @kbn/eslint/no-restricted-paths */ +import React from 'react'; +import axios from 'axios'; +import axiosXhrAdapter from 'axios/lib/adapters/xhr'; + +import { + notificationServiceMock, + docLinksServiceMock, +} from '../../../../../../src/core/public/mocks'; +import { AppContextProvider } from '../../../public/application/app_context'; +import { httpService } from '../../../public/application/services/http'; +import { breadcrumbService } from '../../../public/application/services/breadcrumbs'; +import { documentationService } from '../../../public/application/services/documentation'; +import { notificationService } from '../../../public/application/services/notification'; +import { ExtensionsService } from '../../../public/services'; +import { UiMetricService } from '../../../public/application/services/ui_metric'; +import { setUiMetricService } from '../../../public/application/services/api'; +import { setExtensionsService } from '../../../public/application/store/selectors'; +import { init as initHttpRequests } from './http_requests'; + +const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); + +export const services = { + extensionsService: new ExtensionsService(), + uiMetricService: new UiMetricService('index_management'), +}; +services.uiMetricService.setup({ reportUiStats() {} } as any); +setExtensionsService(services.extensionsService); +setUiMetricService(services.uiMetricService); +const appDependencies = { services, core: {}, plugins: {} } as any; + +export const setupEnvironment = () => { + // Mock initialization of services + // @ts-ignore + httpService.setup(mockHttpClient); + breadcrumbService.setup(() => undefined); + documentationService.setup(docLinksServiceMock.createStartContract()); + notificationService.setup(notificationServiceMock.createSetupContract()); + + const { server, httpRequestsMockHelpers } = initHttpRequests(); + + return { + server, + httpRequestsMockHelpers, + }; +}; + +export const WithAppDependencies = (Comp: any) => (props: any) => ( + + + +); diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/template_clone.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/helpers/template_clone.helpers.ts new file mode 100644 index 0000000000000..36498b99ba143 --- /dev/null +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/template_clone.helpers.ts @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { registerTestBed, TestBedConfig } from '../../../../../test_utils'; +import { BASE_PATH } from '../../../common/constants'; +import { TemplateClone } from '../../../public/application/sections/template_clone'; // eslint-disable-line @kbn/eslint/no-restricted-paths +import { formSetup } from './template_form.helpers'; +import { TEMPLATE_NAME } from './constants'; +import { WithAppDependencies } from './setup_environment'; + +const testBedConfig: TestBedConfig = { + memoryRouter: { + initialEntries: [`${BASE_PATH}clone_template/${TEMPLATE_NAME}`], + componentRoutePath: `${BASE_PATH}clone_template/:name`, + }, + doMountAsync: true, +}; + +const initTestBed = registerTestBed(WithAppDependencies(TemplateClone), testBedConfig); + +export const setup = formSetup.bind(null, initTestBed); diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/template_create.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/helpers/template_create.helpers.ts new file mode 100644 index 0000000000000..14a44968a93c3 --- /dev/null +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/template_create.helpers.ts @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { registerTestBed, TestBedConfig } from '../../../../../test_utils'; +import { BASE_PATH } from '../../../common/constants'; +import { TemplateCreate } from '../../../public/application/sections/template_create'; // eslint-disable-line @kbn/eslint/no-restricted-paths +import { formSetup, TestSubjects } from './template_form.helpers'; +import { WithAppDependencies } from './setup_environment'; + +const testBedConfig: TestBedConfig = { + memoryRouter: { + initialEntries: [`${BASE_PATH}create_template`], + componentRoutePath: `${BASE_PATH}create_template`, + }, + doMountAsync: true, +}; + +const initTestBed = registerTestBed( + WithAppDependencies(TemplateCreate), + testBedConfig +); + +export const setup = formSetup.bind(null, initTestBed); diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/template_edit.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/helpers/template_edit.helpers.ts new file mode 100644 index 0000000000000..af5fa8b79ecad --- /dev/null +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/template_edit.helpers.ts @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { registerTestBed, TestBedConfig } from '../../../../../test_utils'; +import { BASE_PATH } from '../../../common/constants'; +import { TemplateEdit } from '../../../public/application/sections/template_edit'; // eslint-disable-line @kbn/eslint/no-restricted-paths +import { formSetup, TestSubjects } from './template_form.helpers'; +import { TEMPLATE_NAME } from './constants'; +import { WithAppDependencies } from './setup_environment'; + +const testBedConfig: TestBedConfig = { + memoryRouter: { + initialEntries: [`${BASE_PATH}edit_template/${TEMPLATE_NAME}`], + componentRoutePath: `${BASE_PATH}edit_template/:name`, + }, + doMountAsync: true, +}; + +const initTestBed = registerTestBed(WithAppDependencies(TemplateEdit), testBedConfig); + +export const setup = formSetup.bind(null, initTestBed); diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/template_form.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/helpers/template_form.helpers.ts new file mode 100644 index 0000000000000..9d4eb631a1c40 --- /dev/null +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/template_form.helpers.ts @@ -0,0 +1,241 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { TestBed, SetupFunc, UnwrapPromise } from '../../../../../test_utils'; +import { Template } from '../../../common/types'; +import { nextTick } from './index'; + +interface MappingField { + name: string; + type: string; +} + +// Look at the return type of formSetup and form a union between that type and the TestBed type. +// This way we an define the formSetup return object and use that to dynamically define our type. +export type TemplateFormTestBed = TestBed & + UnwrapPromise>; + +export const formSetup = async (initTestBed: SetupFunc) => { + const testBed = await initTestBed(); + + // User actions + const clickNextButton = () => { + testBed.find('nextButton').simulate('click'); + }; + + const clickBackButton = () => { + testBed.find('backButton').simulate('click'); + }; + + const clickSubmitButton = () => { + testBed.find('submitButton').simulate('click'); + }; + + const clickEditButtonAtField = (index: number) => { + testBed + .find('editFieldButton') + .at(index) + .simulate('click'); + }; + + const clickEditFieldUpdateButton = () => { + testBed.find('editFieldUpdateButton').simulate('click'); + }; + + const clickRemoveButtonAtField = (index: number) => { + testBed + .find('removeFieldButton') + .at(index) + .simulate('click'); + + testBed.find('confirmModalConfirmButton').simulate('click'); + }; + + const clickCancelCreateFieldButton = () => { + testBed.find('createFieldWrapper.cancelButton').simulate('click'); + }; + + const completeStepOne = async ({ + name, + indexPatterns, + order, + version, + }: Partial