index.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. 'use client'
  2. import React from 'react'
  3. import type { FC } from 'react'
  4. import DetailHeader from './detail-header'
  5. import EndpointList from './endpoint-list'
  6. import ActionList from './action-list'
  7. import ModelList from './model-list'
  8. import AgentStrategyList from './agent-strategy-list'
  9. import Drawer from '@/app/components/base/drawer'
  10. import type { PluginDetail } from '@/app/components/plugins/types'
  11. import cn from '@/utils/classnames'
  12. type Props = {
  13. detail?: PluginDetail
  14. onUpdate: () => void
  15. onHide: () => void
  16. }
  17. const PluginDetailPanel: FC<Props> = ({
  18. detail,
  19. onUpdate,
  20. onHide,
  21. }) => {
  22. const handleUpdate = (isDelete = false) => {
  23. if (isDelete)
  24. onHide()
  25. onUpdate()
  26. }
  27. if (!detail)
  28. return null
  29. return (
  30. <Drawer
  31. isOpen={!!detail}
  32. clickOutsideNotOpen={false}
  33. onClose={onHide}
  34. footer={null}
  35. mask={false}
  36. positionCenter={false}
  37. 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')}
  38. >
  39. {detail && (
  40. <>
  41. <DetailHeader
  42. detail={detail}
  43. onHide={onHide}
  44. onUpdate={handleUpdate}
  45. />
  46. <div className='grow overflow-y-auto'>
  47. {!!detail.declaration.tool && <ActionList detail={detail} />}
  48. {!!detail.declaration.agent_strategy && <AgentStrategyList detail={detail} />}
  49. {!!detail.declaration.endpoint && <EndpointList detail={detail} />}
  50. {!!detail.declaration.model && <ModelList detail={detail} />}
  51. </div>
  52. </>
  53. )}
  54. </Drawer>
  55. )
  56. }
  57. export default PluginDetailPanel