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
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m7s
This commit is contained in:
@@ -1538,7 +1538,7 @@ function EditServerModal({ show, server, onChange, onSave, onClose }) {
|
|||||||
<label className="form-label">Тип туннеля</label>
|
<label className="form-label">Тип туннеля</label>
|
||||||
<input type="text" className="form-control" value={localServer.tunnel || ''} onChange={e => handleChange('tunnel', e.target.value)} />
|
<input type="text" className="form-control" value={localServer.tunnel || ''} onChange={e => handleChange('tunnel', e.target.value)} />
|
||||||
</div>
|
</div>
|
||||||
{NEEDS_GATEWAYS(localServer.type) && (
|
{NEEDS_GATEWAYS(localServer.type) && (
|
||||||
<>
|
<>
|
||||||
<div className="form-label">Шлюзы</div>
|
<div className="form-label">Шлюзы</div>
|
||||||
<div className="list-group list-group-flush border rounded mb-2">
|
<div className="list-group list-group-flush border rounded mb-2">
|
||||||
@@ -1633,13 +1633,15 @@ function EditServerModal({ show, server, onChange, onSave, onClose }) {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-outline-primary btn-sm"
|
className="btn btn-outline-primary btn-sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const list = Array.isArray(localServer.gateways) ? localServer.gateways : [];
|
setLocalServer((prev) => {
|
||||||
|
const list = Array.isArray(prev?.gateways) ? prev.gateways : [];
|
||||||
const nextList = [...list, makeGateway({ primary: list.length === 0 })];
|
const nextList = [...list, makeGateway({ primary: list.length === 0 })];
|
||||||
const next = { ...localServer, gateways: nextList };
|
const next = { ...(prev || {}), gateways: nextList };
|
||||||
setLocalServer(next);
|
|
||||||
onChange && onChange(next);
|
onChange && onChange(next);
|
||||||
}}
|
return next;
|
||||||
|
});
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<IconPlus className="icon" />
|
<IconPlus className="icon" />
|
||||||
Добавить шлюз
|
Добавить шлюз
|
||||||
|
|||||||
Reference in New Issue
Block a user