fix: unified error handling for GotoAnything search actions (#23715)
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
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 = {
|
||||
@@ -12,32 +10,14 @@ export const workflowNodesAction: ActionItem = {
|
||||
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
|
||||
if (workflowNodesAction.searchFn)
|
||||
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>
|
||||
),
|
||||
}]
|
||||
}
|
||||
|
||||
// If not in workflow context, return empty array
|
||||
return []
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Error searching workflow nodes:', error)
|
||||
catch (error) {
|
||||
console.warn('Workflow nodes search failed:', error)
|
||||
return []
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user