[NP] Remove ui/agg_types dependencies and move paginated table to kibana_legacy (#60276) (#60769)

* 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 <johannes.reuter@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
# Conflicts:
#	src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_state.test.ts
This commit is contained in:
Daniil Suleiman 2020-03-20 22:02:00 +03:00 committed by GitHub
parent 788b889cf6
commit 7f362e6e18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
98 changed files with 576 additions and 730 deletions

View file

@ -7,5 +7,5 @@
<b>Signature:</b>
```typescript
QueryStringInput: React.FC<Pick<Props, "query" | "placeholder" | "onChange" | "onSubmit" | "prepend" | "indexPatterns" | "screenTitle" | "dataTestSubj" | "disableAutoFocus" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition">>
QueryStringInput: React.FC<Pick<Props, "query" | "placeholder" | "onChange" | "onSubmit" | "prepend" | "indexPatterns" | "disableAutoFocus" | "screenTitle" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition" | "dataTestSubj">>
```

View file

@ -7,7 +7,7 @@
<b>Signature:</b>
```typescript
SearchBar: React.ComponentClass<Pick<Pick<SearchBarProps, "query" | "isLoading" | "intl" | "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">, "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<Pick<SearchBarProps, "query" | "isLoading" | "intl" | "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"> & ReactIntl.InjectedIntlProps>;
SearchBar: React.ComponentClass<Pick<Pick<SearchBarProps, "query" | "isLoading" | "intl" | "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">, "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<Pick<SearchBarProps, "query" | "isLoading" | "intl" | "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"> & ReactIntl.InjectedIntlProps>;
}
```

View file

@ -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$': '<rootDir>/node_modules/@elastic/eui/test-env',

View file

@ -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: [],
},
}));
jest.mock('ui/state_management/state', () => ({
State: {},
}));

View file

@ -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 {

View file

@ -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;

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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;
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 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 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 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 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 most recently entered search/filter
let prevSearch;
// the list of hits, used to render display
self.hits = [];
// the list of hits, used to render display
self.hits = [];
self.service = savedSheetLoader;
self.properties = self.service.loaderProperties;
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;
}
return '#';
};
self.preventClick = function($event) {
$event.preventDefault();
};
/**
* 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);
}
const url = self.makeUrl(hit);
if (!url || url === '#' || url.charAt(0) !== '#') return;
$event.preventDefault();
// we want the '/path', not '#/path'
kbnUrl.change(url.substr(1));
};
$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;
};
/**
* Boolean that keeps track of whether hits are sorted ascending (true)
* or descending (false) by title
* @type {Boolean}
*/
self.isAscending = true;
//manages the state of the keyboard selector
self.selector = {
enabled: false,
index: -1,
};
/**
* 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();
};
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;
$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');
/**
* 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;
}
return '#';
};
self.preventClick = function($event) {
$event.preventDefault();
};
/**
* 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);
}
const url = self.makeUrl(hit);
if (!url || url === '#' || url.charAt(0) !== '#') return;
$event.preventDefault();
// we want the '/path', not '#/path'
kbnUrl.change(url.substr(1));
};
$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;
}
};
//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;
$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');
}
});
}
},
};
});

View file

@ -1,70 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`DefaultEditorAggParams component should init with the default set of params 1`] = `
<EuiForm
data-test-subj="visAggEditorParams"
error=""
isInvalid={false}
>
<DefaultEditorAggSelect
aggTypeOptions={Array []}
indexPattern={Object {}}
isSubAggregation={false}
onChangeAggType={[Function]}
setValue={[Function]}
showValidation={false}
value={
Object {
"params": Array [
Object {
"deserialize": [MockFunction],
"name": "interval",
},
],
}
}
/>
<DefaultEditorAggParam
aggParam={
Object {
"displayName": "Custom label",
"name": "customLabel",
"type": "string",
}
}
formIsTouched={false}
key="customLabelundefined"
onChangeParamsState={[Function]}
setAggParamValue={[MockFunction]}
showValidation={false}
/>
<EuiSpacer
size="m"
/>
<EuiAccordion
buttonContent="Advanced"
data-test-subj="advancedParams-undefined"
id="advancedAccordion"
initialIsOpen={false}
paddingSize="none"
>
<EuiSpacer
size="s"
/>
<DefaultEditorAggParam
aggParam={
Object {
"advanced": true,
"name": "json",
"type": "json",
}
}
formIsTouched={false}
key="jsonundefined"
onChangeParamsState={[Function]}
setAggParamValue={[MockFunction]}
showValidation={false}
/>
</EuiAccordion>
</EuiForm>
`;

View file

@ -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,
}));

View file

@ -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';

View file

@ -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 {

View file

@ -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'];

View file

@ -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: () => <div />,
}));

View file

@ -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(

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { IAggConfig } from '../legacy_imports';
import { IAggConfig } from 'src/plugins/data/public';
import {
isAggRemovable,
calcAggIsTooLow,

View file

@ -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';

View file

@ -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',

View file

@ -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';

View file

@ -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) => (
<KibanaContextProvider services={{ data: dataPluginMock.createStartContract() }}>
<PureDefaultEditorAggParams {...props} />
</KibanaContextProvider>
);
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(<DefaultEditorAggParams {...defaultProps} />);
expect(comp).toMatchSnapshot();
});
it('should reset the validity to true when destroyed', () => {
const comp = mount(<DefaultEditorAggParams {...defaultProps} aggIsTooLow={true} />);

View file

@ -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<VisDefaultEditorKibanaServices>();
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(

View file

@ -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']);
});

View file

@ -19,23 +19,23 @@
import { get, isEmpty } from 'lodash';
import { IndexPattern, IndexPatternField } from 'src/plugins/data/public';
import {
AggTypeFieldFilters,
IAggConfig,
AggParam,
IFieldParamType,
IAggType,
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,
IAggConfig,
AggParam,
IFieldParamType,
IAggType,
} from '../legacy_imports';
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<IAggType> {
const aggTypeOptions = aggTypeFilters.filter(
(aggTypes as any)[groupName],
const aggTypeOptions = search.aggs.aggTypeFilters.filter(
aggTypes[groupName],
indexPattern,
agg,
allowedAggs

View file

@ -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,

View file

@ -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';

View file

@ -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 {

View file

@ -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,

View file

@ -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,

View file

@ -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<any>;

View file

@ -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';

View file

@ -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;

View file

@ -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<boolean>) {
useEffect(() => {
props.setValue(props.value && props.agg.params.min_doc_count);

View file

@ -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', () => ({

View file

@ -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<boolean>) {
const fieldTypeIsNotString = !isStringType(props.agg);
const fieldTypeIsNotString = !search.aggs.isStringType(props.agg);
useEffect(() => {
if (fieldTypeIsNotString) {

View file

@ -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({

View file

@ -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;

View file

@ -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';

View file

@ -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 = [
{

View file

@ -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';

View file

@ -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';

View file

@ -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';

View file

@ -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 = {

View file

@ -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();
}
};

View file

@ -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;

View file

@ -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 {

View file

@ -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[];

View file

@ -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;

View file

@ -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]
);

View file

@ -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 {

View file

@ -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';

View file

@ -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<EditorAction>] {
const [state, dispatch] = useReducer(editorStateReducer, vis, initEditorState);
const { services } = useKibana<VisDefaultEditorKibanaServices>();
const [state, dispatch] = useReducer(
createEditorStateReducer(services.data.search),
vis,
initEditorState
);
useEffect(() => {
const handleVisUpdate = (params: VisParams) => {

View file

@ -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 };

View file

@ -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';

View file

@ -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;
}

View file

@ -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 = [
{

View file

@ -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<VisParamType = unknown> {

View file

@ -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');
/**

View file

@ -18,4 +18,3 @@
*/
export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities';
export { AggGroupNames, Schemas } from 'ui/agg_types';

View file

@ -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', () => {

View file

@ -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', () => {

View file

@ -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',

View file

@ -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;

View file

@ -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;

View file

@ -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,

View file

@ -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();

View file

@ -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';

View file

@ -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', () => ({

View file

@ -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

View file

@ -17,5 +17,4 @@
* under the License.
*/
export { Schemas } from 'ui/agg_types';
export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities';

View file

@ -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';

View file

@ -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,

View file

@ -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 =

View file

@ -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',
}));

View file

@ -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';

View file

@ -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';

View file

@ -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',

View file

@ -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';

View file

@ -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,

View file

@ -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,

View file

@ -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;

View file

@ -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,

View file

@ -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';

View file

@ -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';

View file

@ -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 => {

View file

@ -1332,7 +1332,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<Pick<Props_3, "query" | "placeholder" | "onChange" | "onSubmit" | "prepend" | "indexPatterns" | "screenTitle" | "dataTestSubj" | "disableAutoFocus" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition">>;
export const QueryStringInput: React.FC<Pick<Props_3, "query" | "placeholder" | "onChange" | "onSubmit" | "prepend" | "indexPatterns" | "disableAutoFocus" | "screenTitle" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition" | "dataTestSubj">>;
// @public (undocumented)
export type QuerySuggestion = QuerySuggestionBasic | QuerySuggestionField;
@ -1541,8 +1541,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<Pick<Pick<SearchBarProps, "query" | "isLoading" | "intl" | "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">, "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<Pick<SearchBarProps, "query" | "isLoading" | "intl" | "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"> & ReactIntl.InjectedIntlProps>;
export const SearchBar: React.ComponentClass<Pick<Pick<SearchBarProps, "query" | "isLoading" | "intl" | "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">, "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<Pick<SearchBarProps, "query" | "isLoading" | "intl" | "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"> & ReactIntl.InjectedIntlProps>;
};
// Warning: (ae-forgotten-export) The symbol "SearchBarOwnProps" needs to be exported by the entry point index.d.ts

View file

@ -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';

View file

@ -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;

View file

@ -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);

View file

@ -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"
></button>
@ -86,7 +86,7 @@
<form class="form-inline pagination-size" ng-if="showSelector">
<div class="form-group">
<label
i18n-id="common.ui.paginateControls.pageSizeLabel"
i18n-id="kibana_legacy.paginate.controls.pageSizeLabel"
i18n-default-message="Page Size"
></label>
<select

View file

@ -28,7 +28,6 @@ import 'uiExports/shareContextMenuExtensions';
import _ from 'lodash';
import 'ui/autoload/all';
import 'ui/agg_response';
import 'ui/agg_types';
import 'leaflet';
import 'plugins/kibana/dashboard/legacy';
import { npStart } from 'ui/new_platform';

View file

@ -8,9 +8,6 @@ import React from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
// TODO: make this new-platform compatible
import { isValidInterval } from 'ui/agg_types';
import {
EuiForm,
EuiFormRow,
@ -26,8 +23,12 @@ import {
import { updateColumnParam } from '../../state_helpers';
import { OperationDefinition } from '.';
import { FieldBasedIndexPatternColumn } from './column_types';
import { IndexPatternAggRestrictions } from '../../../../../../../../src/plugins/data/public';
import {
IndexPatternAggRestrictions,
search,
} from '../../../../../../../../src/plugins/data/public';
const { isValidInterval } = search.aggs;
const autoInterval = 'auto';
const calendarOnlyIntervals = new Set(['w', 'M', 'q', 'y']);

View file

@ -5,8 +5,6 @@
*/
import { npSetup, npStart } from 'ui/new_platform';
import { aggTypeFilters } from 'ui/agg_types';
import { aggTypeFieldFilters } from 'ui/agg_types';
import { RollupPlugin } from './plugin';
import { setup as management } from '../../../../../src/legacy/core_plugins/management/public/legacy';
@ -15,9 +13,7 @@ const plugin = new RollupPlugin();
export const setup = plugin.setup(npSetup.core, {
...npSetup.plugins,
__LEGACY: {
aggTypeFilters,
aggTypeFieldFilters,
managementLegacy: management,
},
});
export const start = plugin.start(npStart.core);
export const start = plugin.start(npStart.core, npStart.plugins);

View file

@ -4,5 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/
export { AggTypeFilters } from 'ui/agg_types';
export { AggTypeFieldFilters } from 'ui/agg_types';
export { PluginsStart } from 'ui/new_platform/new_platform';

View file

@ -6,7 +6,7 @@
import { i18n } from '@kbn/i18n';
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { AggTypeFilters, AggTypeFieldFilters } from './legacy_imports';
import { PluginsStart } from './legacy_imports';
import { ManagementSetup as ManagementSetupLegacy } from '../../../../../src/legacy/core_plugins/management/public/np_ready';
import { rollupBadgeExtension, rollupToggleExtension } from './extend_index_management';
// @ts-ignore
@ -26,6 +26,7 @@ import {
import { CRUD_APP_BASE_PATH } from './crud_app/constants';
import { ManagementSetup } from '../../../../../src/plugins/management/public';
import { IndexMgmtSetup } from '../../../../plugins/index_management/public';
import { search } from '../../../../../src/plugins/data/public';
// @ts-ignore
import { setEsBaseAndXPackBase, setHttp } from './crud_app/services';
import { setNotifications, setFatalErrors } from './kibana_services';
@ -33,8 +34,6 @@ import { renderApp } from './application';
export interface RollupPluginSetupDependencies {
__LEGACY: {
aggTypeFilters: AggTypeFilters;
aggTypeFieldFilters: AggTypeFieldFilters;
managementLegacy: ManagementSetupLegacy;
};
home?: HomePublicPluginSetup;
@ -46,7 +45,7 @@ export class RollupPlugin implements Plugin {
setup(
core: CoreSetup,
{
__LEGACY: { aggTypeFilters, aggTypeFieldFilters, managementLegacy },
__LEGACY: { managementLegacy },
home,
management,
indexManagement,
@ -64,8 +63,6 @@ export class RollupPlugin implements Plugin {
if (isRollupIndexPatternsEnabled) {
managementLegacy.indexPattern.creation.add(RollupIndexPatternCreationConfig);
managementLegacy.indexPattern.list.add(RollupIndexPatternListConfig);
initAggTypeFilter(aggTypeFilters);
initAggTypeFieldFilter(aggTypeFieldFilters);
}
if (home) {
@ -104,9 +101,16 @@ export class RollupPlugin implements Plugin {
}
}
start(core: CoreStart) {
start(core: CoreStart, plugins: PluginsStart) {
setHttp(core.http);
setNotifications(core.notifications);
setEsBaseAndXPackBase(core.docLinks.ELASTIC_WEBSITE_URL, core.docLinks.DOC_LINK_VERSION);
const isRollupIndexPatternsEnabled = core.uiSettings.get(CONFIG_ROLLUPS);
if (isRollupIndexPatternsEnabled) {
initAggTypeFilter(search.aggs.aggTypeFilters);
initAggTypeFieldFilter(plugins.data.search.__LEGACY.aggTypeFieldFilters);
}
}
}

View file

@ -77,7 +77,6 @@
},
"messages": {
"common.ui.aggResponse.allDocsTitle": "すべてのドキュメント",
"common.ui.directives.paginate.size.allDropDownOptionLabel": "すべて",
"common.ui.errorAutoCreateIndex.breadcrumbs.errorText": "エラー",
"common.ui.errorAutoCreateIndex.errorDescription": "Elasticsearch クラスターの {autoCreateIndexActionConfig} 設定が原因で、Kibana が保存されたオブジェクトを格納するインデックスを自動的に作成できないようです。Kibana は、保存されたオブジェクトインデックスが適切なマッピング/スキーマを使用し Kibana から Elasticsearch へのポーリングの回数を減らすための最適な手段であるため、この Elasticsearch の機能を使用します。",
"common.ui.errorAutoCreateIndex.errorDisclaimer": "申し訳ございませんが、この問題が解決されるまで Kibana で何も保存することができません。",
@ -245,8 +244,6 @@
"common.ui.flotCharts.thuLabel": "木",
"common.ui.flotCharts.tueLabel": "火",
"common.ui.flotCharts.wedLabel": "水",
"common.ui.paginateControls.pageSizeLabel": "ページサイズ",
"common.ui.paginateControls.scrollTopButtonLabel": "最上部に移動",
"common.ui.scriptingLanguages.errorFetchingToastDescription": "Elasticsearch から利用可能なスクリプト言語の取得中にエラーが発生しました",
"common.ui.stateManagement.unableToParseUrlErrorMessage": "URL をパースできません",
"common.ui.stateManagement.unableToRestoreUrlErrorMessage": "URL を完全に復元できません。共有機能を使用していることを確認してください。",
@ -1543,6 +1540,9 @@
"kibana_legacy.notify.toaster.errorMessage": "错误:{errorMessage}\n {errorStack}",
"kibana_legacy.notify.toaster.errorStatusMessage": "错误 {errStatus} {errStatusText}{errMessage}",
"kibana_legacy.notify.toaster.unavailableServerErrorMessage": "HTTP 请求无法连接。请检查 Kibana 服务器是否正在运行以及您的浏览器是否具有有效的连接,或请联系您的系统管理员。",
"kibana_legacy.paginate.controls.pageSizeLabel": "ページサイズ",
"kibana_legacy.paginate.controls.scrollTopButtonLabel": "最上部に移動",
"kibana_legacy.paginate.size.allDropDownOptionLabel": "すべて",
"home.addData.apm.addApmButtonLabel": "APM を追加",
"home.addData.apm.nameDescription": "APM は、集約内から自動的に詳細なパフォーマンスメトリックやエラーを集めます。",
"home.addData.apm.nameTitle": "APM",

View file

@ -77,7 +77,6 @@
},
"messages": {
"common.ui.aggResponse.allDocsTitle": "所有文档",
"common.ui.directives.paginate.size.allDropDownOptionLabel": "全部",
"common.ui.errorAutoCreateIndex.breadcrumbs.errorText": "错误",
"common.ui.errorAutoCreateIndex.errorDescription": "似乎 Elasticsearch 集群的 {autoCreateIndexActionConfig} 设置使 Kibana 无法自动创建用于存储已保存对象的索引。Kibana 将使用此 Elasticsearch 功能,因为这是确保已保存对象索引使用正确映射/架构的最好方式,而且其允许 Kibana 较少地轮询 Elasticsearch。",
"common.ui.errorAutoCreateIndex.errorDisclaimer": "但是,只有解决了此问题后,您才能在 Kibana 保存内容。",
@ -245,8 +244,6 @@
"common.ui.flotCharts.thuLabel": "周四",
"common.ui.flotCharts.tueLabel": "周二",
"common.ui.flotCharts.wedLabel": "周三",
"common.ui.paginateControls.pageSizeLabel": "页面大小",
"common.ui.paginateControls.scrollTopButtonLabel": "滚动至顶部",
"common.ui.scriptingLanguages.errorFetchingToastDescription": "从 Elasticsearch 获取可用的脚本语言时出错",
"common.ui.stateManagement.unableToParseUrlErrorMessage": "无法解析 URL",
"common.ui.stateManagement.unableToRestoreUrlErrorMessage": "无法完整还原 URL确保使用共享功能。",
@ -1544,6 +1541,9 @@
"kibana_legacy.notify.toaster.errorMessage": "错误:{errorMessage}\n {errorStack}",
"kibana_legacy.notify.toaster.errorStatusMessage": "错误 {errStatus} {errStatusText}{errMessage}",
"kibana_legacy.notify.toaster.unavailableServerErrorMessage": "HTTP 请求无法连接。请检查 Kibana 服务器是否正在运行以及您的浏览器是否具有有效的连接,或请联系您的系统管理员。",
"kibana_legacy.paginate.controls.pageSizeLabel": "页面大小",
"kibana_legacy.paginate.controls.scrollTopButtonLabel": "滚动至顶部",
"kibana_legacy.paginate.size.allDropDownOptionLabel": "全部",
"home.addData.apm.addApmButtonLabel": "添加 APM",
"home.addData.apm.nameDescription": "APM 自动从您的应用程序内收集深入全面的性能指标和错误。",
"home.addData.apm.nameTitle": "APM",