Skip to content

Commit b04a47a

Browse files
authored
Handle "in:true,false" variable rules as checkbox (pterodactyl#4334)
1 parent 8e1a215 commit b04a47a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

resources/scripts/components/server/startup/VariableBox.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ const VariableBox = ({ variable }: Props) => {
5252
.then(() => setLoading(false));
5353
}, 500);
5454

55-
const useSwitch = variable.rules.some((v) => v === 'boolean' || v === 'in:0,1');
55+
const useSwitch = variable.rules.some(
56+
(v) => v === 'boolean' || v === 'in:0,1' || v === 'in:1,0' || v === 'in:true,false' || v === 'in:false,true'
57+
);
58+
const isStringSwitch = variable.rules.some((v) => v === 'string');
5659
const selectValues = variable.rules.find((v) => v.startsWith('in:'))?.split(',') || [];
5760

5861
return (
@@ -73,10 +76,16 @@ const VariableBox = ({ variable }: Props) => {
7376
<Switch
7477
readOnly={!canEdit || !variable.isEditable}
7578
name={variable.envVariable}
76-
defaultChecked={variable.serverValue === '1'}
79+
defaultChecked={
80+
isStringSwitch ? variable.serverValue === 'true' : variable.serverValue === '1'
81+
}
7782
onChange={() => {
7883
if (canEdit && variable.isEditable) {
79-
setVariableValue(variable.serverValue === '1' ? '0' : '1');
84+
if (isStringSwitch) {
85+
setVariableValue(variable.serverValue === 'true' ? 'false' : 'true');
86+
} else {
87+
setVariableValue(variable.serverValue === '1' ? '0' : '1');
88+
}
8089
}
8190
}}
8291
/>

0 commit comments

Comments
 (0)