mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
refactor(trigger): rename trigger references to event for consistency
- Updated variable names and types from 'trigger' to 'event' across multiple files to enhance clarity and maintain consistency in the codebase. - Adjusted related data structures and API responses to reflect the new naming convention. - Improved type annotations and error handling in the workflow trigger run API and associated services.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import type { TriggerWithProvider } from '../types'
|
||||
import type { Trigger } from '@/app/components/tools/types'
|
||||
import type { Event } from '@/app/components/tools/types'
|
||||
import { BlockEnum } from '../../types'
|
||||
import type { TriggerDefaultValue } from '../types'
|
||||
import Tooltip from '@/app/components/base/tooltip'
|
||||
@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next'
|
||||
|
||||
type Props = {
|
||||
provider: TriggerWithProvider
|
||||
payload: Trigger
|
||||
payload: Event
|
||||
disabled?: boolean
|
||||
isAdded?: boolean
|
||||
onSelect: (type: BlockEnum, trigger?: TriggerDefaultValue) => void
|
||||
@ -63,9 +63,9 @@ const TriggerPluginActionItem: FC<Props> = ({
|
||||
provider_id: provider.id,
|
||||
provider_type: provider.type as string,
|
||||
provider_name: provider.name,
|
||||
trigger_name: payload.name,
|
||||
trigger_label: payload.label[language],
|
||||
trigger_description: payload.description[language],
|
||||
event_name: payload.name,
|
||||
event_label: payload.label[language],
|
||||
event_description: payload.description[language],
|
||||
plugin_unique_identifier: provider.plugin_unique_identifier,
|
||||
title: payload.label[language],
|
||||
is_team_authorization: provider.is_team_authorization,
|
||||
|
||||
@ -27,7 +27,7 @@ const TriggerPluginItem: FC<Props> = ({
|
||||
const { t } = useTranslation()
|
||||
const language = useGetLanguage()
|
||||
const notShowProvider = payload.type === CollectionType.workflow
|
||||
const actions = payload.triggers
|
||||
const actions = payload.events
|
||||
const hasAction = !notShowProvider
|
||||
const [isFold, setFold] = React.useState<boolean>(true)
|
||||
const ref = useRef(null)
|
||||
@ -71,10 +71,10 @@ const TriggerPluginItem: FC<Props> = ({
|
||||
return
|
||||
}
|
||||
|
||||
const trigger = actions[0]
|
||||
const event = actions[0]
|
||||
const params: Record<string, string> = {}
|
||||
if (trigger.parameters) {
|
||||
trigger.parameters.forEach((item) => {
|
||||
if (event.parameters) {
|
||||
event.parameters.forEach((item: any) => {
|
||||
params[item.name] = ''
|
||||
})
|
||||
}
|
||||
@ -82,14 +82,14 @@ const TriggerPluginItem: FC<Props> = ({
|
||||
provider_id: payload.id,
|
||||
provider_type: payload.type,
|
||||
provider_name: payload.name,
|
||||
trigger_name: trigger.name,
|
||||
trigger_label: trigger.label[language],
|
||||
trigger_description: trigger.description[language],
|
||||
title: trigger.label[language],
|
||||
event_name: event.name,
|
||||
event_label: event.label[language],
|
||||
event_description: event.description[language],
|
||||
title: event.label[language],
|
||||
plugin_unique_identifier: payload.plugin_unique_identifier,
|
||||
is_team_authorization: payload.is_team_authorization,
|
||||
output_schema: trigger.output_schema || {},
|
||||
paramSchemas: trigger.parameters,
|
||||
output_schema: event.output_schema || {},
|
||||
paramSchemas: event.parameters,
|
||||
params,
|
||||
})
|
||||
}}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import type { TypeWithI18N } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||
import type { PluginMeta, SupportedCreationMethods } from '../../plugins/types'
|
||||
import type { Collection, Trigger } from '../../tools/types'
|
||||
import type { Collection, Event } from '../../tools/types'
|
||||
|
||||
export enum TabsEnum {
|
||||
Start = 'start',
|
||||
@ -32,9 +32,9 @@ type PluginCommonDefaultValue = {
|
||||
}
|
||||
|
||||
export type TriggerDefaultValue = PluginCommonDefaultValue & {
|
||||
trigger_name: string
|
||||
trigger_label: string
|
||||
trigger_description: string
|
||||
event_name: string
|
||||
event_label: string
|
||||
event_description: string
|
||||
title: string
|
||||
plugin_unique_identifier: string
|
||||
is_team_authorization: boolean
|
||||
@ -207,7 +207,7 @@ export type TriggerProviderApiEntity = {
|
||||
|
||||
// Frontend types - compatible with ToolWithProvider
|
||||
export type TriggerWithProvider = Collection & {
|
||||
triggers: Trigger[]
|
||||
events: Event[]
|
||||
meta: PluginMeta
|
||||
plugin_unique_identifier: string
|
||||
credentials_schema?: TriggerCredentialField[]
|
||||
|
||||
Reference in New Issue
Block a user