fix(explore): Value undefined and Unhashable type errors (#22207)

This commit is contained in:
Kamil Gabryjelski 2022-11-23 20:45:10 +01:00 committed by GitHub
parent 888f43c6ad
commit 1809d2b957
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,6 +37,7 @@ import {
SupersetTheme, SupersetTheme,
useTheme, useTheme,
isDefined, isDefined,
JsonValue,
} from '@superset-ui/core'; } from '@superset-ui/core';
import { import {
ControlPanelSectionConfig, ControlPanelSectionConfig,
@ -276,11 +277,9 @@ export const ControlPanelsContainer = (props: ControlPanelsContainerProps) => {
>(state => state.explore.controlsTransferred); >(state => state.explore.controlsTransferred);
useEffect(() => { useEffect(() => {
if (props.chart.chartStatus === 'success') { const removeDatasourceWarningFromControl = (
controlsTransferred?.forEach(controlName => { value: JsonValue | undefined,
const alteredControls = ensureIsArray( ) => {
props.controls[controlName].value,
).map(value => {
if ( if (
typeof value === 'object' && typeof value === 'object' &&
isDefined(value) && isDefined(value) &&
@ -289,8 +288,25 @@ export const ControlPanelsContainer = (props: ControlPanelsContainerProps) => {
return { ...value, datasourceWarning: false }; return { ...value, datasourceWarning: false };
} }
return value; return value;
}); };
if (props.chart.chartStatus === 'success') {
controlsTransferred?.forEach(controlName => {
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); props.actions.setControlValue(controlName, alteredControls);
} else {
props.actions.setControlValue(
controlName,
removeDatasourceWarningFromControl(
props.controls[controlName].value,
),
);
}
}); });
} }
}, [ }, [