Enhance node update functionality to include base address
CI / Backend (build + test) (push) Successful in 1m25s
CI / Frontend (lint + typecheck + build) (push) Successful in 33s

- Added `BaseAddress` property to `UpdateNodeCommand` and `UpdateNodeBody` for improved node management.
- Implemented validation for the base address in `UpdateNodeCommandHandler`, ensuring it is a valid absolute URI.
- Updated `Node` class to support address updates, including logic to invalidate cached clients on address changes.
- Enhanced frontend components to handle base address input in the node editing dialog and API requests.
- Updated validation rules to enforce base address requirements in `UpdateNodeCommandValidator`.
This commit is contained in:
Leonid Pershin
2026-07-23 01:05:02 +03:00
parent 6b449dbfb5
commit ee6b8a35b8
10 changed files with 270 additions and 10 deletions
@@ -14,13 +14,15 @@ export function EditNodeDialog({ node, open, onOpenChange }: { node: NodeDto; op
const { t } = useTranslation()
const queryClient = useQueryClient()
const [name, setName] = useState(node.name)
const [baseAddress, setBaseAddress] = useState(node.baseAddress)
const [location, setLocation] = useState(node.location ?? '')
const [isEnabled, setIsEnabled] = useState(node.isEnabled)
const [username, setUsername] = useState('')
const [username, setUsername] = useState(node.username)
const [password, setPassword] = useState('')
const mutation = useMutation({
mutationFn: () => updateNode(node.id, name.trim(), location.trim() || undefined, isEnabled, username.trim() || undefined, password || undefined),
mutationFn: () =>
updateNode(node.id, name.trim(), baseAddress.trim(), location.trim() || undefined, isEnabled, username.trim() || undefined, password || undefined),
onSuccess: async () => {
toast.success(t('admin.nodes.updated'))
await queryClient.invalidateQueries({ queryKey: ['admin-nodes'] })
@@ -46,6 +48,16 @@ export function EditNodeDialog({ node, open, onOpenChange }: { node: NodeDto; op
<Label htmlFor="editName">{t('admin.nodes.name')}</Label>
<Input id="editName" value={name} onChange={(e) => setName(e.target.value)} required />
</div>
<div className="flex flex-col gap-1.5">
<Label htmlFor="editBaseAddress">{t('admin.nodes.baseAddress')}</Label>
<Input
id="editBaseAddress"
placeholder="https://panel.example.com:2053"
value={baseAddress}
onChange={(e) => setBaseAddress(e.target.value)}
required
/>
</div>
<div className="flex flex-col gap-1.5">
<Label htmlFor="editLocation">{t('admin.nodes.location')}</Label>
<Input id="editLocation" value={location} onChange={(e) => setLocation(e.target.value)} />
@@ -62,7 +74,7 @@ export function EditNodeDialog({ node, open, onOpenChange }: { node: NodeDto; op
</div>
<div className="flex flex-col gap-1.5">
<Label htmlFor="editPassword">
{t('admin.nodes.password')} ({t('admin.nodes.optional')})
{t('admin.nodes.password')} ({t('admin.nodes.passwordKeepUnchanged')})
</Label>
<Input
id="editPassword"
@@ -72,11 +84,12 @@ export function EditNodeDialog({ node, open, onOpenChange }: { node: NodeDto; op
data-1p-ignore
data-bwignore
data-form-type="other"
placeholder="••••••••"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
</div>
<Button type="submit" disabled={!name.trim() || mutation.isPending}>
<Button type="submit" disabled={!name.trim() || !baseAddress.trim() || mutation.isPending}>
{t('admin.roles.save')}
</Button>
</form>