refactor(trigger): update variable names for clarity and consistency

- Renamed variables related to triggers to use 'trigger' terminology consistently across the codebase.
- Adjusted filtering logic in `TriggerPluginList` to reference 'events' instead of 'triggers' for improved clarity.
- Updated the `getTriggerIcon` function to reflect the new naming conventions and ensure proper icon rendering.
This commit is contained in:
Harry
2025-10-09 12:23:48 +08:00
parent 8a5fbf183b
commit b8ca480b07
2 changed files with 12 additions and 11 deletions

View File

@@ -57,15 +57,16 @@ const getTriggerIcon = (trigger: AppTrigger, triggerPlugins: any[]) => {
blockType = BlockEnum.TriggerWebhook
}
let toolIcon: string | undefined
let triggerIcon: string | undefined
if (trigger_type === 'trigger-plugin' && provider_name) {
const targetTools = triggerPlugins || []
const foundTool = targetTools.find(toolWithProvider =>
canFindTool(toolWithProvider.id, provider_name)
|| toolWithProvider.id.includes(provider_name)
|| toolWithProvider.name === provider_name,
const targetTriggers = triggerPlugins || []
const foundTrigger = targetTriggers.find(triggerWithProvider =>
canFindTool(triggerWithProvider.id, provider_name)
|| triggerWithProvider.id.includes(provider_name)
|| triggerWithProvider.name === provider_name,
)
toolIcon = foundTool?.icon
triggerIcon = foundTrigger?.icon
console.log('triggerIcon', triggerIcon)
}
return (
@@ -73,7 +74,7 @@ const getTriggerIcon = (trigger: AppTrigger, triggerPlugins: any[]) => {
<BlockIcon
type={blockType}
size="md"
toolIcon={toolIcon}
toolIcon={triggerIcon}
/>
{getStatusDot()}
</div>

View File

@@ -24,13 +24,13 @@ const TriggerPluginList = ({
const triggerPlugins = useMemo(() => {
// Follow exact same pattern as tools
return (triggerPluginsData || []).filter((triggerWithProvider) => {
if (triggerWithProvider.triggers.length === 0) return false
if (triggerWithProvider.events.length === 0) return false
// Filter by search text
if (searchText) {
const matchesSearch = triggerWithProvider.name.toLowerCase().includes(searchText.toLowerCase())
|| triggerWithProvider.triggers.some(tool =>
tool.label[language].toLowerCase().includes(searchText.toLowerCase()),
|| triggerWithProvider.events.some(event =>
event.label[language].toLowerCase().includes(searchText.toLowerCase()),
)
if (!matchesSearch) return false
}