mirror of
https://github.com/apache/superset.git
synced 2026-05-31 21:29:19 +00:00
feat(plugin): add plugin-chart-cartodiagram (#25869)
Co-authored-by: Jakob Miksch <jakob@meggsimum.de>
This commit is contained in:
@@ -31,7 +31,10 @@ interface SelectAsyncControlProps extends SelectAsyncProps {
|
||||
ariaLabel?: string;
|
||||
dataEndpoint: string;
|
||||
default?: SelectValue;
|
||||
mutator?: (response: Record<string, any>) => SelectOptionsType;
|
||||
mutator?: (
|
||||
response: Record<string, any>,
|
||||
value: SelectValue | undefined,
|
||||
) => SelectOptionsType;
|
||||
multi?: boolean;
|
||||
onChange: (val: SelectValue) => void;
|
||||
// ControlHeader related props
|
||||
@@ -57,6 +60,7 @@ const SelectAsyncControl = ({
|
||||
...props
|
||||
}: SelectAsyncControlProps) => {
|
||||
const [options, setOptions] = useState<SelectOptionsType>([]);
|
||||
const [loaded, setLoaded] = useState<Boolean>(false);
|
||||
|
||||
const handleOnChange = (val: SelectValue) => {
|
||||
let onChangeVal = val;
|
||||
@@ -92,12 +96,20 @@ const SelectAsyncControl = ({
|
||||
endpoint: dataEndpoint,
|
||||
})
|
||||
.then(response => {
|
||||
const data = mutator ? mutator(response.json) : response.json.result;
|
||||
const data = mutator
|
||||
? mutator(response.json, value)
|
||||
: response.json.result;
|
||||
setOptions(data);
|
||||
})
|
||||
.catch(onError);
|
||||
loadOptions();
|
||||
}, [addDangerToast, dataEndpoint, mutator]);
|
||||
.catch(onError)
|
||||
.finally(() => {
|
||||
setLoaded(true);
|
||||
});
|
||||
|
||||
if (!loaded) {
|
||||
loadOptions();
|
||||
}
|
||||
}, [addDangerToast, dataEndpoint, mutator, value, loaded]);
|
||||
|
||||
return (
|
||||
<Select
|
||||
|
||||
Reference in New Issue
Block a user