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