Feat node search (#23685)
Co-authored-by: GuanMu <ballmanjq@gmail.com> Co-authored-by: zhujiruo <zhujiruo@foxmail.com> Co-authored-by: Matri Qi <matrixdom@126.com> Co-authored-by: croatialu <wuli.croatia@foxmail.com> Co-authored-by: HyaCinth <88471803+HyaCiovo@users.noreply.github.com> Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com>
This commit is contained in:
44
web/app/components/goto-anything/actions/workflow-nodes.tsx
Normal file
44
web/app/components/goto-anything/actions/workflow-nodes.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
import type { ActionItem } from './types'
|
||||
import { BoltIcon } from '@heroicons/react/24/outline'
|
||||
import i18n from 'i18next'
|
||||
|
||||
// Create the workflow nodes action
|
||||
export const workflowNodesAction: ActionItem = {
|
||||
key: '@node',
|
||||
shortcut: '@node',
|
||||
title: 'Search Workflow Nodes',
|
||||
description: 'Find and jump to nodes in the current workflow by name or type',
|
||||
searchFn: undefined, // Will be set by useWorkflowSearch hook
|
||||
search: async (_, searchTerm = '', locale) => {
|
||||
try {
|
||||
// Use the searchFn if available (set by useWorkflowSearch hook)
|
||||
if (workflowNodesAction.searchFn) {
|
||||
// searchFn already returns SearchResult[] type, no need to use parser
|
||||
return workflowNodesAction.searchFn(searchTerm)
|
||||
}
|
||||
|
||||
// If not in workflow context or search function not registered
|
||||
if (!searchTerm.trim()) {
|
||||
return [{
|
||||
id: 'help',
|
||||
title: i18n.t('app.gotoAnything.actions.searchWorkflowNodes', { lng: locale }),
|
||||
description: i18n.t('app.gotoAnything.actions.searchWorkflowNodesHelp', { lng: locale }),
|
||||
type: 'workflow-node',
|
||||
path: '#',
|
||||
data: {} as any,
|
||||
icon: (
|
||||
<div className="flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-blue-50 text-blue-600">
|
||||
<BoltIcon className="h-5 w-5" />
|
||||
</div>
|
||||
),
|
||||
}]
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Error searching workflow nodes:', error)
|
||||
return []
|
||||
}
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user