Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(project): support project logo and move delete into an advanced tab (#20641)

Arvin Xubb80e346d894
diff --git a/locales/en-US/project.json b/locales/en-US/project.json
index 276e46f3c25..05b55db4d3a 100644
--- a/locales/en-US/project.json
+++ b/locales/en-US/project.json
@@ -153,6 +153,7 @@
"settings.addDirectoryDescription": "Select an environment and a connected device, then enter the full path of an existing folder. Files stay on that device.",
"settings.addDirectoryFailed": "Could not add working directory",
"settings.addEnvironment": "Add environment",
+ "settings.advanced": "Advanced",
"settings.allEnvironments": "All environments",
"settings.configureDirectory": "Add a working directory",
"settings.description": "Description",
@@ -166,6 +167,10 @@
"settings.generalDescription": "Manage the project name, address, and description.",
"settings.identifier": "Project identifier",
"settings.identifierDescription": "Used in task references. This identifier is set when the project is created.",
+ "settings.logo": "Logo",
+ "settings.logoDescription": "Shown in the project header, sidebar and switcher.",
+ "settings.logoSizeExceeded": "The logo must be smaller than 2 MB.",
+ "settings.logoUploadFailed": "Could not upload the logo",
"settings.noDirectories": "No folders in this environment yet. Add an existing folder on a connected device to start working.",
"settings.noEnvironments": "No environments associated yet",
"settings.noRepository": "No GitHub repository linked",
diff --git a/locales/zh-CN/project.json b/locales/zh-CN/project.json
index a946e75a1f4..1b852615d3e 100644
--- a/locales/zh-CN/project.json
+++ b/locales/zh-CN/project.json
@@ -153,6 +153,7 @@
"settings.addDirectoryDescription": "选择环境和已连接的设备,再填写设备上已有文件夹的完整路径。文件保留在原设备上。",
"settings.addDirectoryFailed": "添加工作位置失败",
"settings.addEnvironment": "关联环境",
+ "settings.advanced": "高级设置",
"settings.allEnvironments": "全部环境",
"settings.configureDirectory": "添加工作目录",
"settings.description": "项目说明",
@@ -166,6 +167,10 @@
"settings.generalDescription": "管理项目名称、链接和说明。",
"settings.identifier": "项目标识",
"settings.identifierDescription": "用于任务编号,创建项目后不可更改。",
+ "settings.logo": "项目 Logo",
+ "settings.logoDescription": "显示在项目头部、侧边栏与项目切换器中。",
+ "settings.logoSizeExceeded": "Logo 需小于 2 MB。",
+ "settings.logoUploadFailed": "Logo 上传失败",
"settings.noDirectories": "还没有工作目录。添加已连接设备上的文件夹后,即可在此新建对话。",
"settings.noEnvironments": "尚未关联环境",
"settings.noRepository": "未关联 GitHub 仓库",
diff --git a/packages/locales/src/default/project.ts b/packages/locales/src/default/project.ts
index c0cfb37ca4c..d04af2057d5 100644
--- a/packages/locales/src/default/project.ts
+++ b/packages/locales/src/default/project.ts
@@ -63,6 +63,11 @@ export default {
'directories.autoFileTopics': 'All {{count}} existing topics will be linked to this project.',
'settings.general': 'General',
+ 'settings.logo': 'Logo',
+ 'settings.logoDescription': 'Shown in the project header, sidebar and switcher.',
+ 'settings.logoSizeExceeded': 'The logo must be smaller than 2 MB.',
+ 'settings.logoUploadFailed': 'Could not upload the logo',
+ 'settings.advanced': 'Advanced',
'settings.noRepository': 'No GitHub repository linked',
'settings.noDirectories':
'No folders in this environment yet. Add an existing folder on a connected device to start working.',
diff --git a/src/features/Projects/WorkingDirectories/AdvancedSettings.tsx b/src/features/Projects/WorkingDirectories/AdvancedSettings.tsx
new file mode 100644
index 00000000000..5d7a419812a
--- /dev/null
+++ b/src/features/Projects/WorkingDirectories/AdvancedSettings.tsx
@@ -0,0 +1,69 @@
+// FormKit migration is blocked on inline-validation support: `FormFieldProps` has no
+// `help`/`validateStatus`, which this form uses for the slug field.
+// eslint-disable-next-line no-restricted-imports
+import { Flexbox, Form } from '@lobehub/ui';
+import { Button, confirmModal, toast } from '@lobehub/ui/base-ui';
+import { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { FORM_STYLE } from '@/const/layoutTokens';
+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import type { ProjectDetail } from '@/store/project';
+import { useProjectStore } from '@/store/project';
+import { useUserStore } from '@/store/user';
+import { userProfileSelectors } from '@/store/user/selectors';
+
+export function AdvancedSettings({ project }: { project: ProjectDetail['project'] }) {
+ const { t } = useTranslation('project');
+ const navigate = useWorkspaceAwareNavigate();
+ const deleteProject = useProjectStore((s) => s.deleteProject);
+ const currentUserId = useUserStore(userProfileSelectors.userId);
+ const [pending, setPending] = useState(false);
+
+ // Destructive settings stay owner-only; the page hides this tab for everyone else.
+ if (currentUserId !== project.userId) return null;
+
+ const confirmDelete = () => {
+ confirmModal({
+ title: t('list.deleteConfirmTitle'),
+ content: t('list.deleteConfirmDescription', { name: project.name }),
+ okText: t('delete', { ns: 'common' }),
+ cancelText: t('cancel', { ns: 'common' }),
+ okButtonProps: { danger: true },
+ onOk: async () => {
+ setPending(true);
+ try {
+ await deleteProject(project.id);
+ navigate('/projects', { replace: true });
+ } catch (error) {
+ console.error('Failed to delete project', error);
+ toast.error(t('list.deleteError'));
+ setPending(false);
+ throw error;
+ }
+ },
+ });
+ };
+
+ return (
+ <Flexbox gap={24}>
+ <Form
+ {...FORM_STYLE}
+ itemsType="flat"
+ variant="filled"
+ items={[
+ {
+ label: t('list.deleteAction'),
+ desc: t('list.deleteConfirmDescription', { name: project.name }),
+ minWidth: undefined,
+ children: (
+ <Button danger disabled={pending} onClick={confirmDelete}>
+ {t('list.deleteAction')}
+ </Button>
+ ),
+ },
+ ]}
+ />
+ </Flexbox>
+ );
+}
diff --git a/src/features/Projects/WorkingDirectories/GeneralSettings.tsx b/src/features/Projects/WorkingDirectories/GeneralSettings.tsx
index 916ed168e9a..05bac149066 100644
--- a/src/features/Projects/WorkingDirectories/GeneralSettings.tsx
+++ b/src/features/Projects/WorkingDirectories/GeneralSettings.tsx
@@ -2,31 +2,57 @@
// `help`/`validateStatus`, which this form uses for the slug field.
// eslint-disable-next-line no-restricted-imports
import { Flexbox, Form } from '@lobehub/ui';
-import { Button, confirmModal, Input, TextArea, toast } from '@lobehub/ui/base-ui';
+import { Button, Input, TextArea, toast } from '@lobehub/ui/base-ui';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
+import EmojiPicker from '@/components/EmojiPicker';
import { FORM_STYLE } from '@/const/layoutTokens';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import { useFileStore } from '@/store/file';
import type { ProjectDetail } from '@/store/project';
import { useProjectStore } from '@/store/project';
-import { useUserStore } from '@/store/user';
-import { userProfileSelectors } from '@/store/user/selectors';
import { isProjectSlugValid } from '../createProjectForm';
+const MAX_LOGO_SIZE = 2 * 1024 * 1024;
+
export function GeneralSettings({ project }: { project: ProjectDetail['project'] }) {
const { t } = useTranslation('project');
const [name, setName] = useState(project.name);
const [slug, setSlug] = useState(project.slug ?? '');
const [description, setDescription] = useState(project.description ?? '');
+ const [avatar, setAvatar] = useState<string | null>(project.avatar ?? null);
+ const [uploading, setUploading] = useState(false);
const navigate = useWorkspaceAwareNavigate();
- const deleteProject = useProjectStore((s) => s.deleteProject);
- const currentUserId = useUserStore(userProfileSelectors.userId);
+ const uploadWithProgress = useFileStore((s) => s.uploadWithProgress);
const [pending, setPending] = useState(false);
const [error, setError] = useState<unknown>();
const updateProject = useProjectStore((s) => s.updateProject);
+
+ const uploadLogo = async (file: File) => {
+ if (file.size > MAX_LOGO_SIZE) {
+ toast.error(t('settings.logoSizeExceeded'));
+ return;
+ }
+
+ setUploading(true);
+ try {
+ const result = await uploadWithProgress({ file });
+ if (!result?.url) {
+ toast.error(t('settings.logoUploadFailed'));
+ return;
+ }
+ setAvatar(result.url);
+ } catch (error) {
+ console.error('Failed to upload project logo', error);
+ toast.error(t('settings.logoUploadFailed'));
+ } finally {
+ setUploading(false);
+ }
+ };
+
const save = async () => {
setPending(true);
setError(undefined);
@@ -35,6 +61,7 @@ export function GeneralSettings({ project }: { project: ProjectDetail['project']
name: name.trim(),
slug: slug.trim() || null,
description: description.trim() || null,
+ avatar,
});
navigate(`/project/${saved.slug ?? saved.id}/settings/general`, { replace: true });
toast.success(t('rename.success'));
@@ -47,11 +74,13 @@ export function GeneralSettings({ project }: { project: ProjectDetail['project']
};
const saveDisabled =
pending ||
+ uploading ||
!name.trim() ||
!isProjectSlugValid(slug) ||
(name.trim() === project.name &&
slug.trim() === (project.slug ?? '') &&
- description.trim() === (project.description ?? ''));
+ description.trim() === (project.description ?? '') &&
+ avatar === (project.avatar ?? null));
return (
<Flexbox gap={24}>
@@ -76,6 +105,25 @@ export function GeneralSettings({ project }: { project: ProjectDetail['project']
{
title: t('settings.general'),
children: [
+ {
+ label: t('settings.logo'),
+ desc: t('settings.logoDescription'),
+ children: (
+ <EmojiPicker
+ allowDelete={!!avatar}
+ allowUpload={{ enableEmoji: true }}
+ loading={uploading}
+ shape="square"
+ size={80}
+ value={avatar || undefined}
+ onDelete={() => setAvatar(null)}
+ onUpload={uploadLogo}
+ onChange={(next) => {
+ if (!next.startsWith('data:')) setAvatar(next || null);
+ }}
+ />
+ ),
+ },
{
label: t('create.nameLabel'),
children: (
@@ -130,47 +178,6 @@ export function GeneralSettings({ project }: { project: ProjectDetail['project']
},
]}
/>
- {currentUserId === project.userId && (
- <Form
- {...FORM_STYLE}
- itemsType="flat"
- variant="filled"
- items={[
- {
- label: t('list.deleteAction'),
- desc: t('list.deleteConfirmDescription', { name: project.name }),
- minWidth: undefined,
- children: (
- <Button
- danger
- disabled={pending}
- onClick={() =>
- confirmModal({
- title: t('list.deleteConfirmTitle'),
- content: t('list.deleteConfirmDescription', { name: project.name }),
- okText: t('delete', { ns: 'common' }),
- cancelText: t('cancel', { ns: 'common' }),
- okButtonProps: { danger: true },
- onOk: async () => {
- try {
- await deleteProject(project.id);
- navigate('/projects', { replace: true });
- } catch (error) {
- console.error('Failed to delete project', error);
- toast.error(t('list.deleteError'));
- throw error;
- }
- },
- })
- }
- >
- {t('list.deleteAction')}
- </Button>
- ),
- },
- ]}
- />
- )}
</Flexbox>
);
}
diff --git a/src/features/Projects/WorkingDirectories/Page.tsx b/src/features/Projects/WorkingDirectories/Page.tsx
index 22482971b8f..bd8a3ea343f 100644
--- a/src/features/Projects/WorkingDirectories/Page.tsx
+++ b/src/features/Projects/WorkingDirectories/Page.tsx
@@ -1,5 +1,6 @@
import { Flexbox } from '@lobehub/ui';
import { Tabs, Text } from '@lobehub/ui/base-ui';
+import type { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
@@ -8,20 +9,61 @@ import { RouteLoading } from '@/components/Skeleton/RouteSegment';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';
import { useCurrentProjectDetail, useProjectStore } from '@/store/project';
+import { useUserStore } from '@/store/user';
+import { userProfileSelectors } from '@/store/user/selectors';
+import { AdvancedSettings } from './AdvancedSettings';
import { GeneralSettings } from './GeneralSettings';
import { ProjectWorkingDirectories } from './index';
import { WorkingDirectorySettings } from './WorkingDirectorySettings';
+interface SectionItem {
+ key: string;
+ label: string;
+ render: () => ReactNode;
+}
+
export function ProjectDirectoriesPage() {
const { t } = useTranslation('project');
const { section = 'general' } = useParams<{ section?: string }>();
const navigate = useWorkspaceAwareNavigate();
const { projectId } = useActiveRouteParams<{ projectId: string }>();
const { error, revalidate } = useProjectStore((s) => s.useFetchProjectDetail)(projectId);
+ const currentUserId = useUserStore(userProfileSelectors.userId);
const detail = useCurrentProjectDetail(projectId);
if (error && !detail) return <AsyncError error={error} variant="page" onRetry={revalidate} />;
if (!detail) return <RouteLoading />;
+
+ const canManage = currentUserId === detail.project.userId;
+ const sections: SectionItem[] = [
+ {
+ key: 'general',
+ label: t('settings.general'),
+ render: () => <GeneralSettings key={detail.project.id} project={detail.project} />,
+ },
+ {
+ key: 'environments',
+ label: t('settings.environments'),
+ render: () => <ProjectWorkingDirectories projectId={detail.project.id} />,
+ },
+ {
+ key: 'directories',
+ label: t('settings.workLocations'),
+ render: () => <WorkingDirectorySettings projectId={detail.project.id} />,
+ },
+ // Destructive settings are owner-only, so the tab is hidden for everyone else.
+ ...(canManage
+ ? [
+ {
+ key: 'advanced',
+ label: t('settings.advanced'),
+ render: () => <AdvancedSettings project={detail.project} />,
+ },
+ ]
+ : []),
+ ];
+ const activeSection = sections.find((item) => item.key === section) ?? sections[0];
+
return (
<Flexbox flex={1} padding={32} style={{ overflow: 'auto' }}>
<Flexbox gap={28} style={{ width: '100%', maxWidth: 800, marginInline: 'auto' }}>
@@ -29,22 +71,12 @@ export function ProjectDirectoriesPage() {
{t('settings.title')}
</Text>
<Tabs
- activeKey={section}
+ activeKey={activeSection.key}
+ items={sections.map(({ key, label }) => ({ key, label }))}
variant="square"
- items={[
- { label: t('settings.general'), key: 'general' },
- { label: t('settings.environments'), key: 'environments' },
- { label: t('settings.workLocations'), key: 'directories' },
- ]}
onChange={(key) => navigate(`/project/${projectId}/settings/${key}`)}
/>
- {section === 'general' ? (
- <GeneralSettings key={detail.project.id} project={detail.project} />
- ) : section === 'directories' ? (
- <WorkingDirectorySettings projectId={detail.project.id} />
- ) : (
- <ProjectWorkingDirectories projectId={detail.project.id} />
- )}
+ {activeSection.render()}
</Flexbox>
</Flexbox>
);
diff --git a/src/services/project.ts b/src/services/project.ts
index a8c375b8d67..845cbe3fdf8 100644
--- a/src/services/project.ts
+++ b/src/services/project.ts
@@ -54,7 +54,12 @@ class ProjectService {
update = async (
id: string,
- input: { description?: string | null; name?: string; slug?: string | null },
+ input: {
+ avatar?: string | null;
+ description?: string | null;
+ name?: string;
+ slug?: string | null;
+ },
) => lambdaClient.project.update.mutate({ id, ...input });
updateStatus = async (id: string, status: 'active' | 'archived' | 'backlog' | 'paused') =>