Skip to content

Commit c95838f

Browse files
committed
refactor: update ProjectPanel component for improved UI and code clarity
This commit refactors the ProjectPanel component by replacing the LoaderPinwheel with Loader2 for a better loading indicator, enhancing the project item display with a ChevronRight icon, and removing the trust_level property from project objects for simplification. Additionally, it improves the layout and styling of the loading message and project items, contributing to a more cohesive user experience.
1 parent 57acfc8 commit c95838f

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

src/components/panels/ProjectPanel.tsx

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect } from "react";
2-
import { LoaderPinwheel, FolderOpen, Plus } from "lucide-react";
2+
import { Loader2, FolderOpen, Plus, ChevronRight } from "lucide-react";
33
import { Button } from "@/components/ui/button";
44
import { Input } from "@/components/ui/input";
55
import { Card, CardContent } from "@/components/ui/card";
@@ -14,13 +14,11 @@ import { toast } from "sonner";
1414

1515
interface FileSystemProject {
1616
path: string;
17-
trust_level: string;
1817
}
1918

2019
interface UnifiedProject {
2120
path: string;
2221
hasCodex: boolean;
23-
trustLevel?: string;
2422
}
2523

2624
export function ProjectPanel() {
@@ -49,7 +47,7 @@ export function ProjectPanel() {
4947
const existingPaths = new Set(codexList.map(p => p.path));
5048
const scannedCodexProjects = scannedList
5149
.filter(p => !existingPaths.has(p.path))
52-
.map(p => ({ path: p.path, trust_level: "untrusted" }));
50+
.map(p => ({ path: p.path }));
5351

5452
if (scannedCodexProjects.length > 0) {
5553
setCodexProjects([...codexList, ...scannedCodexProjects]);
@@ -69,7 +67,6 @@ export function ProjectPanel() {
6967
const unifiedProjects = codexProjects.map((project) => ({
7068
path: project.path,
7169
hasCodex: true,
72-
trustLevel: project.trust_level,
7370
}));
7471

7572
setUnifiedProjects(unifiedProjects);
@@ -135,7 +132,10 @@ export function ProjectPanel() {
135132
if (loading) {
136133
return (
137134
<div className="flex items-center justify-center h-full">
138-
<div>Loading projects...</div>
135+
<div className="flex flex-col items-center gap-3">
136+
<Loader2 className="w-6 h-6 animate-spin" />
137+
<div className="text-sm text-muted-foreground">Loading projects...</div>
138+
</div>
139139
</div>
140140
);
141141
}
@@ -146,31 +146,28 @@ export function ProjectPanel() {
146146
return (
147147
<div
148148
key={project.path}
149-
className="p-4 hover:bg-accent/50 transition-colors cursor-pointer rounded-lg"
149+
onClick={(e) => handleCodexClick(project, e)}
150+
className={`p-4 rounded-lg transition-colors ${
151+
project.hasCodex
152+
? "hover:bg-accent/50 cursor-pointer"
153+
: "opacity-60 cursor-not-allowed"
154+
}`}
155+
title={
156+
project.hasCodex
157+
? "Click to open in Codex"
158+
: "Not a Codex project"
159+
}
150160
>
151161
<div className="flex items-center justify-between gap-3 min-w-0 mb-1">
152162
<div className="flex items-center gap-2 min-w-0 flex-1">
153163
<FolderOpen className="w-5 h-5 flex-shrink-0" />
154164
<span className="truncate font-medium">{projectName}</span>
155165
</div>
156-
<div className="flex items-center gap-2 flex-shrink-0">
157-
<Button
158-
variant={project.hasCodex ? "ghost" : "ghost"}
159-
size="icon"
160-
className={`w-8 h-8 ${
161-
project.hasCodex
162-
? "hover:bg-primary/10 text-foreground"
163-
: "opacity-30 cursor-not-allowed"
164-
}`}
165-
onClick={(e) => handleCodexClick(project, e)}
166-
disabled={!project.hasCodex}
167-
title={project.hasCodex ? "Open in Codex" : "Not a Codex project"}
168-
>
169-
<LoaderPinwheel className="w-4 h-4" />
170-
</Button>
171-
</div>
166+
<ChevronRight className={`w-4 h-4 flex-shrink-0 ${
167+
project.hasCodex ? "text-foreground" : "text-muted-foreground"
168+
}`} />
172169
</div>
173-
<div className="text-xs text-muted-foreground truncate pl-7">{project.path}</div>
170+
<div className="text-sm text-muted-foreground pl-7 break-words">{project.path}</div>
174171
</div>
175172
);
176173
};
@@ -190,7 +187,6 @@ export function ProjectPanel() {
190187
placeholder="Search projects..."
191188
value={searchTerm}
192189
onChange={(e) => setSearchTerm(e.target.value)}
193-
autoFocus
194190
className="text-sm"
195191
/>
196192
</div>

0 commit comments

Comments
 (0)