Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

2.0 KB
Raw Blame
'use client'
import type { FC } from 'react'
import type { ToolWithProvider } from '../../../workflow/types'
import { cn } from '@langgenius/dify-ui/cn'
import {
  Drawer,
  DrawerBackdrop,
  DrawerContent,
  DrawerPopup,
  DrawerPortal,
  DrawerViewport,
} from '@langgenius/dify-ui/drawer'
import * as React from 'react'
import MCPDetailContent from './content'

type Props = Readonly<{
  detail?: ToolWithProvider
  onUpdate: () => void
  onEdit: (providerID: string) => void
  onDelete: (providerID: string) => void
  onHide: () => void
  isTriggerAuthorize: boolean
  onFirstCreate: () => void
}>

const MCPDetailPanel: FC<Props> = ({
  detail,
  onUpdate,
  onEdit,
  onDelete,
  onHide,
  isTriggerAuthorize,
  onFirstCreate,
}) => {
  if (!detail) return null

  return (
    <Drawer
      open={!!detail}
      modal
      swipeDirection="right"
      onOpenChange={(open) => {
        if (!open) onHide()
      }}
    >
      <DrawerPortal>
        <DrawerBackdrop className="bg-transparent" />
        <DrawerViewport>
          <DrawerPopup
            className={cn(
              'justify-start bg-components-panel-bg! p-0! shadow-xl data-[swipe-direction=right]:top-2 data-[swipe-direction=right]:right-2 data-[swipe-direction=right]:bottom-2 data-[swipe-direction=right]:h-[calc(100dvh-16px)] data-[swipe-direction=right]:w-100 data-[swipe-direction=right]:max-w-[calc(100vw-1rem)] data-[swipe-direction=right]:rounded-2xl',
            )}
          >
            <DrawerContent>
              {detail && (
                <MCPDetailContent
                  detail={detail}
                  onHide={onHide}
                  onUpdate={onUpdate}
                  onEdit={onEdit}
                  onDelete={onDelete}
                  isTriggerAuthorize={isTriggerAuthorize}
                  onFirstCreate={onFirstCreate}
                />
              )}
            </DrawerContent>
          </DrawerPopup>
        </DrawerViewport>
      </DrawerPortal>
    </Drawer>
  )
}

export default MCPDetailPanel