feat: Refactor gateway addition logic in EditServerModal to ensure safe state updates and improve clarity in handling gateways, enhancing server configuration reliability.
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m7s

This commit is contained in:
2025-12-07 00:47:35 +07:00
parent f246d5407a
commit e14839ca21
+8 -6
View File
@@ -1538,7 +1538,7 @@ function EditServerModal({ show, server, onChange, onSave, onClose }) {
<label className="form-label">Тип туннеля</label>
<input type="text" className="form-control" value={localServer.tunnel || ''} onChange={e => handleChange('tunnel', e.target.value)} />
</div>
{NEEDS_GATEWAYS(localServer.type) && (
{NEEDS_GATEWAYS(localServer.type) && (
<>
<div className="form-label">Шлюзы</div>
<div className="list-group list-group-flush border rounded mb-2">
@@ -1633,13 +1633,15 @@ function EditServerModal({ show, server, onChange, onSave, onClose }) {
<button
type="button"
className="btn btn-outline-primary btn-sm"
onClick={() => {
const list = Array.isArray(localServer.gateways) ? localServer.gateways : [];
onClick={() => {
setLocalServer((prev) => {
const list = Array.isArray(prev?.gateways) ? prev.gateways : [];
const nextList = [...list, makeGateway({ primary: list.length === 0 })];
const next = { ...localServer, gateways: nextList };
setLocalServer(next);
const next = { ...(prev || {}), gateways: nextList };
onChange && onChange(next);
}}
return next;
});
}}
>
<IconPlus className="icon" />
Добавить шлюз