chore: Extract common select component code (#21094)

This commit is contained in:
cccs-RyanK
2022-09-15 08:57:37 -04:00
committed by GitHub
parent 2c7323a87d
commit 4fcc1d952f
9 changed files with 621 additions and 681 deletions

View File

@@ -20,7 +20,8 @@ import React, { useEffect, useState } from 'react';
import { t, SupersetClient } from '@superset-ui/core';
import ControlHeader from 'src/explore/components/ControlHeader';
import { Select } from 'src/components';
import { SelectProps, OptionsType } from 'src/components/Select/Select';
import { SelectProps } from 'src/components/Select/Select';
import { SelectOptionsType } from 'src/components/Select/utils';
import { SelectValue, LabeledValue } from 'antd/lib/select';
import withToasts from 'src/components/MessageToasts/withToasts';
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
@@ -32,7 +33,7 @@ interface SelectAsyncControlProps extends SelectAsyncProps {
ariaLabel?: string;
dataEndpoint: string;
default?: SelectValue;
mutator?: (response: Record<string, any>) => OptionsType;
mutator?: (response: Record<string, any>) => SelectOptionsType;
multi?: boolean;
onChange: (val: SelectValue) => void;
// ControlHeader related props
@@ -57,7 +58,7 @@ const SelectAsyncControl = ({
value,
...props
}: SelectAsyncControlProps) => {
const [options, setOptions] = useState<OptionsType>([]);
const [options, setOptions] = useState<SelectOptionsType>([]);
const handleOnChange = (val: SelectValue) => {
let onChangeVal = val;