From a4f3963a5a81720b679f92d7ceeeb23594efbedd Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Thu, 15 Jan 2026 03:34:42 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8Fupdate=20approval=20filter=20?= =?UTF-8?q?&=20set=20approval=20to=20denied=20when=20blocked?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- messages/en-US.json | 2 + server/routers/client/blockClient.ts | 2 +- src/components/UserDevicesTable.tsx | 75 +++++++++++++--------------- 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/messages/en-US.json b/messages/en-US.json index 05a900ad..75e251ac 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -459,6 +459,7 @@ "approve": "Approve", "approved": "Approved", "denied": "Denied", + "deniedApproval": "Denied Approval", "all": "All", "deny": "Deny", "viewDetails": "View Details", @@ -1334,6 +1335,7 @@ "refreshError": "Failed to refresh data", "verified": "Verified", "pending": "Pending", + "pendingApproval": "Pending Approval", "sidebarBilling": "Billing", "billing": "Billing", "orgBillingDescription": "Manage billing information and subscriptions", diff --git a/server/routers/client/blockClient.ts b/server/routers/client/blockClient.ts index e1a00ff6..68ae64f8 100644 --- a/server/routers/client/blockClient.ts +++ b/server/routers/client/blockClient.ts @@ -73,7 +73,7 @@ export async function blockClient( // Block the client await trx .update(clients) - .set({ blocked: true }) + .set({ blocked: true, approvalState: "denied" }) .where(eq(clients.clientId, clientId)); // Send terminate signal if there's an associated OLM and it's connected diff --git a/src/components/UserDevicesTable.tsx b/src/components/UserDevicesTable.tsx index ef4e016c..b2a5fd8b 100644 --- a/src/components/UserDevicesTable.tsx +++ b/src/components/UserDevicesTable.tsx @@ -65,8 +65,6 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) { null ); - const { isPaidUser } = usePaidStatus(); - const api = createApiClient(useEnvContext()); const [isRefreshing, startTransition] = useTransition(); @@ -222,6 +220,14 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) { {t("blocked")} )} + {r.approvalState === "pending" && ( + + {t("pendingApproval")} + + )} ); } @@ -415,38 +421,6 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) { } ]; - if (build !== "oss" && isPaidUser) { - // insert as the 3rd item - baseColumns.splice(3, 0, { - id: "approvalState", - enableHiding: false, - header: () => {t("approvalState")}, - cell: ({ row }) => { - const { approvalState } = row.original; - switch (approvalState) { - case "approved": - return ( - {t("approved")} - ); - case "denied": - return {t("denied")}; - case "pending": - return ( - - {t("pending")} - - ); - default: - return ( - - N/A - - ); - } - } - }); - } - baseColumns.push({ id: "actions", enableHiding: false, @@ -592,17 +566,27 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) { options: [ { id: "active", - label: t("active") || "Active", + label: t("active"), value: "active" }, + { + id: "pending", + label: t("pendingApproval"), + value: "pending" + }, + { + id: "denied", + label: t("deniedApproval"), + value: "denied" + }, { id: "archived", - label: t("archived") || "Archived", + label: t("archived"), value: "archived" }, { id: "blocked", - label: t("blocked") || "Blocked", + label: t("blocked"), value: "blocked" } ], @@ -611,12 +595,23 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) { selectedValues: (string | number | boolean)[] ) => { if (selectedValues.length === 0) return true; - const rowArchived = row.archived || false; - const rowBlocked = row.blocked || false; + const rowArchived = row.archived; + const rowBlocked = row.blocked; + const approvalState = row.approvalState; const isActive = !rowArchived && !rowBlocked; if (selectedValues.includes("active") && isActive) return true; + if ( + selectedValues.includes("pending") && + approvalState === "pending" + ) + return true; + if ( + selectedValues.includes("denied") && + approvalState === "denied" + ) + return true; if ( selectedValues.includes("archived") && rowArchived @@ -629,7 +624,7 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) { return true; return false; }, - defaultValues: ["active"] // Default to showing active clients + defaultValues: ["active", "pending"] // Default to showing active clients } ]} />