mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-04 17:56:38 +00:00
add edit button to domain table
This commit is contained in:
@@ -60,7 +60,7 @@ export default async function DomainsPage(props: Props) {
|
|||||||
title={t("domains")}
|
title={t("domains")}
|
||||||
description={t("domainsDescription")}
|
description={t("domainsDescription")}
|
||||||
/>
|
/>
|
||||||
<DomainsTable domains={domains} />
|
<DomainsTable domains={domains} orgId={org.org.orgId} />
|
||||||
</OrgProvider>
|
</OrgProvider>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { ColumnDef } from "@tanstack/react-table";
|
import { ColumnDef } from "@tanstack/react-table";
|
||||||
import { DomainsDataTable } from "@app/components/DomainsDataTable";
|
import { DomainsDataTable } from "@app/components/DomainsDataTable";
|
||||||
import { Button } from "@app/components/ui/button";
|
import { Button } from "@app/components/ui/button";
|
||||||
import { ArrowUpDown } from "lucide-react";
|
import { ArrowRight, ArrowUpDown, MoreHorizontal } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
|
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
|
||||||
import { formatAxiosError } from "@app/lib/api";
|
import { formatAxiosError } from "@app/lib/api";
|
||||||
@@ -15,6 +15,8 @@ import { useTranslations } from "next-intl";
|
|||||||
import CreateDomainForm from "@app/components/CreateDomainForm";
|
import CreateDomainForm from "@app/components/CreateDomainForm";
|
||||||
import { useToast } from "@app/hooks/useToast";
|
import { useToast } from "@app/hooks/useToast";
|
||||||
import { useOrgContext } from "@app/hooks/useOrgContext";
|
import { useOrgContext } from "@app/hooks/useOrgContext";
|
||||||
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "./ui/dropdown-menu";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
export type DomainRow = {
|
export type DomainRow = {
|
||||||
domainId: string;
|
domainId: string;
|
||||||
@@ -30,9 +32,10 @@ export type DomainRow = {
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
domains: DomainRow[];
|
domains: DomainRow[];
|
||||||
|
orgId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function DomainsTable({ domains }: Props) {
|
export default function DomainsTable({ domains, orgId }: Props) {
|
||||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||||
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
||||||
const [selectedDomain, setSelectedDomain] = useState<DomainRow | null>(
|
const [selectedDomain, setSelectedDomain] = useState<DomainRow | null>(
|
||||||
@@ -207,12 +210,51 @@ export default function DomainsTable({ domains }: Props) {
|
|||||||
>
|
>
|
||||||
{isRestarting
|
{isRestarting
|
||||||
? t("restarting", {
|
? t("restarting", {
|
||||||
fallback: "Restarting..."
|
fallback: "Restarting..."
|
||||||
})
|
})
|
||||||
: t("restart", { fallback: "Restart" })}
|
: t("restart", { fallback: "Restart" })}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<Button
|
<div className="flex items-center justify-end gap-2">
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button variant="ghost" className="h-8 w-8 p-0">
|
||||||
|
<span className="sr-only">Open menu</span>
|
||||||
|
<MoreHorizontal className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align="end">
|
||||||
|
<Link
|
||||||
|
className="block w-full"
|
||||||
|
href={`/${orgId}/settings/domains/${domain.domainId}`}
|
||||||
|
>
|
||||||
|
<DropdownMenuItem>
|
||||||
|
{t("viewSettings")}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</Link>
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedDomain(domain);
|
||||||
|
setIsDeleteModalOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span className="text-red-500">
|
||||||
|
{t("delete")}
|
||||||
|
</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
|
||||||
|
<Link
|
||||||
|
href={`/${orgId}/settings/domains/${domain.domainId}`}
|
||||||
|
>
|
||||||
|
<Button variant={"secondary"} size="sm">
|
||||||
|
{t("edit")}
|
||||||
|
<ArrowRight className="ml-2 w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
{/* <Button
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="sm"
|
size="sm"
|
||||||
disabled={domain.configManaged}
|
disabled={domain.configManaged}
|
||||||
@@ -222,7 +264,7 @@ export default function DomainsTable({ domains }: Props) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t("delete")}
|
{t("delete")}
|
||||||
</Button>
|
</Button> */}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user