Skip to content

Commit

Permalink
[New Platform Migration Phase I]: update dateHisogramInterval & parse…
Browse files Browse the repository at this point in the history
…EsInterval imports (#42917) (#43169)

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

* fix tests

* modify MIGRATION.md

* Update src/core/MIGRATION.md

Co-Authored-By: Rudolf Meijering <[email protected]>

# Conflicts:
#	src/core/MIGRATION.md
  • Loading branch information
alexwizp authored Aug 13, 2019
1 parent a884b6a commit 28cef8f
Show file tree
Hide file tree
Showing 28 changed files with 83 additions and 61 deletions.
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';
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {

import {
parseEsInterval,
} from 'ui/utils/parse_es_interval';
} from '../../../../../../../../../src/legacy/core_plugins/data/public';

import {
dateHistogramDetailsUrl,
Expand Down
Loading

0 comments on commit 28cef8f

Please sign in to comment.