feat(ui): refine default frontend layouts
This commit is contained in:
+6
-1
@@ -55,7 +55,9 @@ const URL_TO_CONFIG_MAP: Record<string, { section: string; module: string }> = {
|
||||
'/dashboard': { section: 'console', module: 'detail' },
|
||||
'/dashboard/overview': { section: 'console', module: 'detail' },
|
||||
'/dashboard/models': { section: 'console', module: 'detail' },
|
||||
'/dashboard/users': { section: 'console', module: 'detail' },
|
||||
'/keys': { section: 'console', module: 'token' },
|
||||
'/usage-logs': { section: 'console', module: 'log' },
|
||||
'/usage-logs/common': { section: 'console', module: 'log' },
|
||||
'/usage-logs/drawing': { section: 'console', module: 'midjourney' },
|
||||
'/usage-logs/task': { section: 'console', module: 'task' },
|
||||
@@ -173,7 +175,10 @@ function isNavItemVisible(
|
||||
|
||||
// Handle direct link type
|
||||
if ('url' in item && item.url) {
|
||||
return isModuleEnabled(item.url as string, adminConfig, userConfig)
|
||||
const configUrls = item.configUrls ?? [item.url]
|
||||
return configUrls.some((url) =>
|
||||
isModuleEnabled(url as string, adminConfig, userConfig)
|
||||
)
|
||||
}
|
||||
|
||||
// Handle collapsible type (with sub-items)
|
||||
|
||||
+17
-9
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
LayoutDashboard,
|
||||
Activity,
|
||||
Key,
|
||||
FileText,
|
||||
Wallet,
|
||||
@@ -12,19 +13,14 @@ import {
|
||||
FlaskConical,
|
||||
MessageSquare,
|
||||
CreditCard,
|
||||
ListTodo,
|
||||
} from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useAuthStore } from '@/stores/auth-store'
|
||||
import { WORKSPACE_IDS } from '@/components/layout/lib/workspace-registry'
|
||||
import { type SidebarData } from '@/components/layout/types'
|
||||
import { getDashboardSectionNavItems } from '@/features/dashboard/section-registry'
|
||||
import { getModelsSectionNavItems } from '@/features/models/section-registry'
|
||||
import { getUsageLogsSectionNavItems } from '@/features/usage-logs/section-registry'
|
||||
|
||||
export function useSidebarData(): SidebarData {
|
||||
const { t } = useTranslation()
|
||||
const user = useAuthStore((s) => s.auth.user)
|
||||
const isAdmin = Boolean(user?.role && user.role >= 10)
|
||||
|
||||
return {
|
||||
workspaces: [
|
||||
@@ -56,10 +52,15 @@ export function useSidebarData(): SidebarData {
|
||||
id: 'general',
|
||||
title: t('General'),
|
||||
items: [
|
||||
{
|
||||
title: t('Overview'),
|
||||
url: '/dashboard/overview',
|
||||
icon: Activity,
|
||||
},
|
||||
{
|
||||
title: t('Dashboard'),
|
||||
url: '/dashboard/models',
|
||||
icon: LayoutDashboard,
|
||||
items: getDashboardSectionNavItems(t, { isAdmin }),
|
||||
},
|
||||
{
|
||||
title: t('API Keys'),
|
||||
@@ -68,8 +69,15 @@ export function useSidebarData(): SidebarData {
|
||||
},
|
||||
{
|
||||
title: t('Usage Logs'),
|
||||
url: '/usage-logs/common',
|
||||
icon: FileText,
|
||||
items: getUsageLogsSectionNavItems(t),
|
||||
},
|
||||
{
|
||||
title: t('Task Logs'),
|
||||
url: '/usage-logs/task',
|
||||
activeUrls: ['/usage-logs/drawing'],
|
||||
configUrls: ['/usage-logs/drawing', '/usage-logs/task'],
|
||||
icon: ListTodo,
|
||||
},
|
||||
{
|
||||
title: t('Wallet'),
|
||||
@@ -94,8 +102,8 @@ export function useSidebarData(): SidebarData {
|
||||
},
|
||||
{
|
||||
title: t('Models'),
|
||||
url: '/models/metadata',
|
||||
icon: Box,
|
||||
items: getModelsSectionNavItems(t),
|
||||
},
|
||||
{
|
||||
title: t('Users'),
|
||||
|
||||
Reference in New Issue
Block a user