From b04a47a4a44fa299fcb2bc262a7c5f3fc598288d Mon Sep 17 00:00:00 2001 From: Boy132 Date: Sun, 25 Sep 2022 21:18:13 +0200 Subject: [PATCH] Handle "in:true,false" variable rules as checkbox (#4334) --- .../components/server/startup/VariableBox.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/resources/scripts/components/server/startup/VariableBox.tsx b/resources/scripts/components/server/startup/VariableBox.tsx index 3154e7fdc..ad73615c6 100644 --- a/resources/scripts/components/server/startup/VariableBox.tsx +++ b/resources/scripts/components/server/startup/VariableBox.tsx @@ -52,7 +52,10 @@ const VariableBox = ({ variable }: Props) => { .then(() => setLoading(false)); }, 500); - const useSwitch = variable.rules.some((v) => v === 'boolean' || v === 'in:0,1'); + const useSwitch = variable.rules.some( + (v) => v === 'boolean' || v === 'in:0,1' || v === 'in:1,0' || v === 'in:true,false' || v === 'in:false,true' + ); + const isStringSwitch = variable.rules.some((v) => v === 'string'); const selectValues = variable.rules.find((v) => v.startsWith('in:'))?.split(',') || []; return ( @@ -73,10 +76,16 @@ const VariableBox = ({ variable }: Props) => { { if (canEdit && variable.isEditable) { - setVariableValue(variable.serverValue === '1' ? '0' : '1'); + if (isStringSwitch) { + setVariableValue(variable.serverValue === 'true' ? 'false' : 'true'); + } else { + setVariableValue(variable.serverValue === '1' ? '0' : '1'); + } } }} />