mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 18:08:07 +08:00
chore: remove frontend changes
This commit is contained in:
@ -1,4 +1,13 @@
|
||||
'use client'
|
||||
import type { TFunction } from 'i18next'
|
||||
import type { FC } from 'react'
|
||||
import type { TriggerEvent } from '@/app/components/plugins/types'
|
||||
import type { TriggerProviderApiEntity } from '@/app/components/workflow/block-selector/types'
|
||||
import {
|
||||
RiArrowLeftLine,
|
||||
RiCloseLine,
|
||||
} from '@remixicon/react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import ActionButton from '@/app/components/base/action-button'
|
||||
import Divider from '@/app/components/base/divider'
|
||||
import Drawer from '@/app/components/base/drawer'
|
||||
@ -7,17 +16,8 @@ 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'
|
||||
import { cn } from '@/utils/classnames'
|
||||
|
||||
type EventDetailDrawerProps = {
|
||||
eventInfo: TriggerEvent
|
||||
@ -27,13 +27,13 @@ type EventDetailDrawerProps = {
|
||||
|
||||
const getType = (type: string, t: TFunction) => {
|
||||
if (type === 'number-input')
|
||||
return t('tools.setBuiltInTools.number')
|
||||
return t('setBuiltInTools.number', { ns: 'tools' })
|
||||
if (type === 'text-input')
|
||||
return t('tools.setBuiltInTools.string')
|
||||
return t('setBuiltInTools.string', { ns: 'tools' })
|
||||
if (type === 'checkbox')
|
||||
return 'boolean'
|
||||
if (type === 'file')
|
||||
return t('tools.setBuiltInTools.file')
|
||||
return t('setBuiltInTools.file', { ns: 'tools' })
|
||||
return type
|
||||
}
|
||||
|
||||
@ -74,10 +74,10 @@ export const EventDetailDrawer: FC<EventDetailDrawerProps> = (props) => {
|
||||
// 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,
|
||||
}))
|
||||
name,
|
||||
field: convertSchemaToField(schema),
|
||||
required: eventInfo.output_schema.required?.includes(name) || false,
|
||||
}))
|
||||
: []
|
||||
|
||||
return (
|
||||
@ -90,63 +90,65 @@ export const EventDetailDrawer: FC<EventDetailDrawerProps> = (props) => {
|
||||
positionCenter={false}
|
||||
panelClassName={cn('mb-2 mr-2 mt-[64px] !w-[420px] !max-w-[420px] justify-start rounded-2xl border-[0.5px] border-components-panel-border !bg-components-panel-bg !p-0 shadow-xl')}
|
||||
>
|
||||
<div className='relative border-b border-divider-subtle p-4 pb-3'>
|
||||
<div className='absolute right-3 top-3'>
|
||||
<div className="relative border-b border-divider-subtle p-4 pb-3">
|
||||
<div className="absolute right-3 top-3">
|
||||
<ActionButton onClick={onClose}>
|
||||
<RiCloseLine className='h-4 w-4' />
|
||||
<RiCloseLine className="h-4 w-4" />
|
||||
</ActionButton>
|
||||
</div>
|
||||
<div
|
||||
className='system-xs-semibold-uppercase mb-2 flex cursor-pointer items-center gap-1 text-text-accent-secondary'
|
||||
className="system-xs-semibold-uppercase mb-2 flex cursor-pointer items-center gap-1 text-text-accent-secondary"
|
||||
onClick={onClose}
|
||||
>
|
||||
<RiArrowLeftLine className='h-4 w-4' />
|
||||
{t('plugin.detailPanel.operation.back')}
|
||||
<RiArrowLeftLine className="h-4 w-4" />
|
||||
{t('detailPanel.operation.back', { ns: 'plugin' })}
|
||||
</div>
|
||||
<div className='flex items-center gap-1'>
|
||||
<Icon size='tiny' className='h-6 w-6' src={providerInfo.icon!} />
|
||||
<div className="flex items-center gap-1">
|
||||
<Icon size="tiny" className="h-6 w-6" src={providerInfo.icon!} />
|
||||
<OrgInfo
|
||||
packageNameClassName='w-auto'
|
||||
packageNameClassName="w-auto"
|
||||
orgName={providerInfo.author}
|
||||
packageName={providerInfo.name.split('/').pop() || ''}
|
||||
/>
|
||||
</div>
|
||||
<div className='system-md-semibold mt-1 text-text-primary'>{eventInfo?.identity?.label[language]}</div>
|
||||
<Description className='mb-2 mt-3 h-auto' text={eventInfo.description[language]} descriptionLineRows={2}></Description>
|
||||
<div className="system-md-semibold mt-1 text-text-primary">{eventInfo?.identity?.label[language]}</div>
|
||||
<Description className="mb-2 mt-3 h-auto" text={eventInfo.description[language]} descriptionLineRows={2}></Description>
|
||||
</div>
|
||||
<div className='flex h-full flex-col gap-2 overflow-y-auto px-4 pb-2 pt-4'>
|
||||
<div className='system-sm-semibold-uppercase text-text-secondary'>{t('tools.setBuiltInTools.parameters')}</div>
|
||||
{parametersSchemas.length > 0 ? (
|
||||
parametersSchemas.map((item, index) => (
|
||||
<div key={index} className='py-1'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='code-sm-semibold text-text-secondary'>{item.label[language]}</div>
|
||||
<div className='system-xs-regular text-text-tertiary'>
|
||||
{getType(item.type, t)}
|
||||
<div className="flex h-full flex-col gap-2 overflow-y-auto px-4 pb-2 pt-4">
|
||||
<div className="system-sm-semibold-uppercase text-text-secondary">{t('setBuiltInTools.parameters', { ns: 'tools' })}</div>
|
||||
{parametersSchemas.length > 0
|
||||
? (
|
||||
parametersSchemas.map((item, index) => (
|
||||
<div key={index} className="py-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="code-sm-semibold text-text-secondary">{item.label[language]}</div>
|
||||
<div className="system-xs-regular text-text-tertiary">
|
||||
{getType(item.type, t)}
|
||||
</div>
|
||||
{item.required && (
|
||||
<div className="system-xs-medium text-text-warning-secondary">{t('setBuiltInTools.required', { ns: 'tools' })}</div>
|
||||
)}
|
||||
</div>
|
||||
{item.description && (
|
||||
<div className="system-xs-regular mt-0.5 text-text-tertiary">
|
||||
{item.description?.[language]}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{item.required && (
|
||||
<div className='system-xs-medium text-text-warning-secondary'>{t('tools.setBuiltInTools.required')}</div>
|
||||
)}
|
||||
</div>
|
||||
{item.description && (
|
||||
<div className='system-xs-regular mt-0.5 text-text-tertiary'>
|
||||
{item.description?.[language]}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))
|
||||
) : <div className='system-xs-regular text-text-tertiary'>{t('pluginTrigger.events.item.noParameters')}</div>}
|
||||
<Divider className='mb-2 mt-1 h-px' />
|
||||
<div className='flex flex-col gap-2'>
|
||||
<div className='system-sm-semibold-uppercase text-text-secondary'>{t('pluginTrigger.events.output')}</div>
|
||||
<div className='relative left-[-7px]'>
|
||||
))
|
||||
)
|
||||
: <div className="system-xs-regular text-text-tertiary">{t('events.item.noParameters', { ns: 'pluginTrigger' })}</div>}
|
||||
<Divider className="mb-2 mt-1 h-px" />
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="system-sm-semibold-uppercase text-text-secondary">{t('events.output', { ns: 'pluginTrigger' })}</div>
|
||||
<div className="relative left-[-7px]">
|
||||
{outputFields.map(item => (
|
||||
<Field
|
||||
key={item.name}
|
||||
name={item.name}
|
||||
payload={item.field}
|
||||
required={item.required}
|
||||
rootClassName='code-sm-semibold text-text-secondary'
|
||||
rootClassName="code-sm-semibold text-text-secondary"
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||
import type { TriggerEvent } from '@/app/components/plugins/types'
|
||||
import type { TriggerProviderApiEntity } from '@/app/components/workflow/block-selector/types'
|
||||
import { useTriggerProviderInfo } from '@/service/use-triggers'
|
||||
import cn from '@/utils/classnames'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||
import { useTriggerProviderInfo } from '@/service/use-triggers'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { usePluginStore } from '../store'
|
||||
import { EventDetailDrawer } from './event-detail-drawer'
|
||||
|
||||
@ -25,8 +25,8 @@ const TriggerEventCard = ({ eventInfo, providerInfo }: TriggerEventCardProps) =>
|
||||
className={cn('bg-components-panel-item-bg cursor-pointer rounded-xl border-[0.5px] border-components-panel-border-subtle px-4 py-3 shadow-xs hover:bg-components-panel-on-panel-item-bg-hover')}
|
||||
onClick={() => setShowDetail(true)}
|
||||
>
|
||||
<div className='system-md-semibold pb-0.5 text-text-secondary'>{title}</div>
|
||||
<div className='system-xs-regular line-clamp-2 text-text-tertiary' title={descriptionText}>{descriptionText}</div>
|
||||
<div className="system-md-semibold pb-0.5 text-text-secondary">{title}</div>
|
||||
<div className="system-xs-regular line-clamp-2 text-text-tertiary" title={descriptionText}>{descriptionText}</div>
|
||||
</div>
|
||||
{showDetail && (
|
||||
<EventDetailDrawer
|
||||
@ -50,20 +50,21 @@ export const TriggerEventsList = () => {
|
||||
return null
|
||||
|
||||
return (
|
||||
<div className='px-4 pb-4 pt-2'>
|
||||
<div className='mb-1 py-1'>
|
||||
<div className='system-sm-semibold-uppercase mb-1 flex h-6 items-center justify-between text-text-secondary'>
|
||||
{t('pluginTrigger.events.actionNum', { num: triggerEvents.length, event: t(`pluginTrigger.events.${triggerEvents.length > 1 ? 'events' : 'event'}`) })}
|
||||
<div className="px-4 pb-4 pt-2">
|
||||
<div className="mb-1 py-1">
|
||||
<div className="system-sm-semibold-uppercase mb-1 flex h-6 items-center justify-between text-text-secondary">
|
||||
{t('events.actionNum', { ns: 'pluginTrigger', num: triggerEvents.length, event: t(`events.${triggerEvents.length > 1 ? 'events' : 'event'}`, { ns: 'pluginTrigger' }) })}
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex flex-col gap-2'>
|
||||
<div className="flex flex-col gap-2">
|
||||
{
|
||||
triggerEvents.map((triggerEvent: TriggerEvent) => (
|
||||
<TriggerEventCard
|
||||
key={`${detail?.plugin_id}${triggerEvent.identity?.name || ''}`}
|
||||
eventInfo={triggerEvent}
|
||||
providerInfo={providerInfo}
|
||||
/>))
|
||||
/>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user