mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-05 02:06:41 +00:00
hide domain status info if not flags.use_pangolin_dns
This commit is contained in:
@@ -5,6 +5,7 @@ import { useTranslations } from "next-intl";
|
|||||||
import { Badge } from "@app/components/ui/badge";
|
import { Badge } from "@app/components/ui/badge";
|
||||||
import { DNSRecordsDataTable } from "./DNSRecordsDataTable";
|
import { DNSRecordsDataTable } from "./DNSRecordsDataTable";
|
||||||
import CopyToClipboard from "@app/components/CopyToClipboard";
|
import CopyToClipboard from "@app/components/CopyToClipboard";
|
||||||
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
|
|
||||||
export type DNSRecordRow = {
|
export type DNSRecordRow = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -24,6 +25,30 @@ export default function DNSRecordsTable({
|
|||||||
type
|
type
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
const env = useEnvContext();
|
||||||
|
|
||||||
|
const statusColumn: ColumnDef<DNSRecordRow> = {
|
||||||
|
accessorKey: "verified",
|
||||||
|
header: ({ column }) => {
|
||||||
|
return <div>{t("status")}</div>;
|
||||||
|
},
|
||||||
|
cell: ({ row }) => {
|
||||||
|
const verified = row.original.verified;
|
||||||
|
return verified ? (
|
||||||
|
type === "wildcard" ? (
|
||||||
|
<Badge variant="outlinePrimary">
|
||||||
|
{t("manual", { fallback: "Manual" })}
|
||||||
|
</Badge>
|
||||||
|
) : (
|
||||||
|
<Badge variant="green">{t("verified")}</Badge>
|
||||||
|
)
|
||||||
|
) : (
|
||||||
|
<Badge variant="yellow">
|
||||||
|
{t("pending", { fallback: "Pending" })}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const columns: ColumnDef<DNSRecordRow>[] = [
|
const columns: ColumnDef<DNSRecordRow>[] = [
|
||||||
{
|
{
|
||||||
@@ -81,28 +106,7 @@ export default function DNSRecordsTable({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
...(env.env.flags.usePangolinDns ? [statusColumn] : [])
|
||||||
accessorKey: "verified",
|
|
||||||
header: ({ column }) => {
|
|
||||||
return <div>{t("status")}</div>;
|
|
||||||
},
|
|
||||||
cell: ({ row }) => {
|
|
||||||
const verified = row.original.verified;
|
|
||||||
return verified ? (
|
|
||||||
type === "wildcard" ? (
|
|
||||||
<Badge variant="outlinePrimary">
|
|
||||||
{t("manual", { fallback: "Manual" })}
|
|
||||||
</Badge>
|
|
||||||
) : (
|
|
||||||
<Badge variant="green">{t("verified")}</Badge>
|
|
||||||
)
|
|
||||||
) : (
|
|
||||||
<Badge variant="yellow">
|
|
||||||
{t("pending", { fallback: "Pending" })}
|
|
||||||
</Badge>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
} from "@app/components/InfoSection";
|
} from "@app/components/InfoSection";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { Badge } from "./ui/badge";
|
import { Badge } from "./ui/badge";
|
||||||
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
|
|
||||||
type DomainInfoCardProps = {
|
type DomainInfoCardProps = {
|
||||||
failed: boolean;
|
failed: boolean;
|
||||||
@@ -22,6 +23,7 @@ export default function DomainInfoCard({
|
|||||||
type
|
type
|
||||||
}: DomainInfoCardProps) {
|
}: DomainInfoCardProps) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
const env = useEnvContext();
|
||||||
|
|
||||||
const getTypeDisplay = (type: string) => {
|
const getTypeDisplay = (type: string) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -46,32 +48,34 @@ export default function DomainInfoCard({
|
|||||||
<span>{getTypeDisplay(type ? type : "")}</span>
|
<span>{getTypeDisplay(type ? type : "")}</span>
|
||||||
</InfoSectionContent>
|
</InfoSectionContent>
|
||||||
</InfoSection>
|
</InfoSection>
|
||||||
<InfoSection>
|
{env.env.flags.usePangolinDns && (
|
||||||
<InfoSectionTitle>{t("status")}</InfoSectionTitle>
|
<InfoSection>
|
||||||
<InfoSectionContent>
|
<InfoSectionTitle>{t("status")}</InfoSectionTitle>
|
||||||
{failed ? (
|
<InfoSectionContent>
|
||||||
<Badge variant="red">
|
{failed ? (
|
||||||
{t("failed", { fallback: "Failed" })}
|
<Badge variant="red">
|
||||||
</Badge>
|
{t("failed", { fallback: "Failed" })}
|
||||||
) : verified ? (
|
|
||||||
type === "wildcard" ? (
|
|
||||||
<Badge variant="outlinePrimary">
|
|
||||||
{t("manual", {
|
|
||||||
fallback: "Manual"
|
|
||||||
})}
|
|
||||||
</Badge>
|
</Badge>
|
||||||
|
) : verified ? (
|
||||||
|
type === "wildcard" ? (
|
||||||
|
<Badge variant="outlinePrimary">
|
||||||
|
{t("manual", {
|
||||||
|
fallback: "Manual"
|
||||||
|
})}
|
||||||
|
</Badge>
|
||||||
|
) : (
|
||||||
|
<Badge variant="green">
|
||||||
|
{t("verified")}
|
||||||
|
</Badge>
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
<Badge variant="green">
|
<Badge variant="yellow">
|
||||||
{t("verified")}
|
{t("pending", { fallback: "Pending" })}
|
||||||
</Badge>
|
</Badge>
|
||||||
)
|
)}
|
||||||
) : (
|
</InfoSectionContent>
|
||||||
<Badge variant="yellow">
|
</InfoSection>
|
||||||
{t("pending", { fallback: "Pending" })}
|
)}
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</InfoSectionContent>
|
|
||||||
</InfoSection>
|
|
||||||
</InfoSections>
|
</InfoSections>
|
||||||
</AlertDescription>
|
</AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ export default function DomainsTable({ domains, orgId }: Props) {
|
|||||||
const [restartingDomains, setRestartingDomains] = useState<Set<string>>(
|
const [restartingDomains, setRestartingDomains] = useState<Set<string>>(
|
||||||
new Set()
|
new Set()
|
||||||
);
|
);
|
||||||
const api = createApiClient(useEnvContext());
|
const env = useEnvContext();
|
||||||
|
const api = createApiClient(env);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
@@ -134,6 +135,41 @@ export default function DomainsTable({ domains, orgId }: Props) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const statusColumn: ColumnDef<DomainRow> = {
|
||||||
|
accessorKey: "verified",
|
||||||
|
header: ({ column }) => {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() =>
|
||||||
|
column.toggleSorting(column.getIsSorted() === "asc")
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{t("status")}
|
||||||
|
<ArrowUpDown className="ml-2 h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
cell: ({ row }) => {
|
||||||
|
const { verified, failed, type } = row.original;
|
||||||
|
if (verified) {
|
||||||
|
return type == "wildcard" ? (
|
||||||
|
<Badge variant="outlinePrimary">{t("manual")}</Badge>
|
||||||
|
) : (
|
||||||
|
<Badge variant="green">{t("verified")}</Badge>
|
||||||
|
);
|
||||||
|
} else if (failed) {
|
||||||
|
return (
|
||||||
|
<Badge variant="red">
|
||||||
|
{t("failed", { fallback: "Failed" })}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return <Badge variant="yellow">{t("pending")}</Badge>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const columns: ColumnDef<DomainRow>[] = [
|
const columns: ColumnDef<DomainRow>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: "baseDomain",
|
accessorKey: "baseDomain",
|
||||||
@@ -173,40 +209,7 @@ export default function DomainsTable({ domains, orgId }: Props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
...(env.env.flags.usePangolinDns ? [statusColumn] : []),
|
||||||
accessorKey: "verified",
|
|
||||||
header: ({ column }) => {
|
|
||||||
return (
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
onClick={() =>
|
|
||||||
column.toggleSorting(column.getIsSorted() === "asc")
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{t("status")}
|
|
||||||
<ArrowUpDown className="ml-2 h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
cell: ({ row }) => {
|
|
||||||
const { verified, failed, type } = row.original;
|
|
||||||
if (verified) {
|
|
||||||
return type == "wildcard" ? (
|
|
||||||
<Badge variant="outlinePrimary">{t("manual")}</Badge>
|
|
||||||
) : (
|
|
||||||
<Badge variant="green">{t("verified")}</Badge>
|
|
||||||
);
|
|
||||||
} else if (failed) {
|
|
||||||
return (
|
|
||||||
<Badge variant="red">
|
|
||||||
{t("failed", { fallback: "Failed" })}
|
|
||||||
</Badge>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return <Badge variant="yellow">{t("pending")}</Badge>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: "actions",
|
id: "actions",
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user