mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-12 02:02:13 +03:00
refactor(settings): reduce proxy registry component size
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { z } from "zod";
|
||||
import { Button, Card, Modal } from "@/shared/components";
|
||||
import { useProxyBatchOperations } from "./useProxyBatchOperations";
|
||||
import { ProxyStatusBadge } from "./ProxyStatusBadge";
|
||||
@@ -24,7 +23,12 @@ import {
|
||||
type TestResult,
|
||||
type UsageInfo,
|
||||
} from "./proxyRegistryConstants";
|
||||
import { loadAllProxyUsage, loadProxyHealth, loadProxyUsage } from "./proxyRegistryData";
|
||||
import {
|
||||
loadAllProxyUsage,
|
||||
loadProxyHealth,
|
||||
loadProxyUsage,
|
||||
repairRelayResponseSchema,
|
||||
} from "./proxyRegistryData";
|
||||
|
||||
export default function ProxyRegistryManager({
|
||||
onRedeployRelay,
|
||||
@@ -164,17 +168,9 @@ import { loadAllProxyUsage, loadProxyHealth, loadProxyUsage } from "./proxyRegis
|
||||
|
||||
const allSelected = items.length > 0 && items.every((item) => selectedIds.has(item.id));
|
||||
|
||||
const handleBatchDelete = useCallback(() => {
|
||||
hookHandleBatchDelete(setError);
|
||||
}, [hookHandleBatchDelete, setError]);
|
||||
|
||||
const handleBatchActivate = useCallback(() => {
|
||||
hookHandleBatchActivate(setError, "active");
|
||||
}, [hookHandleBatchActivate, setError]);
|
||||
|
||||
const handleAutoTestAll = useCallback(() => {
|
||||
hookHandleAutoTestAll(setError, setTestById);
|
||||
}, [hookHandleAutoTestAll, setError, setTestById]);
|
||||
const handleBatchDelete = () => hookHandleBatchDelete(setError);
|
||||
const handleBatchActivate = () => hookHandleBatchActivate(setError, "active");
|
||||
const handleAutoTestAll = () => hookHandleAutoTestAll(setError, setTestById);
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
@@ -243,12 +239,6 @@ import { loadAllProxyUsage, loadProxyHealth, loadProxyUsage } from "./proxyRegis
|
||||
}
|
||||
};
|
||||
|
||||
const repairRelayResponseSchema = z.object({
|
||||
repaired: z.boolean().optional(),
|
||||
mode: z.enum(["noop", "recovered", "redeploy"]).optional(),
|
||||
error: z.object({ message: z.string() }).optional(),
|
||||
});
|
||||
|
||||
const handleRepairRelay = async (item: ProxyItem) => {
|
||||
if (repairingId || !item.relayInfo?.isRelay) return;
|
||||
setRepairingId(item.id);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { z } from "zod";
|
||||
import type { HealthInfo, UsageInfo } from "./proxyRegistryConstants";
|
||||
|
||||
type SetState<T> = (value: T | ((previous: T) => T)) => void;
|
||||
@@ -50,6 +51,12 @@ export async function loadAllProxyUsage(
|
||||
}
|
||||
}
|
||||
|
||||
export const repairRelayResponseSchema = z.object({
|
||||
repaired: z.boolean().optional(),
|
||||
mode: z.enum(["noop", "recovered", "redeploy"]).optional(),
|
||||
error: z.object({ message: z.string() }).optional(),
|
||||
});
|
||||
|
||||
export async function loadProxyUsage(
|
||||
proxyId: string,
|
||||
setUsageById: SetState<Record<string, UsageInfo>>
|
||||
|
||||
Reference in New Issue
Block a user