mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 15:14:10 +00:00
fix(webui): sidebar selection styling, kanban active state, pointer cursors, and owner dashboard (#344)
* fix(webui): update sidebar selection styling, kanban active state, and pointer cursors * feat(webui): move dashboard to left sidebar and prevent mount animation * fix(e2e): update create-project test to click Home button in sidebar
This commit is contained in:
@@ -40,8 +40,8 @@ test('owner should create a project with a cover image', async ({ owner, prisma
|
|||||||
await expect(page).toHaveURL(/\/projects\/[^/]+/)
|
await expect(page).toHaveURL(/\/projects\/[^/]+/)
|
||||||
await expect(page.locator(`text=${projectName}`).first()).toBeVisible()
|
await expect(page.locator(`text=${projectName}`).first()).toBeVisible()
|
||||||
|
|
||||||
// Back on the dashboard the new project card is visible with its cover
|
// Back on the home page the new project card is visible with its cover
|
||||||
await page.click('button[aria-label="Dashboard"]')
|
await page.click('button[aria-label="Home"]')
|
||||||
await expect(page).toHaveURL(/\/teams\/[^/]+/)
|
await expect(page).toHaveURL(/\/teams\/[^/]+/)
|
||||||
await expect(page.locator(`img[alt="${projectName}"]`)).toBeVisible()
|
await expect(page.locator(`img[alt="${projectName}"]`)).toBeVisible()
|
||||||
|
|
||||||
|
|||||||
@@ -1998,7 +1998,7 @@ describe('AssetService', () => {
|
|||||||
expect(await prisma.asset.findUnique({ where: { id: folderA.id } })).toBeNull()
|
expect(await prisma.asset.findUnique({ where: { id: folderA.id } })).toBeNull()
|
||||||
const remainingChildren = await prisma.asset.count({ where: { parentId: folderA.id } })
|
const remainingChildren = await prisma.asset.count({ where: { parentId: folderA.id } })
|
||||||
expect(remainingChildren).toBe(0)
|
expect(remainingChildren).toBe(0)
|
||||||
})
|
}, 20000)
|
||||||
|
|
||||||
it('should delete the entire directory prefix for assets with complex keys (e.g., files/ULID/raw)', async () => {
|
it('should delete the entire directory prefix for assets with complex keys (e.g., files/ULID/raw)', async () => {
|
||||||
const { project } = await setupBasicAssets()
|
const { project } = await setupBasicAssets()
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ interface DualSidebarItemProps {
|
|||||||
badge?: React.ReactNode
|
badge?: React.ReactNode
|
||||||
children?: React.ReactNode
|
children?: React.ReactNode
|
||||||
onItemClick?: () => void
|
onItemClick?: () => void
|
||||||
|
active?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// A declarative component that holds props for a sidebar item. It doesn't render anything itself.
|
// A declarative component that holds props for a sidebar item. It doesn't render anything itself.
|
||||||
@@ -103,32 +104,35 @@ export const DualSidebar: React.FC<DualSidebarProps> = ({ children }) => {
|
|||||||
<div className="absolute bottom-0 w-full h-[70dvh] bg-linear-to-t from-sidebar-primary/10 to-transparent"></div>
|
<div className="absolute bottom-0 w-full h-[70dvh] bg-linear-to-t from-sidebar-primary/10 to-transparent"></div>
|
||||||
{/* Level 1: Icon Bar */}
|
{/* Level 1: Icon Bar */}
|
||||||
<nav className="w-16 bg-card border-r border-sidebar-border flex flex-col items-center pb-4 pt-0 space-y-2 flex-shrink-0">
|
<nav className="w-16 bg-card border-r border-sidebar-border flex flex-col items-center pb-4 pt-0 space-y-2 flex-shrink-0">
|
||||||
<div className="flex-1 w-full flex flex-col items-center space-y-5 pt-1">
|
<div className="flex-1 w-full flex flex-col items-center gap-5 pt-1">
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
{sidebarItems.map((item, index) => (
|
{sidebarItems.map((item, index) => {
|
||||||
<Tooltip key={item.props.label}>
|
const isItemActive = Boolean(item.props.active || activeItem === index)
|
||||||
<TooltipTrigger asChild>
|
return (
|
||||||
<Button
|
<Tooltip key={item.props.label}>
|
||||||
variant="ghost"
|
<TooltipTrigger asChild>
|
||||||
size="icon-lg"
|
<Button
|
||||||
onClick={() => handleItemClick(index)}
|
variant="ghost"
|
||||||
aria-label={item.props.label}
|
size="icon-lg"
|
||||||
aria-expanded={activeItem === index}
|
onClick={() => handleItemClick(index)}
|
||||||
className={`relative w-12 h-12 [&_svg:not([class*='size-'])]:size-6 transition-all duration-200 ${
|
aria-label={item.props.label}
|
||||||
activeItem === index
|
aria-expanded={activeItem === index}
|
||||||
? 'bg-sidebar-primary text-sidebar-primary-foreground shadow-lg hover:bg-sidebar-primary hover:text-sidebar-primary-foreground'
|
className={`relative w-12 h-12 [&_svg:not([class*='size-'])]:size-6 transition-colors duration-200 ${
|
||||||
: 'text-sidebar-foreground/60 hover:text-sidebar-foreground hover:bg-sidebar-accent'
|
isItemActive
|
||||||
}`}
|
? 'text-sidebar-primary hover:bg-sidebar-accent hover:text-sidebar-primary'
|
||||||
>
|
: 'text-sidebar-foreground/60 hover:text-sidebar-foreground hover:bg-sidebar-accent'
|
||||||
{item.props.icon}
|
}`}
|
||||||
{item.props.badge}
|
>
|
||||||
</Button>
|
{item.props.icon}
|
||||||
</TooltipTrigger>
|
{item.props.badge}
|
||||||
<TooltipContent side="right">
|
</Button>
|
||||||
<p>{item.props.label}</p>
|
</TooltipTrigger>
|
||||||
</TooltipContent>
|
<TooltipContent side="right">
|
||||||
</Tooltip>
|
<p>{item.props.label}</p>
|
||||||
))}
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
)
|
||||||
|
})}
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-auto w-full flex flex-col items-center pb-2">
|
<div className="mt-auto w-full flex flex-col items-center pb-2">
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Slot } from 'radix-ui'
|
|||||||
import { cn } from '@/ui/lib/utils'
|
import { cn } from '@/ui/lib/utils'
|
||||||
|
|
||||||
const buttonVariants = cva(
|
const buttonVariants = cva(
|
||||||
"inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
"inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap cursor-pointer transition-colors outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
|
|||||||
@@ -265,3 +265,16 @@ export const KanbanFillIcon: React.FC<React.SVGProps<SVGSVGElement>> = ({
|
|||||||
<path d="M172-84q-36.3 0-62.15-25.85T84-172v-616q0-36.3 25.85-62.15T172-876h616q36.3 0 62.15 25.85T876-788v616q0 36.3-25.85 62.15T788-84H172Zm88-176h88v-440h-88v440Zm176 0h88v-264h-88v264Zm176 0h88v-352h-88v352Z" />
|
<path d="M172-84q-36.3 0-62.15-25.85T84-172v-616q0-36.3 25.85-62.15T172-876h616q36.3 0 62.15 25.85T876-788v616q0 36.3-25.85 62.15T788-84H172Zm88-176h88v-440h-88v440Zm176 0h88v-264h-88v264Zm176 0h88v-352h-88v352Z" />
|
||||||
</svg>
|
</svg>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
export const DashboardFillIcon: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 -960 960 960"
|
||||||
|
fill="currentColor"
|
||||||
|
aria-hidden="true"
|
||||||
|
focusable="false"
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<path d="M520-600v-240h320v240H520ZM120-440v-400h320v400H120Zm400 320v-400h320v400H520Zm-400 0v-240h320v240H120Z" />
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ export function UserMenu() {
|
|||||||
return (
|
return (
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Avatar className="rounded-lg w-10 h-10">
|
<Avatar className="rounded-lg w-10 h-10 cursor-pointer">
|
||||||
{me?.image && (
|
{me?.image && (
|
||||||
<AvatarImage
|
<AvatarImage
|
||||||
src={me.image}
|
src={me.image}
|
||||||
@@ -146,19 +146,6 @@ export function UserMenu() {
|
|||||||
</DropdownMenuPortal>
|
</DropdownMenuPortal>
|
||||||
</DropdownMenuSub>
|
</DropdownMenuSub>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
{me?.role?.toLowerCase() === 'owner' && (
|
|
||||||
<DropdownMenuItem
|
|
||||||
onClick={() =>
|
|
||||||
navigate({
|
|
||||||
to: '/teams/$teamId/dashboard',
|
|
||||||
params: { teamId: teamId! },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
disabled={!teamId}
|
|
||||||
>
|
|
||||||
{m.dashboard()}
|
|
||||||
</DropdownMenuItem>
|
|
||||||
)}
|
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
navigate({
|
navigate({
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||||
|
"home": "Home",
|
||||||
"dashboard": "Dashboard",
|
"dashboard": "Dashboard",
|
||||||
"notifications": "Notifications",
|
"notifications": "Notifications",
|
||||||
"uploads": "Uploads",
|
"uploads": "Uploads",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||||
|
"home": "主页",
|
||||||
"dashboard": "仪表板",
|
"dashboard": "仪表板",
|
||||||
"notifications": "通知",
|
"notifications": "通知",
|
||||||
"uploads": "上传管理",
|
"uploads": "上传管理",
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
export * from "./home.js";
|
||||||
export * from "./dashboard.js";
|
export * from "./dashboard.js";
|
||||||
export * from "./notifications.js";
|
export * from "./notifications.js";
|
||||||
export * from "./uploads.js";
|
export * from "./uploads.js";
|
||||||
|
|||||||
+1
@@ -1,5 +1,6 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||||
|
export * from './home.js'
|
||||||
export * from './dashboard.js'
|
export * from './dashboard.js'
|
||||||
export * from './notifications.js'
|
export * from './notifications.js'
|
||||||
export * from './uploads.js'
|
export * from './uploads.js'
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* | output |
|
||||||
|
* | --- |
|
||||||
|
* | "Home" |
|
||||||
|
*
|
||||||
|
* @param {HomeInputs} inputs
|
||||||
|
* @param {{ locale?: "en" | "zh" }} options
|
||||||
|
* @returns {LocalizedString}
|
||||||
|
*/
|
||||||
|
export const home: ((inputs?: HomeInputs, options?: {
|
||||||
|
locale?: "en" | "zh";
|
||||||
|
}) => LocalizedString) & import("../runtime.js").MessageMetadata<HomeInputs, {
|
||||||
|
locale?: "en" | "zh";
|
||||||
|
}, {}>;
|
||||||
|
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||||
|
export type HomeInputs = {};
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||||
|
|
||||||
|
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||||
|
|
||||||
|
/** @typedef {{}} HomeInputs */
|
||||||
|
|
||||||
|
const en_home = /** @type {(inputs: HomeInputs) => LocalizedString} */ () => {
|
||||||
|
return /** @type {LocalizedString} */ (`Home`)
|
||||||
|
};
|
||||||
|
|
||||||
|
const zh_home = /** @type {(inputs: HomeInputs) => LocalizedString} */ () => {
|
||||||
|
return /** @type {LocalizedString} */ (`主页`)
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* | output |
|
||||||
|
* | --- |
|
||||||
|
* | "Home" |
|
||||||
|
*
|
||||||
|
* @param {HomeInputs} inputs
|
||||||
|
* @param {{ locale?: "en" | "zh" }} options
|
||||||
|
* @returns {LocalizedString}
|
||||||
|
*/
|
||||||
|
export const home = /** @type {((inputs?: HomeInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<HomeInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||||
|
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||||
|
if (locale === "en") return en_home(inputs)
|
||||||
|
return zh_home(inputs)
|
||||||
|
});
|
||||||
@@ -3,6 +3,7 @@ import { DualSidebar, DualSidebarItem } from '@/ui/components/dual-sidebar'
|
|||||||
import { NotificationList } from '@/ui/components/notification-list'
|
import { NotificationList } from '@/ui/components/notification-list'
|
||||||
import { TopNav } from '@/ui/components/top-nav'
|
import { TopNav } from '@/ui/components/top-nav'
|
||||||
import {
|
import {
|
||||||
|
DashboardFillIcon,
|
||||||
HomeIcon,
|
HomeIcon,
|
||||||
KanbanFillIcon,
|
KanbanFillIcon,
|
||||||
NotificationFillIcon,
|
NotificationFillIcon,
|
||||||
@@ -83,13 +84,16 @@ function RootComponent() {
|
|||||||
</span>
|
</span>
|
||||||
) : null
|
) : null
|
||||||
|
|
||||||
|
const isKanbanActive = pathname.includes('/kanban')
|
||||||
|
const isDashboardActive = pathname.includes('/dashboard')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen w-full bg-background overflow-hidden">
|
<div className="flex h-screen w-full bg-background overflow-hidden">
|
||||||
<Toaster />
|
<Toaster />
|
||||||
<DualSidebar>
|
<DualSidebar>
|
||||||
<DualSidebarItem
|
<DualSidebarItem
|
||||||
icon={<HomeIcon />}
|
icon={<HomeIcon />}
|
||||||
label={m.dashboard()}
|
label={m.home()}
|
||||||
onItemClick={() => {
|
onItemClick={() => {
|
||||||
if (storedTeamId) {
|
if (storedTeamId) {
|
||||||
navigate({
|
navigate({
|
||||||
@@ -116,6 +120,7 @@ function RootComponent() {
|
|||||||
<DualSidebarItem
|
<DualSidebarItem
|
||||||
icon={<KanbanFillIcon />}
|
icon={<KanbanFillIcon />}
|
||||||
label={m.kanban()}
|
label={m.kanban()}
|
||||||
|
active={isKanbanActive}
|
||||||
onItemClick={() => {
|
onItemClick={() => {
|
||||||
if (storedTeamId) {
|
if (storedTeamId) {
|
||||||
navigate({
|
navigate({
|
||||||
@@ -125,6 +130,21 @@ function RootComponent() {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{me?.role?.toLowerCase() === 'owner' && (
|
||||||
|
<DualSidebarItem
|
||||||
|
icon={<DashboardFillIcon />}
|
||||||
|
label={m.dashboard()}
|
||||||
|
active={isDashboardActive}
|
||||||
|
onItemClick={() => {
|
||||||
|
if (storedTeamId) {
|
||||||
|
navigate({
|
||||||
|
to: '/teams/$teamId/dashboard',
|
||||||
|
params: { teamId: storedTeamId },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</DualSidebar>
|
</DualSidebar>
|
||||||
<div className="flex flex-col flex-1 md:pl-16 overflow-hidden relative">
|
<div className="flex flex-col flex-1 md:pl-16 overflow-hidden relative">
|
||||||
<TopNav />
|
<TopNav />
|
||||||
|
|||||||
@@ -252,20 +252,14 @@ describe('LocalExecutor Integration Tests', () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Wait briefly for Prisma Client Extension's async submits to trigger
|
// Wait briefly for Prisma Client Extension's async submits to trigger
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100))
|
await vi.waitFor(() => expect(mocks.agentChat).toHaveBeenCalledTimes(5))
|
||||||
|
|
||||||
// Exactly 5 tasks should be running concurrently
|
|
||||||
expect(mocks.agentChat).toHaveBeenCalledTimes(5)
|
|
||||||
|
|
||||||
// Resolve 2 tasks to let the remaining 2 start
|
// Resolve 2 tasks to let the remaining 2 start
|
||||||
activeResolvers[0](undefined)
|
activeResolvers[0](undefined)
|
||||||
activeResolvers[1](undefined)
|
activeResolvers[1](undefined)
|
||||||
|
|
||||||
// Wait briefly for the pool to dequeue
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 50))
|
|
||||||
|
|
||||||
// Now all 7 tasks should have started
|
// Now all 7 tasks should have started
|
||||||
expect(mocks.agentChat).toHaveBeenCalledTimes(7)
|
await vi.waitFor(() => expect(mocks.agentChat).toHaveBeenCalledTimes(7))
|
||||||
|
|
||||||
// Clean up remaining tasks
|
// Clean up remaining tasks
|
||||||
activeResolvers.slice(2).forEach((resolve) => resolve(undefined))
|
activeResolvers.slice(2).forEach((resolve) => resolve(undefined))
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ describe('WorkflowService', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const submitSpy = vi.spyOn(workflowService, 'submit')
|
const submitSpy = vi.spyOn(workflowService, 'submit').mockImplementation(async () => 'mock-id')
|
||||||
|
|
||||||
const task = await prisma.workflowTask.create({
|
const task = await prisma.workflowTask.create({
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
Reference in New Issue
Block a user