mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
feat: disable save button when saving datasource (#11493)
This commit is contained in:
parent
074f8c2e8c
commit
93693690a3
@ -82,6 +82,7 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
|
||||
}) => {
|
||||
const [currentDatasource, setCurrentDatasource] = useState(datasource);
|
||||
const [errors, setErrors] = useState<any[]>([]);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const dialog = useRef<any>(null);
|
||||
|
||||
const onConfirmSave = () => {
|
||||
@ -90,6 +91,9 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
|
||||
currentDatasource.schema ||
|
||||
currentDatasource.databaseSelector?.schema ||
|
||||
currentDatasource.tableSelector?.schema;
|
||||
|
||||
setIsSaving(true);
|
||||
|
||||
SupersetClient.post({
|
||||
endpoint: '/datasource/save/',
|
||||
postPayload: {
|
||||
@ -111,7 +115,8 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
|
||||
onDatasourceSave(json);
|
||||
onHide();
|
||||
})
|
||||
.catch(response =>
|
||||
.catch(response => {
|
||||
setIsSaving(false);
|
||||
getClientErrorObject(response).then(({ error }) => {
|
||||
dialog.current.show({
|
||||
title: 'Error',
|
||||
@ -120,8 +125,8 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
|
||||
actions: [Dialog.DefaultAction('Ok', () => {}, 'btn-danger')],
|
||||
body: error || t('An error has occurred'),
|
||||
});
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const onDatasourceChange = (data: Record<string, any>, err: Array<any>) => {
|
||||
@ -196,7 +201,7 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
|
||||
className="m-r-5"
|
||||
data-test="datasource-modal-save"
|
||||
onClick={onClickSave}
|
||||
disabled={errors.length > 0}
|
||||
disabled={isSaving || errors.length > 0}
|
||||
>
|
||||
{t('Save')}
|
||||
</Button>
|
||||
|
Loading…
Reference in New Issue
Block a user