Files
pterodactyl-panel/resources/scripts/components/admin/mounts/MountFormFields.tsx
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

121 lines
3.8 KiB
TypeScript

import type { AppForm } from '@/components/form';
import type { MountValues } from '@/api/admin/mounts/queries';
import TitledGreyBox from '@/components/elements/TitledGreyBox';
interface Props {
form: AppForm<MountValues>;
}
const DetailsFields = ({ form }: Props) => (
<div className={'space-y-6'}>
<form.AppField
name={'name'}
validators={{
onChange: ({ value }) =>
value.length < 2
? 'A name must be at least 2 characters.'
: value.length > 64
? 'A name must not exceed 64 characters.'
: undefined,
}}
>
{(field) => (
<field.TextField
type={'text'}
id={'name'}
label={'Name'}
description={'A unique name used to identify this mount.'}
/>
)}
</form.AppField>
<form.AppField
name={'description'}
validators={{
onChange: ({ value }) =>
value.length <= 191 ? undefined : 'A description must not exceed 191 characters.',
}}
>
{(field) => (
<field.TextField
type={'text'}
id={'description'}
label={'Description'}
description={'A longer description for this mount.'}
/>
)}
</form.AppField>
</div>
);
const PathFields = ({ form }: Props) => (
<div className={'grid grid-cols-1 lg:grid-cols-2 gap-6'}>
<form.AppField
name={'source'}
validators={{
onChange: ({ value }) => (value.length >= 1 ? undefined : 'A source path must be provided.'),
}}
>
{(field) => (
<field.TextField
type={'text'}
id={'source'}
label={'Source'}
description={'The path on the host system to mount into the container.'}
/>
)}
</form.AppField>
<form.AppField
name={'target'}
validators={{
onChange: ({ value }) => (value.length >= 1 ? undefined : 'A target path must be provided.'),
}}
>
{(field) => (
<field.TextField
type={'text'}
id={'target'}
label={'Target'}
description={'The path inside the container where the source will be mounted.'}
/>
)}
</form.AppField>
</div>
);
const AccessFields = ({ form }: Props) => (
<div className={'space-y-6'}>
<form.AppField name={'readOnly'}>
{(field) => (
<field.SwitchField
label={'Read Only'}
description={'Mount this volume as read only inside the container.'}
/>
)}
</form.AppField>
<form.AppField name={'userMountable'}>
{(field) => (
<field.SwitchField
label={'User Mountable'}
description={'Allow this mount to be added to servers by users.'}
/>
)}
</form.AppField>
</div>
);
export default function MountFormFields({ form }: Props) {
return (
<div className={'space-y-6'}>
<TitledGreyBox title={'Mount Details'}>
<DetailsFields form={form} />
</TitledGreyBox>
<TitledGreyBox title={'Paths'}>
<PathFields form={form} />
</TitledGreyBox>
<TitledGreyBox title={'Access'}>
<AccessFields form={form} />
</TitledGreyBox>
</div>
);
}