1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-22 00:52:43 +01:00

ui(server): fix defaultValue not being used with VariableBox select

This commit is contained in:
Matthew Penner 2023-10-20 19:30:25 -06:00
parent 341eda7855
commit 8abf2d8106
No known key found for this signature in database
2 changed files with 10 additions and 8 deletions

View File

@ -23,7 +23,7 @@ export interface ServerEggVariable {
description: string; description: string;
envVariable: string; envVariable: string;
defaultValue: string; defaultValue: string;
serverValue: string; serverValue: string | null;
isEditable: boolean; isEditable: boolean;
rules: string[]; rules: string[];
} }

View File

@ -5,7 +5,6 @@ import { usePermissions } from '@/plugins/usePermissions';
import InputSpinner from '@/components/elements/InputSpinner'; import InputSpinner from '@/components/elements/InputSpinner';
import Input from '@/components/elements/Input'; import Input from '@/components/elements/Input';
import Switch from '@/components/elements/Switch'; import Switch from '@/components/elements/Switch';
import tw from 'twin.macro';
import { debounce } from 'debounce'; import { debounce } from 'debounce';
import updateStartupVariable from '@/api/server/updateStartupVariable'; import updateStartupVariable from '@/api/server/updateStartupVariable';
import useFlash from '@/plugins/useFlash'; import useFlash from '@/plugins/useFlash';
@ -61,15 +60,15 @@ const VariableBox = ({ variable }: Props) => {
return ( return (
<TitledGreyBox <TitledGreyBox
title={ title={
<p css={tw`text-sm uppercase`}> <p className="text-sm uppercase">
{!variable.isEditable && ( {!variable.isEditable && (
<span css={tw`bg-neutral-700 text-xs py-1 px-2 rounded-full mr-2 mb-1`}>Read Only</span> <span className="bg-neutral-700 text-xs py-1 px-2 rounded-full mr-2 mb-1">Read Only</span>
)} )}
{variable.name} {variable.name}
</p> </p>
} }
> >
<FlashMessageRender byKey={FLASH_KEY} css={tw`mb-2 md:mb-4`} /> <FlashMessageRender byKey={FLASH_KEY} className="mb-2 md:mb-4" />
<InputSpinner visible={loading}> <InputSpinner visible={loading}>
{useSwitch ? ( {useSwitch ? (
<> <>
@ -97,7 +96,7 @@ const VariableBox = ({ variable }: Props) => {
<Select <Select
onChange={(e) => setVariableValue(e.target.value)} onChange={(e) => setVariableValue(e.target.value)}
name={variable.envVariable} name={variable.envVariable}
defaultValue={variable.serverValue} defaultValue={variable.serverValue ?? variable.defaultValue}
disabled={!canEdit || !variable.isEditable} disabled={!canEdit || !variable.isEditable}
> >
{selectValues.map((selectValue) => ( {selectValues.map((selectValue) => (
@ -120,7 +119,7 @@ const VariableBox = ({ variable }: Props) => {
}} }}
readOnly={!canEdit || !variable.isEditable} readOnly={!canEdit || !variable.isEditable}
name={variable.envVariable} name={variable.envVariable}
defaultValue={variable.serverValue} defaultValue={variable.serverValue ?? ''}
placeholder={variable.defaultValue} placeholder={variable.defaultValue}
/> />
</> </>
@ -128,7 +127,10 @@ const VariableBox = ({ variable }: Props) => {
</> </>
)} )}
</InputSpinner> </InputSpinner>
<p css={tw`mt-1 text-xs text-neutral-300`}>{variable.description}</p>
<p className="mt-1 text-xs text-neutral-300">
{variable.description}
</p>
</TitledGreyBox> </TitledGreyBox>
); );
}; };