Skip to content

Commit bad68f9

Browse files
committed
ack comments
1 parent afae856 commit bad68f9

File tree

3 files changed

+59
-50
lines changed

3 files changed

+59
-50
lines changed

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

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { Database, HelpCircle, Layout, Settings } from 'lucide-react'
66
import { useParams, useRouter } from 'next/navigation'
77
import { createPortal } from 'react-dom'
88
import { Library } from '@/components/emcn'
9-
import { useBrandConfig } from '@/lib/branding/branding'
109
import { cn } from '@/lib/core/utils/cn'
1110
import { hasTriggerCapability } from '@/lib/workflows/triggers/trigger-utils'
1211
import { SIDEBAR_SCROLL_EVENT } from '@/app/workspace/[workspaceId]/w/components/sidebar/sidebar'
12+
import { usePermissionConfig } from '@/hooks/use-permission-config'
1313
import { useSearchModalStore } from '@/stores/modals/search/store'
1414
import type {
1515
SearchBlockItem,
@@ -65,6 +65,7 @@ interface PageItem {
6565
href?: string
6666
onClick?: () => void
6767
shortcut?: string
68+
hidden?: boolean
6869
}
6970

7071
export function SearchModal({
@@ -77,10 +78,10 @@ export function SearchModal({
7778
const params = useParams()
7879
const router = useRouter()
7980
const workspaceId = params.workspaceId as string
80-
const brand = useBrandConfig()
8181
const inputRef = useRef<HTMLInputElement>(null)
8282
const [mounted, setMounted] = useState(false)
8383
const openSettingsModal = useSettingsModalStore((state) => state.openModal)
84+
const { config: permissionConfig } = usePermissionConfig()
8485

8586
useEffect(() => {
8687
setMounted(true)
@@ -95,40 +96,49 @@ export function SearchModal({
9596
}, [])
9697

9798
const pages = useMemo(
98-
(): PageItem[] => [
99-
{
100-
id: 'logs',
101-
name: 'Logs',
102-
icon: Library,
103-
href: `/workspace/${workspaceId}/logs`,
104-
shortcut: '⌘⇧L',
105-
},
106-
{
107-
id: 'templates',
108-
name: 'Templates',
109-
icon: Layout,
110-
href: `/workspace/${workspaceId}/templates`,
111-
},
112-
{
113-
id: 'knowledge-base',
114-
name: 'Knowledge Base',
115-
icon: Database,
116-
href: `/workspace/${workspaceId}/knowledge`,
117-
},
118-
{
119-
id: 'help',
120-
name: 'Help',
121-
icon: HelpCircle,
122-
onClick: openHelpModal,
123-
},
124-
{
125-
id: 'settings',
126-
name: 'Settings',
127-
icon: Settings,
128-
onClick: openSettingsModal,
129-
},
130-
],
131-
[workspaceId, openHelpModal, openSettingsModal]
99+
(): PageItem[] =>
100+
[
101+
{
102+
id: 'logs',
103+
name: 'Logs',
104+
icon: Library,
105+
href: `/workspace/${workspaceId}/logs`,
106+
shortcut: '⌘⇧L',
107+
},
108+
{
109+
id: 'templates',
110+
name: 'Templates',
111+
icon: Layout,
112+
href: `/workspace/${workspaceId}/templates`,
113+
hidden: permissionConfig.hideTemplates,
114+
},
115+
{
116+
id: 'knowledge-base',
117+
name: 'Knowledge Base',
118+
icon: Database,
119+
href: `/workspace/${workspaceId}/knowledge`,
120+
hidden: permissionConfig.hideKnowledgeBaseTab,
121+
},
122+
{
123+
id: 'help',
124+
name: 'Help',
125+
icon: HelpCircle,
126+
onClick: openHelpModal,
127+
},
128+
{
129+
id: 'settings',
130+
name: 'Settings',
131+
icon: Settings,
132+
onClick: openSettingsModal,
133+
},
134+
].filter((page) => !page.hidden),
135+
[
136+
workspaceId,
137+
openHelpModal,
138+
openSettingsModal,
139+
permissionConfig.hideTemplates,
140+
permissionConfig.hideKnowledgeBaseTab,
141+
]
132142
)
133143

134144
useEffect(() => {

apps/sim/stores/modals/search/store.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export const useSearchModalStore = create<SearchModalState>()(
5353
const searchItem: SearchBlockItem = {
5454
id: block.type,
5555
name: block.name,
56-
description: block.description || '',
5756
icon: block.icon,
5857
bgColor: block.bgColor || '#6B7280',
5958
type: block.type,
@@ -79,15 +78,13 @@ export const useSearchModalStore = create<SearchModalState>()(
7978
{
8079
id: 'loop',
8180
name: 'Loop',
82-
description: 'Create a Loop',
8381
icon: RepeatIcon,
8482
bgColor: '#2FB3FF',
8583
type: 'loop',
8684
},
8785
{
8886
id: 'parallel',
8987
name: 'Parallel',
90-
description: 'Parallel Execution',
9188
icon: SplitIcon,
9289
bgColor: '#FEE12B',
9390
type: 'parallel',
@@ -116,7 +113,6 @@ export const useSearchModalStore = create<SearchModalState>()(
116113
(block): SearchBlockItem => ({
117114
id: block.type,
118115
name: block.name,
119-
description: block.description || '',
120116
icon: block.icon,
121117
bgColor: block.bgColor || '#6B7280',
122118
type: block.type,
@@ -127,15 +123,19 @@ export const useSearchModalStore = create<SearchModalState>()(
127123
const allowedBlockTypes = new Set(tools.map((t) => t.type))
128124
const toolOperations: SearchToolOperationItem[] = getToolOperationsIndex()
129125
.filter((op) => allowedBlockTypes.has(op.blockType))
130-
.map((op) => ({
131-
id: op.id,
132-
name: op.operationName,
133-
searchValue: `${op.serviceName} ${op.operationName}`,
134-
icon: op.icon,
135-
bgColor: op.bgColor,
136-
blockType: op.blockType,
137-
operationId: op.operationId,
138-
}))
126+
.map((op) => {
127+
// Include aliases in searchValue so synonym search works (e.g., "post" finds "Send Message")
128+
const aliasesStr = op.aliases?.length ? ` ${op.aliases.join(' ')}` : ''
129+
return {
130+
id: op.id,
131+
name: op.operationName,
132+
searchValue: `${op.serviceName} ${op.operationName}${aliasesStr}`,
133+
icon: op.icon,
134+
bgColor: op.bgColor,
135+
blockType: op.blockType,
136+
operationId: op.operationId,
137+
}
138+
})
139139

140140
set({
141141
data: {

apps/sim/stores/modals/search/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import type { BlockConfig } from '@/blocks/types'
77
export interface SearchBlockItem {
88
id: string
99
name: string
10-
description: string
1110
icon: ComponentType<{ className?: string }>
1211
bgColor: string
1312
type: string

0 commit comments

Comments
 (0)