fix: Обновление фильтрации и валидации в компонентах ASNsNewManager, AutoUrlManager, DomainsNewManager, IPRangesManager и FilterManager. Добавлена проверка на null для предотвращения ошибок и улучшения стабильности приложения.
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m40s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m40s
This commit is contained in:
@@ -225,7 +225,7 @@ function IPRangesManager() {
|
||||
const [analyzeFilters, setAnalyzeFilters] = useState({ community: '', minMask: 0, maxMask: 32, type: 'any', supernet16: false });
|
||||
|
||||
const handlePreviewDiff = () => {
|
||||
const valid = items.filter(i => isValidCidr(i.ipRange) && isValidCommunity(i.community))
|
||||
const valid = items.filter(i => i != null && isValidCidr(i.ipRange) && isValidCommunity(i.community))
|
||||
.map(i => ({ ipRange: i.ipRange.trim(), community: String(i.community).trim() }));
|
||||
const unique = deduplicate(valid);
|
||||
setDiff(computeDiff(originalItems, unique));
|
||||
@@ -234,7 +234,7 @@ function IPRangesManager() {
|
||||
|
||||
const handleSaveChanges = async () => {
|
||||
// подготовим diff и спросим подтверждение только при массовых изменениях (>10)
|
||||
const valid = items.filter(i => isValidCidr(i.ipRange) && isValidCommunity(i.community))
|
||||
const valid = items.filter(i => i != null && isValidCidr(i.ipRange) && isValidCommunity(i.community))
|
||||
.map(i => ({ ipRange: i.ipRange.trim(), community: String(i.community).trim() }));
|
||||
const unique = deduplicate(valid);
|
||||
const diffData = computeDiff(originalItems, unique);
|
||||
@@ -329,7 +329,7 @@ function IPRangesManager() {
|
||||
const parsed = lines.map(l => {
|
||||
const [cidr, c] = l.split(/\s+/);
|
||||
return { ipRange: (cidr || '').trim(), community: (c || '').trim() };
|
||||
}).filter(i => isValidCidr(i.ipRange) && isValidCommunity(i.community));
|
||||
}).filter(i => i != null && isValidCidr(i.ipRange) && isValidCommunity(i.community));
|
||||
setItems(prev => {
|
||||
const merged = [...prev, ...parsed];
|
||||
const map = new Map();
|
||||
@@ -342,7 +342,7 @@ function IPRangesManager() {
|
||||
};
|
||||
|
||||
const clearInvalid = () => {
|
||||
setItems(prev => prev.filter(i => i.ipRange || i.community)
|
||||
setItems(prev => prev.filter(i => i != null && (i.ipRange || i.community))
|
||||
.filter(i => isValidCidr(i.ipRange) && isValidCommunity(i.community))
|
||||
);
|
||||
};
|
||||
@@ -603,7 +603,7 @@ function IPRangesManager() {
|
||||
const community = String(analyzeFilters.community || '').trim();
|
||||
if (!community) { window.notify?.error?.('Выберите community'); return; }
|
||||
// исходные для community
|
||||
const allForCommunity = items.filter(i => i.community === community && isValidCidr(i.ipRange));
|
||||
const allForCommunity = items.filter(i => i != null && i.community === community && isValidCidr(i.ipRange));
|
||||
const totalBefore = allForCommunity.length;
|
||||
|
||||
const filtered = allForCommunity.filter(i => {
|
||||
@@ -641,7 +641,7 @@ function IPRangesManager() {
|
||||
const applyAnalysisToItems = () => {
|
||||
if (!analysisPreview) return;
|
||||
const { community, afterCidrs, unchangedCidrs } = analysisPreview;
|
||||
const keptOthers = items.filter(i => i.community !== community);
|
||||
const keptOthers = items.filter(i => i != null && i.community !== community);
|
||||
const newCommunityItems = [
|
||||
...unchangedCidrs.map(ipRange => ({ ipRange, community })),
|
||||
...afterCidrs.map(ipRange => ({ ipRange, community }))
|
||||
@@ -1054,7 +1054,7 @@ function IPRangesManager() {
|
||||
message={`Будут удалены все IP-диапазоны с community "${filterCommunity}". Действие НЕ сохраняет изменения автоматически.`}
|
||||
confirmText={'Удалить'}
|
||||
cancelText={'Отмена'}
|
||||
onConfirm={() => { setItems(prev => prev.filter(i => i.community !== filterCommunity)); setClearCommunitiesOpen(false); }}
|
||||
onConfirm={() => { setItems(prev => prev.filter(i => i != null && i.community !== filterCommunity)); setClearCommunitiesOpen(false); }}
|
||||
onCancel={() => setClearCommunitiesOpen(false)}
|
||||
/>
|
||||
{/* Analyze Settings Modal */}
|
||||
|
||||
Reference in New Issue
Block a user