2024-10-12 12:35:56 +08:00
|
|
|
'use client'
|
2024-10-19 13:53:55 +08:00
|
|
|
import React from 'react'
|
2024-10-12 12:35:56 +08:00
|
|
|
import type { FC } from 'react'
|
2024-10-19 13:53:55 +08:00
|
|
|
import DetailHeader from './detail-header'
|
2024-10-12 16:29:46 +08:00
|
|
|
import EndpointList from './endpoint-list'
|
|
|
|
import ActionList from './action-list'
|
|
|
|
import ModelList from './model-list'
|
2024-12-25 11:55:42 +08:00
|
|
|
import AgentStrategyList from './agent-strategy-list'
|
2024-10-12 12:35:56 +08:00
|
|
|
import Drawer from '@/app/components/base/drawer'
|
2024-11-21 15:35:24 +08:00
|
|
|
import type { PluginDetail } from '@/app/components/plugins/types'
|
2024-10-12 12:35:56 +08:00
|
|
|
import cn from '@/utils/classnames'
|
2025-01-07 14:41:48 +08:00
|
|
|
import ToolSelector from '@/app/components/plugins/plugin-detail-panel/tool-selector'
|
2024-10-12 12:35:56 +08:00
|
|
|
|
|
|
|
type Props = {
|
2024-11-21 15:35:24 +08:00
|
|
|
detail?: PluginDetail
|
2024-11-08 17:01:49 +08:00
|
|
|
onUpdate: () => void
|
2024-11-21 18:11:19 +08:00
|
|
|
onHide: () => void
|
2024-10-12 12:35:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const PluginDetailPanel: FC<Props> = ({
|
2024-11-21 15:35:24 +08:00
|
|
|
detail,
|
2024-11-08 17:01:49 +08:00
|
|
|
onUpdate,
|
2024-11-21 18:11:19 +08:00
|
|
|
onHide,
|
2024-10-12 12:35:56 +08:00
|
|
|
}) => {
|
2024-11-19 17:21:07 +08:00
|
|
|
const handleUpdate = (isDelete = false) => {
|
|
|
|
if (isDelete)
|
2024-11-21 18:11:19 +08:00
|
|
|
onHide()
|
2024-11-19 17:21:07 +08:00
|
|
|
onUpdate()
|
|
|
|
}
|
|
|
|
|
2025-01-07 14:41:48 +08:00
|
|
|
const [value, setValue] = React.useState({
|
|
|
|
provider_name: 'langgenius/google/google',
|
|
|
|
tool_name: 'google_search',
|
|
|
|
})
|
|
|
|
|
|
|
|
const testHandle = (item: any) => {
|
|
|
|
console.log(item)
|
|
|
|
setValue(item)
|
|
|
|
}
|
|
|
|
|
2024-11-21 15:35:24 +08:00
|
|
|
if (!detail)
|
2024-10-12 12:35:56 +08:00
|
|
|
return null
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Drawer
|
2024-11-21 15:35:24 +08:00
|
|
|
isOpen={!!detail}
|
2024-10-12 12:35:56 +08:00
|
|
|
clickOutsideNotOpen={false}
|
2024-11-21 18:11:19 +08:00
|
|
|
onClose={onHide}
|
2024-10-12 12:35:56 +08:00
|
|
|
footer={null}
|
|
|
|
mask={false}
|
|
|
|
positionCenter={false}
|
2024-10-12 16:29:46 +08:00
|
|
|
panelClassname={cn('justify-start mt-[64px] mr-2 mb-2 !w-[420px] !max-w-[420px] !p-0 !bg-components-panel-bg rounded-2xl border-[0.5px] border-components-panel-border shadow-xl')}
|
2024-10-12 12:35:56 +08:00
|
|
|
>
|
2024-11-21 15:35:24 +08:00
|
|
|
{detail && (
|
2024-10-12 16:29:46 +08:00
|
|
|
<>
|
2024-10-19 13:53:55 +08:00
|
|
|
<DetailHeader
|
2024-11-21 15:35:24 +08:00
|
|
|
detail={detail}
|
2024-11-21 18:11:19 +08:00
|
|
|
onHide={onHide}
|
2024-11-19 17:21:07 +08:00
|
|
|
onUpdate={handleUpdate}
|
2024-10-19 13:53:55 +08:00
|
|
|
/>
|
2024-10-12 16:29:46 +08:00
|
|
|
<div className='grow overflow-y-auto'>
|
2024-11-21 15:35:24 +08:00
|
|
|
{!!detail.declaration.tool && <ActionList detail={detail} />}
|
2024-12-25 11:55:42 +08:00
|
|
|
{!!detail.declaration.agent_strategy && <AgentStrategyList detail={detail} />}
|
2024-11-21 15:35:24 +08:00
|
|
|
{!!detail.declaration.endpoint && <EndpointList detail={detail} />}
|
|
|
|
{!!detail.declaration.model && <ModelList detail={detail} />}
|
2025-01-07 14:41:48 +08:00
|
|
|
{false && (
|
|
|
|
<div className='px-4'>
|
|
|
|
<ToolSelector
|
|
|
|
scope={'all'}
|
|
|
|
value={value}
|
|
|
|
onSelect={item => testHandle(item)}
|
|
|
|
onDelete={() => testHandle(null)}
|
|
|
|
supportEnableSwitch
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
2024-10-12 16:29:46 +08:00
|
|
|
</div>
|
|
|
|
</>
|
2024-10-12 12:35:56 +08:00
|
|
|
)}
|
|
|
|
</Drawer>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PluginDetailPanel
|