From 48f683b7afae68849b62e6646dbfbb74bb17dd00 Mon Sep 17 00:00:00 2001 From: Krist Wongsuphasawat Date: Thu, 20 Sep 2018 17:23:00 -0700 Subject: [PATCH] Remove slugify and use kebabCase from lodash instead --- .../assets/spec/javascripts/modules/utils_spec.jsx | 7 ------- superset/assets/src/components/Button.jsx | 4 ++-- .../assets/src/components/InfoTooltipWithTrigger.jsx | 4 ++-- superset/assets/src/components/TooltipWrapper.jsx | 4 ++-- superset/assets/src/modules/utils.js | 11 ----------- 5 files changed, 6 insertions(+), 24 deletions(-) diff --git a/superset/assets/spec/javascripts/modules/utils_spec.jsx b/superset/assets/spec/javascripts/modules/utils_spec.jsx index 10a4fbc0c11ef..0f864352e3b47 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/components/Button.jsx b/superset/assets/src/components/Button.jsx index d895a02d20ec3..1485f1f560d8d 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 ( {tooltip}} + overlay={{tooltip}} > {button} diff --git a/superset/assets/src/components/InfoTooltipWithTrigger.jsx b/superset/assets/src/components/InfoTooltipWithTrigger.jsx index caacb914a50de..cb0b4890a47e6 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({ + {tooltip} } diff --git a/superset/assets/src/components/TooltipWrapper.jsx b/superset/assets/src/components/TooltipWrapper.jsx index b189041603de8..761ef41eda3fb 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 ( {tooltip}} + overlay={{tooltip}} > {children} diff --git a/superset/assets/src/modules/utils.js b/superset/assets/src/modules/utils.js index 0694cdcd0ae18..491fcf5318896 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 :