mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-18 17:31:55 +08:00
feat(ui): show errmsg if table loaded error
This commit is contained in:
parent
3a2baba746
commit
d1dbbae101
@ -129,7 +129,7 @@ const WorkflowRuns = ({ className, style, workflowId }: WorkflowRunsProps) => {
|
||||
const [page, setPage] = useState<number>(1);
|
||||
const [pageSize, setPageSize] = useState<number>(10);
|
||||
|
||||
const { loading } = useRequest(
|
||||
const { loading, loadedError } = useRequest(
|
||||
() => {
|
||||
return listWorkflowRuns({
|
||||
workflowId: workflowId,
|
||||
@ -150,6 +150,8 @@ const WorkflowRuns = ({ className, style, workflowId }: WorkflowRunsProps) => {
|
||||
|
||||
console.error(err);
|
||||
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
||||
|
||||
throw err;
|
||||
},
|
||||
}
|
||||
);
|
||||
@ -164,7 +166,7 @@ const WorkflowRuns = ({ className, style, workflowId }: WorkflowRunsProps) => {
|
||||
dataSource={tableData}
|
||||
loading={loading}
|
||||
locale={{
|
||||
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />,
|
||||
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={loadedError ? getErrMsg(loadedError) : undefined} />,
|
||||
}}
|
||||
pagination={{
|
||||
current: page,
|
||||
|
@ -130,7 +130,7 @@ const AccessList = () => {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const { loading, run: refreshTableData } = useRequest(
|
||||
const { loading, run: refreshData } = useRequest(
|
||||
() => {
|
||||
const startIndex = (page - 1) * pageSize;
|
||||
const endIndex = startIndex + pageSize;
|
||||
@ -157,7 +157,7 @@ const AccessList = () => {
|
||||
// TODO: 有关联数据的不允许被删除
|
||||
try {
|
||||
await deleteAccess(data);
|
||||
refreshTableData();
|
||||
refreshData();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||
import { DeleteOutlined as DeleteOutlinedIcon, SelectOutlined as SelectOutlinedIcon } from "@ant-design/icons";
|
||||
import { DeleteOutlined as DeleteOutlinedIcon, SelectOutlined as SelectOutlinedIcon, WarningOutlined as WarningOutlinedIcon } from "@ant-design/icons";
|
||||
import { PageHeader } from "@ant-design/pro-components";
|
||||
import { useRequest } from "ahooks";
|
||||
import { Button, Divider, Empty, Menu, type MenuProps, Modal, Radio, Space, Table, type TableProps, Tooltip, Typography, notification, theme } from "antd";
|
||||
@ -188,7 +188,11 @@ const CertificateList = () => {
|
||||
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 listCertificate({
|
||||
page: page,
|
||||
@ -209,6 +213,8 @@ const CertificateList = () => {
|
||||
|
||||
console.error(err);
|
||||
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
||||
|
||||
throw err;
|
||||
},
|
||||
}
|
||||
);
|
||||
@ -222,7 +228,7 @@ const CertificateList = () => {
|
||||
const resp = await removeCertificate(certificate);
|
||||
if (resp) {
|
||||
setTableData((prev) => prev.filter((item) => item.id !== certificate.id));
|
||||
refreshTableData();
|
||||
refreshData();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
@ -244,7 +250,7 @@ const CertificateList = () => {
|
||||
dataSource={tableData}
|
||||
loading={loading}
|
||||
locale={{
|
||||
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={t("certificate.nodata")} />,
|
||||
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={loadedError ? getErrMsg(loadedError) : t("certificate.nodata")} />,
|
||||
}}
|
||||
pagination={{
|
||||
current: page,
|
||||
|
@ -66,6 +66,8 @@ const Dashboard = () => {
|
||||
|
||||
console.error(err);
|
||||
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
||||
|
||||
throw err;
|
||||
},
|
||||
}
|
||||
);
|
||||
@ -176,6 +178,8 @@ const Dashboard = () => {
|
||||
|
||||
console.error(err);
|
||||
notificationApi.error({ message: t("common.text.request_error"), description: getErrMsg(err) });
|
||||
|
||||
throw err;
|
||||
},
|
||||
}
|
||||
);
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user