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

[New Platform Migration Phase I]: update dateHisogramInterval & parseEsInterval imports #42917

Merged
merged 7 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
1 change: 1 addition & 0 deletions src/core/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,7 @@ import { setup, start } from '../core_plugins/visualizations/public/legacy';
| `ui/vis` | `visualizations.types` | -- |
| `ui/vis/vis_factory` | `visualizations.types` | -- |
| `ui/vis/vis_filters` | `visualizations.filters` | -- |
| `ui/utils/parse_es_interval` | `import { parseEsInterval } '../data/public'` | `parseEsInterval`, `ParsedInterval`, `InvalidEsCalendarIntervalError`, `InvalidEsIntervalFormatError` items were moved to the `Data Plugin` as a static code |
alexwizp marked this conversation as resolved.
Show resolved Hide resolved


#### Server-side
Expand Down
10 changes: 1 addition & 9 deletions src/legacy/core_plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,4 @@ export {
} from './filter/filter_manager';

/** @public static code */
export { dateHistogramInterval } from '../common/date_histogram_interval';
/** @public static code */
export {
isValidEsInterval,
InvalidEsCalendarIntervalError,
InvalidEsIntervalFormatError,
parseEsInterval,
ParsedInterval,
} from '../common/parse_es_interval';
export * from '../common';
Copy link
Contributor

Choose a reason for hiding this comment

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

<3

11 changes: 1 addition & 10 deletions src/legacy/core_plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,4 @@
*/

/** @public static code */
export { dateHistogramInterval } from '../common/date_histogram_interval';

/** @public static code */
export {
isValidEsInterval,
InvalidEsCalendarIntervalError,
InvalidEsIntervalFormatError,
parseEsInterval,
ParsedInterval,
} from '../common/parse_es_interval';
export * from '../common';
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
import moment from 'moment';
import { i18n } from '@kbn/i18n';
import { get } from 'lodash';

import { parseEsInterval } from '../../../../data/public';
import { GTE_INTERVAL_RE } from '../../../common/interval_regexp';
import { parseEsInterval } from '../../../../data/common/parse_es_interval';

export const AUTO_INTERVAL = 'auto';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

jest.mock('ui/visualize/loader/visualize_loader', () => ({}));

jest.mock('ui/new_platform');

import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { VisEditorVisualization } from './vis_editor_visualization';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import _ from 'lodash';
import { dateHistogramInterval } from '../../../../../../data/common';
import { dateHistogramInterval } from '../../../../../../data/server';
import { getBucketSize } from '../../helpers/get_bucket_size';
import { getTimerange } from '../../helpers/get_timerange';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { set } from 'lodash';
import { dateHistogramInterval } from '../../../../../../data/common';
import { dateHistogramInterval } from '../../../../../../data/server';
import { getBucketSize } from '../../helpers/get_bucket_size';
import { offsetTime } from '../../offset_time';
import { getIntervalAndTimefield } from '../../get_interval_and_timefield';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { set } from 'lodash';
import { dateHistogramInterval } from '../../../../../../data/common';
import { dateHistogramInterval } from '../../../../../../data/server';
import { getBucketSize } from '../../helpers/get_bucket_size';
import { isLastValueTimerangeMode } from '../../helpers/get_timerange_mode';
import { getIntervalAndTimefield } from '../../get_interval_and_timefield';
Expand Down
2 changes: 2 additions & 0 deletions src/legacy/ui/public/agg_types/__tests__/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import { isValidJson } from '../utils';

jest.mock('ui/new_platform');

const input = {
valid: '{ "test": "json input" }',
invalid: 'strings are not json',
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/agg_types/buckets/date_histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { intervalOptions } from './_interval_options';
import { TimeIntervalParamEditor } from '../controls/time_interval';
import { timefilter } from '../../timefilter';
import { DropPartialsParamEditor } from '../controls/drop_partials';
import { dateHistogramInterval } from '../../../../core_plugins/data/common';
import { dateHistogramInterval } from '../../../../core_plugins/data/public';
import { i18n } from '@kbn/i18n';

const config = chrome.getUiSettingsClient();
Expand Down
8 changes: 6 additions & 2 deletions src/legacy/ui/public/new_platform/new_platform.karma_mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import sinon from 'sinon';

export const npSetup = {
core: {},
core: {
chrome: {}
},
plugins: {
data: {
expressions: {
Expand All @@ -41,7 +43,9 @@ export const npSetup = {
};

export const npStart = {
core: {},
core: {
chrome: {}
},
plugins: {
data: {},
inspector: {
Expand Down
3 changes: 2 additions & 1 deletion src/legacy/ui/public/time_buckets/calc_es_interval.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/

import dateMath from '@elastic/datemath';
import { parseEsInterval } from 'ui/utils/parse_es_interval';

import { parseEsInterval } from '../../../core_plugins/data/public';

const unitsDesc = dateMath.unitsDesc;
const largeMax = unitsDesc.indexOf('M');
Expand Down
27 changes: 0 additions & 27 deletions src/legacy/ui/public/utils/parse_es_interval.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import { EditorConfigProviderRegistry } from './editor_config_providers';
import { EditorParamConfig, FixedParam, NumericIntervalParam, TimeIntervalParam } from './types';

jest.mock('ui/new_platform');

describe('EditorConfigProvider', () => {
let registry: EditorConfigProviderRegistry;
const indexPattern = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { AggConfig } from '../..';
import { AggType } from '../../../agg_types';
import { IndexPattern } from '../../../index_patterns';
import { leastCommonMultiple } from '../../../utils/math';
import { parseEsInterval } from '../../../utils/parse_es_interval';
import { parseEsInterval } from '../../../../../core_plugins/data/public';
import { leastCommonInterval } from '../../lib/least_common_interval';
import { EditorConfig, EditorParamConfig, FixedParam, NumericIntervalParam } from './types';

Expand Down
2 changes: 2 additions & 0 deletions src/legacy/ui/public/vis/lib/least_common_interval.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import { leastCommonInterval } from './least_common_interval';

jest.mock('ui/new_platform');

describe('leastCommonInterval', () => {
it('should correctly return lowest common interval for fixed units', () => {
expect(leastCommonInterval('1ms', '1s')).toBe('1s');
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/vis/lib/least_common_interval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import dateMath from '@elastic/datemath';
import { leastCommonMultiple } from '../../utils/math';
import { parseEsInterval } from '../../utils/parse_es_interval';
import { parseEsInterval } from '../../../../core_plugins/data/public';

/**
* Finds the lowest common interval between two given ES date histogram intervals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import { setupEnvironment, pageHelpers } from './helpers';
import { JOB_TO_CLONE, JOB_CLONE_INDEX_PATTERN_CHECK } from './helpers/constants';

jest.mock('ui/new_platform');

jest.mock('ui/index_patterns', () => {
const { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } = require.requireActual(
'../../../../../../src/legacy/ui/public/index_patterns/constants'
Expand All @@ -18,8 +20,12 @@ jest.mock('ui/chrome', () => ({
addBasePath: () => '/api/rollup',
breadcrumbs: { set: () => {} },
getInjected: () => ({}),
getUiSettingsClient: () => ({}),
getSavedObjectsClient: () => ({}),
}));

jest.mock('ui/timefilter', () => {});

jest.mock('lodash/function/debounce', () => fn => fn);

const { setup } = pageHelpers.jobClone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import moment from 'moment-timezone';

import { setupEnvironment, pageHelpers } from './helpers';

jest.mock('ui/new_platform');

jest.mock('ui/index_patterns', () => {
const { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } = require.requireActual('../../../../../../src/legacy/ui/public/index_patterns/constants'); // eslint-disable-line max-len
return { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE };
Expand All @@ -17,8 +19,12 @@ jest.mock('ui/chrome', () => ({
addBasePath: () => '/api/rollup',
breadcrumbs: { set: () => {} },
getInjected: () => ({}),
getUiSettingsClient: () => ({}),
getSavedObjectsClient: () => ({}),
}));

jest.mock('ui/timefilter', () => {});

jest.mock('lodash/function/debounce', () => fn => fn);

const { setup } = pageHelpers.jobCreate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import { setupEnvironment, pageHelpers } from './helpers';

jest.mock('ui/new_platform');

jest.mock('ui/index_patterns', () => {
const { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } = require.requireActual('../../../../../../src/legacy/ui/public/index_patterns/constants'); // eslint-disable-line max-len
return { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE };
Expand All @@ -15,8 +17,12 @@ jest.mock('ui/chrome', () => ({
addBasePath: () => '/api/rollup',
breadcrumbs: { set: () => {} },
getInjected: () => ({}),
getUiSettingsClient: () => ({}),
getSavedObjectsClient: () => ({}),
}));

jest.mock('ui/timefilter', () => {});

jest.mock('lodash/function/debounce', () => fn => fn);

const { setup } = pageHelpers.jobCreate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { MINUTE, HOUR, DAY, WEEK, MONTH, YEAR } from '../../public/crud_app/serv
import { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } from '../../../../../../src/legacy/ui/public/index_patterns';
import { setupEnvironment, pageHelpers } from './helpers';

jest.mock('ui/new_platform');

jest.mock('ui/index_patterns', () => {
const { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } = require.requireActual('../../../../../../src/legacy/ui/public/index_patterns/constants'); // eslint-disable-line max-len
return { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE };
Expand All @@ -17,8 +19,12 @@ jest.mock('ui/chrome', () => ({
addBasePath: () => '/api/rollup',
breadcrumbs: { set: () => {} },
getInjected: () => ({}),
getUiSettingsClient: () => ({}),
getSavedObjectsClient: () => ({}),
}));

jest.mock('ui/timefilter', () => {});

jest.mock('lodash/function/debounce', () => fn => fn);

const { setup } = pageHelpers.jobCreate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import { setupEnvironment, pageHelpers } from './helpers';

jest.mock('ui/new_platform');

jest.mock('ui/index_patterns', () => {
const { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } = require.requireActual('../../../../../../src/legacy/ui/public/index_patterns/constants'); // eslint-disable-line max-len
return { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE };
Expand All @@ -15,8 +17,12 @@ jest.mock('ui/chrome', () => ({
addBasePath: () => '/api/rollup',
breadcrumbs: { set: () => {} },
getInjected: () => ({}),
getUiSettingsClient: () => ({}),
getSavedObjectsClient: () => ({}),
}));

jest.mock('ui/timefilter', () => {});

jest.mock('lodash/function/debounce', () => fn => fn);

const { setup } = pageHelpers.jobCreate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { setupEnvironment, pageHelpers } from './helpers';
import { first } from 'lodash';
import { JOBS } from './helpers/constants';

jest.mock('ui/new_platform');

jest.mock('ui/index_patterns', () => {
const { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } = require.requireActual('../../../../../../src/legacy/ui/public/index_patterns/constants'); // eslint-disable-line max-len
return { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE };
Expand All @@ -17,8 +19,12 @@ jest.mock('ui/chrome', () => ({
addBasePath: (path) => path,
breadcrumbs: { set: () => {} },
getInjected: () => ({}),
getUiSettingsClient: () => ({}),
getSavedObjectsClient: () => ({}),
}));

jest.mock('ui/timefilter', () => {});

jest.mock('lodash/function/debounce', () => fn => fn);

const { setup } = pageHelpers.jobCreate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import { setupEnvironment, pageHelpers } from './helpers';

jest.mock('ui/new_platform');

jest.mock('ui/index_patterns', () => {
const { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } = require.requireActual('../../../../../../src/legacy/ui/public/index_patterns/constants'); // eslint-disable-line max-len
return { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE };
Expand All @@ -15,8 +17,12 @@ jest.mock('ui/chrome', () => ({
addBasePath: () => '/api/rollup',
breadcrumbs: { set: () => {} },
getInjected: () => ({}),
getUiSettingsClient: () => ({}),
getSavedObjectsClient: () => ({}),
}));

jest.mock('ui/timefilter', () => {});

jest.mock('lodash/function/debounce', () => fn => fn);

const { setup } = pageHelpers.jobCreate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { getRouter } from '../../public/crud_app/services';
import { setupEnvironment, pageHelpers, nextTick } from './helpers';
import { JOBS } from './helpers/constants';

jest.mock('ui/new_platform');

jest.mock('ui/index_patterns', () => {
const { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } = require.requireActual('../../../../../../src/legacy/ui/public/index_patterns/constants'); // eslint-disable-line max-len
return { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE };
Expand All @@ -25,9 +27,13 @@ jest.mock('ui/chrome', () => ({
};
}
throw new Error(`Unexpected call to chrome.getInjected with key ${key}`);
}
},
getUiSettingsClient: () => ({}),
getSavedObjectsClient: () => ({}),
}));

jest.mock('ui/timefilter', () => {});

jest.mock('../../public/crud_app/services', () => {
const services = require.requireActual('../../public/crud_app/services');
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { JOB_TO_CLONE, JOB_CLONE_INDEX_PATTERN_CHECK } from './helpers/constants
import { getRouter } from '../../public/crud_app/services/routing';
import { CRUD_APP_BASE_PATH } from '../../public/crud_app/constants';

jest.mock('ui/new_platform');

jest.mock('ui/index_patterns', () => {
const { INDEX_PATTERN_ILLEGAL_CHARACTERS_VISIBLE } = require.requireActual(
'../../../../../../src/legacy/ui/public/index_patterns/constants'
Expand All @@ -20,8 +22,12 @@ jest.mock('ui/chrome', () => ({
addBasePath: () => '/api/rollup',
breadcrumbs: { set: () => {} },
getInjected: () => ({}),
getUiSettingsClient: () => ({}),
getSavedObjectsClient: () => ({}),
}));

jest.mock('ui/timefilter', () => {});

jest.mock('lodash/function/debounce', () => fn => fn);

const { setup } = pageHelpers.jobList;
Expand Down
Loading