feat: Improve gateway handling in ServerManager by ensuring safe access to gateways array and enhancing the addition of new gateways, promoting better server configuration reliability.
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m1s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m1s
This commit is contained in:
@@ -1095,7 +1095,7 @@ function ServerManager() {
|
||||
<>
|
||||
<div className="form-label">Шлюзы</div>
|
||||
<div className="list-group list-group-flush border rounded mb-2">
|
||||
{newServer.gateways.map((gw, idx) => (
|
||||
{(newServer.gateways || []).map((gw, idx) => (
|
||||
<div key={gw.id || idx} className="list-group-item">
|
||||
<div className="row g-2 align-items-end">
|
||||
<div className="col-12 col-md-4">
|
||||
@@ -1177,7 +1177,12 @@ function ServerManager() {
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-outline-primary btn-sm"
|
||||
onClick={() => setNewServer({ ...newServer, gateways: [...newServer.gateways, makeGateway({ primary: newServer.gateways.length === 0 })] })}
|
||||
onClick={() => {
|
||||
setNewServer((prev) => {
|
||||
const list = Array.isArray(prev.gateways) ? prev.gateways : [];
|
||||
return { ...prev, gateways: [...list, makeGateway({ primary: list.length === 0 })] };
|
||||
});
|
||||
}}
|
||||
>
|
||||
<IconPlus className="icon" />
|
||||
Добавить шлюз
|
||||
@@ -1629,8 +1634,9 @@ function EditServerModal({ show, server, onChange, onSave, onClose }) {
|
||||
type="button"
|
||||
className="btn btn-outline-primary btn-sm"
|
||||
onClick={() => {
|
||||
const list = [...(localServer.gateways || []), makeGateway({ primary: !(localServer.gateways || []).length })];
|
||||
const next = { ...localServer, gateways: list };
|
||||
const list = Array.isArray(localServer.gateways) ? localServer.gateways : [];
|
||||
const nextList = [...list, makeGateway({ primary: list.length === 0 })];
|
||||
const next = { ...localServer, gateways: nextList };
|
||||
setLocalServer(next);
|
||||
onChange && onChange(next);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user