Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 24 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7eed77e
fix agg type shims and move paginated table to kibana_legacy
flash1293 Feb 14, 2020
3e992c2
Merge remote-tracking branch 'upstream/master' into fix-visualize-shims
flash1293 Feb 17, 2020
f880e2d
fix types
flash1293 Feb 17, 2020
7abddc4
fix i18n ids
flash1293 Feb 17, 2020
555e19e
fix unit tests
flash1293 Feb 17, 2020
d70fac3
Merge remote-tracking branch 'upstream/master' into fix-visualize-shims
flash1293 Feb 18, 2020
94f8f84
Merge branch 'master' into fix-visualize-shims
sulemanof Mar 16, 2020
f390d01
Update imports
sulemanof Mar 16, 2020
d4688bf
Remove ui/agg_types imports
sulemanof Mar 17, 2020
97f40f4
Clean up vis_default_editor plugin
sulemanof Mar 17, 2020
111d502
Remove agg_types imports in vis_type_table
sulemanof Mar 17, 2020
7a9b879
Clean up x-pack
sulemanof Mar 18, 2020
87bc3dc
Clean up vis_type_vislib
sulemanof Mar 18, 2020
bbd5256
Last cleanups
sulemanof Mar 18, 2020
1d0cb79
Merge remote-tracking branch 'upstream/master' into fix-visualize-shims
sulemanof Mar 18, 2020
fc3c455
Update docs
sulemanof Mar 18, 2020
895c69b
Merge remote-tracking branch 'upstream/master' into fix-visualize-shims
sulemanof Mar 18, 2020
b68ab0b
Mock Schemas in vis_type_metric
sulemanof Mar 18, 2020
7c358a9
Use data plugin mocks
sulemanof Mar 19, 2020
b258b21
Remove ui/directives/paginate reference
sulemanof Mar 19, 2020
79b7b88
Merge remote-tracking branch 'upstream/master' into fix-visualize-shims
sulemanof Mar 19, 2020
937777f
Remove snapshot
sulemanof Mar 19, 2020
57ea6fa
Remove shallow
sulemanof Mar 19, 2020
40c15a0
Merge branch 'master' into fix-visualize-shims
elasticmachine Mar 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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">>
```
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}
```
2 changes: 0 additions & 2 deletions src/dev/jest/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Copy link
Contributor Author

@sulemanof sulemanof Mar 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no necessity to collect coverage from these folders (agg_types doesn't exist anymore, vis contains only legacy mocka tests since the most of code was moved)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

],
moduleNameMapper: {
'@elastic/eui$': '<rootDir>/node_modules/@elastic/eui/test-env',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {
getRequestInspectorStats,
getResponseInspectorStats,
getServices,
intervalOptions,
unhashUrl,
subscribeWithScope,
tabifyAggResponse,
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -286,7 +286,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;
Expand Down
1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana/public/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/tile_map/public/tile_map_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 />,
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { IAggConfig } from '../legacy_imports';
import { IAggConfig } from 'src/plugins/data/public';
import {
isAggRemovable,
calcAggIsTooLow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import React from 'react';
import { mount, shallow } from 'enzyme';

import { VisState } from 'src/legacy/core_plugins/visualizations/public';
import { IndexPattern } from 'src/plugins/data/public';
import { IndexPattern, IAggConfig, AggGroupNames } from 'src/plugins/data/public';
import { DefaultEditorAggParams, DefaultEditorAggParamsProps } from './agg_params';
import { IAggConfig, AggGroupNames } from '../legacy_imports';

const mockEditorConfig = {
useNormalizedEsInterval: { hidden: false, fixedValue: false },
Expand All @@ -35,7 +34,6 @@ const mockEditorConfig = {
},
};

jest.mock('ui/new_platform');
jest.mock('./utils', () => ({
getEditorConfig: jest.fn(() => mockEditorConfig),
}));
Expand Down Expand Up @@ -70,6 +68,27 @@ jest.mock('./agg_select', () => ({
jest.mock('./agg_param', () => ({
DefaultEditorAggParam: () => null,
}));
jest.mock('../../../../../plugins/kibana_react/public', () => ({
useKibana: () => ({
services: {
data: {
search: {
aggs: {
types: {
getAll: () => [],
},
},
__LEGACY: {
aggTypeFieldFilters: {
filter: () => [],
},
},
},
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - It would probably make maintenance easier if you passed the mocks from src/plugins/data/public/mocks.ts here (assuming that works for these specific tests)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.
Wrapped KibanaContextProvider with dataPluginMock service .

},
}),
withKibana: (x: any) => x,
}));

describe('DefaultEditorAggParams component', () => {
let setAggParamValue: jest.Mock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -83,18 +84,24 @@ function DefaultEditorAggParams({
allowedAggs = [],
hideCustomLabel = false,
}: DefaultEditorAggParamsProps) {
const schema = getSchemaByName(schemas, agg.schema);
const { title } = schema;
const aggFilter = [...allowedAggs, ...(schema.aggFilter || [])];
kertal marked this conversation as resolved.
Show resolved Hide resolved
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;
Expand All @@ -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(
Expand Down
Loading