Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useDashboardSidebarState } from "renderer/routes/_authenticated/hooks/u
import { DashboardSidebarHeader } from "./components/DashboardSidebarHeader";
import { DashboardSidebarPortsList } from "./components/DashboardSidebarPortsList";
import { DashboardSidebarProjectSection } from "./components/DashboardSidebarProjectSection";
import { DashboardSidebarSectionRenameProvider } from "./components/DashboardSidebarSectionRenameContext";
import { useDashboardSidebarData } from "./hooks/useDashboardSidebarData";
import { useDashboardSidebarShortcuts } from "./hooks/useDashboardSidebarShortcuts";
import type { DashboardSidebarProject } from "./types";
Expand Down Expand Up @@ -132,60 +133,62 @@ export function DashboardSidebar({
);

return (
<div className="flex h-full flex-col border-r border-border bg-muted/45 dark:bg-muted/35">
<DashboardSidebarHeader isCollapsed={isCollapsed} />
<DashboardSidebarSectionRenameProvider>
<div className="flex h-full flex-col border-r border-border bg-muted/45 dark:bg-muted/35">
<DashboardSidebarHeader isCollapsed={isCollapsed} />

<div className="flex-1 overflow-y-auto hide-scrollbar">
<DndContext
sensors={sensors}
collisionDetection={closestCenter}
measuring={{
droppable: { strategy: MeasuringStrategy.Always },
}}
onDragStart={({ active }) => {
const project = groups.find((p) => p.id === active.id);
setActiveProject(project ?? null);
}}
onDragEnd={handleDragEnd}
onDragCancel={() => setActiveProject(null)}
>
<SortableContext
items={projectOrder}
strategy={verticalListSortingStrategy}
<div className="flex-1 overflow-y-auto hide-scrollbar">
<DndContext
sensors={sensors}
collisionDetection={closestCenter}
measuring={{
droppable: { strategy: MeasuringStrategy.Always },
}}
onDragStart={({ active }) => {
const project = groups.find((p) => p.id === active.id);
setActiveProject(project ?? null);
}}
onDragEnd={handleDragEnd}
onDragCancel={() => setActiveProject(null)}
>
{orderedGroups.map((project) => (
<SortableProjectWrapper
key={project.id}
project={project}
isCollapsed={isCollapsed}
isDraggingProject={activeProject != null}
workspaceShortcutLabels={workspaceShortcutLabels}
onWorkspaceHover={refreshWorkspacePullRequest}
onToggleCollapse={toggleProjectCollapsed}
/>
))}
</SortableContext>
<SortableContext
items={projectOrder}
strategy={verticalListSortingStrategy}
>
{orderedGroups.map((project) => (
<SortableProjectWrapper
key={project.id}
project={project}
isCollapsed={isCollapsed}
isDraggingProject={activeProject != null}
workspaceShortcutLabels={workspaceShortcutLabels}
onWorkspaceHover={refreshWorkspacePullRequest}
onToggleCollapse={toggleProjectCollapsed}
/>
))}
</SortableContext>

{createPortal(
<DragOverlay dropAnimation={null}>
{activeProject && (
<div className="bg-background shadow-lg border-b border-border">
<DashboardSidebarProjectSection
project={activeProject}
isSidebarCollapsed={isCollapsed}
isDraggingProject
workspaceShortcutLabels={workspaceShortcutLabels}
onWorkspaceHover={() => {}}
onToggleCollapse={() => {}}
/>
</div>
)}
</DragOverlay>,
document.body,
)}
</DndContext>
{createPortal(
<DragOverlay dropAnimation={null}>
{activeProject && (
<div className="bg-background shadow-lg border-b border-border">
<DashboardSidebarProjectSection
project={activeProject}
isSidebarCollapsed={isCollapsed}
isDraggingProject
workspaceShortcutLabels={workspaceShortcutLabels}
onWorkspaceHover={() => {}}
onToggleCollapse={() => {}}
/>
</div>
)}
</DragOverlay>,
document.body,
)}
</DndContext>
</div>
{!isCollapsed && <DashboardSidebarPortsList />}
</div>
{!isCollapsed && <DashboardSidebarPortsList />}
</div>
</DashboardSidebarSectionRenameProvider>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function DashboardSidebarProjectContextMenu({
</ContextMenuItem>
<ContextMenuItem onSelect={onCreateSection}>
<LuFolderPlus className="size-4 mr-2" />
New Section
New group
</ContextMenuItem>
<ContextMenuSeparator />
<ContextMenuItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { alert } from "@superset/ui/atoms/Alert";
import { toast } from "@superset/ui/sonner";
import { useNavigate } from "@tanstack/react-router";
import { useState } from "react";
import { useDashboardSidebarSectionRename } from "renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarSectionRenameContext";
import { useDashboardSidebarState } from "renderer/routes/_authenticated/hooks/useDashboardSidebarState";
import { useOptimisticCollectionActions } from "renderer/routes/_authenticated/hooks/useOptimisticCollectionActions";
import { useOpenNewWorkspaceModal } from "renderer/stores/new-workspace-modal";
Expand All @@ -17,11 +18,13 @@ export function useDashboardSidebarProjectSectionActions({
const openModal = useOpenNewWorkspaceModal();
const navigate = useNavigate();
const { v2Projects: projectActions } = useOptimisticCollectionActions();
const { requestSectionRename } = useDashboardSidebarSectionRename();
const {
createSection,
deleteSection,
removeProjectFromSidebar,
renameSection,
toggleProjectCollapsed,
toggleSectionCollapsed,
} = useDashboardSidebarState();

Expand Down Expand Up @@ -77,7 +80,11 @@ export function useDashboardSidebarProjectSectionActions({
};

const handleNewSection = () => {
createSection(project.id);
const sectionId = createSection(project.id);
requestSectionRename(sectionId);
if (project.isCollapsed) {
toggleProjectCollapsed(project.id);
}
};

return {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import {
ContextMenu,
ContextMenuContent,
ContextMenuItem,
ContextMenuSeparator,
ContextMenuSub,
ContextMenuSubContent,
ContextMenuSubTrigger,
ContextMenuTrigger,
} from "@superset/ui/context-menu";
import { LuPalette, LuPencil, LuTrash2 } from "react-icons/lu";
import { ColorSelector } from "renderer/components/ColorSelector";
import { PROJECT_COLOR_DEFAULT } from "shared/constants/project-colors";
import { SectionActionsMenuItems } from "./components/SectionActionsMenuItems";
import type { DashboardSidebarSectionActionsProps } from "./types";

interface DashboardSidebarSectionContextMenuProps {
color: string | null;
onRename: () => void;
onSetColor: (color: string | null) => void;
onDelete: () => void;
interface DashboardSidebarSectionContextMenuProps
extends DashboardSidebarSectionActionsProps {
children: React.ReactNode;
}

Expand All @@ -30,38 +21,18 @@ export function DashboardSidebarSectionContextMenu({
return (
<ContextMenu>
<ContextMenuTrigger asChild>{children}</ContextMenuTrigger>
<ContextMenuContent>
<ContextMenuItem onSelect={onRename}>
<LuPencil className="size-4 mr-2" />
Rename
</ContextMenuItem>
<ContextMenuSub>
<ContextMenuSubTrigger>
<LuPalette className="size-4 mr-2" />
Set Color
</ContextMenuSubTrigger>
<ContextMenuSubContent className="w-40 max-h-80 overflow-y-auto">
<ColorSelector
variant="menu"
selectedColor={color}
onSelectColor={(selectedColor) =>
onSetColor(
selectedColor === PROJECT_COLOR_DEFAULT
? null
: selectedColor,
)
}
/>
</ContextMenuSubContent>
</ContextMenuSub>
<ContextMenuSeparator />
<ContextMenuItem
onSelect={onDelete}
className="text-destructive focus:text-destructive"
>
<LuTrash2 className="size-4 mr-2 text-destructive" />
Delete Section
</ContextMenuItem>
<ContextMenuContent
onCloseAutoFocus={(event) => event.preventDefault()}
onClick={(event) => event.stopPropagation()}
onPointerDown={(event) => event.stopPropagation()}
>
<SectionActionsMenuItems
color={color}
kind="context"
onRename={onRename}
onSetColor={onSetColor}
onDelete={onDelete}
/>
</ContextMenuContent>
</ContextMenu>
);
Expand Down
Loading
Loading