diff --git a/superset-frontend/spec/javascripts/modules/utils_spec.jsx b/superset-frontend/spec/javascripts/modules/utils_spec.jsx index 3da8848bc..0c8515f8a 100644 --- a/superset-frontend/spec/javascripts/modules/utils_spec.jsx +++ b/superset-frontend/spec/javascripts/modules/utils_spec.jsx @@ -16,25 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -import { formatSelectOptionsForRange, mainMetric } from 'src/modules/utils'; +import { mainMetric } from 'src/modules/utils'; describe('utils', () => { - describe('formatSelectOptionsForRange', () => { - it('returns an array of arrays for the range specified (inclusive)', () => { - expect(formatSelectOptionsForRange(0, 4)).toEqual([ - [0, '0'], - [1, '1'], - [2, '2'], - [3, '3'], - [4, '4'], - ]); - expect(formatSelectOptionsForRange(1, 2)).toEqual([ - [1, '1'], - [2, '2'], - ]); - }); - }); - describe('mainMetric', () => { it('is null when no options', () => { expect(mainMetric([])).toBeUndefined(); diff --git a/superset-frontend/src/dashboard/actions/sliceEntities.js b/superset-frontend/src/dashboard/actions/sliceEntities.js index bf5cd5b39..7c9f04444 100644 --- a/superset-frontend/src/dashboard/actions/sliceEntities.js +++ b/superset-frontend/src/dashboard/actions/sliceEntities.js @@ -19,9 +19,9 @@ /* eslint camelcase: 0 */ import { t, SupersetClient } from '@superset-ui/core'; -import { addDangerToast } from '../../messageToasts/actions'; -import { getDatasourceParameter } from '../../modules/utils'; -import getClientErrorObject from '../../utils/getClientErrorObject'; +import { addDangerToast } from 'src/messageToasts/actions'; +import { getDatasourceParameter } from 'src/modules/utils'; +import getClientErrorObject from 'src/utils/getClientErrorObject'; export const SET_ALL_SLICES = 'SET_ALL_SLICES'; export function setAllSlices(slices) { diff --git a/superset-frontend/src/dashboard/reducers/getInitialState.js b/superset-frontend/src/dashboard/reducers/getInitialState.js index 108d14adc..d9ddc59cd 100644 --- a/superset-frontend/src/dashboard/reducers/getInitialState.js +++ b/superset-frontend/src/dashboard/reducers/getInitialState.js @@ -21,15 +21,15 @@ import { isString } from 'lodash'; import shortid from 'shortid'; import { CategoricalColorNamespace } from '@superset-ui/core'; -import { chart } from '../../chart/chartReducer'; +import { initSliceEntities } from 'src/dashboard/reducers/sliceEntities'; +import { getParam } from 'src/modules/utils'; +import { applyDefaultFormData } from 'src/explore/store'; +import { buildActiveFilters } from 'src/dashboard/util/activeDashboardFilters'; import { DASHBOARD_FILTER_SCOPE_GLOBAL, dashboardFilter, } from './dashboardFilters'; -import { initSliceEntities } from './sliceEntities'; -import { getParam } from '../../modules/utils'; -import { applyDefaultFormData } from '../../explore/store'; -import { buildActiveFilters } from '../util/activeDashboardFilters'; +import { chart } from '../../chart/chartReducer'; import { DASHBOARD_HEADER_ID, GRID_DEFAULT_CHART_WIDTH, diff --git a/superset-frontend/src/explore/controlPanels/DeckArc.js b/superset-frontend/src/explore/controlPanels/DeckArc.js index 4aaad9407..c7e88639a 100644 --- a/superset-frontend/src/explore/controlPanels/DeckArc.js +++ b/superset-frontend/src/explore/controlPanels/DeckArc.js @@ -17,9 +17,9 @@ * under the License. */ import { t, validateNonEmpty, legacyValidateInteger } from '@superset-ui/core'; -import timeGrainSqlaAnimationOverrides from './timeGrainSqlaAnimationOverrides'; -import { columnChoices, PRIMARY_COLOR } from '../controls'; -import { formatSelectOptions } from '../../modules/utils'; +import timeGrainSqlaAnimationOverrides from 'src/explore/controlPanels/timeGrainSqlaAnimationOverrides'; +import { columnChoices, PRIMARY_COLOR } from 'src/explore/controls'; +import { formatSelectOptions } from 'src/modules/utils'; import { filterNulls, autozoom, diff --git a/superset-frontend/src/explore/controlPanels/DeckGeojson.js b/superset-frontend/src/explore/controlPanels/DeckGeojson.js index 9e75c3f49..f67652614 100644 --- a/superset-frontend/src/explore/controlPanels/DeckGeojson.js +++ b/superset-frontend/src/explore/controlPanels/DeckGeojson.js @@ -17,8 +17,8 @@ * under the License. */ import { t, validateNonEmpty, legacyValidateInteger } from '@superset-ui/core'; -import { formatSelectOptions } from '../../modules/utils'; -import { columnChoices } from '../controls'; +import { formatSelectOptions } from 'src/modules/utils'; +import { columnChoices } from 'src/explore/controls'; import { filterNulls, jsColumns, diff --git a/superset-frontend/src/explore/controlPanels/DeckHex.js b/superset-frontend/src/explore/controlPanels/DeckHex.js index 6d7adc99c..b6794c716 100644 --- a/superset-frontend/src/explore/controlPanels/DeckHex.js +++ b/superset-frontend/src/explore/controlPanels/DeckHex.js @@ -17,7 +17,7 @@ * under the License. */ import { t } from '@superset-ui/core'; -import { formatSelectOptions } from '../../modules/utils'; +import { formatSelectOptions } from 'src/modules/utils'; import { filterNulls, autozoom, diff --git a/superset-frontend/src/explore/controlPanels/DeckPolygon.js b/superset-frontend/src/explore/controlPanels/DeckPolygon.js index b2d91c5b5..dd39e7454 100644 --- a/superset-frontend/src/explore/controlPanels/DeckPolygon.js +++ b/superset-frontend/src/explore/controlPanels/DeckPolygon.js @@ -17,8 +17,8 @@ * under the License. */ import { t } from '@superset-ui/core'; +import { formatSelectOptions } from 'src/modules/utils'; import timeGrainSqlaAnimationOverrides from './timeGrainSqlaAnimationOverrides'; -import { formatSelectOptions } from '../../modules/utils'; import { filterNulls, autozoom, diff --git a/superset-frontend/src/explore/controlPanels/Separator.js b/superset-frontend/src/explore/controlPanels/Separator.js index 19ab99bf0..aaca4a6d8 100644 --- a/superset-frontend/src/explore/controlPanels/Separator.js +++ b/superset-frontend/src/explore/controlPanels/Separator.js @@ -17,7 +17,7 @@ * under the License. */ import { t, validateNonEmpty } from '@superset-ui/core'; -import { formatSelectOptions } from '../../modules/utils'; +import { formatSelectOptions } from 'src/modules/utils'; export default { controlPanelSections: [ diff --git a/superset-frontend/src/explore/controlPanels/sections.jsx b/superset-frontend/src/explore/controlPanels/sections.jsx index f9cae320b..5e225bcaa 100644 --- a/superset-frontend/src/explore/controlPanels/sections.jsx +++ b/superset-frontend/src/explore/controlPanels/sections.jsx @@ -18,7 +18,7 @@ */ import React from 'react'; import { t } from '@superset-ui/core'; -import { formatSelectOptions } from '../../modules/utils'; +import { formatSelectOptions } from 'src/modules/utils'; export const druidTimeSeries = { label: t('Time'), diff --git a/superset-frontend/src/explore/controls.jsx b/superset-frontend/src/explore/controls.jsx index 1c7793867..145c3262a 100644 --- a/superset-frontend/src/explore/controls.jsx +++ b/superset-frontend/src/explore/controls.jsx @@ -66,7 +66,7 @@ import { ColumnOption, } from '@superset-ui/core'; -import { formatSelectOptions, mainMetric } from '../modules/utils'; +import { formatSelectOptions, mainMetric } from 'src/modules/utils'; import { TIME_FILTER_LABELS } from './constants'; const categoricalSchemeRegistry = getCategoricalSchemeRegistry(); diff --git a/superset-frontend/src/modules/utils.js b/superset-frontend/src/modules/utils.js index a4e510003..6520936c4 100644 --- a/superset-frontend/src/modules/utils.js +++ b/superset-frontend/src/modules/utils.js @@ -17,41 +17,6 @@ * under the License. */ /* eslint camelcase: 0 */ -import $ from 'jquery'; - -/** - * Sets the body and title content of a modal, and shows it. Assumes HTML for modal exists and that - * it handles closing (i.e., works with bootstrap) - * - * @param {object} options object of the form - * { - * title: {string}, - * body: {string}, - * modalSelector: {string, default: '.misc-modal' }, - * titleSelector: {string, default: '.misc-modal .modal-title' }, - * bodySelector: {string, default: '.misc-modal .modal-body' }, - * } - */ -export function showModal(options) { - /* eslint no-param-reassign: 0 */ - options.modalSelector = options.modalSelector || '.misc-modal'; - options.titleSelector = options.titleSelector || '.misc-modal .modal-title'; - options.bodySelector = options.bodySelector || '.misc-modal .modal-body'; - $(options.titleSelector).html(options.title || ''); - $(options.bodySelector).html(options.body || ''); - $(options.modalSelector).modal('show'); -} - -export function formatSelectOptionsForRange(start, end) { - // outputs array of arrays - // formatSelectOptionsForRange(1, 5) - // returns [[1,1], [2,2], [3,3], [4,4], [5,5]] - const options = []; - for (let i = start; i <= end; i += 1) { - options.push([i, i.toString()]); - } - return options; -} export function formatSelectOptions(options) { return options.map(opt => [opt, opt.toString()]);