Skip to content

Commit

Permalink
fix: add primary button loading state to modals (#20018)
Browse files Browse the repository at this point in the history
  • Loading branch information
kgopal492 committed May 18, 2022
1 parent 1e46902 commit 63702c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions superset-frontend/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface ModalProps {
className?: string;
children: React.ReactNode;
disablePrimaryButton?: boolean;
primaryButtonLoading?: boolean;
onHide: () => void;
onHandledPrimaryAction?: () => void;
primaryButtonName?: string;
Expand Down Expand Up @@ -190,6 +191,7 @@ export const StyledModal = styled(BaseModal)<StyledModalProps>`
const CustomModal = ({
children,
disablePrimaryButton = false,
primaryButtonLoading = false,
onHide,
onHandledPrimaryAction,
primaryButtonName = t('OK'),
Expand Down Expand Up @@ -240,6 +242,7 @@ const CustomModal = ({
key="submit"
buttonStyle={primaryButtonType}
disabled={disablePrimaryButton}
loading={primaryButtonLoading}
onClick={onHandledPrimaryAction}
cta
data-test="modal-confirm-button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -114,6 +117,7 @@ const DatasetModal: FunctionComponent<DatasetModalProps> = ({
return (
<Modal
disablePrimaryButton={disableSave}
primaryButtonLoading={loading}
onHandledPrimaryAction={onSave}
onHide={hide}
primaryButtonName={t('Add')}
Expand Down

0 comments on commit 63702c4

Please sign in to comment.