fix: Fix the prompts in batch deletion
When batch deletion error, the error message will pop up according to the queue Change-Id: I3b3cf4b2a76aad13ebe79fc1a02d036ed163b9c4
This commit is contained in:
parent
caf0429302
commit
e504f7e3c6
@ -30,10 +30,6 @@ function getDefaultMsg(action, data) {
|
|||||||
action: actionName.toLowerCase() || title,
|
action: actionName.toLowerCase() || title,
|
||||||
name,
|
name,
|
||||||
});
|
});
|
||||||
const submitErrorMsgBatch = t('Unable to batch {action} {name}.', {
|
|
||||||
action: actionName.toLowerCase() || title,
|
|
||||||
name,
|
|
||||||
});
|
|
||||||
const performErrorMsg = t('You are not allowed to { action } {name}.', {
|
const performErrorMsg = t('You are not allowed to { action } {name}.', {
|
||||||
action: actionName.toLowerCase() || title,
|
action: actionName.toLowerCase() || title,
|
||||||
name,
|
name,
|
||||||
@ -50,7 +46,6 @@ function getDefaultMsg(action, data) {
|
|||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
submitErrorMsg,
|
submitErrorMsg,
|
||||||
submitErrorMsgBatch,
|
|
||||||
submitSuccessMsg,
|
submitSuccessMsg,
|
||||||
confirmContext,
|
confirmContext,
|
||||||
performErrorMsg,
|
performErrorMsg,
|
||||||
@ -236,18 +231,6 @@ class ActionButton extends Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
onShowErrorBatch = (data, error) => {
|
|
||||||
// this.handleModalVisible();
|
|
||||||
const { submitErrorMsgBatch } = this.props.action;
|
|
||||||
const message = submitErrorMsgBatch
|
|
||||||
? submitErrorMsgBatch(data)
|
|
||||||
: getDefaultMsg(this.props.action, data).submitErrorMsgBatch;
|
|
||||||
const { data: responseData } = error.response || error || {};
|
|
||||||
Notify.errorWithDetail(responseData || error, message);
|
|
||||||
this.onCallback(false, true);
|
|
||||||
};
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
onShowError = (data, error) => {
|
onShowError = (data, error) => {
|
||||||
// this.handleModalVisible();
|
// this.handleModalVisible();
|
||||||
@ -340,23 +323,31 @@ class ActionButton extends Component {
|
|||||||
const promises = data.map((it, index) =>
|
const promises = data.map((it, index) =>
|
||||||
onSubmit(it, containerProps, isBatch, index, data)
|
onSubmit(it, containerProps, isBatch, index, data)
|
||||||
);
|
);
|
||||||
const results = Promise.all(promises);
|
const results = Promise.allSettled(promises);
|
||||||
// TODO: add catch to do with part error
|
results.then((res) => {
|
||||||
results.then(
|
const failedDatas = res
|
||||||
() => {
|
.map((it, idx) => {
|
||||||
|
if (it.status === 'rejected') {
|
||||||
|
return {
|
||||||
|
data: data[idx],
|
||||||
|
reason: it.reason,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
})
|
||||||
|
.filter((it) => !!it);
|
||||||
|
if (failedDatas.length === 0) {
|
||||||
this.onShowSuccess(data);
|
this.onShowSuccess(data);
|
||||||
resolve();
|
return resolve();
|
||||||
},
|
|
||||||
(error) => {
|
|
||||||
reject(error);
|
|
||||||
}
|
}
|
||||||
);
|
failedDatas.forEach((it) => {
|
||||||
}).catch((error) => {
|
this.onShowError(it.data, it.reason);
|
||||||
if (data.length === 1) {
|
});
|
||||||
this.onShowError(data[0], error);
|
if (failedDatas.length === data.length) {
|
||||||
} else {
|
return reject();
|
||||||
this.onShowErrorBatch(data, error);
|
|
||||||
}
|
}
|
||||||
|
return resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
onConfirmOK = (data, onSubmit, isBatch, containerProps) => {
|
onConfirmOK = (data, onSubmit, isBatch, containerProps) => {
|
||||||
|
@ -180,19 +180,6 @@ export default class ConfirmAction {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
submitErrorMsgBatch = (data) => {
|
|
||||||
if (!this.messageHasItemName) {
|
|
||||||
return t('Unable to {action}.', {
|
|
||||||
action: this.actionNameDisplay || this.title,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const name = this.getName(data);
|
|
||||||
return t('Unable to batch {action}, instance: {name}.', {
|
|
||||||
action: this.actionNameDisplay || this.title,
|
|
||||||
name,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
onSubmit = (data) => Promise.resolve();
|
onSubmit = (data) => Promise.resolve();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user