feat(settings): reorganize settings into personal, team, and AI sections (#324)

This commit is contained in:
Yiling-J
2026-08-18 08:35:23 +08:00
committed by GitHub
parent 4935eeff28
commit f806272c06
12 changed files with 219 additions and 45 deletions
+16 -11
View File
@@ -21,19 +21,23 @@ const currentDir = path.dirname(fileURLToPath(import.meta.url))
const envPath = path.resolve(currentDir, '.env.e2e')
const fixturesDir = path.resolve(currentDir, '../../../packages/e2e/fixtures')
// Load E2E environment variables if present
if (fs.existsSync(envPath)) {
const content = fs.readFileSync(envPath, 'utf8')
content.split('\n').forEach((line) => {
const parts = line.split('=')
if (parts.length >= 2) {
const key = parts[0].trim()
const value = parts.slice(1).join('=').trim()
process.env[key] = value
}
})
function loadEnv() {
if (fs.existsSync(envPath)) {
const content = fs.readFileSync(envPath, 'utf8')
content.split('\n').forEach((line) => {
const parts = line.split('=')
if (parts.length >= 2) {
const key = parts[0].trim()
const value = parts.slice(1).join('=').trim()
process.env[key] = value
}
})
}
}
// Load E2E environment variables if present
loadEnv()
export interface OwnerFixture {
/** Page opened in a browser context logged in as the team owner. */
page: Page
@@ -104,6 +108,7 @@ export const test = base.extend<{
prisma: [
// eslint-disable-next-line no-empty-pattern
async ({}, use) => {
loadEnv()
const connectionString = process.env.DATABASE_URL
const pool = new Pool({ connectionString })
const adapter = new PrismaPg(pool)
+3
View File
@@ -9,6 +9,9 @@
"assets_added_to_context": "Assets added to context:",
"select_preferred_language": "Select your preferred display language.",
"settings": "Settings",
"personal_settings": "Personal Settings",
"team_settings": "Team Settings",
"ai_settings": "AI Settings",
"welcome_back": "Welcome Back",
"create_account": "Create Account",
"select_a_team": "Select a Team",
+3
View File
@@ -9,6 +9,9 @@
"assets_added_to_context": "已添加至上下文的资源:",
"select_preferred_language": "选择您首选的显示语言。",
"settings": "设置",
"personal_settings": "个人设置",
"team_settings": "团队设置",
"ai_settings": "AI 设置",
"welcome_back": "欢迎回来",
"create_account": "创建账户",
"select_a_team": "选择团队",
+3
View File
@@ -7,6 +7,9 @@ export * from "./language_settings.js";
export * from "./assets_added_to_context.js";
export * from "./select_preferred_language.js";
export * from "./settings.js";
export * from "./personal_settings.js";
export * from "./team_settings.js";
export * from "./ai_settings.js";
export * from "./welcome_back.js";
export * from "./create_account.js";
export * from "./select_a_team.js";
+3
View File
@@ -9,6 +9,9 @@ export * from './language_settings.js'
export * from './assets_added_to_context.js'
export * from './select_preferred_language.js'
export * from './settings.js'
export * from './personal_settings.js'
export * from './team_settings.js'
export * from './ai_settings.js'
export * from './welcome_back.js'
export * from './create_account.js'
export * from './select_a_team.js'
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "AI Settings" |
*
* @param {Ai_SettingsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const ai_settings: ((inputs?: Ai_SettingsInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Ai_SettingsInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Ai_SettingsInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Ai_SettingsInputs */
const en_ai_settings = /** @type {(inputs: Ai_SettingsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`AI Settings`)
};
const zh_ai_settings = /** @type {(inputs: Ai_SettingsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`AI 设置`)
};
/**
* | output |
* | --- |
* | "AI Settings" |
*
* @param {Ai_SettingsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const ai_settings = /** @type {((inputs?: Ai_SettingsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Ai_SettingsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_ai_settings(inputs)
return zh_ai_settings(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Personal Settings" |
*
* @param {Personal_SettingsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const personal_settings: ((inputs?: Personal_SettingsInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Personal_SettingsInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Personal_SettingsInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Personal_SettingsInputs */
const en_personal_settings = /** @type {(inputs: Personal_SettingsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Personal Settings`)
};
const zh_personal_settings = /** @type {(inputs: Personal_SettingsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`个人设置`)
};
/**
* | output |
* | --- |
* | "Personal Settings" |
*
* @param {Personal_SettingsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const personal_settings = /** @type {((inputs?: Personal_SettingsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Personal_SettingsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_personal_settings(inputs)
return zh_personal_settings(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Team Settings" |
*
* @param {Team_SettingsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const team_settings: ((inputs?: Team_SettingsInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Team_SettingsInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Team_SettingsInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Team_SettingsInputs */
const en_team_settings = /** @type {(inputs: Team_SettingsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Team Settings`)
};
const zh_team_settings = /** @type {(inputs: Team_SettingsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`团队设置`)
};
/**
* | output |
* | --- |
* | "Team Settings" |
*
* @param {Team_SettingsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const team_settings = /** @type {((inputs?: Team_SettingsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Team_SettingsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_team_settings(inputs)
return zh_team_settings(inputs)
});
@@ -113,6 +113,21 @@ function TeamSettingsPage() {
}
}, [me])
useEffect(() => {
const ownerOnlyTabs: SettingsTab[] = [
'transcode',
'quotas',
'providers',
'skills',
'mcp',
'agents',
'sandbox',
]
if (me && me.role !== 'owner' && ownerOnlyTabs.includes(activeTab)) {
setActiveTab('general')
}
}, [me, activeTab])
const getInitials = (name?: string) => {
if (!name) return 'U'
const names = name.split(' ')
@@ -256,8 +271,9 @@ function TeamSettingsPage() {
{/* Sidebar */}
<div className="w-full h-full md:w-72 bg-sidebar border-b md:border-b-0 md:border-r border-sidebar-border z-10 md:left-16 overflow-y-auto transition-colors duration-300">
<nav className="p-4 space-y-1 mt-4">
{/* Personal Settings */}
<div className="mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider">
{m.settings()}
{m.personal_settings()}
</div>
<button
@@ -276,8 +292,45 @@ function TeamSettingsPage() {
)}
</button>
<button
onClick={() => setActiveTab('notifications')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'notifications'
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
)}
>
<Bell className="w-5 h-5" />
{m.notifications()}
{activeTab === 'notifications' && (
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
)}
</button>
<button
onClick={() => setActiveTab('developer')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'developer'
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
)}
>
<Key className="w-5 h-5" />
{m.api_tokens()}
{activeTab === 'developer' && (
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
)}
</button>
{/* Team Settings */}
{me?.role === 'owner' && (
<>
<div className="mt-6 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border">
{m.team_settings()}
</div>
<button
onClick={() => setActiveTab('transcode')}
className={cn(
@@ -312,42 +365,11 @@ function TeamSettingsPage() {
</>
)}
<button
onClick={() => setActiveTab('notifications')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'notifications'
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
)}
>
<Bell className="w-5 h-5" />
{m.notifications()}
{activeTab === 'notifications' && (
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
)}
</button>
<button
onClick={() => setActiveTab('developer')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'developer'
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
)}
>
<Key className="w-5 h-5" />
{m.api_tokens()}
{activeTab === 'developer' && (
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
)}
</button>
{/* AI */}
{me?.role === 'owner' && (
<>
<div className="mt-6 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border">
{m.ai()}
{m.ai_settings()}
</div>
<button