Files
pterodactyl-panel/resources/scripts/components/admin/settings/GeneralSettingsForm.tsx
T
ItzLinaton 60b72365d8 Feat: Custom User Avatars (V2) (#7295)
Added custom user avatar support.

## Extra Details:
- Users can upload custom `PNG, JPEG, SVG, WebP, AVIF`, and `ICO`
avatars.
- Added avatar management to the user account area.
- Added admin controls to update and remove user avatars.
- Custom User avatars appear in:
  - Panel Navbar.
  - Panel Admin Activity Logs.
  - Server Sub user List.
  - Server Activity Logs
  - Personal Account Activity Logs.
  - Server Ownership Details.
  
---

<img width="1329" height="327"
alt="{B32EBD7F-1FCA-4356-966C-0D60A9A23E49}"
src="https://github.com/user-attachments/assets/881fa5b3-9599-4370-975d-83b6bd91a7d1"
/>

---

<img width="997" height="847" alt="adminpage"
src="https://github.com/user-attachments/assets/989acbcc-351c-431b-ab7f-557ba4c7e070"
/>

---

<img width="955" height="781" alt="serverinfo"
src="https://github.com/user-attachments/assets/6556afac-1971-4112-9686-b71137072c5f"
/>

---

<img width="1376" height="919" alt="userarea"
src="https://github.com/user-attachments/assets/d49f0ddb-1f38-4884-b186-8db78bfed4b0"
/>

---

<img width="936" height="232" alt="userslist"
src="https://github.com/user-attachments/assets/0e8a4b4a-719a-4d52-a485-d7577736b43f"
/>

---

<img width="983" height="772" alt="activity"
src="https://github.com/user-attachments/assets/37ef7176-a804-43f7-ae32-ae65e1a2671b"
/>
2026-10-20 15:09:33 -04:00

98 lines
4.3 KiB
TypeScript

import { useAppForm, Form } from '@/components/form';
import type { AdminSettings } from '@/api/admin/settings/queries';
import { useAdminLanguages } from '@/api/admin/languages/queries';
import { updateAdminGeneralSettingsInput, useUpdateAdminGeneralSettings } from '@/api/admin/settings/queries';
import TitledGreyBox from '@/components/elements/TitledGreyBox';
import { languageOptions } from '@/components/admin/languageOptions';
export default function GeneralSettingsForm({ settings }: { settings: AdminSettings }) {
const readOnly = settings.meta.load_environment_only;
const updateGeneralSettings = useUpdateAdminGeneralSettings();
const { data: languages, isLoading: languagesLoading } = useAdminLanguages();
const languagesList = languageOptions(languages, settings.general['app:locale']);
const form = useAppForm({
defaultValues: {
name: settings.general['app:name'],
twoFactorRequired: settings.general['pterodactyl:auth:2fa_required'],
userAvatarsEnabled: settings.general['pterodactyl:client_features:avatars:enabled'],
locale: settings.general['app:locale'],
},
onSubmit: async ({ value }) => {
if (readOnly) {
return;
}
try {
await updateGeneralSettings.mutateAsync(updateAdminGeneralSettingsInput(value));
} catch {
// Error toast is handled by the mutation.
}
},
});
return (
<Form form={form}>
<TitledGreyBox title='General'>
<form.AppField name='name'>
{(field) => (
<field.TextField
type='text'
id='app_name'
label='Company Name'
description='The name of your company, used throughout the Panel.'
disabled={readOnly}
/>
)}
</form.AppField>
<div className='mt-4'>
<form.AppField name='twoFactorRequired'>
{(field) => (
<field.SelectField
id='twoFactorRequired'
label='Require 2-Factor Authentication'
options={[
{ value: 0, label: 'Not Required' },
{ value: 1, label: 'Required for Admins' },
{ value: 2, label: 'Required for All Users' },
]}
disabled={readOnly}
/>
)}
</form.AppField>
</div>
<div className='mt-4'>
<form.AppField name='locale'>
{(field) => (
<field.SelectField
id='app_locale'
label='Default Language'
options={languagesList}
disabled={readOnly || (languagesLoading && !languages)}
placeholder='Select a language'
description='The default language used for the Panel.'
/>
)}
</form.AppField>
</div>
<div className='mt-6'>
<form.AppField name='userAvatarsEnabled'>
{(field) => (
<field.SwitchField
label='User Avatars'
description='Should users be allowed to use custom avatars on their profiles?'
disabled={readOnly}
/>
)}
</form.AppField>
</div>
<div className='flex justify-end mt-4'>
<form.AppForm>
<form.SubmitButton disabled={readOnly}>Save Changes</form.SubmitButton>
</form.AppForm>
</div>
</TitledGreyBox>
</Form>
);
}