'use client' import type { Placement } from '@langgenius/dify-ui/popover' import type { ComponentProps, ReactNode } from 'react' import { Button } from '@langgenius/dify-ui/button' import { cn } from '@langgenius/dify-ui/cn' import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover' import { RiArrowRightUpLine, RiBugLine, } from '@remixicon/react' import { useTranslation } from 'react-i18next' import { useDocLink } from '@/context/i18n' import { useDebugKey } from '@/service/use-plugins' import KeyValueItem from '../base/key-value-item' import { PluginSidecarPanel } from './plugin-sidecar-panel' const i18nPrefix = 'debugInfo' type DebugInfoProps = { popupPlacement?: Placement triggerClassName?: string triggerContent?: ReactNode triggerVariant?: ComponentProps['variant'] } function DebugInfo({ popupPlacement = 'bottom', triggerClassName, triggerContent, triggerVariant = 'secondary', }: DebugInfoProps) { const { t } = useTranslation() const docLink = useDocLink() const { data: info, isLoading } = useDebugKey() const trigger = triggerContent ?? const triggerClassNames = cn( !triggerClassName && 'size-full p-2 text-components-button-secondary-text', triggerClassName, ) // info.key likes 4580bdb7-b878-471c-a8a4-bfd760263a53 mask the middle part using *. const maskedKey = info?.key?.replace(/(.{8})(.*)(.{8})/, '$1********$3') if (isLoading) return null if (!info) { return ( ) } return ( {trigger} )} /> )} >
) } export default DebugInfo