Skip to content

Commit 0b8ef32

Browse files
committed
Merge remote-tracking branch 'origin/main' into storybook-tool-messages
2 parents ee6039e + d9354ae commit 0b8ef32

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

src/App.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ function App() {
257257
}
258258
};
259259

260-
const handleRemoveWorkspace = async (workspaceId: string) => {
260+
const handleRemoveWorkspace = async (
261+
workspaceId: string
262+
): Promise<{ success: boolean; error?: string }> => {
261263
const result = await window.api.workspace.remove(workspaceId);
262264
if (result.success) {
263265
// Reload config since backend has updated it
@@ -272,8 +274,10 @@ function App() {
272274
if (selectedWorkspace?.workspaceId === workspaceId) {
273275
setSelectedWorkspace(null);
274276
}
277+
return { success: true };
275278
} else {
276279
console.error("Failed to remove workspace:", result.error);
280+
return { success: false, error: result.error };
277281
}
278282
};
279283

@@ -327,7 +331,7 @@ function App() {
327331
onAddProject={() => void handleAddProject()}
328332
onAddWorkspace={(projectPath) => void handleAddWorkspace(projectPath)}
329333
onRemoveProject={(path) => void handleRemoveProject(path)}
330-
onRemoveWorkspace={(workspaceId) => void handleRemoveWorkspace(workspaceId)}
334+
onRemoveWorkspace={handleRemoveWorkspace}
331335
onRenameWorkspace={handleRenameWorkspace}
332336
/>
333337
<MainContent>

src/components/ProjectSidebar.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ const WorkspaceNameInput = styled.input`
297297
}
298298
`;
299299

300-
const RenameErrorContainer = styled.div`
300+
const WorkspaceErrorContainer = styled.div`
301301
position: absolute;
302302
top: 100%;
303303
left: 28px;
@@ -332,7 +332,7 @@ interface ProjectSidebarProps {
332332
onAddProject: () => void;
333333
onAddWorkspace: (projectPath: string) => void;
334334
onRemoveProject: (path: string) => void;
335-
onRemoveWorkspace: (workspaceId: string) => void;
335+
onRemoveWorkspace: (workspaceId: string) => Promise<{ success: boolean; error?: string }>;
336336
onRenameWorkspace: (
337337
workspaceId: string,
338338
newName: string
@@ -365,6 +365,9 @@ const ProjectSidebar: React.FC<ProjectSidebarProps> = ({
365365
const [editingWorkspaceId, setEditingWorkspaceId] = useState<string | null>(null);
366366
const [editingName, setEditingName] = useState<string>("");
367367
const [renameError, setRenameError] = useState<string | null>(null);
368+
const [removeError, setRemoveError] = useState<{ workspaceId: string; error: string } | null>(
369+
null
370+
);
368371

369372
const getProjectName = (path: string) => {
370373
if (!path || typeof path !== "string") {
@@ -423,6 +426,20 @@ const ProjectSidebar: React.FC<ProjectSidebarProps> = ({
423426
}
424427
};
425428

429+
const handleRemoveWorkspace = async (workspaceId: string) => {
430+
const result = await onRemoveWorkspace(workspaceId);
431+
if (!result.success) {
432+
setRemoveError({
433+
workspaceId,
434+
error: result.error ?? "Failed to remove workspace",
435+
});
436+
// Clear error after 5 seconds
437+
setTimeout(() => {
438+
setRemoveError(null);
439+
}, 5000);
440+
}
441+
};
442+
426443
// Handle keyboard shortcuts
427444
useEffect(() => {
428445
const handleKeyDown = (e: KeyboardEvent) => {
@@ -533,14 +550,17 @@ const ProjectSidebar: React.FC<ProjectSidebarProps> = ({
533550
<WorkspaceRemoveBtn
534551
onClick={(e) => {
535552
e.stopPropagation();
536-
onRemoveWorkspace(workspaceId);
553+
void handleRemoveWorkspace(workspaceId);
537554
}}
538555
title="Remove workspace"
539556
>
540557
×
541558
</WorkspaceRemoveBtn>
542559
{isEditing && renameError && (
543-
<RenameErrorContainer>{renameError}</RenameErrorContainer>
560+
<WorkspaceErrorContainer>{renameError}</WorkspaceErrorContainer>
561+
)}
562+
{!isEditing && removeError?.workspaceId === workspaceId && (
563+
<WorkspaceErrorContainer>{removeError.error}</WorkspaceErrorContainer>
544564
)}
545565
</WorkspaceItem>
546566
);

0 commit comments

Comments
 (0)