feat: introduce trigger functionality (#27644)
Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: Stream <Stream_2@qq.com> Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com> Co-authored-by: zhsama <torvalds@linux.do> Co-authored-by: Harry <xh001x@hotmail.com> Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: yessenia <yessenia.contact@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: WTW0313 <twwu@dify.ai> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
'use client'
|
||||
import React from 'react'
|
||||
import Drawer from '@/app/components/base/drawer'
|
||||
import { PluginCategoryEnum, type PluginDetail } from '@/app/components/plugins/types'
|
||||
import cn from '@/utils/classnames'
|
||||
import type { FC } from 'react'
|
||||
import { useCallback, useEffect } from 'react'
|
||||
import ActionList from './action-list'
|
||||
import AgentStrategyList from './agent-strategy-list'
|
||||
import DatasourceActionList from './datasource-action-list'
|
||||
import DetailHeader from './detail-header'
|
||||
import EndpointList from './endpoint-list'
|
||||
import ActionList from './action-list'
|
||||
import DatasourceActionList from './datasource-action-list'
|
||||
import ModelList from './model-list'
|
||||
import AgentStrategyList from './agent-strategy-list'
|
||||
import Drawer from '@/app/components/base/drawer'
|
||||
import type { PluginDetail } from '@/app/components/plugins/types'
|
||||
import cn from '@/utils/classnames'
|
||||
import { SubscriptionList } from './subscription-list'
|
||||
import { usePluginStore } from './store'
|
||||
import { TriggerEventsList } from './trigger/event-list'
|
||||
import { ReadmeEntrance } from '../readme-panel/entrance'
|
||||
|
||||
type Props = {
|
||||
detail?: PluginDetail
|
||||
@@ -22,11 +26,24 @@ const PluginDetailPanel: FC<Props> = ({
|
||||
onUpdate,
|
||||
onHide,
|
||||
}) => {
|
||||
const handleUpdate = (isDelete = false) => {
|
||||
const handleUpdate = useCallback((isDelete = false) => {
|
||||
if (isDelete)
|
||||
onHide()
|
||||
onUpdate()
|
||||
}
|
||||
}, [onHide, onUpdate])
|
||||
|
||||
const { setDetail } = usePluginStore()
|
||||
|
||||
useEffect(() => {
|
||||
setDetail(!detail ? undefined : {
|
||||
plugin_id: detail.plugin_id,
|
||||
provider: `${detail.plugin_id}/${detail.declaration.name}`,
|
||||
plugin_unique_identifier: detail.plugin_unique_identifier || '',
|
||||
declaration: detail.declaration,
|
||||
name: detail.name,
|
||||
id: detail.id,
|
||||
})
|
||||
}, [detail])
|
||||
|
||||
if (!detail)
|
||||
return null
|
||||
@@ -43,17 +60,24 @@ const PluginDetailPanel: FC<Props> = ({
|
||||
>
|
||||
{detail && (
|
||||
<>
|
||||
<DetailHeader
|
||||
detail={detail}
|
||||
onHide={onHide}
|
||||
onUpdate={handleUpdate}
|
||||
/>
|
||||
<DetailHeader detail={detail} onUpdate={handleUpdate} onHide={onHide} />
|
||||
<div className='grow overflow-y-auto'>
|
||||
{!!detail.declaration.tool && <ActionList detail={detail} />}
|
||||
{!!detail.declaration.agent_strategy && <AgentStrategyList detail={detail} />}
|
||||
{!!detail.declaration.endpoint && <EndpointList detail={detail} />}
|
||||
{!!detail.declaration.model && <ModelList detail={detail} />}
|
||||
{!!detail.declaration.datasource && <DatasourceActionList detail={detail} />}
|
||||
<div className='flex min-h-full flex-col'>
|
||||
<div className='flex-1'>
|
||||
{detail.declaration.category === PluginCategoryEnum.trigger && (
|
||||
<>
|
||||
<SubscriptionList />
|
||||
<TriggerEventsList />
|
||||
</>
|
||||
)}
|
||||
{!!detail.declaration.tool && <ActionList detail={detail} />}
|
||||
{!!detail.declaration.agent_strategy && <AgentStrategyList detail={detail} />}
|
||||
{!!detail.declaration.endpoint && <EndpointList detail={detail} />}
|
||||
{!!detail.declaration.model && <ModelList detail={detail} />}
|
||||
{!!detail.declaration.datasource && <DatasourceActionList detail={detail} />}
|
||||
</div>
|
||||
<ReadmeEntrance pluginDetail={detail} className='mt-auto' />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user