修复添加ck和cron未更新列表

This commit is contained in:
whyour
2021-04-10 13:48:44 +08:00
parent fb98bc44e4
commit f9c299cfbe
6 changed files with 107 additions and 31 deletions
+16 -3
View File
@@ -347,10 +347,10 @@ const Crontab = () => {
}
};
const handleCancel = (needUpdate?: boolean) => {
const handleCancel = (cron?: any) => {
setIsModalVisible(false);
if (needUpdate) {
getCronDetail(editedCron);
if (cron) {
handleCrons(cron);
}
};
@@ -358,6 +358,19 @@ const Crontab = () => {
setSearchText(value);
};
const handleCrons = (cron: any) => {
const index = value.findIndex((x) => x._id === cron._id);
const result = [...value];
if (index === -1) {
result.push(cron);
} else {
result.splice(index, 1, {
...cron,
});
}
setValue(result);
};
const getCronDetail = (cron: any) => {
request
.get(`${config.apiPrefix}crons/${cron._id}`)
+1 -1
View File
@@ -33,7 +33,7 @@ const CronModal = ({
message: data,
});
}
handleCancel(true);
handleCancel(data);
};
useEffect(() => {