chore: cleaning out unused code from utils (#11076)
* removing unused stuff (and some jquery) from utils.js * linting
This commit is contained in:
parent
7f1e4e441d
commit
cff034e2cf
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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: [
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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()]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue