'use client' 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 ModelList from './model-list' 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 onUpdate: () => void onHide: () => void } const PluginDetailPanel: FC = ({ detail, onUpdate, onHide, }) => { 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 return ( {detail && ( <>
{detail.declaration.category === PluginCategoryEnum.trigger && ( <> )} {!!detail.declaration.tool && } {!!detail.declaration.agent_strategy && } {!!detail.declaration.endpoint && } {!!detail.declaration.model && } {!!detail.declaration.datasource && }
)}
) } export default PluginDetailPanel