mirror of
https://github.com/apache/superset.git
synced 2024-09-06 22:07:34 -04:00
fix: add primary button loading state to modals (#20018)
This commit is contained in:
parent
1e46902602
commit
63702c48ab
@ -34,6 +34,7 @@ export interface ModalProps {
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
disablePrimaryButton?: boolean;
|
||||
primaryButtonLoading?: boolean;
|
||||
onHide: () => void;
|
||||
onHandledPrimaryAction?: () => void;
|
||||
primaryButtonName?: string;
|
||||
@ -190,6 +191,7 @@ export const StyledModal = styled(BaseModal)<StyledModalProps>`
|
||||
const CustomModal = ({
|
||||
children,
|
||||
disablePrimaryButton = false,
|
||||
primaryButtonLoading = false,
|
||||
onHide,
|
||||
onHandledPrimaryAction,
|
||||
primaryButtonName = t('OK'),
|
||||
@ -240,6 +242,7 @@ const CustomModal = ({
|
||||
key="submit"
|
||||
buttonStyle={primaryButtonType}
|
||||
disabled={disablePrimaryButton}
|
||||
loading={primaryButtonLoading}
|
||||
onClick={onHandledPrimaryAction}
|
||||
cta
|
||||
data-test="modal-confirm-button"
|
||||
|
@ -56,7 +56,10 @@ const DatasetModal: FunctionComponent<DatasetModalProps> = ({
|
||||
const [currentSchema, setSchema] = useState<string | undefined>('');
|
||||
const [currentTableName, setTableName] = useState('');
|
||||
const [disableSave, setDisableSave] = useState(true);
|
||||
const { createResource } = useSingleViewResource<Partial<DatasetAddObject>>(
|
||||
const {
|
||||
createResource,
|
||||
state: { loading },
|
||||
} = useSingleViewResource<Partial<DatasetAddObject>>(
|
||||
'dataset',
|
||||
t('dataset'),
|
||||
addDangerToast,
|
||||
@ -114,6 +117,7 @@ const DatasetModal: FunctionComponent<DatasetModalProps> = ({
|
||||
return (
|
||||
<Modal
|
||||
disablePrimaryButton={disableSave}
|
||||
primaryButtonLoading={loading}
|
||||
onHandledPrimaryAction={onSave}
|
||||
onHide={hide}
|
||||
primaryButtonName={t('Add')}
|
||||
|
Loading…
Reference in New Issue
Block a user