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',
|
||||
header: t('protocols'),
|
||||
cell: ({ row }) => {
|
||||
const list = row.original.protocols.filter(
|
||||
(p) => p.enable !== false,
|
||||
) as API.Protocol[];
|
||||
const list = row.original.protocols.filter((p) => p.enable) as API.Protocol[];
|
||||
if (!list.length) return '—';
|
||||
return (
|
||||
<div className='flex flex-col gap-1'>
|
||||
|
||||
@ -492,7 +492,7 @@ export default function ServerForm(props: {
|
||||
PROTOCOLS.findIndex((t) => t === type),
|
||||
);
|
||||
const current = (protocolsValues[i] || {}) as Record<string, any>;
|
||||
const isEnabled = current?.enable !== false;
|
||||
const isEnabled = current?.enable;
|
||||
const fields = PROTOCOL_FIELDS[type] || [];
|
||||
return (
|
||||
<AccordionItem key={type} value={type} className='mb-2 rounded-lg border'>
|
||||
@ -529,7 +529,8 @@ export default function ServerForm(props: {
|
||||
checked={!!isEnabled}
|
||||
disabled={Boolean(
|
||||
initialValues?.id &&
|
||||
isProtocolUsedInNodes(initialValues?.id || 0, type),
|
||||
isProtocolUsedInNodes(initialValues?.id || 0, type) &&
|
||||
isEnabled,
|
||||
)}
|
||||
onCheckedChange={(checked) => {
|
||||
form.setValue(`protocols.${i}.enable`, checked);
|
||||
|
||||
@ -65,7 +65,7 @@ export const useServerStore = create<ServerState>((set, get) => ({
|
||||
|
||||
getServerEnabledProtocols: (serverId: number) => {
|
||||
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) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user