superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: Remove lodash.throttle and replace underscore calls with lodash (#5946)
Date Thu, 27 Sep 2018 06:29:04 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin 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 4c21c65  Remove lodash.throttle and replace underscore calls with lodash (#5946)
4c21c65 is described below

commit 4c21c658244f995e76de027ec35d98ec7b173534
Author: Krist Wongsuphasawat <krist.wongz@gmail.com>
AuthorDate: Wed Sep 26 23:28:57 2018 -0700

    Remove lodash.throttle and replace underscore calls with lodash (#5946)
    
    * remove lodash.throttle from dependency
    
    * add babel-plugin-lodash'
    
    * use lodash instead of underscore for isFunction
    
    * switch underscore to lodash
    
    * switch from underscore to lodash flatten
    
    * Remove slugify and use kebabCase from lodash instead
---
 superset/assets/.babelrc                                      |  2 +-
 superset/assets/package.json                                  |  2 +-
 superset/assets/spec/javascripts/modules/utils_spec.jsx       |  7 -------
 superset/assets/src/SqlLab/components/SqlEditor.jsx           |  2 +-
 superset/assets/src/components/AlteredSliceTag.jsx            |  2 +-
 superset/assets/src/components/Button.jsx                     |  4 ++--
 superset/assets/src/components/InfoTooltipWithTrigger.jsx     |  4 ++--
 superset/assets/src/components/TooltipWrapper.jsx             |  4 ++--
 superset/assets/src/dashboard/components/dnd/handleHover.js   |  2 +-
 .../src/explore/components/controls/ColorSchemeControl.jsx    |  6 +++---
 superset/assets/src/modules/utils.js                          | 11 -----------
 superset/assets/src/reduxUtils.js                             |  2 +-
 superset/assets/src/visualizations/deckgl/layers/polygon.jsx  |  4 ++--
 superset/assets/src/visualizations/nvd3/NVD3Vis.js            |  2 +-
 superset/assets/yarn.lock                                     |  6 +-----
 15 files changed, 19 insertions(+), 41 deletions(-)

diff --git a/superset/assets/.babelrc b/superset/assets/.babelrc
index 0c426be..c2ea3fd 100644
--- a/superset/assets/.babelrc
+++ b/superset/assets/.babelrc
@@ -1,4 +1,4 @@
 {
   "presets" : ["airbnb", "react", "env"],
-  "plugins": ["syntax-dynamic-import", "react-hot-loader/babel"]
+  "plugins": ["lodash", "syntax-dynamic-import", "react-hot-loader/babel"]
 }
diff --git a/superset/assets/package.json b/superset/assets/package.json
index c08ee50..9394c11 100644
--- a/superset/assets/package.json
+++ b/superset/assets/package.json
@@ -80,7 +80,6 @@
     "jquery": "3.1.1",
     "json-bigint": "^0.3.0",
     "lodash": "^4.17.11",
-    "lodash.throttle": "^4.1.1",
     "mapbox-gl": "^0.45.0",
     "mathjs": "^3.20.2",
     "moment": "^2.20.1",
@@ -138,6 +137,7 @@
     "babel-loader": "^7.1.4",
     "babel-plugin-css-modules-transform": "^1.1.0",
     "babel-plugin-dynamic-import-node": "^1.2.0",
+    "babel-plugin-lodash": "^3.3.4",
     "babel-plugin-syntax-dynamic-import": "^6.18.0",
     "babel-polyfill": "^6.23.0",
     "babel-preset-airbnb": "^2.1.1",
diff --git a/superset/assets/spec/javascripts/modules/utils_spec.jsx b/superset/assets/spec/javascripts/modules/utils_spec.jsx
index 10a4fbc..0f86435 100644
--- a/superset/assets/spec/javascripts/modules/utils_spec.jsx
+++ b/superset/assets/spec/javascripts/modules/utils_spec.jsx
@@ -1,6 +1,5 @@
 import { expect, assert } from 'chai';
 import {
-  slugify,
   formatSelectOptionsForRange,
   d3format,
   d3FormatPreset,
@@ -10,12 +9,6 @@ import {
 } from '../../../src/modules/utils';
 
 describe('utils', () => {
-  it('slugify slugifies', () => {
-    expect(slugify('My Neat Label! ')).to.equal('my-neat-label');
-    expect(slugify('Some Letters AnD a 5')).to.equal('some-letters-and-a-5');
-    expect(slugify(' 439278 ')).to.equal('439278');
-    expect(slugify('5')).to.equal('5');
-  });
   it('formatSelectOptionsForRange', () => {
     expect(formatSelectOptionsForRange(0, 4)).to.deep.equal([
       [0, '0'],
diff --git a/superset/assets/src/SqlLab/components/SqlEditor.jsx b/superset/assets/src/SqlLab/components/SqlEditor.jsx
index c595ea6..3dd9d48 100644
--- a/superset/assets/src/SqlLab/components/SqlEditor.jsx
+++ b/superset/assets/src/SqlLab/components/SqlEditor.jsx
@@ -1,6 +1,6 @@
 import React from 'react';
 import PropTypes from 'prop-types';
-import throttle from 'lodash.throttle';
+import { throttle } from 'lodash';
 import {
   Col,
   FormGroup,
diff --git a/superset/assets/src/components/AlteredSliceTag.jsx b/superset/assets/src/components/AlteredSliceTag.jsx
index a317a04..a0c1f1e 100644
--- a/superset/assets/src/components/AlteredSliceTag.jsx
+++ b/superset/assets/src/components/AlteredSliceTag.jsx
@@ -1,7 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
 import { Table, Tr, Td, Thead, Th } from 'reactable';
-import { isEqual, isEmpty } from 'underscore';
+import { isEqual, isEmpty } from 'lodash';
 
 import TooltipWrapper from './TooltipWrapper';
 import { controls } from '../explore/controls';
diff --git a/superset/assets/src/components/Button.jsx b/superset/assets/src/components/Button.jsx
index d895a02..1485f1f 100644
--- a/superset/assets/src/components/Button.jsx
+++ b/superset/assets/src/components/Button.jsx
@@ -1,7 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
+import { kebabCase } from 'lodash';
 import { Button as BootstrapButton, Tooltip, OverlayTrigger } from 'react-bootstrap';
-import { slugify } from '../modules/utils';
 
 const propTypes = {
   tooltip: PropTypes.node,
@@ -41,7 +41,7 @@ export default function Button(props) {
     return (
       <OverlayTrigger
         placement={placement}
-        overlay={<Tooltip id={`${slugify(tooltip)}-tooltip`}>{tooltip}</Tooltip>}
+        overlay={<Tooltip id={`${kebabCase(tooltip)}-tooltip`}>{tooltip}</Tooltip>}
       >
         {button}
       </OverlayTrigger>
diff --git a/superset/assets/src/components/InfoTooltipWithTrigger.jsx b/superset/assets/src/components/InfoTooltipWithTrigger.jsx
index caacb91..cb0b489 100644
--- a/superset/assets/src/components/InfoTooltipWithTrigger.jsx
+++ b/superset/assets/src/components/InfoTooltipWithTrigger.jsx
@@ -1,7 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
+import { kebabCase } from 'lodash';
 import { Tooltip, OverlayTrigger } from 'react-bootstrap';
-import { slugify } from '../modules/utils';
 
 const propTypes = {
   label: PropTypes.string.isRequired,
@@ -36,7 +36,7 @@ export default function InfoTooltipWithTrigger({
     <OverlayTrigger
       placement={placement}
       overlay={
-        <Tooltip id={`${slugify(label)}-tooltip`} style={tooltipStyle}>
+        <Tooltip id={`${kebabCase(label)}-tooltip`} style={tooltipStyle}>
           {tooltip}
         </Tooltip>
       }
diff --git a/superset/assets/src/components/TooltipWrapper.jsx b/superset/assets/src/components/TooltipWrapper.jsx
index b189041..761ef41 100644
--- a/superset/assets/src/components/TooltipWrapper.jsx
+++ b/superset/assets/src/components/TooltipWrapper.jsx
@@ -1,7 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
+import { kebabCase } from 'lodash';
 import { Tooltip, OverlayTrigger } from 'react-bootstrap';
-import { slugify } from '../modules/utils';
 
 const propTypes = {
   label: PropTypes.string.isRequired,
@@ -18,7 +18,7 @@ export default function TooltipWrapper({ label, tooltip, children, placement
})
   return (
     <OverlayTrigger
       placement={placement}
-      overlay={<Tooltip id={`${slugify(label)}-tooltip`}>{tooltip}</Tooltip>}
+      overlay={<Tooltip id={`${kebabCase(label)}-tooltip`}>{tooltip}</Tooltip>}
     >
       {children}
     </OverlayTrigger>
diff --git a/superset/assets/src/dashboard/components/dnd/handleHover.js b/superset/assets/src/dashboard/components/dnd/handleHover.js
index a3b16aa..7c449c9 100644
--- a/superset/assets/src/dashboard/components/dnd/handleHover.js
+++ b/superset/assets/src/dashboard/components/dnd/handleHover.js
@@ -1,4 +1,4 @@
-import throttle from 'lodash.throttle';
+import { throttle } from 'lodash';
 import getDropPosition from '../../util/getDropPosition';
 
 const HOVER_THROTTLE_MS = 100;
diff --git a/superset/assets/src/explore/components/controls/ColorSchemeControl.jsx b/superset/assets/src/explore/components/controls/ColorSchemeControl.jsx
index 9463150..f09125d 100644
--- a/superset/assets/src/explore/components/controls/ColorSchemeControl.jsx
+++ b/superset/assets/src/explore/components/controls/ColorSchemeControl.jsx
@@ -1,6 +1,6 @@
 import React from 'react';
 import PropTypes from 'prop-types';
-import _ from 'underscore';
+import { isFunction } from 'lodash';
 import { Creatable } from 'react-select';
 import ControlHeader from '../ControlHeader';
 import { colorScalerFactory } from '../../../modules/colors';
@@ -48,7 +48,7 @@ export default class ColorSchemeControl extends React.PureComponent {
 
   renderOption(key) {
     const { schemes } = this.props;
-    const schemeLookup = _.isFunction(schemes) ? schemes() : schemes;
+    const schemeLookup = isFunction(schemes) ? schemes() : schemes;
     const currentScheme = schemeLookup[key.value || defaultProps.value];
 
     let colors = currentScheme;
@@ -68,7 +68,7 @@ export default class ColorSchemeControl extends React.PureComponent {
 
   render() {
     const { choices } = this.props;
-    const options = (_.isFunction(choices) ? choices() : choices)
+    const options = (isFunction(choices) ? choices() : choices)
       .map(choice => ({ value: choice[0], label: choice[1] }));
 
     const selectProps = {
diff --git a/superset/assets/src/modules/utils.js b/superset/assets/src/modules/utils.js
index 0694cdc..491fcf5 100644
--- a/superset/assets/src/modules/utils.js
+++ b/superset/assets/src/modules/utils.js
@@ -1,7 +1,6 @@
 /* eslint camelcase: 0 */
 import d3 from 'd3';
 import $ from 'jquery';
-
 import { formatDate, UTC } from './dates';
 
 const siFormatter = d3.format('.3s');
@@ -186,16 +185,6 @@ export function formatSelectOptions(options) {
   );
 }
 
-export function slugify(string) {
-  // slugify('My Neat Label! '); returns 'my-neat-label'
-  return string
-          .toString()
-          .toLowerCase()
-          .trim()
-          .replace(/[\s\W-]+/g, '-') // replace spaces, non-word chars, w/ a single dash
(-)
-          .replace(/-$/, ''); // remove last floating dash
-}
-
 export function getAjaxErrorMsg(error) {
   const respJSON = error.responseJSON;
   return (respJSON && respJSON.error) ? respJSON.error :
diff --git a/superset/assets/src/reduxUtils.js b/superset/assets/src/reduxUtils.js
index 5bd2565..cc0b581 100644
--- a/superset/assets/src/reduxUtils.js
+++ b/superset/assets/src/reduxUtils.js
@@ -1,7 +1,7 @@
 import shortid from 'shortid';
 import { compose } from 'redux';
 import persistState from 'redux-localstorage';
-import { isEqual } from 'underscore';
+import { isEqual } from 'lodash';
 
 export function addToObject(state, arrKey, obj) {
   const newObject = Object.assign({}, state[arrKey]);
diff --git a/superset/assets/src/visualizations/deckgl/layers/polygon.jsx b/superset/assets/src/visualizations/deckgl/layers/polygon.jsx
index c0ac6d0..e84b943 100644
--- a/superset/assets/src/visualizations/deckgl/layers/polygon.jsx
+++ b/superset/assets/src/visualizations/deckgl/layers/polygon.jsx
@@ -2,7 +2,7 @@ import React from 'react';
 import ReactDOM from 'react-dom';
 
 import { PolygonLayer } from 'deck.gl';
-import _ from 'underscore';
+import { flatten } from 'lodash';
 import d3 from 'd3';
 
 import DeckGLContainer from './../DeckGLContainer';
@@ -12,7 +12,7 @@ import { colorScalerFactory } from '../../../modules/colors';
 import sandboxedEval from '../../../modules/sandbox';
 
 function getPoints(features) {
-  return _.flatten(features.map(d => d.polygon), true);
+  return flatten(features.map(d => d.polygon), true);
 }
 
 function getLayer(formData, payload, slice) {
diff --git a/superset/assets/src/visualizations/nvd3/NVD3Vis.js b/superset/assets/src/visualizations/nvd3/NVD3Vis.js
index 73cb7b7..4e47b8e 100644
--- a/superset/assets/src/visualizations/nvd3/NVD3Vis.js
+++ b/superset/assets/src/visualizations/nvd3/NVD3Vis.js
@@ -1,4 +1,4 @@
-import throttle from 'lodash.throttle';
+import { throttle } from 'lodash';
 import d3 from 'd3';
 import nv from 'nvd3';
 import mathjs from 'mathjs';
diff --git a/superset/assets/yarn.lock b/superset/assets/yarn.lock
index e6825d8..1604338 100644
--- a/superset/assets/yarn.lock
+++ b/superset/assets/yarn.lock
@@ -1671,7 +1671,7 @@ babel-plugin-dynamic-import-node@^1.2.0:
   dependencies:
     babel-plugin-syntax-dynamic-import "^6.18.0"
 
-babel-plugin-lodash@^3.3.2:
+babel-plugin-lodash@^3.3.2, babel-plugin-lodash@^3.3.4:
   version "3.3.4"
   resolved "https://registry.yarnpkg.com/babel-plugin-lodash/-/babel-plugin-lodash-3.3.4.tgz#4f6844358a1340baed182adbeffa8df9967bc196"
   dependencies:
@@ -7467,10 +7467,6 @@ lodash.once@^4.1.1:
   version "4.1.1"
   resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac"
 
-lodash.throttle@^4.1.1:
-  version "4.1.1"
-  resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
-
 lodash.union@~4.6.0:
   version "4.6.0"
   resolved "https://registry.yarnpkg.com/lodash.union/-/lodash.union-4.6.0.tgz#48bb5088409f16f1821666641c44dd1aaae3cd88"


Mime
View raw message