Skip to content

Commit 76b9b22

Browse files
authored
feat(frontend): add model settings button to model selector dropdown (#200)
- Add settings link at bottom of model selector dropdown - Navigate to settings page with models tab selected - Add 'manage' translation key for both en and zh-CN locales - Add models path configuration in paths.ts Co-authored-by: qdaxb <[email protected]>
1 parent 8fde464 commit 76b9b22

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

frontend/src/config/paths.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,8 @@ export const paths = {
4040
team: {
4141
getHref: () => '/settings?tab=team',
4242
},
43+
models: {
44+
getHref: () => '/settings?tab=models',
45+
},
4346
},
4447
} as const;

frontend/src/features/tasks/components/ModelSelector.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
'use client';
66

77
import React, { useEffect, useMemo, useState, useCallback } from 'react';
8-
import { CpuChipIcon } from '@heroicons/react/24/outline';
8+
import { CpuChipIcon, Cog6ToothIcon } from '@heroicons/react/24/outline';
99
import { Check } from 'lucide-react';
10+
import { useRouter } from 'next/navigation';
1011
import { Checkbox } from '@/components/ui/checkbox';
1112
import { Team, BotSummary } from '@/types/api';
1213
import { modelApis, UnifiedModel, ModelTypeEnum } from '@/apis/models';
1314
import { useTranslation } from '@/hooks/useTranslation';
1415
import { useMediaQuery } from '@/hooks/useMediaQuery';
1516
import { Tag } from '@/components/ui/tag';
1617
import { cn } from '@/lib/utils';
18+
import { paths } from '@/config/paths';
1719
import {
1820
Command,
1921
CommandEmpty,
@@ -99,6 +101,7 @@ export default function ModelSelector({
99101
isLoading: externalLoading,
100102
}: ModelSelectorProps) {
101103
const { t } = useTranslation('common');
104+
const router = useRouter();
102105
const isMobile = useMediaQuery('(max-width: 767px)');
103106
const [models, setModels] = useState<Model[]>([]);
104107
const [isLoading, setIsLoading] = useState(false);
@@ -410,6 +413,22 @@ export default function ModelSelector({
410413
</label>
411414
</div>
412415
)}
416+
{/* Model Settings Link */}
417+
<div
418+
className="border-t border-border bg-base cursor-pointer group flex items-center space-x-2 px-2.5 py-2 text-xs text-text-secondary hover:bg-muted transition-colors duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary w-full"
419+
onClick={() => router.push(paths.settings.models.getHref())}
420+
role="button"
421+
tabIndex={0}
422+
onKeyDown={e => {
423+
if (e.key === 'Enter' || e.key === ' ') {
424+
e.preventDefault();
425+
router.push(paths.settings.models.getHref());
426+
}
427+
}}
428+
>
429+
<Cog6ToothIcon className="w-4 h-4 text-text-secondary group-hover:text-text-primary" />
430+
<span className="font-medium group-hover:text-text-primary">{t('models.manage', '模型设置')}</span>
431+
</div>
413432
</Command>
414433
</PopoverContent>
415434
</Popover>

frontend/src/i18n/locales/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@
477477
"title": "Model Management",
478478
"description": "Manage your AI model configurations",
479479
"public": "Public",
480+
"manage": "Model settings",
480481
"create": "Create Model",
481482
"edit": "Edit Model",
482483
"delete": "Delete Model",

frontend/src/i18n/locales/zh-CN/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@
478478
"title": "模型管理",
479479
"description": "管理您的 AI 模型配置",
480480
"public": "公共",
481+
"manage": "模型设置",
481482
"create": "创建模型",
482483
"edit": "编辑模型",
483484
"delete": "删除模型",

0 commit comments

Comments
 (0)