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

View file

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