forked from Alex/Pterodactyl-Panel
Don't allow editing read only values; closes #2252
This commit is contained in:
parent
92929c45d5
commit
5173f1f7e8
@ -55,9 +55,13 @@ class StartupController extends ClientApiController
|
|||||||
/** @var \Pterodactyl\Models\EggVariable $variable */
|
/** @var \Pterodactyl\Models\EggVariable $variable */
|
||||||
$variable = $server->variables()->where('env_variable', $request->input('key'))->first();
|
$variable = $server->variables()->where('env_variable', $request->input('key'))->first();
|
||||||
|
|
||||||
if (is_null($variable) || !$variable->user_viewable || !$variable->user_editable) {
|
if (is_null($variable) || !$variable->user_viewable) {
|
||||||
throw new BadRequestHttpException(
|
throw new BadRequestHttpException(
|
||||||
"The environment variable you are trying to edit [\"{$request->input('key')}\"] does not exist."
|
"The environment variable you are trying to edit does not exist."
|
||||||
|
);
|
||||||
|
} else if (! $variable->user_editable) {
|
||||||
|
throw new BadRequestHttpException(
|
||||||
|
"The environment variable you are trying to edit is read-only."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,12 +43,25 @@ const VariableBox = ({ variable }: Props) => {
|
|||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TitledGreyBox title={variable.name}>
|
<TitledGreyBox
|
||||||
|
title={
|
||||||
|
<p css={tw`text-sm uppercase`}>
|
||||||
|
{!variable.isEditable &&
|
||||||
|
<span css={tw`bg-neutral-700 text-xs py-1 px-2 rounded-full mr-2`}>Read Only</span>
|
||||||
|
}
|
||||||
|
{variable.name}
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
>
|
||||||
<FlashMessageRender byKey={FLASH_KEY} css={tw`mb-4`}/>
|
<FlashMessageRender byKey={FLASH_KEY} css={tw`mb-4`}/>
|
||||||
<InputSpinner visible={loading}>
|
<InputSpinner visible={loading}>
|
||||||
<Input
|
<Input
|
||||||
onKeyUp={e => setVariableValue(e.currentTarget.value)}
|
onKeyUp={e => {
|
||||||
readOnly={!canEdit}
|
if (canEdit && variable.isEditable) {
|
||||||
|
setVariableValue(e.currentTarget.value);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
readOnly={!canEdit || !variable.isEditable}
|
||||||
name={variable.envVariable}
|
name={variable.envVariable}
|
||||||
defaultValue={variable.serverValue}
|
defaultValue={variable.serverValue}
|
||||||
placeholder={variable.defaultValue}
|
placeholder={variable.defaultValue}
|
||||||
|
Loading…
Reference in New Issue
Block a user