This is an automated email from the ASF dual-hosted git repository.
graceguo 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 64383ce Rename color constants and move util function into separate
file (#6074)
64383ce is described below
commit 64383ce96ec200106f6abed1f66af6bf75273dad
Author: Krist Wongsuphasawat <[email protected]>
AuthorDate: Thu Oct 11 14:05:34 2018 -0700
Rename color constants and move util function into separate file (#6074)
* rename constant colors to UPPERCASE
* Move isDefined into its own file and add unit test
---
.../spec/javascripts/utils/isDefined_spec.js | 22 ++++++++++++++++++++++
superset/assets/src/explore/controls.jsx | 12 ++++++------
superset/assets/src/modules/colors.js | 4 ++--
superset/assets/src/modules/visUtils.js | 6 ++----
superset/assets/src/utils/isDefined.js | 3 +++
.../src/visualizations/BigNumber/BigNumber.jsx | 4 ++--
6 files changed, 37 insertions(+), 14 deletions(-)
diff --git a/superset/assets/spec/javascripts/utils/isDefined_spec.js
b/superset/assets/spec/javascripts/utils/isDefined_spec.js
new file mode 100644
index 0000000..545c585
--- /dev/null
+++ b/superset/assets/spec/javascripts/utils/isDefined_spec.js
@@ -0,0 +1,22 @@
+import { it, describe } from 'mocha';
+import { expect } from 'chai';
+import isDefined from '../../../src/utils/isDefined';
+
+describe('isDefined(value)', () => {
+ it('returns true if value is not null and not undefined', () => {
+ expect(isDefined(0)).to.equal(true);
+ expect(isDefined(1)).to.equal(true);
+ expect(isDefined('')).to.equal(true);
+ expect(isDefined('a')).to.equal(true);
+ expect(isDefined([])).to.equal(true);
+ expect(isDefined([0])).to.equal(true);
+ expect(isDefined([1])).to.equal(true);
+ expect(isDefined({})).to.equal(true);
+ expect(isDefined({ a: 1 })).to.equal(true);
+ expect(isDefined([{}])).to.equal(true);
+ });
+ it('returns false otherwise', () => {
+ expect(isDefined(null)).to.equal(false);
+ expect(isDefined(undefined)).to.equal(false);
+ });
+});
diff --git a/superset/assets/src/explore/controls.jsx
b/superset/assets/src/explore/controls.jsx
index 15b0460..67f21ac 100644
--- a/superset/assets/src/explore/controls.jsx
+++ b/superset/assets/src/explore/controls.jsx
@@ -45,7 +45,7 @@ import {
mainMetric,
} from '../modules/utils';
import * as v from './validators';
-import { colorPrimary } from '../modules/colors';
+import { PRIMARY_COLOR } from '../modules/colors';
import { defaultViewport } from '../modules/geo';
import ColumnOption from '../components/ColumnOption';
import OptionDescription from '../components/OptionDescription';
@@ -240,7 +240,7 @@ export const controls = {
label: t('Fixed Color'),
description: t('Use this to define a static color for all circles'),
type: 'ColorPickerControl',
- default: colorPrimary,
+ default: PRIMARY_COLOR,
renderTrigger: true,
},
@@ -248,7 +248,7 @@ export const controls = {
label: t('Target Color'),
description: t('Color of the target location'),
type: 'ColorPickerControl',
- default: colorPrimary,
+ default: PRIMARY_COLOR,
renderTrigger: true,
},
@@ -272,7 +272,7 @@ export const controls = {
label: t('Fill Color'),
description: t(' Set the opacity to 0 if you do not want to override the
color specified in the GeoJSON'),
type: 'ColorPickerControl',
- default: colorPrimary,
+ default: PRIMARY_COLOR,
renderTrigger: true,
},
@@ -280,7 +280,7 @@ export const controls = {
label: t('Stroke Color'),
description: t(' Set the opacity to 0 if you do not want to override the
color specified in the GeoJSON'),
type: 'ColorPickerControl',
- default: colorPrimary,
+ default: PRIMARY_COLOR,
renderTrigger: true,
},
@@ -1853,7 +1853,7 @@ export const controls = {
color: {
type: 'ColorPickerControl',
label: t('Color'),
- default: colorPrimary,
+ default: PRIMARY_COLOR,
description: t('Pick a color'),
},
diff --git a/superset/assets/src/modules/colors.js
b/superset/assets/src/modules/colors.js
index 413239c..8e86d46 100644
--- a/superset/assets/src/modules/colors.js
+++ b/superset/assets/src/modules/colors.js
@@ -1,8 +1,8 @@
import d3 from 'd3';
import sequentialSchemes from './colorSchemes/sequential';
-export const brandColor = '#00A699';
-export const colorPrimary = { r: 0, g: 122, b: 135, a: 1 };
+export const BRAND_COLOR = '#00A699';
+export const PRIMARY_COLOR = { r: 0, g: 122, b: 135, a: 1 };
export function hexToRGB(hex, alpha = 255) {
if (!hex) {
diff --git a/superset/assets/src/modules/visUtils.js
b/superset/assets/src/modules/visUtils.js
index c1f2a69..6ff06d7 100644
--- a/superset/assets/src/modules/visUtils.js
+++ b/superset/assets/src/modules/visUtils.js
@@ -1,8 +1,6 @@
-const SVG_NS = 'http://www.w3.org/2000/svg';
+import isDefined from '../utils/isDefined';
-function isDefined(x) {
- return x !== null && x !== undefined;
-}
+const SVG_NS = 'http://www.w3.org/2000/svg';
export function getTextDimension({
text,
diff --git a/superset/assets/src/utils/isDefined.js
b/superset/assets/src/utils/isDefined.js
new file mode 100644
index 0000000..807bbb7
--- /dev/null
+++ b/superset/assets/src/utils/isDefined.js
@@ -0,0 +1,3 @@
+export default function isDefined(x) {
+ return x !== null && x !== undefined;
+}
diff --git a/superset/assets/src/visualizations/BigNumber/BigNumber.jsx
b/superset/assets/src/visualizations/BigNumber/BigNumber.jsx
index 2ea19c2..34b77e5 100644
--- a/superset/assets/src/visualizations/BigNumber/BigNumber.jsx
+++ b/superset/assets/src/visualizations/BigNumber/BigNumber.jsx
@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import shortid from 'shortid';
import { XYChart, AreaSeries, CrossHair, LinearGradient } from
'@data-ui/xy-chart';
-import { brandColor } from '../../modules/colors';
+import { BRAND_COLOR } from '../../modules/colors';
import { formatDateVerbose } from '../../modules/dates';
import { computeMaxFontSize } from '../../modules/visUtils';
@@ -63,7 +63,7 @@ const defaultProps = {
showTrendLine: false,
startYAxisAtZero: true,
trendLineData: null,
- mainColor: brandColor,
+ mainColor: BRAND_COLOR,
renderTooltip: renderTooltipFactory(identity),
};