Skip to content

Commit

Permalink
fix(explore): Value undefined and Unhashable type errors (#22207)
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje authored Nov 23, 2022
1 parent 888f43c commit 1809d2b
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions superset-frontend/src/explore/components/ControlPanelsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
SupersetTheme,
useTheme,
isDefined,
JsonValue,
} from '@superset-ui/core';
import {
ControlPanelSectionConfig,
Expand Down Expand Up @@ -276,21 +277,36 @@ export const ControlPanelsContainer = (props: ControlPanelsContainerProps) => {
>(state => state.explore.controlsTransferred);

useEffect(() => {
const removeDatasourceWarningFromControl = (
value: JsonValue | undefined,
) => {
if (
typeof value === 'object' &&
isDefined(value) &&
'datasourceWarning' in value
) {
return { ...value, datasourceWarning: false };
}
return value;
};
if (props.chart.chartStatus === 'success') {
controlsTransferred?.forEach(controlName => {
const alteredControls = ensureIsArray(
props.controls[controlName].value,
).map(value => {
if (
typeof value === 'object' &&
isDefined(value) &&
'datasourceWarning' in value
) {
return { ...value, datasourceWarning: false };
}
return value;
});
props.actions.setControlValue(controlName, alteredControls);
if (!isDefined(props.controls[controlName])) {
return;
}
if (Array.isArray(props.controls[controlName].value)) {
const alteredControls = ensureIsArray(
props.controls[controlName].value,
)?.map(removeDatasourceWarningFromControl);
props.actions.setControlValue(controlName, alteredControls);
} else {
props.actions.setControlValue(
controlName,
removeDatasourceWarningFromControl(
props.controls[controlName].value,
),
);
}
});
}
}, [
Expand Down

0 comments on commit 1809d2b

Please sign in to comment.