From 37ceba6b815cadd0ce2d5b6f9678ab90b0380247 Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Fri, 6 Mar 2026 04:36:12 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20show=20attached=20resources=20in?= =?UTF-8?q?=20policy=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- messages/en-US.json | 4 +- server/routers/resource/types.ts | 7 +- .../(private)/policies/resource/page.tsx | 1 - src/components/ResourcePoliciesTable.tsx | 84 ++++++++++++++++++- 4 files changed, 91 insertions(+), 5 deletions(-) diff --git a/messages/en-US.json b/messages/en-US.json index af2eef9cb..72e8baa5e 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -167,6 +167,9 @@ "resourceAdd": "Add Resource", "resourceErrorDelte": "Error deleting resource", "resourcePoliciesTitle": "Manage Resource Policies", + "resourcePoliciesAttachedResourcesColumnTitle": "Attached resources", + "resourcePoliciesAttachedResources": "{count} resource(s)", + "resourcePoliciesAttachedResourcesEmpty": "no resources", "resourcePoliciesDescription": "Create and manage authentication policies to control access to your resources", "resourcePoliciesSearch": "Search policies...", "resourcePoliciesAdd": "Add Policy", @@ -1069,7 +1072,6 @@ "pageNotFoundDescription": "Oops! The page you're looking for doesn't exist.", "overview": "Overview", "home": "Home", - "accessControl": "Access Control", "settings": "Settings", "usersAll": "All Users", "license": "License", diff --git a/server/routers/resource/types.ts b/server/routers/resource/types.ts index c79e78d69..eee70bd35 100644 --- a/server/routers/resource/types.ts +++ b/server/routers/resource/types.ts @@ -12,11 +12,16 @@ export type GetMaintenanceInfoResponse = { maintenanceEstimatedTime: string | null; }; +export type AttachedResource = Pick< + Resource, + "resourceId" | "name" | "fullDomain" +>; + export type ResourcePolicyWithResources = Pick< ResourcePolicy, "resourcePolicyId" | "niceId" | "name" | "orgId" > & { - resources: Array>; + resources: Array; }; export type ListResourcePoliciesResponse = PaginatedResponse<{ diff --git a/src/app/[orgId]/settings/(private)/policies/resource/page.tsx b/src/app/[orgId]/settings/(private)/policies/resource/page.tsx index 3f2ec53b0..a51bbef3a 100644 --- a/src/app/[orgId]/settings/(private)/policies/resource/page.tsx +++ b/src/app/[orgId]/settings/(private)/policies/resource/page.tsx @@ -3,7 +3,6 @@ import SettingsSectionTitle from "@app/components/SettingsSectionTitle"; import { internal } from "@app/lib/api"; import { authCookieHeader } from "@app/lib/api/cookies"; import { getCachedOrg } from "@app/lib/api/getCachedOrg"; -import OrgProvider from "@app/providers/OrgProvider"; import type { GetOrgResponse } from "@server/routers/org"; import type { ListResourcePoliciesResponse } from "@server/routers/resource/types"; import type { AxiosResponse } from "axios"; diff --git a/src/components/ResourcePoliciesTable.tsx b/src/components/ResourcePoliciesTable.tsx index 69dee6963..5dfc007df 100644 --- a/src/components/ResourcePoliciesTable.tsx +++ b/src/components/ResourcePoliciesTable.tsx @@ -3,9 +3,17 @@ import { useEnvContext } from "@app/hooks/useEnvContext"; import { useNavigationContext } from "@app/hooks/useNavigationContext"; import { toast } from "@app/hooks/useToast"; import { createApiClient } from "@app/lib/api"; -import type { ListResourcePoliciesResponse } from "@server/routers/resource/types"; +import type { + AttachedResource, + ListResourcePoliciesResponse +} from "@server/routers/resource/types"; import type { PaginationState } from "@tanstack/react-table"; -import { ArrowRight, MoreHorizontal } from "lucide-react"; +import { + ArrowRight, + ChevronDown, + MoreHorizontal, + Waypoints +} from "lucide-react"; import { useTranslations } from "next-intl"; import Link from "next/link"; import { useRouter } from "next/navigation"; @@ -20,6 +28,8 @@ import { DropdownMenuItem, DropdownMenuTrigger } from "./ui/dropdown-menu"; +import type { targets } from "@server/db"; +import type { TargetHealth } from "./ProxyResourcesTable"; type ResourcePolicyRow = ListResourcePoliciesResponse["policies"][number]; @@ -65,6 +75,63 @@ export function ResourcePoliciesTable({ }); }; + function ResourceListCell({ + resources + }: { + resources?: AttachedResource[]; + }) { + if (!resources || resources.length === 0) { + return ( +
+ + + {t("resourcePoliciesAttachedResourcesEmpty")} + +
+ ); + } + + return ( + + + + + + {resources.map((resource) => ( + +
+ {resource.name} +
+ + {resource.fullDomain} + +
+ ))} +
+
+ ); + } + const proxyColumns: ExtendedColumnDef[] = [ { accessorKey: "name", @@ -83,6 +150,19 @@ export function ResourcePoliciesTable({ return {row.original.niceId || "-"}; } }, + { + id: "resources", + accessorKey: "resources", + friendlyName: t("resourcePoliciesAttachedResourcesColumnTitle"), + header: () => ( + + {t("resourcePoliciesAttachedResourcesColumnTitle")} + + ), + cell: ({ row }) => { + return ; + } + }, { id: "actions", enableHiding: false,