feat(ui): add system settings to sidebar and unhide frontend theme switcher
- Add System Settings entry to Admin sidebar group with Settings icon - Register /system-settings URL mapping in sidebar config - Remove 3-click hidden unlock from Frontend Theme setting, making it directly visible in System Information section
This commit is contained in:
parent
b44faec66b
commit
3896fd71e9
@ -3,7 +3,6 @@ import type { Resolver } from 'react-hook-form'
|
|||||||
import { zodResolver } from '@hookform/resolvers/zod'
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
import { RotateCcw } from 'lucide-react'
|
import { RotateCcw } from 'lucide-react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useHiddenClickUnlock } from '@/hooks/use-hidden-click-unlock'
|
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
@ -60,7 +59,6 @@ function normalizeValue(value: unknown): string {
|
|||||||
export function SystemInfoSection({ defaultValues }: SystemInfoSectionProps) {
|
export function SystemInfoSection({ defaultValues }: SystemInfoSectionProps) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const updateOption = useUpdateOption()
|
const updateOption = useUpdateOption()
|
||||||
const frontendThemeUnlock = useHiddenClickUnlock({ requiredClicks: 3 })
|
|
||||||
|
|
||||||
const normalizedDefaults: SystemInfoFormValues = {
|
const normalizedDefaults: SystemInfoFormValues = {
|
||||||
theme: {
|
theme: {
|
||||||
@ -127,47 +125,41 @@ export function SystemInfoSection({ defaultValues }: SystemInfoSectionProps) {
|
|||||||
|
|
||||||
<SettingsSection
|
<SettingsSection
|
||||||
title={t('System Information')}
|
title={t('System Information')}
|
||||||
titleProps={{
|
|
||||||
className: 'cursor-pointer select-none',
|
|
||||||
onClick: frontendThemeUnlock.handleClick,
|
|
||||||
}}
|
|
||||||
description={t('Configure basic system information and branding')}
|
description={t('Configure basic system information and branding')}
|
||||||
>
|
>
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form onSubmit={handleSubmit} className='space-y-6'>
|
<form onSubmit={handleSubmit} className='space-y-6'>
|
||||||
<FormDirtyIndicator isDirty={isDirty} />
|
<FormDirtyIndicator isDirty={isDirty} />
|
||||||
{frontendThemeUnlock.unlocked && (
|
<FormField
|
||||||
<FormField
|
control={form.control}
|
||||||
control={form.control}
|
name='theme.frontend'
|
||||||
name='theme.frontend'
|
render={({ field }) => (
|
||||||
render={({ field }) => (
|
<FormItem>
|
||||||
<FormItem>
|
<FormLabel>{t('Frontend Theme')}</FormLabel>
|
||||||
<FormLabel>{t('Frontend Theme')}</FormLabel>
|
<Select onValueChange={field.onChange} value={field.value}>
|
||||||
<Select onValueChange={field.onChange} value={field.value}>
|
<FormControl>
|
||||||
<FormControl>
|
<SelectTrigger className='w-full'>
|
||||||
<SelectTrigger className='w-full'>
|
<SelectValue />
|
||||||
<SelectValue />
|
</SelectTrigger>
|
||||||
</SelectTrigger>
|
</FormControl>
|
||||||
</FormControl>
|
<SelectContent>
|
||||||
<SelectContent>
|
<SelectItem value='default'>
|
||||||
<SelectItem value='default'>
|
{t('Default (New Frontend)')}
|
||||||
{t('Default (New Frontend)')}
|
</SelectItem>
|
||||||
</SelectItem>
|
<SelectItem value='classic'>
|
||||||
<SelectItem value='classic'>
|
{t('Classic (Legacy Frontend)')}
|
||||||
{t('Classic (Legacy Frontend)')}
|
</SelectItem>
|
||||||
</SelectItem>
|
</SelectContent>
|
||||||
</SelectContent>
|
</Select>
|
||||||
</Select>
|
<FormDescription>
|
||||||
<FormDescription>
|
{t(
|
||||||
{t(
|
'Switch between the new frontend and the classic frontend. Changes take effect after page reload.'
|
||||||
'Switch between the new frontend and the classic frontend. Changes take effect after page reload.'
|
)}
|
||||||
)}
|
</FormDescription>
|
||||||
</FormDescription>
|
<FormMessage />
|
||||||
<FormMessage />
|
</FormItem>
|
||||||
</FormItem>
|
)}
|
||||||
)}
|
/>
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
|||||||
2
web/default/src/hooks/use-sidebar-config.ts
vendored
2
web/default/src/hooks/use-sidebar-config.ts
vendored
@ -70,6 +70,8 @@ const URL_TO_CONFIG_MAP: Record<string, { section: string; module: string }> = {
|
|||||||
'/users': { section: 'admin', module: 'user' },
|
'/users': { section: 'admin', module: 'user' },
|
||||||
'/redemption-codes': { section: 'admin', module: 'redemption' },
|
'/redemption-codes': { section: 'admin', module: 'redemption' },
|
||||||
'/subscriptions': { section: 'admin', module: 'subscription' },
|
'/subscriptions': { section: 'admin', module: 'subscription' },
|
||||||
|
'/system-settings': { section: 'admin', module: 'setting' },
|
||||||
|
'/system-settings/general': { section: 'admin', module: 'setting' },
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
7
web/default/src/hooks/use-sidebar-data.ts
vendored
7
web/default/src/hooks/use-sidebar-data.ts
vendored
@ -14,6 +14,7 @@ import {
|
|||||||
MessageSquare,
|
MessageSquare,
|
||||||
CreditCard,
|
CreditCard,
|
||||||
ListTodo,
|
ListTodo,
|
||||||
|
Settings,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { WORKSPACE_IDS } from '@/components/layout/lib/workspace-registry'
|
import { WORKSPACE_IDS } from '@/components/layout/lib/workspace-registry'
|
||||||
@ -120,6 +121,12 @@ export function useSidebarData(): SidebarData {
|
|||||||
url: '/subscriptions',
|
url: '/subscriptions',
|
||||||
icon: CreditCard,
|
icon: CreditCard,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: t('System Settings'),
|
||||||
|
url: '/system-settings/general',
|
||||||
|
activeUrls: ['/system-settings'],
|
||||||
|
icon: Settings,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user