[PR #25204] feat(trigger): implement trigger plugin block selector following tools pattern #30969

Closed
opened 2026-02-21 20:48:34 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/25204

State: closed
Merged: Yes


Summary

This PR implements the trigger plugin block selector functionality in the workflow system, allowing users to select and configure trigger plugins from the block selector interface.

Key Changes

🔧 Backend Integration

  • Created use-triggers.ts hook that follows the exact same pattern as existing tools hooks
  • Integrated with /workspaces/current/triggers API endpoint
  • Implemented proper data transformation from backend TriggerProviderApiEntity to frontend ToolWithProvider format

🎨 Frontend Components

  • TriggerPluginList: Main list component with filtering and search functionality
  • TriggerPluginItem: Individual trigger provider display with expand/collapse
  • TriggerPluginActionItem: Individual trigger action items with tooltips and selection

📝 Type Safety & Standards

  • Defined precise TypeScript types matching backend Python API definitions
  • Maintained compatibility with existing ToolWithProvider structure
  • Used standard TypeWithI18N format for internationalization
  • Reused existing Collection and Tool types for consistency

Features

  • Search functionality across trigger names and descriptions
  • Internationalization support (en_US, zh_Hans)
  • Consistent UI/UX with existing tools components
  • Proper error handling and loading states
  • Tooltip documentation for each trigger action

Technical Implementation

Data Flow

  1. API Call: useAllTriggerPlugins()/workspaces/current/triggers
  2. Data Transform: TriggerProviderApiEntity[]TriggerWithProvider[]
  3. Component Render: Compatible with existing block selector architecture
  4. User Selection: Triggers onSelect callback with proper ToolDefaultValue format

Code Quality

  • Follows existing tools component patterns exactly
  • Maintains type safety throughout the stack
  • Passes all ESLint checks and unit tests
  • Uses React best practices (memo, useMemo, useEffect)
  • Proper separation of concerns

Testing

The implementation has been tested to ensure:

  • Proper integration with existing workflow block selector
  • Correct data transformation from backend API
  • UI consistency with tools components
  • Type safety across the entire stack

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Note: This implementation follows the established tools pattern exactly, ensuring consistency and maintainability across the codebase.

**Original Pull Request:** https://github.com/langgenius/dify/pull/25204 **State:** closed **Merged:** Yes --- ## Summary This PR implements the trigger plugin block selector functionality in the workflow system, allowing users to select and configure trigger plugins from the block selector interface. ### Key Changes #### 🔧 **Backend Integration** - Created `use-triggers.ts` hook that follows the exact same pattern as existing tools hooks - Integrated with `/workspaces/current/triggers` API endpoint - Implemented proper data transformation from backend `TriggerProviderApiEntity` to frontend `ToolWithProvider` format #### 🎨 **Frontend Components** - **TriggerPluginList**: Main list component with filtering and search functionality - **TriggerPluginItem**: Individual trigger provider display with expand/collapse - **TriggerPluginActionItem**: Individual trigger action items with tooltips and selection #### 📝 **Type Safety & Standards** - Defined precise TypeScript types matching backend Python API definitions - Maintained compatibility with existing `ToolWithProvider` structure - Used standard `TypeWithI18N` format for internationalization - Reused existing `Collection` and `Tool` types for consistency #### ✨ **Features** - Search functionality across trigger names and descriptions - Internationalization support (en_US, zh_Hans) - Consistent UI/UX with existing tools components - Proper error handling and loading states - Tooltip documentation for each trigger action ### Technical Implementation #### Data Flow 1. **API Call**: `useAllTriggerPlugins()` → `/workspaces/current/triggers` 2. **Data Transform**: `TriggerProviderApiEntity[]` → `TriggerWithProvider[]` 3. **Component Render**: Compatible with existing block selector architecture 4. **User Selection**: Triggers `onSelect` callback with proper `ToolDefaultValue` format #### Code Quality - ✅ Follows existing tools component patterns exactly - ✅ Maintains type safety throughout the stack - ✅ Passes all ESLint checks and unit tests - ✅ Uses React best practices (memo, useMemo, useEffect) - ✅ Proper separation of concerns ### Testing The implementation has been tested to ensure: - Proper integration with existing workflow block selector - Correct data transformation from backend API - UI consistency with tools components - Type safety across the entire stack ## Checklist - [x] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods --- **Note**: This implementation follows the established tools pattern exactly, ensuring consistency and maintainability across the codebase.
yindo added the pull-request label 2026-02-21 20:48:34 -05:00
yindo closed this issue 2026-02-21 20:48:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#30969