From ea8eaf97361adef687e5a5d387676fa13005d217 Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Fri, 5 Jun 2026 12:42:52 -0700 Subject: [PATCH] adjust targets input styles --- .../public/ProxyResourceTargetsForm.tsx | 62 ++++++-- .../resource-target-address-item.tsx | 141 ++++++++++-------- 2 files changed, 123 insertions(+), 80 deletions(-) diff --git a/src/app/[orgId]/settings/resources/public/ProxyResourceTargetsForm.tsx b/src/app/[orgId]/settings/resources/public/ProxyResourceTargetsForm.tsx index 7289c2767..d707996b5 100644 --- a/src/app/[orgId]/settings/resources/public/ProxyResourceTargetsForm.tsx +++ b/src/app/[orgId]/settings/resources/public/ProxyResourceTargetsForm.tsx @@ -10,7 +10,10 @@ import { PathRewriteDisplay, PathRewriteModal } from "@app/components/PathMatchRenameModal"; -import { ResourceTargetAddressItem } from "@app/components/resource-target-address-item"; +import { + ResourceTargetAddressItem, + ResourceTargetSiteItem +} from "@app/components/resource-target-address-item"; import { SettingsSection, SettingsSectionBody, @@ -65,6 +68,7 @@ import { useMemo, useState } from "react"; +import { maxSize } from "zod"; export type LocalTarget = Omit< ArrayElement & { @@ -269,7 +273,7 @@ export function ProxyResourceTargetsForm({ const priorityColumn: ColumnDef = { id: "priority", header: () => ( -
+
{t("priority")} @@ -285,7 +289,6 @@ export function ProxyResourceTargetsForm({ ), cell: ({ row }) => { return ( -
-
); }, size: 120, @@ -437,13 +439,12 @@ export function ProxyResourceTargetsForm({ maxSize: 200 }; - const addressColumn: ColumnDef = { - accessorKey: "address", - header: () => {t("address")}, + const siteColumn: ColumnDef = { + accessorKey: "site", + header: () => {t("site")}, cell: ({ row }) => { return ( - ); }, - size: 400, - minSize: 350, - maxSize: 500 + size: 220, + minSize: 180, + maxSize: 280 + }; + + const addressColumn: ColumnDef = { + accessorKey: "address", + header: () => {t("address")}, + cell: ({ row }) => { + return ( + + ); + }, + size: 350, + minSize: 300, + maxSize: 450 }; const rewritePathColumn: ColumnDef = { @@ -567,6 +585,7 @@ export function ProxyResourceTargetsForm({ if (isAdvancedMode) { const cols = [ + siteColumn, addressColumn, healthCheckColumn, enabledColumn, @@ -575,12 +594,13 @@ export function ProxyResourceTargetsForm({ if (isHttp) { cols.unshift(matchPathColumn); - cols.splice(3, 0, rewritePathColumn, priorityColumn); + cols.splice(4, 0, rewritePathColumn, priorityColumn); } return cols; } else { return [ + siteColumn, addressColumn, healthCheckColumn, enabledColumn, @@ -818,6 +838,10 @@ export function ProxyResourceTargetsForm({ header.column .id === "actions"; + const isSiteColumn = + header.column + .id === + "site"; return ( {header.isPlaceholder @@ -858,6 +884,10 @@ export function ProxyResourceTargetsForm({ cell.column .id === "actions"; + const isSiteColumn = + cell.column + .id === + "site"; return ( {flexRender( diff --git a/src/components/resource-target-address-item.tsx b/src/components/resource-target-address-item.tsx index abd4ed45b..f6ebc5752 100644 --- a/src/components/resource-target-address-item.tsx +++ b/src/components/resource-target-address-item.tsx @@ -1,15 +1,12 @@ import { cn } from "@app/lib/cn"; import type { DockerState } from "@app/lib/docker"; import { parseHostTarget } from "@app/lib/parseHostTarget"; -import { orgQueries } from "@app/lib/queries"; import { CaretSortIcon } from "@radix-ui/react-icons"; import type { ListSitesResponse } from "@server/routers/site"; import { type ListTargetsResponse } from "@server/routers/target"; import type { ArrayElement } from "@server/types/ArrayElement"; -import { useQuery } from "@tanstack/react-query"; -import { CheckIcon } from "lucide-react"; import { useTranslations } from "next-intl"; -import { useMemo, useState } from "react"; +import { useState } from "react"; import { ContainersSelector } from "./ContainersSelector"; import { Button } from "./ui/button"; import { Input } from "./ui/input"; @@ -28,23 +25,21 @@ export type LocalTarget = Omit< "protocol" >; -export type ResourceTargetAddressItemProps = { +export type ResourceTargetSiteItemProps = { getDockerStateForSite: (siteId: number) => DockerState; updateTarget: (targetId: number, data: Partial) => void; orgId: string; proxyTarget: LocalTarget; - isHttp: boolean; refreshContainersForSite: (siteId: number) => void; }; -export function ResourceTargetAddressItem({ +export function ResourceTargetSiteItem({ orgId, getDockerStateForSite, updateTarget, proxyTarget, - isHttp, refreshContainersForSite -}: ResourceTargetAddressItemProps) { +}: ResourceTargetSiteItemProps) { const t = useTranslations(); const [selectedSite, setSelectedSite] = useState + {selectedSite && selectedSite.type === "newt" && ( + + refreshContainersForSite(selectedSite.siteId) + } + /> + )} + + + + + + + { + updateTarget(proxyTarget.targetId, { + siteId: site.siteId, + siteType: site.type, + siteName: site.name + }); + setSelectedSite(site); + }} + /> + + +
+ ); +} + +export type ResourceTargetAddressItemProps = { + updateTarget: (targetId: number, data: Partial) => void; + proxyTarget: LocalTarget; + isHttp: boolean; +}; + +export function ResourceTargetAddressItem({ + updateTarget, + proxyTarget, + isHttp +}: ResourceTargetAddressItemProps) { return (
- {selectedSite && selectedSite.type === "newt" && ( - - refreshContainersForSite(selectedSite.siteId) - } - /> - )} - - - - - - - { - updateTarget(proxyTarget.targetId, { - siteId: site.siteId, - siteType: site.type, - siteName: site.name - }); - setSelectedSite(site); - }} - /> - - - {isHttp && (