feat(ui): show errmsg if table loaded error

This commit is contained in:
Fu Diwei
2025-01-16 22:07:01 +08:00
parent 3a2baba746
commit d1dbbae101
5 changed files with 30 additions and 11 deletions

View File

@@ -20,6 +20,7 @@ import {
type MenuProps,
Modal,
Radio,
Result,
Space,
Switch,
Table,
@@ -240,7 +241,11 @@ const WorkflowList = () => {
const [page, setPage] = useState<number>(() => parseInt(+searchParams.get("page")! + "") || 1);
const [pageSize, setPageSize] = useState<number>(() => parseInt(+searchParams.get("perPage")! + "") || 10);
const { loading, run: refreshTableData } = useRequest(
const {
loading,
error: loadedError,
run: refreshData,
} = useRequest(
() => {
return listWorkflow({
page: page,
@@ -261,6 +266,8 @@ const WorkflowList = () => {
console.error(err);
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
throw err;
},
}
);
@@ -305,7 +312,7 @@ const WorkflowList = () => {
const resp = await removeWorkflow(workflow);
if (resp) {
setTableData((prev) => prev.filter((item) => item.id !== workflow.id));
refreshTableData();
refreshData();
}
} catch (err) {
console.error(err);
@@ -342,7 +349,7 @@ const WorkflowList = () => {
dataSource={tableData}
loading={loading}
locale={{
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={t("workflow.nodata")} />,
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={loadedError ? getErrMsg(loadedError) : t("workflow.nodata")} />,
}}
pagination={{
current: page,