don't allow deleting config managed domains

This commit is contained in:
miloschwartz 2025-07-15 13:20:44 -07:00
parent ffe8593a07
commit 83a4677026
No known key found for this signature in database
5 changed files with 40 additions and 21 deletions

View file

@ -1161,7 +1161,7 @@
"selectDomainTypeNsDescription": "This domain and all its subdomains. Use this when you want to control an entire domain zone.",
"selectDomainTypeCnameName": "Single Domain (CNAME)",
"selectDomainTypeCnameDescription": "Just this specific domain. Use this for individual subdomains or specific domain entries.",
"selectDomainTypeWildcardName": "Wildcard Domain (CNAME)",
"selectDomainTypeWildcardName": "Wildcard Domain",
"selectDomainTypeWildcardDescription": "This domain and its first level of subdomains.",
"domainDelegation": "Single Domain",
"selectType": "Select a type",

View file

@ -42,6 +42,7 @@ async function queryDomains(orgId: string, limit: number, offset: number) {
type: domains.type,
failed: domains.failed,
tries: domains.tries,
configManaged: domains.configManaged
})
.from(orgDomains)
.where(eq(orgDomains.orgId, orgId))

View file

@ -23,6 +23,7 @@ export type DomainRow = {
verified: boolean;
failed: boolean;
tries: number;
configManaged: boolean;
};
type Props = {
@ -36,7 +37,9 @@ export default function DomainsTable({ domains }: Props) {
null
);
const [isRefreshing, setIsRefreshing] = useState(false);
const [restartingDomains, setRestartingDomains] = useState<Set<string>>(new Set());
const [restartingDomains, setRestartingDomains] = useState<Set<string>>(
new Set()
);
const api = createApiClient(useEnvContext());
const router = useRouter();
const t = useTranslations();
@ -46,6 +49,7 @@ export default function DomainsTable({ domains }: Props) {
const refreshData = async () => {
setIsRefreshing(true);
try {
await new Promise((resolve) => setTimeout(resolve, 200));
router.refresh();
} catch (error) {
toast({
@ -77,12 +81,14 @@ export default function DomainsTable({ domains }: Props) {
};
const restartDomain = async (domainId: string) => {
setRestartingDomains(prev => new Set(prev).add(domainId));
setRestartingDomains((prev) => new Set(prev).add(domainId));
try {
await api.post(`/org/${org.org.orgId}/domain/${domainId}/restart`);
toast({
title: t("success"),
description: t("domainRestartedDescription", { fallback: "Domain verification restarted successfully" })
description: t("domainRestartedDescription", {
fallback: "Domain verification restarted successfully"
})
});
refreshData();
} catch (e) {
@ -92,7 +98,7 @@ export default function DomainsTable({ domains }: Props) {
variant: "destructive"
});
} finally {
setRestartingDomains(prev => {
setRestartingDomains((prev) => {
const newSet = new Set(prev);
newSet.delete(domainId);
return newSet;
@ -172,7 +178,11 @@ export default function DomainsTable({ domains }: Props) {
if (verified) {
return <Badge variant="green">{t("verified")}</Badge>;
} else if (failed) {
return <Badge variant="destructive">{t("failed", { fallback: "Failed" })}</Badge>;
return (
<Badge variant="destructive">
{t("failed", { fallback: "Failed" })}
</Badge>
);
} else {
return <Badge variant="yellow">{t("pending")}</Badge>;
}
@ -193,9 +203,14 @@ export default function DomainsTable({ domains }: Props) {
onClick={() => restartDomain(domain.domainId)}
disabled={isRestarting}
>
{isRestarting ? t("restarting", { fallback: "Restarting..." }) : t("restart", { fallback: "Restart" })}
{isRestarting
? t("restarting", {
fallback: "Restarting..."
})
: t("restart", { fallback: "Restart" })}
</Button>
)}
{!domain.configManaged && (
<Button
variant="secondary"
size="sm"
@ -206,6 +221,7 @@ export default function DomainsTable({ domains }: Props) {
>
{t("delete")}
</Button>
)}
</div>
);
}

View file

@ -26,7 +26,6 @@ import { toast } from "@app/hooks/useToast";
import { formatAxiosError } from "@app/lib/api";
import { createApiClient } from "@app/lib/api";
import { useEnvContext } from "@app/hooks/useEnvContext";
import CreateSiteFormModal from "./CreateSiteModal";
import { useTranslations } from "next-intl";
import { parseDataSize } from "@app/lib/dataSize";
import { Badge } from "@app/components/ui/badge";
@ -68,8 +67,10 @@ export default function SitesTable({ sites, orgId }: SitesTableProps) {
}, [sites]);
const refreshData = async () => {
console.log("Data refreshed");
setIsRefreshing(true);
try {
await new Promise((resolve) => setTimeout(resolve, 200));
router.refresh();
} catch (error) {
toast({

View file

@ -111,9 +111,10 @@ export function DataTable<TData, TValue>({
variant="outline"
onClick={onRefresh}
disabled={isRefreshing}
loading={isRefreshing}
>
<RefreshCw className={`mr-2 h-4 w-4 ${isRefreshing ? 'animate-spin' : ''}`} />
<RefreshCw
className={`mr-2 h-4 w-4 ${isRefreshing ? "animate-spin" : ""}`}
/>
{t("refresh")}
</Button>
)}