You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2021/10/11 13:17:05 UTC

[superset] branch master updated: fix: Exclude SUPERSET_DEFAULT from the list of available color schemes (#17018)

This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 14b7f6c  fix: Exclude SUPERSET_DEFAULT from the list of available color schemes (#17018)
14b7f6c is described below

commit 14b7f6cdbaad3a97aa24d234768a47752b700a11
Author: Geido <60...@users.noreply.github.com>
AuthorDate: Mon Oct 11 16:16:06 2021 +0300

    fix: Exclude SUPERSET_DEFAULT from the list of available color schemes (#17018)
    
    * Handle SUPERSET_DEFAULT theme
    
    * Update superset-frontend/src/explore/components/controls/ColorSchemeControl.jsx
    
    Co-authored-by: Michael S. Molina <70...@users.noreply.github.com>
    
    * Update superset-frontend/src/explore/components/controls/ColorSchemeControl.jsx
    
    Co-authored-by: Michael S. Molina <70...@users.noreply.github.com>
    
    Co-authored-by: Michael S. Molina <70...@users.noreply.github.com>
---
 .../components/controls/ColorSchemeControl.jsx     | 26 ++++++++++++++--------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/superset-frontend/src/explore/components/controls/ColorSchemeControl.jsx b/superset-frontend/src/explore/components/controls/ColorSchemeControl.jsx
index da363aa..20be45d 100644
--- a/superset-frontend/src/explore/components/controls/ColorSchemeControl.jsx
+++ b/superset-frontend/src/explore/components/controls/ColorSchemeControl.jsx
@@ -110,23 +110,31 @@ export default class ColorSchemeControl extends React.PureComponent {
     // save parsed schemes for later
     this.schemes = isFunction(schemes) ? schemes() : schemes;
 
-    const options = (isFunction(choices) ? choices() : choices).map(
-      ([value]) => ({
-        value,
-        label: this.schemes?.[value]?.label || value,
-        customLabel: this.renderOption(value),
-      }),
+    const allColorOptions = (isFunction(choices) ? choices() : choices).filter(
+      o => o[0] !== 'SUPERSET_DEFAULT',
     );
+    const options = allColorOptions.map(([value]) => ({
+      value,
+      label: this.schemes?.[value]?.label || value,
+      customLabel: this.renderOption(value),
+    }));
+
+    let currentScheme =
+      this.props.value ||
+      (this.props.default !== undefined ? this.props.default : undefined);
+
+    if (currentScheme === 'SUPERSET_DEFAULT') {
+      currentScheme = this.schemes?.SUPERSET_DEFAULT?.id;
+    }
+
     const selectProps = {
       ariaLabel: t('Select color scheme'),
       allowClear: this.props.clearable,
-      defaultValue: this.props.default,
       name: `select-${this.props.name}`,
       onChange: this.onChange,
       options,
       placeholder: `Select (${options.length})`,
-      showSearch: true,
-      value: this.props.value,
+      value: currentScheme,
     };
     return (
       <Select header={<ControlHeader {...this.props} />} {...selectProps} />