mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-02 12:25:44 -05:00
Added a configurable panel company/brand logo.
## Extra Details:
- New logo is used for:
- Login page
- Navigation bar
- Page Favicon
- Panel Falls back to the default Ptero logo when no custom one is set.
- Supported File Formats: PNG, JPEG, WebP, AVIF, ICO, and safe SVG
files.
---
## Preview:
<img width="912" height="151"
alt="{67E9647B-AD26-41F8-8272-8B7F4D1CDFB7}"
src="https://github.com/user-attachments/assets/1af9c52b-ad4a-4f82-bb67-14a2b662beb2"
/>
<img width="916" height="256"
alt="{F49323AE-974C-4C16-B129-D60D3494BA0F}"
src="https://github.com/user-attachments/assets/3e35d7f1-c95b-4007-bf1f-69e2ce9891a2"
/>
<img width="1749" height="940"
alt="{252E88D0-BA45-43C8-99E2-5B31E81B739E}"
src="https://github.com/user-attachments/assets/2e807035-bbd0-48ca-823a-4510a9be696e"
/>
<img width="996" height="452" alt="image"
src="https://github.com/user-attachments/assets/c0bef229-285c-4cda-9291-7295e70b2189"
/>
141 lines
5.9 KiB
TypeScript
141 lines
5.9 KiB
TypeScript
import { useState } from 'react';
|
|
import { useAppForm, Form } from '@/components/form';
|
|
import type { AdminSettings } from '@/api/admin/settings/queries';
|
|
import { useAdminLanguages } from '@/api/admin/languages/queries';
|
|
import {
|
|
updateAdminGeneralSettingsInput,
|
|
useClearAdminLogo,
|
|
useUpdateAdminGeneralSettings,
|
|
useUploadAdminLogo,
|
|
} from '@/api/admin/settings/queries';
|
|
import TitledGreyBox from '@/components/elements/TitledGreyBox';
|
|
import { languageOptions } from '@/components/admin/languageOptions';
|
|
import LogoSettingsForm from '@/components/admin/settings/LogoSettingsForm';
|
|
|
|
export default function GeneralSettingsForm({ settings }: { settings: AdminSettings }) {
|
|
const readOnly = settings.meta.load_environment_only;
|
|
const updateGeneralSettings = useUpdateAdminGeneralSettings();
|
|
const uploadLogo = useUploadAdminLogo();
|
|
const clearLogo = useClearAdminLogo();
|
|
const [pendingLogo, setPendingLogo] = useState<File | null>(null);
|
|
const [removeLogo, setRemoveLogo] = useState(false);
|
|
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));
|
|
|
|
if (pendingLogo) {
|
|
await uploadLogo.mutateAsync(pendingLogo);
|
|
setPendingLogo(null);
|
|
setRemoveLogo(false);
|
|
} else if (removeLogo) {
|
|
await clearLogo.mutateAsync();
|
|
setRemoveLogo(false);
|
|
}
|
|
} catch {
|
|
// Error toasts are handled by the mutations.
|
|
}
|
|
},
|
|
});
|
|
|
|
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>
|
|
<LogoSettingsForm
|
|
settings={settings}
|
|
pendingFile={pendingLogo}
|
|
removePending={removeLogo}
|
|
disabled={uploadLogo.isPending || clearLogo.isPending}
|
|
onFileSelected={(file) => {
|
|
setPendingLogo(file ?? null);
|
|
setRemoveLogo(false);
|
|
}}
|
|
onRemove={() => {
|
|
setPendingLogo(null);
|
|
setRemoveLogo(true);
|
|
}}
|
|
/>
|
|
<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 ||
|
|
updateGeneralSettings.isPending ||
|
|
uploadLogo.isPending ||
|
|
clearLogo.isPending
|
|
}
|
|
>
|
|
Save Changes
|
|
</form.SubmitButton>
|
|
</form.AppForm>
|
|
</div>
|
|
</TitledGreyBox>
|
|
</Form>
|
|
);
|
|
}
|