fix sorting auth column if no auth closes #149

This commit is contained in:
Milo Schwartz 2025-02-03 22:47:47 -05:00
parent 149de243a5
commit 394fa00d7c
2 changed files with 34 additions and 31 deletions

View file

@ -38,7 +38,7 @@ export type ResourceRow = {
domain: string; domain: string;
site: string; site: string;
siteId: string; siteId: string;
hasAuth: boolean; authState: string;
http: boolean; http: boolean;
protocol: string; protocol: string;
proxyPort: number | null; proxyPort: number | null;
@ -165,9 +165,7 @@ export default function SitesTable({ resources, orgId }: ResourcesTableProps) {
header: "Protocol", header: "Protocol",
cell: ({ row }) => { cell: ({ row }) => {
const resourceRow = row.original; const resourceRow = row.original;
return ( return <span>{resourceRow.protocol.toUpperCase()}</span>;
<span>{resourceRow.protocol.toUpperCase()}</span>
);
} }
}, },
{ {
@ -177,17 +175,23 @@ export default function SitesTable({ resources, orgId }: ResourcesTableProps) {
const resourceRow = row.original; const resourceRow = row.original;
return ( return (
<div> <div>
{!resourceRow.http ? ( {!resourceRow.http ? (
<CopyToClipboard text={resourceRow.proxyPort!.toString()} isLink={false} /> <CopyToClipboard
) : ( text={resourceRow.proxyPort!.toString()}
<CopyToClipboard text={resourceRow.domain} isLink={true} /> isLink={false}
)} />
) : (
<CopyToClipboard
text={resourceRow.domain}
isLink={true}
/>
)}
</div> </div>
); );
} }
}, },
{ {
accessorKey: "hasAuth", accessorKey: "authState",
header: ({ column }) => { header: ({ column }) => {
return ( return (
<Button <Button
@ -205,23 +209,19 @@ export default function SitesTable({ resources, orgId }: ResourcesTableProps) {
const resourceRow = row.original; const resourceRow = row.original;
return ( return (
<div> <div>
{resourceRow.authState === "protected" ? (
<span className="text-green-500 flex items-center space-x-2">
{!resourceRow.http ? ( <ShieldCheck className="w-4 h-4" />
<span>Protected</span>
</span>
) : resourceRow.authState === "not_protected" ? (
<span className="text-yellow-500 flex items-center space-x-2">
<ShieldOff className="w-4 h-4" />
<span>Not Protected</span>
</span>
) : (
<span>--</span> <span>--</span>
) : )}
resourceRow.hasAuth ? (
<span className="text-green-500 flex items-center space-x-2">
<ShieldCheck className="w-4 h-4" />
<span>Protected</span>
</span>
) : (
<span className="text-yellow-500 flex items-center space-x-2">
<ShieldOff className="w-4 h-4" />
<span>Not Protected</span>
</span>
)
}
</div> </div>
); );
} }

View file

@ -56,11 +56,14 @@ export default async function ResourcesPage(props: ResourcesPageProps) {
protocol: resource.protocol, protocol: resource.protocol,
proxyPort: resource.proxyPort, proxyPort: resource.proxyPort,
http: resource.http, http: resource.http,
hasAuth: authState: !resource.http
resource.sso || ? "none"
resource.pincodeId !== null || : resource.sso ||
resource.pincodeId !== null || resource.pincodeId !== null ||
resource.whitelist resource.pincodeId !== null ||
resource.whitelist
? "protected"
: "not_protected"
}; };
}); });