mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-19 13:42:09 +03:00
Release v3.8.30 (#4267)
Release v3.8.30 — see CHANGELOG.md [3.8.30] for the full release notes.
This commit is contained in:
committed by
GitHub
parent
ab8096071c
commit
db362b0126
@@ -4,6 +4,12 @@ import { useState, useEffect, useMemo } from "react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import Modal from "./Modal";
|
||||
import Button from "./Button";
|
||||
import {
|
||||
type ProxyAssignmentItem,
|
||||
normalizeScopeId,
|
||||
isSameScopeAssignment,
|
||||
selectScopeAssignment,
|
||||
} from "./proxyAssignment";
|
||||
|
||||
const ALL_PROXY_TYPES = [
|
||||
{ value: "http", label: "HTTP" },
|
||||
@@ -33,12 +39,6 @@ type ProxyRegistryItem = {
|
||||
source?: string | null;
|
||||
};
|
||||
|
||||
type ProxyAssignmentItem = {
|
||||
proxyId?: string | null;
|
||||
scope?: string | null;
|
||||
scopeId?: string | null;
|
||||
};
|
||||
|
||||
type ProxyConfigModalProps = {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
@@ -59,20 +59,6 @@ function getAssignmentScopeId(level: ProxyConfigLevel, levelId?: string) {
|
||||
return level === "global" ? null : levelId || null;
|
||||
}
|
||||
|
||||
function normalizeScopeId(scopeId?: string | null) {
|
||||
return !scopeId || scopeId === "__global__" ? null : scopeId;
|
||||
}
|
||||
|
||||
function isSameScopeAssignment(
|
||||
assignment: ProxyAssignmentItem,
|
||||
scope: string,
|
||||
scopeId: string | null
|
||||
) {
|
||||
return (
|
||||
assignment.scope === scope && normalizeScopeId(assignment.scopeId) === normalizeScopeId(scopeId)
|
||||
);
|
||||
}
|
||||
|
||||
function getCustomProxyName(level: ProxyConfigLevel, levelId?: string, levelLabel?: string) {
|
||||
const label = levelLabel || levelId || "";
|
||||
const suffix = label ? ` (${label})` : "";
|
||||
@@ -95,7 +81,7 @@ async function fetchAssignmentForScope(scope: string, scopeId: string | null) {
|
||||
|
||||
const payload = await readJson(res);
|
||||
const items: ProxyAssignmentItem[] = Array.isArray(payload?.items) ? payload.items : [];
|
||||
return items.find((item) => isSameScopeAssignment(item, scope, scopeId)) || items[0] || null;
|
||||
return selectScopeAssignment(items, scope, scopeId);
|
||||
}
|
||||
|
||||
async function fetchRegistryProxy(proxyId: string, cachedProxies: ProxyRegistryItem[]) {
|
||||
@@ -198,8 +184,7 @@ export default function ProxyConfigModal({
|
||||
if (assignmentRes.ok) {
|
||||
const assignmentPayload = await assignmentRes.json();
|
||||
const items = Array.isArray(assignmentPayload?.items) ? assignmentPayload.items : [];
|
||||
const target =
|
||||
items.find((item) => isSameScopeAssignment(item, scope, scopeId)) || items[0];
|
||||
const target = selectScopeAssignment(items, scope, scopeId);
|
||||
if (target?.proxyId) {
|
||||
setSelectedProxyId(target.proxyId);
|
||||
setHasOwnProxy(true);
|
||||
|
||||
Reference in New Issue
Block a user