add factory utils for creating header function
This commit is contained in:
1 parent
3351115e3c
commit
105353c9f6
2 files changed
+23
-74
No files matched your search
@@ -0,0 +1,11 @@
|
|||||||
|
export const createHeaderFactory = (getCellSx = () => {}) => {
|
||||||
|
return ({ id, content, onClick = () => {}, render = () => {} }) => {
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
content,
|
||||||
|
onClick,
|
||||||
|
getCellSx,
|
||||||
|
render,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -7,6 +7,7 @@ import { useTheme } from "@emotion/react";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { TypeToPathMap } from "../../../../Utils/monitorUtils";
|
import { TypeToPathMap } from "../../../../Utils/monitorUtils";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { createHeaderFactory } from "../../../../Components/Table/TableUtils";
|
||||||
|
|
||||||
const JobTable = ({ jobs = [] }) => {
|
const JobTable = ({ jobs = [] }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -33,110 +34,47 @@ const JobTable = ({ jobs = [] }) => {
|
|||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
const headers = [
|
const createHeader = createHeaderFactory(buildSx);
|
||||||
|
const headersData = [
|
||||||
{
|
{
|
||||||
id: "id",
|
id: "id",
|
||||||
content: t("queuePage.jobTable.idHeader"),
|
content: t("queuePage.jobTable.idHeader"),
|
||||||
render: (row) => {
|
render: (row) => row.monitorId,
|
||||||
return row.monitorId;
|
|
||||||
},
|
|
||||||
getCellSx: (row) => {
|
|
||||||
return buildSx(row);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "url",
|
id: "url",
|
||||||
content: t("queuePage.jobTable.urlHeader"),
|
content: t("queuePage.jobTable.urlHeader"),
|
||||||
render: (row) => {
|
render: (row) => row.monitorUrl,
|
||||||
return row.monitorUrl;
|
|
||||||
},
|
|
||||||
getCellSx: (row) => {
|
|
||||||
return buildSx(row);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "type",
|
id: "type",
|
||||||
content: t("queuePage.jobTable.typeHeader"),
|
content: t("queuePage.jobTable.typeHeader"),
|
||||||
render: (row) => {
|
render: (row) => row.monitorType,
|
||||||
return row.monitorType;
|
|
||||||
},
|
|
||||||
getCellSx: (row) => {
|
|
||||||
return buildSx(row);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "active",
|
id: "active",
|
||||||
content: t("queuePage.jobTable.activeHeader"),
|
content: t("queuePage.jobTable.activeHeader"),
|
||||||
render: (row) => {
|
render: (row) => row.active.toString(),
|
||||||
return row.active.toString();
|
|
||||||
},
|
|
||||||
getCellSx: (row) => {
|
|
||||||
return buildSx(row);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "runCount",
|
id: "runCount",
|
||||||
content: t("queuePage.jobTable.runCountHeader"),
|
content: t("queuePage.jobTable.runCountHeader"),
|
||||||
render: (row) => {
|
render: (row) => row.runCount,
|
||||||
return row.runCount;
|
|
||||||
},
|
|
||||||
getCellSx: (row) => {
|
|
||||||
return buildSx(row);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "failCount",
|
id: "failCount",
|
||||||
content: t("queuePage.jobTable.failCountHeader"),
|
content: t("queuePage.jobTable.failCountHeader"),
|
||||||
render: (row) => {
|
render: (row) => row.failCount,
|
||||||
return row.failCount;
|
|
||||||
},
|
|
||||||
getCellSx: (row) => {
|
|
||||||
return buildSx(row);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "lastRun",
|
id: "lastRun",
|
||||||
content: t("queuePage.jobTable.lastRunHeader"),
|
content: t("queuePage.jobTable.lastRunHeader"),
|
||||||
render: (row) => {
|
render: (row) => row.lastRunAt || "-",
|
||||||
return row.lastRunAt || "-";
|
|
||||||
},
|
|
||||||
getCellSx: (row) => {
|
|
||||||
return buildSx(row);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "lockedAt",
|
|
||||||
content: t("queuePage.jobTable.lockedAtHeader"),
|
|
||||||
render: (row) => {
|
|
||||||
return row.lockedAt || "-";
|
|
||||||
},
|
|
||||||
getCellSx: (row) => {
|
|
||||||
return buildSx(row);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "lastFinish",
|
|
||||||
content: t("queuePage.jobTable.lastFinishedAtHeader"),
|
|
||||||
render: (row) => {
|
|
||||||
return row.lastFinishedAt || "-";
|
|
||||||
},
|
|
||||||
getCellSx: (row) => {
|
|
||||||
return buildSx(row);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "lastRunTook",
|
|
||||||
content: t("queuePage.jobTable.lastRunTookHeader"),
|
|
||||||
render: (row) => {
|
|
||||||
const value = row.lastRunTook ? row.lastRunTook + " ms" : "-";
|
|
||||||
return value;
|
|
||||||
},
|
|
||||||
getCellSx: (row) => {
|
|
||||||
return buildSx(row);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const headers = headersData.map((header) => createHeader(header));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack gap={theme.spacing(2)}>
|
<Stack gap={theme.spacing(2)}>
|
||||||
<Typography variant="h2">{t("queuePage.jobTable.title")}</Typography>
|
<Typography variant="h2">{t("queuePage.jobTable.title")}</Typography>
|
||||||
|
|||||||
Reference in new issue
Block a user