You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

workflow-nodes.tsx 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import type { ActionItem } from './types'
  2. import { BoltIcon } from '@heroicons/react/24/outline'
  3. import i18n from 'i18next'
  4. // Create the workflow nodes action
  5. export const workflowNodesAction: ActionItem = {
  6. key: '@node',
  7. shortcut: '@node',
  8. title: 'Search Workflow Nodes',
  9. description: 'Find and jump to nodes in the current workflow by name or type',
  10. searchFn: undefined, // Will be set by useWorkflowSearch hook
  11. search: async (_, searchTerm = '', locale) => {
  12. try {
  13. // Use the searchFn if available (set by useWorkflowSearch hook)
  14. if (workflowNodesAction.searchFn) {
  15. // searchFn already returns SearchResult[] type, no need to use parser
  16. return workflowNodesAction.searchFn(searchTerm)
  17. }
  18. // If not in workflow context or search function not registered
  19. if (!searchTerm.trim()) {
  20. return [{
  21. id: 'help',
  22. title: i18n.t('app.gotoAnything.actions.searchWorkflowNodes', { lng: locale }),
  23. description: i18n.t('app.gotoAnything.actions.searchWorkflowNodesHelp', { lng: locale }),
  24. type: 'workflow-node',
  25. path: '#',
  26. data: {} as any,
  27. icon: (
  28. <div className="flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-blue-50 text-blue-600">
  29. <BoltIcon className="h-5 w-5" />
  30. </div>
  31. ),
  32. }]
  33. }
  34. return []
  35. }
  36. catch (error) {
  37. console.error('Error searching workflow nodes:', error)
  38. return []
  39. }
  40. },
  41. }