♻️update approval filter & set approval to denied when blocked

This commit is contained in:
Fred KISSIE
2026-01-15 03:34:42 +01:00
parent fb51f42f35
commit a4f3963a5a
3 changed files with 38 additions and 41 deletions

View File

@@ -459,6 +459,7 @@
"approve": "Approve", "approve": "Approve",
"approved": "Approved", "approved": "Approved",
"denied": "Denied", "denied": "Denied",
"deniedApproval": "Denied Approval",
"all": "All", "all": "All",
"deny": "Deny", "deny": "Deny",
"viewDetails": "View Details", "viewDetails": "View Details",
@@ -1334,6 +1335,7 @@
"refreshError": "Failed to refresh data", "refreshError": "Failed to refresh data",
"verified": "Verified", "verified": "Verified",
"pending": "Pending", "pending": "Pending",
"pendingApproval": "Pending Approval",
"sidebarBilling": "Billing", "sidebarBilling": "Billing",
"billing": "Billing", "billing": "Billing",
"orgBillingDescription": "Manage billing information and subscriptions", "orgBillingDescription": "Manage billing information and subscriptions",

View File

@@ -73,7 +73,7 @@ export async function blockClient(
// Block the client // Block the client
await trx await trx
.update(clients) .update(clients)
.set({ blocked: true }) .set({ blocked: true, approvalState: "denied" })
.where(eq(clients.clientId, clientId)); .where(eq(clients.clientId, clientId));
// Send terminate signal if there's an associated OLM and it's connected // Send terminate signal if there's an associated OLM and it's connected

View File

@@ -65,8 +65,6 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) {
null null
); );
const { isPaidUser } = usePaidStatus();
const api = createApiClient(useEnvContext()); const api = createApiClient(useEnvContext());
const [isRefreshing, startTransition] = useTransition(); const [isRefreshing, startTransition] = useTransition();
@@ -222,6 +220,14 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) {
{t("blocked")} {t("blocked")}
</Badge> </Badge>
)} )}
{r.approvalState === "pending" && (
<Badge
variant="outlinePrimary"
className="flex items-center gap-1"
>
{t("pendingApproval")}
</Badge>
)}
</div> </div>
); );
} }
@@ -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: () => <span className="p-3">{t("approvalState")}</span>,
cell: ({ row }) => {
const { approvalState } = row.original;
switch (approvalState) {
case "approved":
return (
<Badge variant="green">{t("approved")}</Badge>
);
case "denied":
return <Badge variant="red">{t("denied")}</Badge>;
case "pending":
return (
<Badge variant="secondary">
{t("pending")}
</Badge>
);
default:
return (
<span className="text-muted-foreground">
N/A
</span>
);
}
}
});
}
baseColumns.push({ baseColumns.push({
id: "actions", id: "actions",
enableHiding: false, enableHiding: false,
@@ -592,17 +566,27 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) {
options: [ options: [
{ {
id: "active", id: "active",
label: t("active") || "Active", label: t("active"),
value: "active" value: "active"
}, },
{
id: "pending",
label: t("pendingApproval"),
value: "pending"
},
{
id: "denied",
label: t("deniedApproval"),
value: "denied"
},
{ {
id: "archived", id: "archived",
label: t("archived") || "Archived", label: t("archived"),
value: "archived" value: "archived"
}, },
{ {
id: "blocked", id: "blocked",
label: t("blocked") || "Blocked", label: t("blocked"),
value: "blocked" value: "blocked"
} }
], ],
@@ -611,12 +595,23 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) {
selectedValues: (string | number | boolean)[] selectedValues: (string | number | boolean)[]
) => { ) => {
if (selectedValues.length === 0) return true; if (selectedValues.length === 0) return true;
const rowArchived = row.archived || false; const rowArchived = row.archived;
const rowBlocked = row.blocked || false; const rowBlocked = row.blocked;
const approvalState = row.approvalState;
const isActive = !rowArchived && !rowBlocked; const isActive = !rowArchived && !rowBlocked;
if (selectedValues.includes("active") && isActive) if (selectedValues.includes("active") && isActive)
return true; return true;
if (
selectedValues.includes("pending") &&
approvalState === "pending"
)
return true;
if (
selectedValues.includes("denied") &&
approvalState === "denied"
)
return true;
if ( if (
selectedValues.includes("archived") && selectedValues.includes("archived") &&
rowArchived rowArchived
@@ -629,7 +624,7 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) {
return true; return true;
return false; return false;
}, },
defaultValues: ["active"] // Default to showing active clients defaultValues: ["active", "pending"] // Default to showing active clients
} }
]} ]}
/> />