You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/10/11 21:05:36 UTC

[GitHub] graceguo-supercat closed pull request #6074: Rename color constants and move util function into separate file

graceguo-supercat closed pull request #6074: Rename color constants and move util function into separate file
URL: https://github.com/apache/incubator-superset/pull/6074
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 0000000000..545c585bae
--- /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 15b04602df..67f21ac667 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 413239c8c8..8e86d46eb5 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 c1f2a692d0..6ff06d76b3 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 0000000000..807bbb76ae
--- /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 2ea19c2d07..34b77e5113 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),
 };
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org