'use client' import ActionButton from '@/app/components/base/action-button' import Divider from '@/app/components/base/divider' import Drawer from '@/app/components/base/drawer' import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' import Icon from '@/app/components/plugins/card/base/card-icon' import Description from '@/app/components/plugins/card/base/description' import OrgInfo from '@/app/components/plugins/card/base/org-info' import { triggerEventParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema' import type { TriggerProviderApiEntity } from '@/app/components/workflow/block-selector/types' import Field from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show/field' import cn from '@/utils/classnames' import { RiArrowLeftLine, RiCloseLine, } from '@remixicon/react' import type { TFunction } from 'i18next' import type { FC } from 'react' import { useTranslation } from 'react-i18next' import type { TriggerEvent } from '@/app/components/plugins/types' type EventDetailDrawerProps = { eventInfo: TriggerEvent providerInfo: TriggerProviderApiEntity onClose: () => void } const getType = (type: string, t: TFunction) => { if (type === 'number-input') return t('tools.setBuiltInTools.number') if (type === 'text-input') return t('tools.setBuiltInTools.string') if (type === 'checkbox') return 'boolean' if (type === 'file') return t('tools.setBuiltInTools.file') return type } // Convert JSON Schema to StructuredOutput format const convertSchemaToField = (schema: any): any => { const field: any = { type: Array.isArray(schema.type) ? schema.type[0] : schema.type || 'string', } if (schema.description) field.description = schema.description if (schema.properties) { field.properties = Object.entries(schema.properties).reduce((acc, [key, value]: [string, any]) => ({ ...acc, [key]: convertSchemaToField(value), }), {}) } if (schema.required) field.required = schema.required if (schema.items) field.items = convertSchemaToField(schema.items) if (schema.enum) field.enum = schema.enum return field } export const EventDetailDrawer: FC = (props) => { const { eventInfo, providerInfo, onClose } = props const language = useLanguage() const { t } = useTranslation() const parametersSchemas = triggerEventParametersToFormSchemas(eventInfo.parameters) // Convert output_schema properties to array for direct rendering const outputFields = eventInfo.output_schema?.properties ? Object.entries(eventInfo.output_schema.properties).map(([name, schema]: [string, any]) => ({ name, field: convertSchemaToField(schema), required: eventInfo.output_schema.required?.includes(name) || false, })) : [] return (
{t('plugin.detailPanel.operation.back')}
{eventInfo?.identity?.label[language]}
{t('tools.setBuiltInTools.parameters')}
{parametersSchemas.length > 0 ? ( parametersSchemas.map((item, index) => (
{item.label[language]}
{getType(item.type, t)}
{item.required && (
{t('tools.setBuiltInTools.required')}
)}
{item.description && (
{item.description?.[language]}
)}
)) ) :
{t('pluginTrigger.events.item.noParameters')}
}
{t('pluginTrigger.events.output')}
{outputFields.map(item => ( ))}
) }