diff --git a/sim/app/w/components/sidebar/components/folder-section/folder-section.tsx b/sim/app/w/components/sidebar/components/folder-section/folder-section.tsx deleted file mode 100644 index 56c143bf0c..0000000000 --- a/sim/app/w/components/sidebar/components/folder-section/folder-section.tsx +++ /dev/null @@ -1,126 +0,0 @@ -'use client' - -import { useEffect, useState } from 'react' -import { usePathname } from 'next/navigation' -import { Folder, LucideIcon } from 'lucide-react' -import { Button } from '@/components/ui/button' -import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' -import { WorkflowMetadata } from '@/stores/workflows/registry/types' -import { NavItem } from '../nav-item/nav-item' - -interface FolderSectionProps { - title: string - workflows: WorkflowMetadata[] - defaultOpen?: boolean - icon?: LucideIcon -} - -export function FolderSection({ - title, - workflows, - defaultOpen = true, - icon: Icon = Folder, -}: FolderSectionProps) { - const [isOpen, setIsOpen] = useState(defaultOpen) - const pathname = usePathname() - - // Auto-expand the folder if the current path is one of the workflows inside it - useEffect(() => { - const isCurrentPathInThisFolder = workflows.some((workflow) => pathname === `/w/${workflow.id}`) - if (isCurrentPathInThisFolder) { - setIsOpen(true) - } - }, [pathname, workflows]) - - if (workflows.length === 0) { - return null - } - - // Calculate height based on number of workflows, with a maximum of 4 - const navItemHeight = 32 // Height of each NavItem in pixels - const gapSize = 12 // Gap between items (3 in rem units = ~12px) - const maxItems = 4 - - // Calculate height for a single item (no gaps) - const singleItemHeight = navItemHeight - - // Calculate heights for different number of items - const twoItemsHeight = navItemHeight * 2 + gapSize - const threeItemsHeight = navItemHeight * 3 + gapSize * 2 - const fourItemsHeight = navItemHeight * 4 + gapSize * 3 - - // Max height is always the height of 4 items - const maxHeight = fourItemsHeight - const needsScroll = workflows.length > maxItems - - // Get exact height based on number of workflows (up to 4) - const getExactHeight = () => { - switch (Math.min(workflows.length, maxItems)) { - case 1: - return singleItemHeight - case 2: - return twoItemsHeight - case 3: - return threeItemsHeight - case 4: - return fourItemsHeight - default: - return 'auto' - } - } - - return ( -
- - - - - {title} - - - {isOpen && ( -
-
-
    - {workflows.map((workflow) => ( -
  • - -
    - -
  • - ))} -
-
-
- )} -
- ) -} diff --git a/sim/app/w/components/sidebar/components/workflow-folders/workflow-folders.tsx b/sim/app/w/components/sidebar/components/workflow-folders/workflow-folders.tsx new file mode 100644 index 0000000000..c14c5ce5d4 --- /dev/null +++ b/sim/app/w/components/sidebar/components/workflow-folders/workflow-folders.tsx @@ -0,0 +1,138 @@ +'use client' + +import { useEffect, useState } from 'react' +import { usePathname } from 'next/navigation' +import { Folder, LucideIcon, Store } from 'lucide-react' +import { Button } from '@/components/ui/button' +import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' +import { WorkflowMetadata } from '@/stores/workflows/registry/types' +import { NavItem } from '../nav-item/nav-item' + +interface WorkflowFolderProps { + title: string + workflows: WorkflowMetadata[] + defaultOpen?: boolean + icon?: LucideIcon + maxItems?: number + hasMarketplace?: boolean +} + +interface WorkflowFoldersProps { + regularWorkflows: WorkflowMetadata[] + marketplaceWorkflows: WorkflowMetadata[] +} + +/** + * WorkflowFolder component for rendering a collapsible group of workflows + */ +function WorkflowFolder({ + title, + workflows, + defaultOpen = true, + icon: Icon = Folder, + maxItems, + hasMarketplace = false, +}: WorkflowFolderProps) { + const [isOpen, setIsOpen] = useState(defaultOpen) + const pathname = usePathname() + + // Auto-expand the folder if the current path is one of the workflows inside it + useEffect(() => { + const isCurrentPathInThisFolder = workflows.some((workflow) => pathname === `/w/${workflow.id}`) + if (isCurrentPathInThisFolder) { + setIsOpen(true) + } + }, [pathname, workflows]) + + if (workflows.length === 0) { + return null + } + + // Filter workflows if maxItems is specified + const displayedWorkflows = maxItems ? workflows.slice(0, maxItems) : workflows + + return ( +
+ {/* Folder Button - This stays fixed */} + + + + + {title} + + + {/* Workflow items with separate scrollable container */} + {isOpen && ( +
+
+ {displayedWorkflows.map((workflow) => ( +
  • + +
    + +
  • + ))} +
    +
    + )} +
    + ) +} + +/** + * WorkflowFolders - main component for sidebar workflow organization + * Handles both regular and marketplace workflows in a single unified component + */ +export function WorkflowFolders({ regularWorkflows, marketplaceWorkflows }: WorkflowFoldersProps) { + const hasMarketplace = marketplaceWorkflows.length > 0 + + // Limit regular workflows to 7 when marketplace workflows exist + const maxRegularWorkflows = hasMarketplace ? 7 : undefined + + return ( +
    + {/* Regular Workflows Section */} +
    + +
    + + {/* Marketplace Workflows Section - Only when marketplace workflows exist */} + {hasMarketplace && ( +
    + +
    + )} +
    + ) +} diff --git a/sim/app/w/components/sidebar/sidebar.tsx b/sim/app/w/components/sidebar/sidebar.tsx index dca2e39bbc..bf1ad5e5b3 100644 --- a/sim/app/w/components/sidebar/sidebar.tsx +++ b/sim/app/w/components/sidebar/sidebar.tsx @@ -10,10 +10,10 @@ import { Button } from '@/components/ui/button' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' import { useWorkflowRegistry } from '@/stores/workflows/registry/store' import { WorkflowMetadata } from '@/stores/workflows/registry/types' -import { FolderSection } from './components/folder-section/folder-section' import { HelpModal } from './components/help-modal/help-modal' import { NavItem } from './components/nav-item/nav-item' import { SettingsModal } from './components/settings-modal/settings-modal' +import { WorkflowFolders } from './components/workflow-folders/workflow-folders' export function Sidebar() { const { workflows, createWorkflow } = useWorkflowRegistry() @@ -85,7 +85,8 @@ export function Sidebar() { return (