You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2020/09/28 03:08:29 UTC

[incubator-superset] branch master updated: chore: cleaning out unused code from utils (#11076)

This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new cff034e  chore: cleaning out unused code from utils (#11076)
cff034e is described below

commit cff034e2cf29d0f5b2c5177fd5b8fb2b1e261d20
Author: Evan Rusackas <ev...@preset.io>
AuthorDate: Sun Sep 27 20:08:05 2020 -0700

    chore: cleaning out unused code from utils (#11076)
    
    * removing unused stuff (and some jquery) from utils.js
    
    * linting
---
 .../spec/javascripts/modules/utils_spec.jsx        | 18 +----------
 .../src/dashboard/actions/sliceEntities.js         |  6 ++--
 .../src/dashboard/reducers/getInitialState.js      | 10 +++----
 .../src/explore/controlPanels/DeckArc.js           |  6 ++--
 .../src/explore/controlPanels/DeckGeojson.js       |  4 +--
 .../src/explore/controlPanels/DeckHex.js           |  2 +-
 .../src/explore/controlPanels/DeckPolygon.js       |  2 +-
 .../src/explore/controlPanels/Separator.js         |  2 +-
 .../src/explore/controlPanels/sections.jsx         |  2 +-
 superset-frontend/src/explore/controls.jsx         |  2 +-
 superset-frontend/src/modules/utils.js             | 35 ----------------------
 11 files changed, 19 insertions(+), 70 deletions(-)

diff --git a/superset-frontend/spec/javascripts/modules/utils_spec.jsx b/superset-frontend/spec/javascripts/modules/utils_spec.jsx
index 3da8848..0c8515f 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 bf5cd5b..7c9f044 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 108d14a..d9ddc59 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 4aaad94..c7e8863 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 9e75c3f..f676526 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 6d7adc9..b6794c7 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 b2d91c5..dd39e74 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 19ab99b..aaca4a6 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 f9cae32..5e225bc 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 1c77938..145c326 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 a4e5100..6520936 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()]);