Skip to content

Commit

Permalink
fix: Exclude SUPERSET_DEFAULT from the list of available color schemes (
Browse files Browse the repository at this point in the history
#17018)

* Handle SUPERSET_DEFAULT theme

* Update superset-frontend/src/explore/components/controls/ColorSchemeControl.jsx

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>

* Update superset-frontend/src/explore/components/controls/ColorSchemeControl.jsx

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
  • Loading branch information
geido and michael-s-molina committed Oct 11, 2021
1 parent 16a1df7 commit 14b7f6c
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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} />
Expand Down

0 comments on commit 14b7f6c

Please sign in to comment.