mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-25 19:07:47 +02:00
fix(ui): disable Add Monitor button when no eligible systems exist (#2392)
This commit is contained in:
@@ -353,6 +353,8 @@ export function AddMonitorDialog({ systemId, monitors }: { systemId?: string; mo
|
|||||||
const bulkFormRef = useRef<HTMLFormElement>(null)
|
const bulkFormRef = useRef<HTMLFormElement>(null)
|
||||||
const { toast } = useToast()
|
const { toast } = useToast()
|
||||||
const { t } = useLingui()
|
const { t } = useLingui()
|
||||||
|
const systems = useStore($systems)
|
||||||
|
const hasEligibleSystems = systemId ? true : systems.some(supportsNetworkMonitors)
|
||||||
|
|
||||||
const resetBulkForm = () => {
|
const resetBulkForm = () => {
|
||||||
setBulkInput("")
|
setBulkInput("")
|
||||||
@@ -443,14 +445,19 @@ export function AddMonitorDialog({ systemId, monitors }: { systemId?: string; mo
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex gap-0 rounded-lg">
|
<div className="flex gap-0 rounded-lg">
|
||||||
<Button variant="outline" onClick={openAdd} className="rounded-e-none grow">
|
<Button variant="outline" onClick={openAdd} className="rounded-e-none grow" disabled={!hasEligibleSystems}>
|
||||||
{/* <PlusIcon className="size-4 me-1" /> */}
|
{/* <PlusIcon className="size-4 me-1" /> */}
|
||||||
<Trans>Add {{ foo: t`Monitor` }}</Trans>
|
<Trans>Add {{ foo: t`Monitor` }}</Trans>
|
||||||
</Button>
|
</Button>
|
||||||
<div className="w-px h-full bg-muted"></div>
|
<div className="w-px h-full bg-muted"></div>
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button variant="outline" className="px-2 rounded-s-none border-s-0" aria-label={`More actions`}>
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
className="px-2 rounded-s-none border-s-0"
|
||||||
|
aria-label={`More actions`}
|
||||||
|
disabled={!hasEligibleSystems}
|
||||||
|
>
|
||||||
<ChevronDownIcon className="size-4" />
|
<ChevronDownIcon className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|||||||
Reference in New Issue
Block a user