Skip to content

Commit d238052

Browse files
feat(ui): show folder path in search modal (#4138)
* feat(ui): show folder path in search modal * Switch truncate folder over workspace name --------- Co-authored-by: Theodore Li <theo@sim.ai>
1 parent c0db9de commit d238052

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/components/command-items.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ export const MemoizedWorkflowItem = memo(
5151
onSelect,
5252
color,
5353
name,
54+
folderPath,
5455
isCurrent,
5556
}: {
5657
value: string
5758
onSelect: () => void
5859
color: string
5960
name: string
61+
folderPath?: string
6062
isCurrent?: boolean
6163
}) {
6264
return (
@@ -73,13 +75,19 @@ export const MemoizedWorkflowItem = memo(
7375
{name}
7476
{isCurrent && ' (current)'}
7577
</span>
78+
{folderPath && (
79+
<span className='ml-auto min-w-0 truncate pl-2 font-base text-[var(--text-subtle)] text-small'>
80+
{folderPath}
81+
</span>
82+
)}
7683
</Command.Item>
7784
)
7885
},
7986
(prev, next) =>
8087
prev.value === next.value &&
8188
prev.color === next.color &&
8289
prev.name === next.name &&
90+
prev.folderPath === next.folderPath &&
8391
prev.isCurrent === next.isCurrent
8492
)
8593

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/components/search-groups.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,11 @@ export const WorkflowsGroup = memo(function WorkflowsGroup({
163163
{items.map((workflow) => (
164164
<MemoizedWorkflowItem
165165
key={workflow.id}
166-
value={`${workflow.name} workflow-${workflow.id}`}
166+
value={`${workflow.name} ${workflow.folderPath ?? ''} workflow-${workflow.id}`}
167167
onSelect={() => onSelect(workflow)}
168168
color={workflow.color}
169169
name={workflow.name}
170+
folderPath={workflow.folderPath}
170171
isCurrent={workflow.isCurrent}
171172
/>
172173
))}

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface WorkflowItem {
1111
name: string
1212
href: string
1313
color: string
14+
folderPath?: string
1415
isCurrent?: boolean
1516
}
1617

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { useSession } from '@/lib/auth/auth-client'
4040
import { SIM_RESOURCES_DRAG_TYPE } from '@/lib/copilot/resource-types'
4141
import { cn } from '@/lib/core/utils/cn'
4242
import { isMacPlatform } from '@/lib/core/utils/platform'
43-
import { buildFolderTree } from '@/lib/folders/tree'
43+
import { buildFolderTree, getFolderPath } from '@/lib/folders/tree'
4444
import { captureEvent } from '@/lib/posthog/client'
4545
import {
4646
START_NAV_TOUR_EVENT,
@@ -635,14 +635,22 @@ export const Sidebar = memo(function Sidebar() {
635635

636636
const searchModalWorkflows = useMemo(
637637
() =>
638-
regularWorkflows.map((workflow) => ({
639-
id: workflow.id,
640-
name: workflow.name,
641-
href: `/workspace/${workspaceId}/w/${workflow.id}`,
642-
color: workflow.color,
643-
isCurrent: workflow.id === workflowId,
644-
})),
645-
[regularWorkflows, workspaceId, workflowId]
638+
regularWorkflows.map((workflow) => {
639+
const folderPath = workflow.folderId
640+
? getFolderPath(folderMap, workflow.folderId)
641+
.map((folder) => folder.name)
642+
.join(' / ')
643+
: ''
644+
return {
645+
id: workflow.id,
646+
name: workflow.name,
647+
href: `/workspace/${workspaceId}/w/${workflow.id}`,
648+
color: workflow.color,
649+
folderPath: folderPath || undefined,
650+
isCurrent: workflow.id === workflowId,
651+
}
652+
}),
653+
[regularWorkflows, folderMap, workspaceId, workflowId]
646654
)
647655

648656
const searchModalWorkspaces = useMemo(

0 commit comments

Comments
 (0)