dify/web/app/components/plugins/plugin-detail-panel/index.tsx

65 lines
1.7 KiB
TypeScript
Raw Normal View History

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-12 14:39:53 +08:00
import { useTranslation } from 'react-i18next'
2024-10-19 14:18:51 +08:00
import type { EndpointListItem, PluginDetail } from '../types'
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-10-12 12:35:56 +08:00
import Drawer from '@/app/components/base/drawer'
import cn from '@/utils/classnames'
type Props = {
2024-10-16 17:30:51 +08:00
pluginDetail: PluginDetail | undefined
2024-10-19 14:18:51 +08:00
endpointList: EndpointListItem[]
2024-10-16 15:37:32 +08:00
onHide: () => void
2024-10-12 12:35:56 +08:00
}
const PluginDetailPanel: FC<Props> = ({
2024-10-16 15:37:32 +08:00
pluginDetail,
2024-10-19 14:18:51 +08:00
endpointList = [],
2024-10-16 15:37:32 +08:00
onHide,
2024-10-12 12:35:56 +08:00
}) => {
2024-10-12 14:39:53 +08:00
const { t } = useTranslation()
2024-10-12 12:35:56 +08:00
2024-10-19 13:53:55 +08:00
const handleDelete = () => {}
2024-10-12 14:39:53 +08:00
2024-10-16 15:37:32 +08:00
if (!pluginDetail)
2024-10-12 12:35:56 +08:00
return null
return (
<Drawer
isOpen={!!pluginDetail}
clickOutsideNotOpen={false}
2024-10-16 15:37:32 +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-10-16 15:37:32 +08:00
{pluginDetail && (
2024-10-12 16:29:46 +08:00
<>
2024-10-19 13:53:55 +08:00
<DetailHeader
detail={pluginDetail}
onHide={onHide}
onDelete={handleDelete}
/>
2024-10-12 16:29:46 +08:00
<div className='grow overflow-y-auto'>
2024-10-19 14:18:51 +08:00
{!!pluginDetail.declaration.endpoint && (
<EndpointList
list={endpointList}
declaration={pluginDetail.declaration.endpoint}
/>
)}
{!!pluginDetail.declaration.tool && <ActionList />}
{!!pluginDetail.declaration.model && <ModelList />}
2024-10-12 16:29:46 +08:00
</div>
</>
2024-10-12 12:35:56 +08:00
)}
</Drawer>
)
}
export default PluginDetailPanel