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,