mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-02-06 03:30:25 -05:00
🐛 fix: Simplify protocol enable checks by removing unnecessary false comparisons
This commit is contained in:
parent
35e1cef18e
commit
4828700776
@ -155,9 +155,7 @@ export default function ServersPage() {
|
|||||||
accessorKey: 'protocols',
|
accessorKey: 'protocols',
|
||||||
header: t('protocols'),
|
header: t('protocols'),
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const list = row.original.protocols.filter(
|
const list = row.original.protocols.filter((p) => p.enable) as API.Protocol[];
|
||||||
(p) => p.enable !== false,
|
|
||||||
) as API.Protocol[];
|
|
||||||
if (!list.length) return '—';
|
if (!list.length) return '—';
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col gap-1'>
|
<div className='flex flex-col gap-1'>
|
||||||
|
|||||||
@ -492,7 +492,7 @@ export default function ServerForm(props: {
|
|||||||
PROTOCOLS.findIndex((t) => t === type),
|
PROTOCOLS.findIndex((t) => t === type),
|
||||||
);
|
);
|
||||||
const current = (protocolsValues[i] || {}) as Record<string, any>;
|
const current = (protocolsValues[i] || {}) as Record<string, any>;
|
||||||
const isEnabled = current?.enable !== false;
|
const isEnabled = current?.enable;
|
||||||
const fields = PROTOCOL_FIELDS[type] || [];
|
const fields = PROTOCOL_FIELDS[type] || [];
|
||||||
return (
|
return (
|
||||||
<AccordionItem key={type} value={type} className='mb-2 rounded-lg border'>
|
<AccordionItem key={type} value={type} className='mb-2 rounded-lg border'>
|
||||||
@ -529,7 +529,8 @@ export default function ServerForm(props: {
|
|||||||
checked={!!isEnabled}
|
checked={!!isEnabled}
|
||||||
disabled={Boolean(
|
disabled={Boolean(
|
||||||
initialValues?.id &&
|
initialValues?.id &&
|
||||||
isProtocolUsedInNodes(initialValues?.id || 0, type),
|
isProtocolUsedInNodes(initialValues?.id || 0, type) &&
|
||||||
|
isEnabled,
|
||||||
)}
|
)}
|
||||||
onCheckedChange={(checked) => {
|
onCheckedChange={(checked) => {
|
||||||
form.setValue(`protocols.${i}.enable`, checked);
|
form.setValue(`protocols.${i}.enable`, checked);
|
||||||
|
|||||||
@ -65,7 +65,7 @@ export const useServerStore = create<ServerState>((set, get) => ({
|
|||||||
|
|
||||||
getServerEnabledProtocols: (serverId: number) => {
|
getServerEnabledProtocols: (serverId: number) => {
|
||||||
const server = get().servers.find((s) => s.id === serverId);
|
const server = get().servers.find((s) => s.id === serverId);
|
||||||
return server?.protocols?.filter((p) => p.enable !== false) || [];
|
return server?.protocols?.filter((p) => p.enable) || [];
|
||||||
},
|
},
|
||||||
|
|
||||||
getProtocolPort: (serverId?: number, protocol?: string) => {
|
getProtocolPort: (serverId?: number, protocol?: string) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user