From commits-return-1644-archive-asf-public=cust-asf.ponee.io@superset.incubator.apache.org Thu Oct 11 23:05:41 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id CE21118064A for ; Thu, 11 Oct 2018 23:05:40 +0200 (CEST) Received: (qmail 86100 invoked by uid 500); 11 Oct 2018 21:05:39 -0000 Mailing-List: contact commits-help@superset.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@superset.incubator.apache.org Delivered-To: mailing list commits@superset.incubator.apache.org Received: (qmail 86091 invoked by uid 99); 11 Oct 2018 21:05:39 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Oct 2018 21:05:39 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 4C00D85B00; Thu, 11 Oct 2018 21:05:39 +0000 (UTC) Date: Thu, 11 Oct 2018 21:05:39 +0000 To: "commits@superset.apache.org" Subject: [incubator-superset] branch master updated: Rename color constants and move util function into separate file (#6074) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <153929193904.26246.2857400621810512898@gitbox.apache.org> From: graceguo@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-superset X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: c0f685b640932bb051188e38654d1e15452b7e37 X-Git-Newrev: 64383ce96ec200106f6abed1f66af6bf75273dad X-Git-Rev: 64383ce96ec200106f6abed1f66af6bf75273dad X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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 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), };