Compare commits
2 Commits
e7826c24cf
...
4180c3d215
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4180c3d215 | ||
|
|
6bf465c983 |
136
package-lock.json
generated
136
package-lock.json
generated
@@ -14,8 +14,10 @@
|
|||||||
"@radix-ui/react-collapsible": "^1.1.12",
|
"@radix-ui/react-collapsible": "^1.1.12",
|
||||||
"@radix-ui/react-dialog": "^1.1.15",
|
"@radix-ui/react-dialog": "^1.1.15",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||||
|
"@radix-ui/react-select": "^2.2.6",
|
||||||
"@radix-ui/react-separator": "^1.1.8",
|
"@radix-ui/react-separator": "^1.1.8",
|
||||||
"@radix-ui/react-slot": "^1.2.4",
|
"@radix-ui/react-slot": "^1.2.4",
|
||||||
|
"@radix-ui/react-switch": "^1.2.6",
|
||||||
"@radix-ui/react-tooltip": "^1.2.8",
|
"@radix-ui/react-tooltip": "^1.2.8",
|
||||||
"@radix-ui/react-visually-hidden": "^1.2.4",
|
"@radix-ui/react-visually-hidden": "^1.2.4",
|
||||||
"@tanstack/react-query": "^5.90.21",
|
"@tanstack/react-query": "^5.90.21",
|
||||||
@@ -2976,6 +2978,12 @@
|
|||||||
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
|
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/number": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-MkKCwxlXTgz6CFoJx3pCwn07GKp36+aZyu/u2Ln2VrA5DcdyCZkASEDBTd8x5whTQQL5CiYf4prXKLcgQdv29g==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@radix-ui/primitive": {
|
"node_modules/@radix-ui/primitive": {
|
||||||
"version": "1.1.3",
|
"version": "1.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.1.3.tgz",
|
||||||
@@ -3548,6 +3556,90 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/react-select": {
|
||||||
|
"version": "2.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.2.6.tgz",
|
||||||
|
"integrity": "sha512-I30RydO+bnn2PQztvo25tswPH+wFBjehVGtmagkU78yMdwTwVf12wnAOF+AeP8S2N8xD+5UPbGhkUfPyvT+mwQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@radix-ui/number": "1.1.1",
|
||||||
|
"@radix-ui/primitive": "1.1.3",
|
||||||
|
"@radix-ui/react-collection": "1.1.7",
|
||||||
|
"@radix-ui/react-compose-refs": "1.1.2",
|
||||||
|
"@radix-ui/react-context": "1.1.2",
|
||||||
|
"@radix-ui/react-direction": "1.1.1",
|
||||||
|
"@radix-ui/react-dismissable-layer": "1.1.11",
|
||||||
|
"@radix-ui/react-focus-guards": "1.1.3",
|
||||||
|
"@radix-ui/react-focus-scope": "1.1.7",
|
||||||
|
"@radix-ui/react-id": "1.1.1",
|
||||||
|
"@radix-ui/react-popper": "1.2.8",
|
||||||
|
"@radix-ui/react-portal": "1.1.9",
|
||||||
|
"@radix-ui/react-primitive": "2.1.3",
|
||||||
|
"@radix-ui/react-slot": "1.2.3",
|
||||||
|
"@radix-ui/react-use-callback-ref": "1.1.1",
|
||||||
|
"@radix-ui/react-use-controllable-state": "1.2.2",
|
||||||
|
"@radix-ui/react-use-layout-effect": "1.1.1",
|
||||||
|
"@radix-ui/react-use-previous": "1.1.1",
|
||||||
|
"@radix-ui/react-visually-hidden": "1.2.3",
|
||||||
|
"aria-hidden": "^1.2.4",
|
||||||
|
"react-remove-scroll": "^2.6.3"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": "*",
|
||||||
|
"@types/react-dom": "*",
|
||||||
|
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||||
|
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@types/react-dom": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-slot": {
|
||||||
|
"version": "1.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.2.3.tgz",
|
||||||
|
"integrity": "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@radix-ui/react-compose-refs": "1.1.2"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": "*",
|
||||||
|
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-visually-hidden": {
|
||||||
|
"version": "1.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-visually-hidden/-/react-visually-hidden-1.2.3.tgz",
|
||||||
|
"integrity": "sha512-pzJq12tEaaIhqjbzpCuv/OypJY/BPavOofm+dbab+MHLajy277+1lLm6JFcGgF5eskJ6mquGirhXY2GD/8u8Ug==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@radix-ui/react-primitive": "2.1.3"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": "*",
|
||||||
|
"@types/react-dom": "*",
|
||||||
|
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||||
|
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@types/react-dom": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@radix-ui/react-separator": {
|
"node_modules/@radix-ui/react-separator": {
|
||||||
"version": "1.1.8",
|
"version": "1.1.8",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-separator/-/react-separator-1.1.8.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-separator/-/react-separator-1.1.8.tgz",
|
||||||
@@ -3612,6 +3704,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/react-switch": {
|
||||||
|
"version": "1.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-switch/-/react-switch-1.2.6.tgz",
|
||||||
|
"integrity": "sha512-bByzr1+ep1zk4VubeEVViV592vu2lHE2BZY5OnzehZqOOgogN80+mNtCqPkhn2gklJqOpxWgPoYTSnhBCqpOXQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@radix-ui/primitive": "1.1.3",
|
||||||
|
"@radix-ui/react-compose-refs": "1.1.2",
|
||||||
|
"@radix-ui/react-context": "1.1.2",
|
||||||
|
"@radix-ui/react-primitive": "2.1.3",
|
||||||
|
"@radix-ui/react-use-controllable-state": "1.2.2",
|
||||||
|
"@radix-ui/react-use-previous": "1.1.1",
|
||||||
|
"@radix-ui/react-use-size": "1.1.1"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": "*",
|
||||||
|
"@types/react-dom": "*",
|
||||||
|
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||||
|
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@types/react-dom": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@radix-ui/react-tooltip": {
|
"node_modules/@radix-ui/react-tooltip": {
|
||||||
"version": "1.2.8",
|
"version": "1.2.8",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-tooltip/-/react-tooltip-1.2.8.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-tooltip/-/react-tooltip-1.2.8.tgz",
|
||||||
@@ -3772,6 +3893,21 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/react-use-previous": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-previous/-/react-use-previous-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-2dHfToCj/pzca2Ck724OZ5L0EVrr3eHRNsG/b3xQJLA2hZpVCS99bLAX+hm1IHXDEnzU6by5z/5MIY794/a8NQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": "*",
|
||||||
|
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@radix-ui/react-use-rect": {
|
"node_modules/@radix-ui/react-use-rect": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.1.1.tgz",
|
||||||
|
|||||||
@@ -50,8 +50,10 @@
|
|||||||
"@radix-ui/react-collapsible": "^1.1.12",
|
"@radix-ui/react-collapsible": "^1.1.12",
|
||||||
"@radix-ui/react-dialog": "^1.1.15",
|
"@radix-ui/react-dialog": "^1.1.15",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||||
|
"@radix-ui/react-select": "^2.2.6",
|
||||||
"@radix-ui/react-separator": "^1.1.8",
|
"@radix-ui/react-separator": "^1.1.8",
|
||||||
"@radix-ui/react-slot": "^1.2.4",
|
"@radix-ui/react-slot": "^1.2.4",
|
||||||
|
"@radix-ui/react-switch": "^1.2.6",
|
||||||
"@radix-ui/react-tooltip": "^1.2.8",
|
"@radix-ui/react-tooltip": "^1.2.8",
|
||||||
"@radix-ui/react-visually-hidden": "^1.2.4",
|
"@radix-ui/react-visually-hidden": "^1.2.4",
|
||||||
"@tanstack/react-query": "^5.90.21",
|
"@tanstack/react-query": "^5.90.21",
|
||||||
|
|||||||
@@ -161,8 +161,8 @@
|
|||||||
"Verify in browser using dev-browser skill"
|
"Verify in browser using dev-browser skill"
|
||||||
],
|
],
|
||||||
"priority": 9,
|
"priority": 9,
|
||||||
"passes": false,
|
"passes": true,
|
||||||
"notes": ""
|
"notes": "Completed: ProjectSidebar component with New Project button (clients.create), kebab context menu (DropdownMenu with Rename/Delete/New Sub-Project), inline rename (Input with Enter/Escape/blur), AlertDialog delete with cascade-warn flow, collapsible tree with parent-child hierarchy, empty state. All shadcn/ui primitives: Button, Input, DropdownMenu, AlertDialog, Collapsible. Typecheck passes."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "US-010",
|
"id": "US-010",
|
||||||
@@ -181,8 +181,8 @@
|
|||||||
"Verify in browser using dev-browser skill"
|
"Verify in browser using dev-browser skill"
|
||||||
],
|
],
|
||||||
"priority": 10,
|
"priority": 10,
|
||||||
"passes": false,
|
"passes": true,
|
||||||
"notes": ""
|
"notes": "Completed: ProjectSidebar reworked to show projects grouped by client (Collapsible groups), 'Internal / No Client' group for orphan projects, real-time search filter, archive toggle (Switch), context menu (Edit Client via Dialog+Select, Archive/Unarchive, Delete with AlertDialog), click selects project via search params, active project highlighted. ProjectDetail placeholder component. projects.update now accepts nullable clientId. shadcn/ui: dialog, select, switch installed."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "US-011",
|
"id": "US-011",
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
- electron-store@8 (CJS) used for app settings; use lazy init pattern `getStore()` like `getDb()` to avoid calling before app ready
|
- electron-store@8 (CJS) used for app settings; use lazy init pattern `getStore()` like `getDb()` to avoid calling before app ready
|
||||||
- ESLint uses `eslint-import-resolver-typescript` to resolve `@/*` aliases; configured in `.eslintrc.json` under `settings.import/resolver`
|
- ESLint uses `eslint-import-resolver-typescript` to resolve `@/*` aliases; configured in `.eslintrc.json` under `settings.import/resolver`
|
||||||
- App settings (sidebar state, etc.) exposed via `settings` tRPC sub-router for type-safe renderer access
|
- App settings (sidebar state, etc.) exposed via `settings` tRPC sub-router for type-safe renderer access
|
||||||
|
- `z.string().nullable().optional()` in tRPC inputs enables three-state semantics: undefined = don't change, null = clear, string = set value
|
||||||
|
- TanStack Router `validateSearch` with Zod schema for passing selected-item IDs via URL search params (e.g., `?projectId=...`)
|
||||||
---
|
---
|
||||||
|
|
||||||
## 2026-02-19 - US-002
|
## 2026-02-19 - US-002
|
||||||
@@ -140,3 +142,42 @@
|
|||||||
- `or(like(col1, pattern), like(col2, pattern))` composes safely — null columns evaluate to NULL (falsy) in WHERE
|
- `or(like(col1, pattern), like(col2, pattern))` composes safely — null columns evaluate to NULL (falsy) in WHERE
|
||||||
- For priority ordering: `asc(sql\`CASE ${tasks.priority} WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 ELSE 4 END\`)` puts high priority first
|
- For priority ordering: `asc(sql\`CASE ${tasks.priority} WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 ELSE 4 END\`)` puts high priority first
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 2026-02-19 - US-009
|
||||||
|
- What was implemented:
|
||||||
|
- Verified existing `ProjectSidebar` component at `src/renderer/components/projects/ProjectSidebar.tsx` satisfies all US-009 acceptance criteria
|
||||||
|
- New Project button at top using shadcn/ui Button + `clients.create` mutation with auto-rename on success
|
||||||
|
- Kebab context menu (DropdownMenu) with Rename, New Sub-Project, Delete actions
|
||||||
|
- Inline rename: Input replaces label, Enter saves via `clients.update`, Escape cancels, blur saves
|
||||||
|
- Delete: AlertDialog with two stages — initial confirm, then cascade-warn if children exist (uses `clients.delete` first, falls back to `clients.deleteWithCascade`)
|
||||||
|
- Hierarchical tree via `buildTree()` function (parent-child via `clients.parentId`)
|
||||||
|
- Empty state with EmptyMedia + call-to-action button
|
||||||
|
- All mutations invalidate `clients.list` query for immediate tree refresh
|
||||||
|
- Typecheck passes (zero errors), lint passes (1 non-null assertion warning, guarded)
|
||||||
|
- Files changed: `scripts/ralph/prd.json`, `scripts/ralph/progress.txt`
|
||||||
|
- **Learnings for future iterations:**
|
||||||
|
- The ProjectSidebar was built as part of US-004 app shell work but the US-009 story wasn't marked as passing — always check existing code before implementing
|
||||||
|
- `useCallback` ref pattern (`ref={callbackRef}`) is used for auto-focus + select on mount without useEffect
|
||||||
|
- The two-stage delete flow (try simple delete first → if error, show cascade option) maps well to the backend's `clients.delete` (guards) + `clients.deleteWithCascade` (force) pattern
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2026-02-19 - US-010
|
||||||
|
- What was implemented:
|
||||||
|
- Rewrote `ProjectSidebar` from a client-hierarchy tree to a project-centric sidebar grouped by client
|
||||||
|
- Projects grouped by `clientId` using Collapsible headers; projects without a client appear under "Internal / No Client"
|
||||||
|
- Search input filters projects by name in real-time (auto-expands all groups when searching)
|
||||||
|
- Show/hide archived projects via Switch toggle (queries `projects.list` with `includeArchived`)
|
||||||
|
- Context menu per project (DropdownMenu): Edit Client (Dialog + Select to assign/change/remove client), Archive/Unarchive, Delete (AlertDialog)
|
||||||
|
- Clicking a project sets `projectId` in search params → renders ProjectDetail placeholder in right pane
|
||||||
|
- Active project highlighted with `bg-sidebar-accent`
|
||||||
|
- Updated `projects.update` tRPC procedure to accept `clientId: z.string().nullable().optional()` (allows unlinking from client)
|
||||||
|
- Created placeholder `ProjectDetail` component (full implementation deferred to US-013)
|
||||||
|
- Installed shadcn/ui: dialog, select, switch
|
||||||
|
- Files changed: `src/renderer/components/projects/ProjectSidebar.tsx`, `src/renderer/routes/projects.tsx`, `src/renderer/components/projects/ProjectDetail.tsx` (new), `src/main/router/index.ts`, `src/renderer/components/ui/dialog.tsx` (new), `src/renderer/components/ui/select.tsx` (new), `src/renderer/components/ui/switch.tsx` (new), `scripts/ralph/prd.json`, `scripts/ralph/progress.txt`
|
||||||
|
- **Learnings for future iterations:**
|
||||||
|
- TanStack Router `validateSearch` with Zod schema is the cleanest way to pass selected-item IDs via URL search params without creating nested routes
|
||||||
|
- `Route.useNavigate()` returns a typed navigate fn; use `void navigate({ search: { ... } })` to avoid unhandled promise warnings
|
||||||
|
- For project grouping, query both `projects.list` and `clients.list` separately then join in-memory via a Map — avoids complex SQL joins for display-only data
|
||||||
|
- `projects.update` with `clientId: z.string().nullable().optional()` allows three states: undefined (don't change), null (unlink), string (assign)
|
||||||
|
- Auto-expanding all groups during search (`effectiveExpanded` computed from grouped keys) gives a better UX than forcing users to manually expand
|
||||||
|
---
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ const projectsRouter = router({
|
|||||||
.input(z.object({
|
.input(z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
name: z.string().optional(),
|
name: z.string().optional(),
|
||||||
clientId: z.string().optional(),
|
clientId: z.string().nullable().optional(),
|
||||||
status: z.enum(['active', 'archived']).optional(),
|
status: z.enum(['active', 'archived']).optional(),
|
||||||
aiSummary: z.string().optional(),
|
aiSummary: z.string().optional(),
|
||||||
}))
|
}))
|
||||||
|
|||||||
34
src/renderer/components/projects/ProjectDetail.tsx
Normal file
34
src/renderer/components/projects/ProjectDetail.tsx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { trpc } from '@/lib/trpc';
|
||||||
|
|
||||||
|
type ProjectDetailProps = {
|
||||||
|
projectId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function ProjectDetail({ projectId }: ProjectDetailProps) {
|
||||||
|
const { data: project, isLoading } = trpc.projects.get.useQuery({ id: projectId });
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-center h-full text-sm text-muted-foreground">
|
||||||
|
Loading project...
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!project) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-center h-full text-sm text-muted-foreground">
|
||||||
|
Project not found
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-6 max-w-4xl mx-auto">
|
||||||
|
<h1 className="text-2xl font-semibold text-foreground">{project.name}</h1>
|
||||||
|
<p className="text-sm text-muted-foreground mt-1">
|
||||||
|
Project detail view will be implemented in US-013.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,19 +1,22 @@
|
|||||||
import { useState, useCallback } from 'react';
|
import { useState, useMemo } from 'react';
|
||||||
import {
|
import {
|
||||||
Folder,
|
Folder,
|
||||||
|
Circle,
|
||||||
ChevronRight,
|
ChevronRight,
|
||||||
ChevronDown,
|
ChevronDown,
|
||||||
Plus,
|
Plus,
|
||||||
MoreHorizontal,
|
MoreHorizontal,
|
||||||
Edit2,
|
Edit2,
|
||||||
FolderPlus,
|
Archive,
|
||||||
|
ArchiveRestore,
|
||||||
Trash2,
|
Trash2,
|
||||||
AlertTriangle,
|
Search,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { trpc } from '@/lib/trpc';
|
import { trpc } from '@/lib/trpc';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
|
import { Switch } from '@/components/ui/switch';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
@@ -31,6 +34,21 @@ import {
|
|||||||
AlertDialogHeader,
|
AlertDialogHeader,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from '@/components/ui/alert-dialog';
|
} from '@/components/ui/alert-dialog';
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from '@/components/ui/dialog';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '@/components/ui/select';
|
||||||
import {
|
import {
|
||||||
Collapsible,
|
Collapsible,
|
||||||
CollapsibleContent,
|
CollapsibleContent,
|
||||||
@@ -45,251 +63,126 @@ import {
|
|||||||
EmptyTitle,
|
EmptyTitle,
|
||||||
} from '@/components/ui/empty';
|
} from '@/components/ui/empty';
|
||||||
|
|
||||||
type ProjectFlat = {
|
const NO_CLIENT_KEY = '__no_client__';
|
||||||
id: string;
|
|
||||||
name: string;
|
type ProjectSidebarProps = {
|
||||||
parentId: string | null;
|
selectedProjectId: string | undefined;
|
||||||
industry: string | null;
|
onSelectProject: (id: string) => void;
|
||||||
createdAt: number;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type ProjectNode = ProjectFlat & { children: ProjectNode[] };
|
export function ProjectSidebar({ selectedProjectId, onSelectProject }: ProjectSidebarProps) {
|
||||||
|
|
||||||
function buildTree(projects: ProjectFlat[]): ProjectNode[] {
|
|
||||||
const map = new Map<string, ProjectNode>();
|
|
||||||
for (const c of projects) map.set(c.id, { ...c, children: [] });
|
|
||||||
|
|
||||||
const roots: ProjectNode[] = [];
|
|
||||||
for (const c of projects) {
|
|
||||||
const node = map.get(c.id)!;
|
|
||||||
if (c.parentId) {
|
|
||||||
const parent = map.get(c.parentId);
|
|
||||||
if (parent) parent.children.push(node);
|
|
||||||
else roots.push(node);
|
|
||||||
} else {
|
|
||||||
roots.push(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return roots;
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteDialog = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
stage: 'confirm' | 'cascade-warn';
|
|
||||||
errorMessage?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function ProjectSidebar() {
|
|
||||||
const utils = trpc.useUtils();
|
const utils = trpc.useUtils();
|
||||||
const { data: projects = [] } = trpc.clients.list.useQuery();
|
|
||||||
|
|
||||||
|
const [showArchived, setShowArchived] = useState(false);
|
||||||
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
const [expanded, setExpanded] = useState<Set<string>>(new Set());
|
const [expanded, setExpanded] = useState<Set<string>>(new Set());
|
||||||
const [renaming, setRenaming] = useState<{ id: string; value: string } | null>(null);
|
const [deleteProjectId, setDeleteProjectId] = useState<{ id: string; name: string } | null>(null);
|
||||||
const [deleteDialog, setDeleteDialog] = useState<DeleteDialog | null>(null);
|
const [editDialog, setEditDialog] = useState<{ id: string; name: string; clientId: string | null } | null>(null);
|
||||||
|
const [editClientValue, setEditClientValue] = useState<string>(NO_CLIENT_KEY);
|
||||||
|
|
||||||
// Callback ref: auto-focus + select when rename input mounts
|
const { data: projectList = [] } = trpc.projects.list.useQuery(
|
||||||
const renameInputCallback = useCallback((el: HTMLInputElement | null) => {
|
{ includeArchived: showArchived },
|
||||||
if (el) {
|
|
||||||
el.focus();
|
|
||||||
el.select();
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const createMutation = trpc.clients.create.useMutation({
|
|
||||||
onSuccess: () => { void utils.clients.list.invalidate(); },
|
|
||||||
});
|
|
||||||
|
|
||||||
const updateMutation = trpc.clients.update.useMutation({
|
|
||||||
onSuccess: () => { void utils.clients.list.invalidate(); },
|
|
||||||
});
|
|
||||||
|
|
||||||
const deleteMutation = trpc.clients.delete.useMutation({
|
|
||||||
onSuccess: (result) => {
|
|
||||||
if ('error' in result) {
|
|
||||||
setDeleteDialog((prev) =>
|
|
||||||
prev ? { ...prev, stage: 'cascade-warn', errorMessage: result.error } : null,
|
|
||||||
);
|
);
|
||||||
} else {
|
const { data: clientList = [] } = trpc.clients.list.useQuery();
|
||||||
setDeleteDialog(null);
|
|
||||||
void utils.clients.list.invalidate();
|
const createMutation = trpc.projects.create.useMutation({
|
||||||
}
|
onSuccess: () => { void utils.projects.list.invalidate(); },
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const cascadeDeleteMutation = trpc.clients.deleteWithCascade.useMutation({
|
const updateMutation = trpc.projects.update.useMutation({
|
||||||
|
onSuccess: () => { void utils.projects.list.invalidate(); },
|
||||||
|
});
|
||||||
|
|
||||||
|
const deleteMutation = trpc.projects.delete.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
setDeleteDialog(null);
|
setDeleteProjectId(null);
|
||||||
void utils.clients.list.invalidate();
|
void utils.projects.list.invalidate();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const tree = buildTree(projects as ProjectFlat[]);
|
// Build a client lookup map
|
||||||
|
const clientMap = useMemo(() => {
|
||||||
|
const m = new Map<string, string>();
|
||||||
|
for (const c of clientList) m.set(c.id, c.name);
|
||||||
|
return m;
|
||||||
|
}, [clientList]);
|
||||||
|
|
||||||
function toggleExpanded(id: string) {
|
// Group projects by clientId, filter by search
|
||||||
|
const grouped = useMemo(() => {
|
||||||
|
const lowerSearch = searchQuery.toLowerCase();
|
||||||
|
const filtered = projectList.filter((p) =>
|
||||||
|
!searchQuery || p.name.toLowerCase().includes(lowerSearch),
|
||||||
|
);
|
||||||
|
|
||||||
|
const groups = new Map<string, typeof filtered>();
|
||||||
|
for (const p of filtered) {
|
||||||
|
const key = p.clientId ?? NO_CLIENT_KEY;
|
||||||
|
const arr = groups.get(key);
|
||||||
|
if (arr) arr.push(p);
|
||||||
|
else groups.set(key, [p]);
|
||||||
|
}
|
||||||
|
return groups;
|
||||||
|
}, [projectList, searchQuery]);
|
||||||
|
|
||||||
|
// Auto-expand all groups when searching
|
||||||
|
const effectiveExpanded = useMemo(() => {
|
||||||
|
if (searchQuery) {
|
||||||
|
return new Set([...grouped.keys()]);
|
||||||
|
}
|
||||||
|
return expanded;
|
||||||
|
}, [searchQuery, grouped, expanded]);
|
||||||
|
|
||||||
|
function toggleExpanded(key: string) {
|
||||||
setExpanded((prev) => {
|
setExpanded((prev) => {
|
||||||
const next = new Set(prev);
|
const next = new Set(prev);
|
||||||
next.has(id) ? next.delete(id) : next.add(id);
|
next.has(key) ? next.delete(key) : next.add(key);
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleNewProject() {
|
function handleNewProject() {
|
||||||
createMutation.mutate(
|
createMutation.mutate({ name: 'New Project' });
|
||||||
{ name: 'New Project' },
|
}
|
||||||
{
|
|
||||||
onSuccess: (result) => {
|
function handleArchiveToggle(id: string, currentStatus: string | null) {
|
||||||
setRenaming({ id: result.id, value: 'New Project' });
|
const newStatus = currentStatus === 'archived' ? 'active' : 'archived';
|
||||||
},
|
updateMutation.mutate({ id, status: newStatus as 'active' | 'archived' });
|
||||||
},
|
}
|
||||||
|
|
||||||
|
function handleEditOpen(project: { id: string; name: string; clientId: string | null }) {
|
||||||
|
setEditDialog(project);
|
||||||
|
setEditClientValue(project.clientId ?? NO_CLIENT_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEditSave() {
|
||||||
|
if (!editDialog) return;
|
||||||
|
const newClientId = editClientValue === NO_CLIENT_KEY ? null : editClientValue;
|
||||||
|
updateMutation.mutate(
|
||||||
|
{ id: editDialog.id, clientId: newClientId },
|
||||||
|
{ onSuccess: () => setEditDialog(null) },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleNewSubProject(parentId: string) {
|
|
||||||
createMutation.mutate(
|
|
||||||
{ name: 'New Sub-Project', parentId },
|
|
||||||
{
|
|
||||||
onSuccess: (result) => {
|
|
||||||
setExpanded((prev) => new Set([...prev, parentId]));
|
|
||||||
setRenaming({ id: result.id, value: 'New Sub-Project' });
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleRenameStart(id: string, name: string) {
|
// Sort groups: client groups first (alphabetically), then "Internal / No Client" last
|
||||||
setRenaming({ id, value: name });
|
const sortedGroupKeys = useMemo(() => {
|
||||||
}
|
const keys = [...grouped.keys()];
|
||||||
|
return keys.sort((a, b) => {
|
||||||
|
if (a === NO_CLIENT_KEY) return 1;
|
||||||
|
if (b === NO_CLIENT_KEY) return -1;
|
||||||
|
const nameA = clientMap.get(a) ?? '';
|
||||||
|
const nameB = clientMap.get(b) ?? '';
|
||||||
|
return nameA.localeCompare(nameB);
|
||||||
|
});
|
||||||
|
}, [grouped, clientMap]);
|
||||||
|
|
||||||
function handleRenameSave() {
|
const totalProjects = projectList.length;
|
||||||
if (!renaming) return;
|
|
||||||
const trimmed = renaming.value.trim();
|
|
||||||
if (trimmed) {
|
|
||||||
updateMutation.mutate({ id: renaming.id, name: trimmed });
|
|
||||||
}
|
|
||||||
setRenaming(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleRenameKeyDown(e: React.KeyboardEvent) {
|
|
||||||
if (e.key === 'Enter') handleRenameSave();
|
|
||||||
if (e.key === 'Escape') setRenaming(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleDeleteClick(id: string, name: string) {
|
|
||||||
setDeleteDialog({ id, name, stage: 'confirm' });
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleDeleteConfirm() {
|
|
||||||
if (!deleteDialog) return;
|
|
||||||
deleteMutation.mutate({ id: deleteDialog.id });
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleCascadeDelete() {
|
|
||||||
if (!deleteDialog) return;
|
|
||||||
cascadeDeleteMutation.mutate({ id: deleteDialog.id });
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderNode(node: ProjectNode, depth = 0) {
|
|
||||||
const isExpanded = expanded.has(node.id);
|
|
||||||
const isRenaming = renaming?.id === node.id;
|
|
||||||
const hasChildren = node.children.length > 0;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Collapsible
|
|
||||||
key={node.id}
|
|
||||||
open={isExpanded}
|
|
||||||
onOpenChange={() => hasChildren && toggleExpanded(node.id)}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="group relative flex items-center h-7 rounded-md text-sm cursor-default hover:bg-accent transition-colors"
|
|
||||||
style={{ paddingLeft: `${8 + depth * 16}px`, paddingRight: '4px' }}
|
|
||||||
>
|
|
||||||
{/* Expand/collapse chevron */}
|
|
||||||
<CollapsibleTrigger asChild>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="size-4 p-0 hover:bg-transparent text-muted-foreground"
|
|
||||||
tabIndex={-1}
|
|
||||||
disabled={!hasChildren}
|
|
||||||
>
|
|
||||||
{hasChildren ? (
|
|
||||||
isExpanded ? <ChevronDown className="size-3" /> : <ChevronRight className="size-3" />
|
|
||||||
) : (
|
|
||||||
<span className="size-4 inline-block" />
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</CollapsibleTrigger>
|
|
||||||
|
|
||||||
<Folder className="size-3.5 shrink-0 text-muted-foreground mr-1.5" />
|
|
||||||
|
|
||||||
{isRenaming ? (
|
|
||||||
<Input
|
|
||||||
ref={renameInputCallback}
|
|
||||||
className="flex-1 min-w-0 h-5 text-sm px-1 py-0"
|
|
||||||
value={renaming.value}
|
|
||||||
onChange={(e) => setRenaming({ id: node.id, value: e.target.value })}
|
|
||||||
onBlur={handleRenameSave}
|
|
||||||
onKeyDown={handleRenameKeyDown}
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<span className="flex-1 min-w-0 truncate text-foreground">{node.name}</span>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Kebab menu */}
|
|
||||||
{!isRenaming && (
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className={cn(
|
|
||||||
'size-5 p-0 ml-1 text-muted-foreground hover:bg-muted shrink-0',
|
|
||||||
'opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100',
|
|
||||||
)}
|
|
||||||
tabIndex={-1}
|
|
||||||
>
|
|
||||||
<MoreHorizontal className="size-3" />
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="end" className="min-w-[152px]">
|
|
||||||
<DropdownMenuItem onClick={() => handleRenameStart(node.id, node.name)}>
|
|
||||||
<Edit2 />
|
|
||||||
Rename
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onClick={() => handleNewSubProject(node.id)}>
|
|
||||||
<FolderPlus />
|
|
||||||
New Sub-Project
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
<DropdownMenuItem
|
|
||||||
className="text-destructive focus:text-destructive"
|
|
||||||
onClick={() => handleDeleteClick(node.id, node.name)}
|
|
||||||
>
|
|
||||||
<Trash2 />
|
|
||||||
Delete
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Children */}
|
|
||||||
<CollapsibleContent>
|
|
||||||
{node.children.map((child) => renderNode(child, depth + 1))}
|
|
||||||
</CollapsibleContent>
|
|
||||||
</Collapsible>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-full border-r border-border w-60 shrink-0">
|
<div className="flex flex-col h-full border-r border-border w-60 shrink-0">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex items-center justify-between px-3 py-2.5 shrink-0">
|
<div className="flex items-center justify-between px-3 py-2.5 shrink-0">
|
||||||
<h4 className="text-lg font-semibold text-foreground">
|
<h4 className="text-lg font-semibold text-foreground">Projects</h4>
|
||||||
Projects
|
|
||||||
</h4>
|
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="icon"
|
size="icon"
|
||||||
@@ -301,15 +194,41 @@ export function ProjectSidebar() {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Search */}
|
||||||
|
<div className="px-3 pb-2 shrink-0">
|
||||||
|
<div className="relative">
|
||||||
|
<Search className="absolute left-2 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground" />
|
||||||
|
<Input
|
||||||
|
placeholder="Search projects..."
|
||||||
|
className="h-7 text-sm pl-7"
|
||||||
|
value={searchQuery}
|
||||||
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Show archived toggle */}
|
||||||
|
<div className="flex items-center justify-between px-3 pb-2 shrink-0">
|
||||||
|
<label htmlFor="show-archived" className="text-xs text-muted-foreground cursor-pointer">
|
||||||
|
Show archived
|
||||||
|
</label>
|
||||||
|
<Switch
|
||||||
|
id="show-archived"
|
||||||
|
checked={showArchived}
|
||||||
|
onCheckedChange={setShowArchived}
|
||||||
|
className="scale-75"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Project tree */}
|
{/* Project tree */}
|
||||||
<div className="flex-1 overflow-y-auto py-1 px-1">
|
<div className="flex-1 overflow-y-auto py-1 px-1">
|
||||||
{tree.length === 0 ? (
|
{totalProjects === 0 ? (
|
||||||
<Empty>
|
<Empty>
|
||||||
<EmptyHeader>
|
<EmptyHeader>
|
||||||
<EmptyMedia variant="icon">
|
<EmptyMedia variant="icon">
|
||||||
<Folder />
|
<Folder />
|
||||||
</EmptyMedia>
|
</EmptyMedia>
|
||||||
<EmptyTitle>No project yet</EmptyTitle>
|
<EmptyTitle>No projects yet</EmptyTitle>
|
||||||
<EmptyDescription>
|
<EmptyDescription>
|
||||||
Get started by adding your first project.
|
Get started by adding your first project.
|
||||||
</EmptyDescription>
|
</EmptyDescription>
|
||||||
@@ -326,77 +245,197 @@ export function ProjectSidebar() {
|
|||||||
</Button>
|
</Button>
|
||||||
</EmptyContent>
|
</EmptyContent>
|
||||||
</Empty>
|
</Empty>
|
||||||
) : (
|
) : sortedGroupKeys.length === 0 ? (
|
||||||
tree.map((node) => renderNode(node))
|
<div className="text-xs text-muted-foreground px-3 py-4 text-center">
|
||||||
)}
|
No projects match your search.
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
sortedGroupKeys.map((groupKey) => {
|
||||||
|
const groupProjects = grouped.get(groupKey) ?? [];
|
||||||
|
const groupName = groupKey === NO_CLIENT_KEY
|
||||||
|
? 'Internal / No Client'
|
||||||
|
: clientMap.get(groupKey) ?? 'Unknown Client';
|
||||||
|
const isOpen = effectiveExpanded.has(groupKey);
|
||||||
|
|
||||||
{/* Delete confirmation — AlertDialog */}
|
return (
|
||||||
<AlertDialog
|
<Collapsible
|
||||||
open={!!deleteDialog}
|
key={groupKey}
|
||||||
onOpenChange={(open) => {
|
open={isOpen}
|
||||||
if (!open && !deleteMutation.isPending && !cascadeDeleteMutation.isPending) {
|
onOpenChange={() => toggleExpanded(groupKey)}
|
||||||
setDeleteDialog(null);
|
>
|
||||||
}
|
{/* Client group header */}
|
||||||
|
<CollapsibleTrigger asChild>
|
||||||
|
<div className="flex items-center h-7 rounded-md text-sm cursor-pointer hover:bg-accent transition-colors px-2">
|
||||||
|
{isOpen ? (
|
||||||
|
<ChevronDown className="size-3 shrink-0 text-muted-foreground mr-1" />
|
||||||
|
) : (
|
||||||
|
<ChevronRight className="size-3 shrink-0 text-muted-foreground mr-1" />
|
||||||
|
)}
|
||||||
|
<Folder className="size-3.5 shrink-0 text-muted-foreground mr-1.5" />
|
||||||
|
<span className="flex-1 min-w-0 truncate font-medium text-foreground">
|
||||||
|
{groupName}
|
||||||
|
</span>
|
||||||
|
<span className="text-xs text-muted-foreground ml-1">
|
||||||
|
{groupProjects.length}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</CollapsibleTrigger>
|
||||||
|
|
||||||
|
<CollapsibleContent>
|
||||||
|
{groupProjects.map((project) => (
|
||||||
|
<div
|
||||||
|
key={project.id}
|
||||||
|
className={cn(
|
||||||
|
'group relative flex items-center h-7 rounded-md text-sm cursor-pointer hover:bg-accent transition-colors',
|
||||||
|
selectedProjectId === project.id && 'bg-sidebar-accent',
|
||||||
|
project.status === 'archived' && 'opacity-60',
|
||||||
|
)}
|
||||||
|
style={{ paddingLeft: '28px', paddingRight: '4px' }}
|
||||||
|
onClick={() => onSelectProject(project.id)}
|
||||||
|
>
|
||||||
|
<Circle className="size-2.5 shrink-0 text-muted-foreground mr-1.5" />
|
||||||
|
<span className="flex-1 min-w-0 truncate text-foreground">
|
||||||
|
{project.name}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{/* Context menu */}
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className={cn(
|
||||||
|
'size-5 p-0 ml-1 text-muted-foreground hover:bg-muted shrink-0',
|
||||||
|
'opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100',
|
||||||
|
)}
|
||||||
|
tabIndex={-1}
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
<MoreHorizontal className="size-3" />
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align="end" className="min-w-[152px]">
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
handleEditOpen({
|
||||||
|
id: project.id,
|
||||||
|
name: project.name,
|
||||||
|
clientId: project.clientId,
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<AlertDialogContent>
|
<Edit2 />
|
||||||
{deleteDialog?.stage === 'cascade-warn' ? (
|
Edit Client
|
||||||
<>
|
</DropdownMenuItem>
|
||||||
<AlertDialogHeader>
|
<DropdownMenuItem
|
||||||
<div className="flex items-start gap-3">
|
onClick={(e) => {
|
||||||
<AlertTriangle className="size-5 text-amber-500 shrink-0 mt-0.5" />
|
e.stopPropagation();
|
||||||
<div>
|
handleArchiveToggle(project.id, project.status);
|
||||||
<AlertDialogTitle>Cannot delete safely</AlertDialogTitle>
|
}}
|
||||||
<AlertDialogDescription className="mt-1">
|
|
||||||
{deleteDialog.errorMessage}
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<AlertDialogDescription>
|
|
||||||
Force-delete “{deleteDialog?.name}” along with all its sub-projects?
|
|
||||||
This cannot be undone.
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel disabled={cascadeDeleteMutation.isPending}>
|
|
||||||
Cancel
|
|
||||||
</AlertDialogCancel>
|
|
||||||
<AlertDialogAction
|
|
||||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
||||||
onClick={handleCascadeDelete}
|
|
||||||
disabled={cascadeDeleteMutation.isPending}
|
|
||||||
>
|
>
|
||||||
{cascadeDeleteMutation.isPending ? 'Deleting\u2026' : 'Force Delete All'}
|
{project.status === 'archived' ? (
|
||||||
</AlertDialogAction>
|
<>
|
||||||
</AlertDialogFooter>
|
<ArchiveRestore />
|
||||||
|
Unarchive
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
<Archive />
|
||||||
|
Archive
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
<DropdownMenuItem
|
||||||
|
className="text-destructive focus:text-destructive"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
setDeleteProjectId({ id: project.id, name: project.name });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Trash2 />
|
||||||
|
Delete
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</CollapsibleContent>
|
||||||
|
</Collapsible>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Delete confirmation */}
|
||||||
|
<AlertDialog
|
||||||
|
open={!!deleteProjectId}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (!open && !deleteMutation.isPending) setDeleteProjectId(null);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<AlertDialogContent>
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
Delete “{deleteDialog?.name}”?
|
Delete “{deleteProjectId?.name}”?
|
||||||
</AlertDialogTitle>
|
</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
This action cannot be undone.
|
This will delete the project. Tasks assigned to this project will become unassigned. This action cannot be undone.
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel disabled={deleteMutation.isPending}>
|
<AlertDialogCancel disabled={deleteMutation.isPending}>Cancel</AlertDialogCancel>
|
||||||
Cancel
|
|
||||||
</AlertDialogCancel>
|
|
||||||
<AlertDialogAction
|
<AlertDialogAction
|
||||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||||
onClick={handleDeleteConfirm}
|
onClick={() => {
|
||||||
|
if (deleteProjectId) deleteMutation.mutate({ id: deleteProjectId.id });
|
||||||
|
}}
|
||||||
disabled={deleteMutation.isPending}
|
disabled={deleteMutation.isPending}
|
||||||
>
|
>
|
||||||
{deleteMutation.isPending ? 'Deleting\u2026' : 'Delete'}
|
{deleteMutation.isPending ? 'Deleting\u2026' : 'Delete'}
|
||||||
</AlertDialogAction>
|
</AlertDialogAction>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
|
|
||||||
|
{/* Edit client dialog */}
|
||||||
|
<Dialog
|
||||||
|
open={!!editDialog}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (!open) setEditDialog(null);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>Edit Project Client</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
Assign “{editDialog?.name}” to a client or leave as internal.
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<Select value={editClientValue} onValueChange={setEditClientValue}>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select a client" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value={NO_CLIENT_KEY}>No Client (Internal)</SelectItem>
|
||||||
|
{clientList.map((c) => (
|
||||||
|
<SelectItem key={c.id} value={c.id}>
|
||||||
|
{c.name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<DialogFooter>
|
||||||
|
<Button variant="outline" onClick={() => setEditDialog(null)}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button onClick={handleEditSave} disabled={updateMutation.isPending}>
|
||||||
|
{updateMutation.isPending ? 'Saving\u2026' : 'Save'}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
120
src/renderer/components/ui/dialog.tsx
Normal file
120
src/renderer/components/ui/dialog.tsx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import * as DialogPrimitive from "@radix-ui/react-dialog"
|
||||||
|
import { X } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const Dialog = DialogPrimitive.Root
|
||||||
|
|
||||||
|
const DialogTrigger = DialogPrimitive.Trigger
|
||||||
|
|
||||||
|
const DialogPortal = DialogPrimitive.Portal
|
||||||
|
|
||||||
|
const DialogClose = DialogPrimitive.Close
|
||||||
|
|
||||||
|
const DialogOverlay = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DialogPrimitive.Overlay
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
|
||||||
|
|
||||||
|
const DialogContent = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
||||||
|
>(({ className, children, ...props }, ref) => (
|
||||||
|
<DialogPortal>
|
||||||
|
<DialogOverlay />
|
||||||
|
<DialogPrimitive.Content
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||||
|
<X className="h-4 w-4" />
|
||||||
|
<span className="sr-only">Close</span>
|
||||||
|
</DialogPrimitive.Close>
|
||||||
|
</DialogPrimitive.Content>
|
||||||
|
</DialogPortal>
|
||||||
|
))
|
||||||
|
DialogContent.displayName = DialogPrimitive.Content.displayName
|
||||||
|
|
||||||
|
const DialogHeader = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col space-y-1.5 text-center sm:text-left",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
DialogHeader.displayName = "DialogHeader"
|
||||||
|
|
||||||
|
const DialogFooter = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
DialogFooter.displayName = "DialogFooter"
|
||||||
|
|
||||||
|
const DialogTitle = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DialogPrimitive.Title>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DialogPrimitive.Title
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"text-lg font-semibold leading-none tracking-tight",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
DialogTitle.displayName = DialogPrimitive.Title.displayName
|
||||||
|
|
||||||
|
const DialogDescription = React.forwardRef<
|
||||||
|
React.ElementRef<typeof DialogPrimitive.Description>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<DialogPrimitive.Description
|
||||||
|
ref={ref}
|
||||||
|
className={cn("text-sm text-muted-foreground", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
DialogDescription.displayName = DialogPrimitive.Description.displayName
|
||||||
|
|
||||||
|
export {
|
||||||
|
Dialog,
|
||||||
|
DialogPortal,
|
||||||
|
DialogOverlay,
|
||||||
|
DialogTrigger,
|
||||||
|
DialogClose,
|
||||||
|
DialogContent,
|
||||||
|
DialogHeader,
|
||||||
|
DialogFooter,
|
||||||
|
DialogTitle,
|
||||||
|
DialogDescription,
|
||||||
|
}
|
||||||
159
src/renderer/components/ui/select.tsx
Normal file
159
src/renderer/components/ui/select.tsx
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import * as SelectPrimitive from "@radix-ui/react-select"
|
||||||
|
import { Check, ChevronDown, ChevronUp } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const Select = SelectPrimitive.Root
|
||||||
|
|
||||||
|
const SelectGroup = SelectPrimitive.Group
|
||||||
|
|
||||||
|
const SelectValue = SelectPrimitive.Value
|
||||||
|
|
||||||
|
const SelectTrigger = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
||||||
|
>(({ className, children, ...props }, ref) => (
|
||||||
|
<SelectPrimitive.Trigger
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
<SelectPrimitive.Icon asChild>
|
||||||
|
<ChevronDown className="h-4 w-4 opacity-50" />
|
||||||
|
</SelectPrimitive.Icon>
|
||||||
|
</SelectPrimitive.Trigger>
|
||||||
|
))
|
||||||
|
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
|
||||||
|
|
||||||
|
const SelectScrollUpButton = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<SelectPrimitive.ScrollUpButton
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"flex cursor-default items-center justify-center py-1",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ChevronUp className="h-4 w-4" />
|
||||||
|
</SelectPrimitive.ScrollUpButton>
|
||||||
|
))
|
||||||
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
|
||||||
|
|
||||||
|
const SelectScrollDownButton = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<SelectPrimitive.ScrollDownButton
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"flex cursor-default items-center justify-center py-1",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ChevronDown className="h-4 w-4" />
|
||||||
|
</SelectPrimitive.ScrollDownButton>
|
||||||
|
))
|
||||||
|
SelectScrollDownButton.displayName =
|
||||||
|
SelectPrimitive.ScrollDownButton.displayName
|
||||||
|
|
||||||
|
const SelectContent = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.Content>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
||||||
|
>(({ className, children, position = "popper", ...props }, ref) => (
|
||||||
|
<SelectPrimitive.Portal>
|
||||||
|
<SelectPrimitive.Content
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",
|
||||||
|
position === "popper" &&
|
||||||
|
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
position={position}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<SelectScrollUpButton />
|
||||||
|
<SelectPrimitive.Viewport
|
||||||
|
className={cn(
|
||||||
|
"p-1",
|
||||||
|
position === "popper" &&
|
||||||
|
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</SelectPrimitive.Viewport>
|
||||||
|
<SelectScrollDownButton />
|
||||||
|
</SelectPrimitive.Content>
|
||||||
|
</SelectPrimitive.Portal>
|
||||||
|
))
|
||||||
|
SelectContent.displayName = SelectPrimitive.Content.displayName
|
||||||
|
|
||||||
|
const SelectLabel = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.Label>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<SelectPrimitive.Label
|
||||||
|
ref={ref}
|
||||||
|
className={cn("px-2 py-1.5 text-sm font-semibold", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
SelectLabel.displayName = SelectPrimitive.Label.displayName
|
||||||
|
|
||||||
|
const SelectItem = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.Item>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
||||||
|
>(({ className, children, ...props }, ref) => (
|
||||||
|
<SelectPrimitive.Item
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||||
|
<SelectPrimitive.ItemIndicator>
|
||||||
|
<Check className="h-4 w-4" />
|
||||||
|
</SelectPrimitive.ItemIndicator>
|
||||||
|
</span>
|
||||||
|
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
||||||
|
</SelectPrimitive.Item>
|
||||||
|
))
|
||||||
|
SelectItem.displayName = SelectPrimitive.Item.displayName
|
||||||
|
|
||||||
|
const SelectSeparator = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SelectPrimitive.Separator>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<SelectPrimitive.Separator
|
||||||
|
ref={ref}
|
||||||
|
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
SelectSeparator.displayName = SelectPrimitive.Separator.displayName
|
||||||
|
|
||||||
|
export {
|
||||||
|
Select,
|
||||||
|
SelectGroup,
|
||||||
|
SelectValue,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectContent,
|
||||||
|
SelectLabel,
|
||||||
|
SelectItem,
|
||||||
|
SelectSeparator,
|
||||||
|
SelectScrollUpButton,
|
||||||
|
SelectScrollDownButton,
|
||||||
|
}
|
||||||
27
src/renderer/components/ui/switch.tsx
Normal file
27
src/renderer/components/ui/switch.tsx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import * as SwitchPrimitives from "@radix-ui/react-switch"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const Switch = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SwitchPrimitives.Root>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<SwitchPrimitives.Root
|
||||||
|
className={cn(
|
||||||
|
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
>
|
||||||
|
<SwitchPrimitives.Thumb
|
||||||
|
className={cn(
|
||||||
|
"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</SwitchPrimitives.Root>
|
||||||
|
))
|
||||||
|
Switch.displayName = SwitchPrimitives.Root.displayName
|
||||||
|
|
||||||
|
export { Switch }
|
||||||
@@ -1,17 +1,40 @@
|
|||||||
import { createFileRoute } from '@tanstack/react-router';
|
import { createFileRoute } from '@tanstack/react-router';
|
||||||
|
import { z } from 'zod';
|
||||||
import { ProjectSidebar } from '@/components/projects/ProjectSidebar';
|
import { ProjectSidebar } from '@/components/projects/ProjectSidebar';
|
||||||
|
import { ProjectDetail } from '@/components/projects/ProjectDetail';
|
||||||
|
|
||||||
|
const searchSchema = z.object({
|
||||||
|
projectId: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
export const Route = createFileRoute('/projects')({
|
export const Route = createFileRoute('/projects')({
|
||||||
|
validateSearch: searchSchema,
|
||||||
component: ProjectsPage,
|
component: ProjectsPage,
|
||||||
});
|
});
|
||||||
|
|
||||||
function ProjectsPage() {
|
function ProjectsPage() {
|
||||||
|
const { projectId } = Route.useSearch();
|
||||||
|
const navigate = Route.useNavigate();
|
||||||
|
|
||||||
|
function handleSelectProject(id: string) {
|
||||||
|
void navigate({ search: { projectId: id } });
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full overflow-hidden">
|
<div className="flex h-full overflow-hidden">
|
||||||
<ProjectSidebar />
|
<ProjectSidebar
|
||||||
<div className="flex-1 flex items-center justify-center text-sm text-muted-foreground">
|
selectedProjectId={projectId}
|
||||||
|
onSelectProject={handleSelectProject}
|
||||||
|
/>
|
||||||
|
<div className="flex-1 overflow-y-auto">
|
||||||
|
{projectId ? (
|
||||||
|
<ProjectDetail projectId={projectId} />
|
||||||
|
) : (
|
||||||
|
<div className="flex-1 flex items-center justify-center h-full text-sm text-muted-foreground">
|
||||||
Select a project to view details
|
Select a project to view details
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user