复用空态原语收口项目新建卡片
PlatformEmptyState 增加 button 形态,支持空列表 CTA 复用同一套空态 chrome。 项目页空列表新建项目卡片改为复用 PlatformEmptyState,保留项目页局部尺寸样式。 补充共享空态按钮形态和项目页空态创建测试,并更新 TRACKING。
This commit is contained in:
@@ -134,4 +134,28 @@ describe('ProjectGalleryView', () => {
|
||||
expect(deleteEditorProjectMock).toHaveBeenCalledWith('editor-project-1');
|
||||
expect(deleteEditorProjectMock).toHaveBeenCalledWith('editor-project-2');
|
||||
});
|
||||
|
||||
it('renders the empty project action with shared empty state chrome', async () => {
|
||||
const onOpenProject = vi.fn();
|
||||
listEditorProjectsMock.mockResolvedValueOnce([]);
|
||||
createEditorProjectMock.mockResolvedValueOnce({
|
||||
...projectItems[0],
|
||||
projectId: 'editor-project-new',
|
||||
});
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(<ProjectGalleryView onOpenProject={onOpenProject} />);
|
||||
|
||||
const newProjectButton = await screen.findByRole('button', {
|
||||
name: '新建项目',
|
||||
});
|
||||
|
||||
expect(newProjectButton.className).toContain('platform-empty-state');
|
||||
expect(newProjectButton.className).toContain('project-gallery__new-card');
|
||||
|
||||
await user.click(newProjectButton);
|
||||
|
||||
expect(createEditorProjectMock).toHaveBeenCalledTimes(1);
|
||||
expect(onOpenProject).toHaveBeenCalledWith('editor-project-new');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -327,14 +327,16 @@ export function ProjectGalleryView({ onOpenProject }: ProjectGalleryViewProps) {
|
||||
正在读取项目
|
||||
</PlatformEmptyState>
|
||||
) : projects.length === 0 ? (
|
||||
<button
|
||||
type="button"
|
||||
<PlatformEmptyState
|
||||
asChild="button"
|
||||
surface="subpanel"
|
||||
size="panel"
|
||||
className="project-gallery__new-card"
|
||||
onClick={createProject}
|
||||
>
|
||||
<Plus className="h-6 w-6" />
|
||||
<span>新建项目</span>
|
||||
</button>
|
||||
</PlatformEmptyState>
|
||||
) : (
|
||||
<section className="project-gallery__grid">{projectCards}</section>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user