feat: Добавить уведомления об успешных мутациях и глобальные горячие клавиши для сохранения изменений в менеджерах ASNs, Domains и IPRanges
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m43s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m43s
This commit is contained in:
@@ -17,7 +17,6 @@ import {
|
||||
IconClock,
|
||||
IconFileText
|
||||
} from '@tabler/icons-react';
|
||||
import LockBanner from './components/LockBanner.jsx';
|
||||
import TableSkeleton from './components/TableSkeleton.jsx';
|
||||
import S3MetaBar from './components/S3MetaBar.jsx';
|
||||
import PageHeaderActions from './components/PageHeaderActions.jsx';
|
||||
@@ -25,6 +24,8 @@ import ConfirmDialog from './components/ConfirmDialog.jsx';
|
||||
import WsUpdateModal from './components/WsUpdateModal.jsx';
|
||||
import ConfirmDiffModal from './components/ConfirmDiffModal.jsx';
|
||||
import HistoryModal from './components/HistoryModal.jsx';
|
||||
import ErrorAlert from './components/ErrorAlert.jsx';
|
||||
import { notifyMutationSuccess } from './components/NotifyProvider.jsx';
|
||||
|
||||
const API_URL = '/api';
|
||||
|
||||
@@ -282,6 +283,7 @@ function IPRangesManager() {
|
||||
setItems(unique);
|
||||
setSuccess('Изменения успешно сохранены!');
|
||||
setTimeout(() => setSuccess(''), 3000);
|
||||
notifyMutationSuccess('Изменения сохранены');
|
||||
} catch (error) {
|
||||
console.error('Error saving changes:', error);
|
||||
setError('Не удалось сохранить изменения.');
|
||||
@@ -390,6 +392,17 @@ function IPRangesManager() {
|
||||
editInputRef.current.focus();
|
||||
}
|
||||
}, [editingIp]);
|
||||
// Глобальные хоткеи: Ctrl+S — сохранить изменения
|
||||
useEffect(() => {
|
||||
const onKey = (e) => {
|
||||
if ((e.ctrlKey || e.metaKey) && (e.key === 's' || e.key === 'S')) {
|
||||
e.preventDefault();
|
||||
if (!loading) handleSaveChanges();
|
||||
}
|
||||
};
|
||||
window.addEventListener('keydown', onKey);
|
||||
return () => window.removeEventListener('keydown', onKey);
|
||||
}, [loading, items, originalItems, etag, sortField, sortOrder, filterCommunity]);
|
||||
|
||||
const handleEditKeyDown = (e, ipRange) => {
|
||||
if (e.key === 'Enter') handleSaveEdit(ipRange);
|
||||
@@ -638,17 +651,7 @@ function IPRangesManager() {
|
||||
return (
|
||||
<>
|
||||
{error && (
|
||||
<div className="alert alert-danger alert-dismissible" role="alert">
|
||||
<div className="d-flex">
|
||||
<div>
|
||||
<IconX className="icon alert-icon" />
|
||||
</div>
|
||||
<div>
|
||||
{error}
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" className="btn-close" onClick={() => setError('')}></button>
|
||||
</div>
|
||||
<ErrorAlert message={error} onClose={() => setError('')} />
|
||||
)}
|
||||
|
||||
{success && (
|
||||
@@ -694,7 +697,7 @@ function IPRangesManager() {
|
||||
if (!res.ok || data.ok === false) {
|
||||
throw new Error(data?.message || `HTTP ${res.status}`);
|
||||
}
|
||||
window.notify?.success('Фоновое обновление запущено', data);
|
||||
notifyMutationSuccess('Фоновое обновление запущено', data);
|
||||
} catch (e) {
|
||||
window.notify?.error('Не удалось запустить фоновое обновление', String(e));
|
||||
}
|
||||
@@ -705,7 +708,6 @@ function IPRangesManager() {
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="col-lg-3">
|
||||
<LockBanner resource="ip-ranges" className="mb-3" />
|
||||
{/* Add New Item Card */}
|
||||
<div className="card card-md">
|
||||
<div className="card-header">
|
||||
@@ -726,6 +728,7 @@ function IPRangesManager() {
|
||||
onChange={(e) => setNewItem({ ...newItem, ipRange: e.target.value })}
|
||||
/>
|
||||
{newInvalid.ipRange && <div className="invalid-feedback">Некорректный CIDR</div>}
|
||||
<div className="form-text">Формат: A.B.C.D/Маска, например 10.0.0.0/24</div>
|
||||
</div>
|
||||
<div className="mb-3">
|
||||
<label className="form-label">Community</label>
|
||||
@@ -848,6 +851,7 @@ function IPRangesManager() {
|
||||
onChange={setEditingValue}
|
||||
communities={communities}
|
||||
className={`form-control d-inline-block w-auto me-2${isValidCommunity(editingValue) ? '' : ' is-invalid'}`}
|
||||
onKeyDown={(e) => handleEditKeyDown(e, item.ipRange)}
|
||||
/>
|
||||
<button className="btn btn-success btn-icon btn-sm me-1" onClick={() => handleSaveEdit(item.ipRange)} disabled={!isValidCommunity(editingValue)}><IconCheck size={16} /></button>
|
||||
<button className="btn btn-secondary btn-icon btn-sm" onClick={handleCancelEdit}><IconX size={16} /></button>
|
||||
|
||||
Reference in New Issue
Block a user