Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@
"postcss": "^8.5.1",
"postcss-preset-mantine": "1.17.0",
"postcss-simple-vars": "^7.0.1",
"prettier": "^3.5.3",
"prettier": "^3.6.2",
"prop-types": "^15.8.1",
"storybook": "^8.5.0",
"storybook-dark-mode": "^4.0.2",
"stylelint": "^16.13.2",
"stylelint-config-standard-scss": "^14.0.0",
"typescript": "^5.7.3",
"typescript": "^5.8.3",
"typescript-eslint": "^8.20.0",
"vite": "^6.0.7",
"vite-tsconfig-paths": "^5.1.4",
Expand Down
55 changes: 55 additions & 0 deletions src/hooks/cluster/useJobs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { useSetAdminClusterSidebar } from "@/utils/helpers";
import moment from "moment";

const getRole = (labels: any) => {
if (!labels) {
return "Unknown";
}
const keys = Object.keys(labels);
if (keys.includes("job-role.kubernetes.io/control-plane")) {
return "Control Plane";
}
return "not yet";
};

const isJobReady = (conditions: any[]) => {
return conditions?.find((condition) => condition.type === "Ready")
? "Ready"
: "Not Ready";
};

const parseNode = (item: any) => ({
name: item?.metadata?.name,
namespace: item?.metadata?.namespace?.length,
completion: getRole(item?.metadata?.labels),
age: moment(item?.metadata?.creationTimestamp).fromNow(),
conditions: isJobReady(item?.status?.conditions),
});

const useJobs = ({ cluster_id }: any) => {
useSetAdminClusterSidebar();

const tableColumns = () => [
{ id: "name", header: "Name" },
{ id: "namespace", header: "namespace" },
{ id: "completion", header: "completion" },
{ id: "age", header: "Age" },
{ id: "conditions", header: "Conditions" },
];

const tableData = (data: any) => {
if (!data) {
return [];
}
if (!Array.isArray(data)) {
return [];
}
return data.map((item: any) => parseNode(item));
};
const dataParent = "jobs";
const apiRoute = `/clusters/${cluster_id}/jobs`;

return { tableColumns, tableData, apiRoute, dataParent };
};

export default useJobs;
3 changes: 2 additions & 1 deletion src/hooks/handlers/useRegisterHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import useServices from "../cluster/useServices";
import useNodeList from "../cluster/useNodes";
import { useApps } from "../useApps";
import useNamespaces from "../cluster/useNamespaces";
import useJobs from "../cluster/useJobs";

// handle register creation
export const registerHooks: Record<string, any> = {
Expand All @@ -21,8 +22,8 @@ export const registerHooks: Record<string, any> = {
services: useServices,
namespaces: useNamespaces,
nodes: useNodeList,
jobs: useJobs,
};

export const sourceApis: Record<string, string> = {
users: "/users",
databases: `${DATABASE_API_URL}/databases`,
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3916,10 +3916,10 @@ prettier-linter-helpers@^1.0.0:
dependencies:
fast-diff "^1.1.2"

prettier@^3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.5.3.tgz#4fc2ce0d657e7a02e602549f053b239cb7dfe1b5"
integrity sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==
prettier@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.6.2.tgz#ccda02a1003ebbb2bfda6f83a074978f608b9393"
integrity sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==

pretty-format@^27.0.2:
version "27.5.1"
Expand Down Expand Up @@ -5031,7 +5031,7 @@ typescript-eslint@^8.20.0:
"@typescript-eslint/parser" "8.32.1"
"@typescript-eslint/utils" "8.32.1"

typescript@^5.7.3:
typescript@^5.8.3:
version "5.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.3.tgz#92f8a3e5e3cf497356f4178c34cd65a7f5e8440e"
integrity sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==
Expand Down