From 1c953ed9d83a701ca106d67f886edd9183afbcbc Mon Sep 17 00:00:00 2001 From: shats Date: Mon, 16 Feb 2026 18:07:48 +0700 Subject: [PATCH] refactor(Managers): replace modal implementation with FormModal for community editing in ASNs, Domains, and IPRanges managers to enhance code maintainability and user experience --- frontend/src/ASNsNewManager.jsx | 83 ++++++++++++------------------ frontend/src/DomainsNewManager.jsx | 83 ++++++++++++------------------ frontend/src/IPRangesManager.jsx | 83 ++++++++++++------------------ 3 files changed, 102 insertions(+), 147 deletions(-) diff --git a/frontend/src/ASNsNewManager.jsx b/frontend/src/ASNsNewManager.jsx index a07b987..c95eebe 100644 --- a/frontend/src/ASNsNewManager.jsx +++ b/frontend/src/ASNsNewManager.jsx @@ -40,6 +40,7 @@ import BulkActionsBar from './components/BulkActionsBar.jsx'; import Tooltip from './components/Tooltip.jsx'; import Pagination from './components/Pagination.jsx'; import AddItemModal from './components/AddItemModal.jsx'; +import FormModal from './components/FormModal.jsx'; import { getAsnName, getAsnNameSync } from './lib/asn.js'; import LastSaved from './components/LastSaved.jsx'; @@ -847,57 +848,41 @@ function ASNsNewManager() { placeholder={'12345 65000:100'} /> {/* Модальное окно редактирования community */} - {editModalOpen && itemBeingEdited && ( -
-
-
- -
-

Редактировать community

-
-
-

- ASN: {itemBeingEdited.asn} -

-
- - - {!isValidCommunity(editingValue) && ( -
- Введите корректное значение community (число или N:N). -
- )} + + {itemBeingEdited && ( + <> +

+ ASN: {itemBeingEdited.asn} +

+
+ + + {!isValidCommunity(editingValue) && ( +
+ Введите корректное значение community (число или N:N).
-
-
- - -
+ )}
-
-
- )} + + )} + setWsOpen(false)} /> {/* Модальное окно редактирования community */} - {editModalOpen && itemBeingEdited && ( -
-
-
- -
-

Редактировать community

-
-
-

- Домен: {itemBeingEdited.domain} -

-
- - - {!isValidCommunity(editingValue) && ( -
- Введите корректное значение community (число или N:N). -
- )} + + {itemBeingEdited && ( + <> +

+ Домен: {itemBeingEdited.domain} +

+
+ + + {!isValidCommunity(editingValue) && ( +
+ Введите корректное значение community (число или N:N).
-
-
- - -
+ )}
-
-
- )} + + )} + setClearCommunitiesOpen(false)} diff --git a/frontend/src/IPRangesManager.jsx b/frontend/src/IPRangesManager.jsx index e0a1b3b..5c1d26a 100644 --- a/frontend/src/IPRangesManager.jsx +++ b/frontend/src/IPRangesManager.jsx @@ -43,6 +43,7 @@ import Tooltip from './components/Tooltip.jsx'; import Pagination from './components/Pagination.jsx'; import AddItemModal from './components/AddItemModal.jsx'; import LastSaved from './components/LastSaved.jsx'; +import FormModal from './components/FormModal.jsx'; const API_URL = '/api'; @@ -1084,57 +1085,41 @@ function IPRangesManager() { placeholder={'192.168.1.0/24 65000:100'} /> {/* Модальное окно редактирования community */} - {editModalOpen && itemBeingEdited && ( -
-
-
- -
-

Редактировать community

-
-
-

- IP-диапазон: {itemBeingEdited.ipRange} -

-
- - - {!isValidCommunity(editingValue) && ( -
- Введите корректное значение community (число или N:N). -
- )} + + {itemBeingEdited && ( + <> +

+ IP-диапазон: {itemBeingEdited.ipRange} +

+
+ + + {!isValidCommunity(editingValue) && ( +
+ Введите корректное значение community (число или N:N).
-
-
- - -
+ )}
-
-
- )} + + )} +