From b99e9a64687e84523eb562695261d45e60d1382d Mon Sep 17 00:00:00 2001 From: Owen Date: Sun, 31 May 2026 17:25:03 -0700 Subject: [PATCH] Working on ui --- server/routers/resource/listResources.ts | 11 +++++++++- .../siteResource/updateSiteResource.ts | 9 ++++---- .../settings/resources/client/page.tsx | 4 ++-- src/components/ContainersSelector.tsx | 2 +- src/components/MachineClientsTable.tsx | 16 +++++++------- src/components/PrivateResourceForm.tsx | 4 +--- ...cesTable.tsx => PrivateResourcesTable.tsx} | 21 +++++++++++-------- src/components/ProxyResourcesTable.tsx | 2 +- src/components/SitesTable.tsx | 4 ++-- 9 files changed, 40 insertions(+), 33 deletions(-) rename src/components/{ClientResourcesTable.tsx => PrivateResourcesTable.tsx} (98%) diff --git a/server/routers/resource/listResources.ts b/server/routers/resource/listResources.ts index 16f33ca0c..57d7a40d0 100644 --- a/server/routers/resource/listResources.ts +++ b/server/routers/resource/listResources.ts @@ -434,7 +434,16 @@ export async function listResources( .from(targets) .innerJoin(sites, eq(targets.siteId, sites.siteId)) .where(and(eq(sites.orgId, orgId), eq(sites.siteId, siteId))); - conditions.push(inArray(resources.resourceId, resourcesWithSite)); + const resourcesWithBrowserGateway = db + .select({ resourceId: browserGatewayTarget.resourceId }) + .from(browserGatewayTarget) + .where(eq(browserGatewayTarget.siteId, siteId)); + conditions.push( + or( + inArray(resources.resourceId, resourcesWithSite), + inArray(resources.resourceId, resourcesWithBrowserGateway) + ) + ); } if (isLabelFeatureEnabled && labelFilter && labelFilter.length > 0) { diff --git a/server/routers/siteResource/updateSiteResource.ts b/server/routers/siteResource/updateSiteResource.ts index 84dc74d3b..50b942cb6 100644 --- a/server/routers/siteResource/updateSiteResource.ts +++ b/server/routers/siteResource/updateSiteResource.ts @@ -144,14 +144,13 @@ const updateSiteResourceSchema = z data.destinationPort <= 65535 ); } else if (data.mode === "ssh") { - // just check the destinationPort + // destinationPort is optional for native mode; allow null/undefined return ( - data.destinationPort === undefined || - (data.destinationPort !== null && - data.destinationPort >= 1 && - data.destinationPort <= 65535) + data.destinationPort == null || + (data.destinationPort >= 1 && data.destinationPort <= 65535) ); } + return true; }, { message: diff --git a/src/app/[orgId]/settings/resources/client/page.tsx b/src/app/[orgId]/settings/resources/client/page.tsx index 0400d63a5..ce42f39c9 100644 --- a/src/app/[orgId]/settings/resources/client/page.tsx +++ b/src/app/[orgId]/settings/resources/client/page.tsx @@ -1,5 +1,5 @@ import type { InternalResourceRow } from "@app/components/ClientResourcesTable"; -import ClientResourcesTable from "@app/components/ClientResourcesTable"; +import PrivateResourcesTable from "@app/components/ClientResourcesTable"; import SettingsSectionTitle from "@app/components/SettingsSectionTitle"; import PrivateResourcesBanner from "@app/components/PrivateResourcesBanner"; import { internal } from "@app/lib/api"; @@ -148,7 +148,7 @@ export default async function ClientResourcesPage( - ({ - labels: false + labels: true }); const t = useTranslations(); diff --git a/src/components/MachineClientsTable.tsx b/src/components/MachineClientsTable.tsx index 793312052..d7bdba029 100644 --- a/src/components/MachineClientsTable.tsx +++ b/src/components/MachineClientsTable.tsx @@ -24,17 +24,12 @@ import { ArrowUp10Icon, ChevronsUpDownIcon, CircleSlash, - MoreHorizontal, + MoreHorizontal } from "lucide-react"; import { useTranslations } from "next-intl"; import Link from "next/link"; import { useRouter } from "next/navigation"; -import { - startTransition, - useMemo, - useState, - useTransition -} from "react"; +import { startTransition, useMemo, useState, useTransition } from "react"; import { useDebouncedCallback } from "use-debounce"; import z from "zod"; import { ColumnFilterButton } from "./ColumnFilterButton"; @@ -110,7 +105,7 @@ export default function MachineClientsTable({ subnet: false, userId: false, niceId: false, - labels: false + labels: true }; const refreshData = () => { @@ -614,7 +609,10 @@ function MachineClientLabelCell({ }: MachineClientLabelCellProps) { const t = useTranslations(); const api = createApiClient(useEnvContext()); - const [localLabels, setLocalLabels] = useLocalLabels(client.labels, client.id); + const [localLabels, setLocalLabels] = useLocalLabels( + client.labels, + client.id + ); function toggleClientLabel( label: SelectedLabel, diff --git a/src/components/PrivateResourceForm.tsx b/src/components/PrivateResourceForm.tsx index 1b57ff910..1557c89f5 100644 --- a/src/components/PrivateResourceForm.tsx +++ b/src/components/PrivateResourceForm.tsx @@ -1128,9 +1128,7 @@ export function PrivateResourceForm({ /> )} - {(mode === "host" || - (mode === "ssh" && - sshServerMode !== "native")) && ( + {(mode === "host" || mode === "ssh") && (
{ const resourceRow = row.original; const display = formatDestinationDisplay(resourceRow); - return ( - - ); + if (resourceRow.destination) { + return ( + + ); + } + return -; } }, { @@ -656,7 +659,7 @@ export default function ClientResourcesTable({ columnVisibility={{ niceId: false, aliasAddress: false, - labels: false + labels: true }} stickyLeftColumn="name" stickyRightColumn="actions" diff --git a/src/components/ProxyResourcesTable.tsx b/src/components/ProxyResourcesTable.tsx index 9a327b602..630d58408 100644 --- a/src/components/ProxyResourcesTable.tsx +++ b/src/components/ProxyResourcesTable.tsx @@ -755,7 +755,7 @@ export default function ProxyResourcesTable({ columnVisibility={{ niceId: false, protocol: false, - labels: false + labels: true }} stickyLeftColumn="name" stickyRightColumn="actions" diff --git a/src/components/SitesTable.tsx b/src/components/SitesTable.tsx index 284bf4de8..51172a9e0 100644 --- a/src/components/SitesTable.tsx +++ b/src/components/SitesTable.tsx @@ -36,7 +36,7 @@ import { ArrowUpRight, ChevronDown, ChevronsUpDownIcon, - MoreHorizontal, + MoreHorizontal } from "lucide-react"; import { useTranslations } from "next-intl"; import Link from "next/link"; @@ -670,7 +670,7 @@ export default function SitesTable({ nice: false, exitNode: false, address: false, - labels: false + labels: true }} enableColumnVisibility stickyLeftColumn="name"