mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-29 07:21:37 +02:00
✨ List of orgs, with all columns
This commit is contained in:
@@ -64,10 +64,16 @@ export type AdminOrgRow = {
|
||||
orgId: string;
|
||||
name: string;
|
||||
subnet: string | null;
|
||||
utilitySubnet: string | null;
|
||||
createdAt: string | null;
|
||||
userCount: number;
|
||||
siteCount: number;
|
||||
resourceCount: number;
|
||||
owner: {
|
||||
userId: string;
|
||||
name: string | null;
|
||||
username: string;
|
||||
} | null;
|
||||
};
|
||||
|
||||
export type AdminListOrgsResponse = PaginatedResponse<{
|
||||
@@ -172,6 +178,7 @@ export async function adminListOrgs(
|
||||
orgId: orgs.orgId,
|
||||
name: orgs.name,
|
||||
subnet: orgs.subnet,
|
||||
utilitySubnet: orgs.utilitySubnet,
|
||||
createdAt: orgs.createdAt,
|
||||
userCount: sql<number>`(
|
||||
SELECT COUNT(*)
|
||||
@@ -189,7 +196,7 @@ export async function adminListOrgs(
|
||||
WHERE ${resources.orgId} = ${orgIdRef}
|
||||
)`.as("resourceCount"),
|
||||
owner: {
|
||||
id: users.userId,
|
||||
userId: users.userId,
|
||||
name: users.name,
|
||||
username: users.username
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||
import OrgsTable, { type OrgRow } from "@app/components/OrgsTable";
|
||||
import OrgsTable from "@app/components/OrgsTable";
|
||||
import { internal } from "@app/lib/api";
|
||||
import { authCookieHeader } from "@app/lib/api/cookies";
|
||||
import type { AdminListOrgsResponse } from "@server/routers/org";
|
||||
@@ -39,16 +39,6 @@ export default async function OrganizationsPage(props: OrganizationsPageProps) {
|
||||
|
||||
const t = await getTranslations();
|
||||
|
||||
const orgRows: OrgRow[] = orgs.map((org) => ({
|
||||
orgId: org.orgId,
|
||||
name: org.name,
|
||||
subnet: org.subnet,
|
||||
createdAt: org.createdAt,
|
||||
userCount: org.userCount,
|
||||
siteCount: org.siteCount,
|
||||
resourceCount: org.resourceCount
|
||||
}));
|
||||
|
||||
return (
|
||||
<>
|
||||
<SettingsSectionTitle
|
||||
@@ -57,7 +47,7 @@ export default async function OrganizationsPage(props: OrganizationsPageProps) {
|
||||
/>
|
||||
|
||||
<OrgsTable
|
||||
orgs={orgRows}
|
||||
orgs={orgs}
|
||||
rowCount={pagination.total}
|
||||
pagination={{
|
||||
pageIndex: pagination.page - 1,
|
||||
|
||||
@@ -5,22 +5,16 @@ import {
|
||||
ControlledDataTable,
|
||||
type ExtendedColumnDef
|
||||
} from "@app/components/ui/controlled-data-table";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger
|
||||
} from "@app/components/ui/dropdown-menu";
|
||||
import { useNavigationContext } from "@app/hooks/useNavigationContext";
|
||||
import { toast } from "@app/hooks/useToast";
|
||||
import { getNextSortOrder, getSortDirection } from "@app/lib/sortColumn";
|
||||
import type { AdminOrgRow } from "@server/routers/org";
|
||||
import { type PaginationState } from "@tanstack/react-table";
|
||||
import {
|
||||
ArrowDown01Icon,
|
||||
ArrowRight,
|
||||
ArrowUp10Icon,
|
||||
ChevronsUpDownIcon,
|
||||
MoreHorizontal
|
||||
ArrowUpRight,
|
||||
ChevronsUpDownIcon
|
||||
} from "lucide-react";
|
||||
import moment from "moment";
|
||||
import { useTranslations } from "next-intl";
|
||||
@@ -29,18 +23,8 @@ import { useRouter } from "next/navigation";
|
||||
import { useMemo, useTransition } from "react";
|
||||
import { useDebouncedCallback } from "use-debounce";
|
||||
|
||||
export type OrgRow = {
|
||||
orgId: string;
|
||||
name: string;
|
||||
subnet: string | null;
|
||||
createdAt: string | null;
|
||||
userCount: number;
|
||||
siteCount: number;
|
||||
resourceCount: number;
|
||||
};
|
||||
|
||||
type OrgTableProps = {
|
||||
orgs: OrgRow[];
|
||||
orgs: AdminOrgRow[];
|
||||
pagination: PaginationState;
|
||||
rowCount: number;
|
||||
};
|
||||
@@ -103,7 +87,7 @@ export default function OrgsTable({
|
||||
);
|
||||
}
|
||||
|
||||
const columns = useMemo<ExtendedColumnDef<OrgRow>[]>(() => {
|
||||
const columns = useMemo<ExtendedColumnDef<AdminOrgRow>[]>(() => {
|
||||
return [
|
||||
{
|
||||
accessorKey: "name",
|
||||
@@ -124,6 +108,31 @@ export default function OrgsTable({
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorKey: "owner",
|
||||
friendlyName: t("accessRoleOwner"),
|
||||
header: () => (
|
||||
<span className="p-3">{t("accessRoleOwner")}</span>
|
||||
),
|
||||
cell: ({ row }) => {
|
||||
const owner = row.original.owner;
|
||||
return owner ? (
|
||||
<Button
|
||||
className="tabular-nums"
|
||||
asChild
|
||||
variant="outline"
|
||||
size="sm"
|
||||
>
|
||||
<Link href={`/admin/users/${owner.userId}`}>
|
||||
{owner.name || owner.username}
|
||||
<ArrowUpRight className="ml-2 h-3 w-3" />
|
||||
</Link>
|
||||
</Button>
|
||||
) : (
|
||||
<code>-</code>
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorKey: "orgId",
|
||||
friendlyName: t("orgId"),
|
||||
@@ -135,6 +144,14 @@ export default function OrgsTable({
|
||||
header: () => <span className="p-3">{t("subnet")}</span>,
|
||||
cell: ({ row }) => <span>{row.original.subnet || "-"}</span>
|
||||
},
|
||||
{
|
||||
accessorKey: "utilitySubnet",
|
||||
friendlyName: t("utilitySubnet"),
|
||||
header: () => <span className="p-3">{t("utilitySubnet")}</span>,
|
||||
cell: ({ row }) => (
|
||||
<span>{row.original.utilitySubnet || "-"}</span>
|
||||
)
|
||||
},
|
||||
{
|
||||
accessorKey: "userCount",
|
||||
friendlyName: t("users"),
|
||||
@@ -218,6 +235,7 @@ export default function OrgsTable({
|
||||
rowCount={rowCount}
|
||||
columnVisibility={{
|
||||
subnet: false,
|
||||
utilitySubnet: false,
|
||||
orgId: false
|
||||
}}
|
||||
enableColumnVisibility
|
||||
|
||||
Reference in New Issue
Block a user