'use client' import type { MenuContentProps } from '@langgenius/dify-ui/menu' import type { MarketplacePluginRef } from '@/features/marketplace/links' import { cn } from '@langgenius/dify-ui/cn' import { IconButton } from '@langgenius/dify-ui/icon-button' import { Menu, MenuContent, MenuItem, MenuLinkItem, MenuSeparator, MenuTrigger, } from '@langgenius/dify-ui/menu' import { useTranslation } from 'react-i18next' import { PluginSource } from '../types' type OperationMenuProps = Readonly< Pick & { source: PluginSource marketplacePlugin?: MarketplacePluginRef repo?: string onInfo: () => void onCheckVersion: () => void onRemove: () => void onViewReadme?: () => void popupClassName?: string triggerSize?: 'm' | 'xs' triggerAriaLabel?: string destructiveRemove?: boolean showCheckVersion?: boolean showRemove?: boolean } > export function OperationMenu({ source, repo, onInfo, onCheckVersion, onRemove, onViewReadme, side, align, popupClassName, triggerSize = 'm', triggerAriaLabel, destructiveRemove = false, showCheckVersion = true, showRemove = true, }: OperationMenuProps) { const { t } = useTranslation(['plugin']) const showInfo = source === PluginSource.github const showCheckVersionAction = showCheckVersion && source === PluginSource.github const detailUrl = source === PluginSource.github && repo ? `https://github.com/${repo}` : undefined const showRemoveAction = showRemove const showSeparator = showRemoveAction && (!!detailUrl || !!onViewReadme) if (!showInfo && !showCheckVersionAction && !detailUrl && !onViewReadme && !showRemoveAction) return null return ( $['detailPanel.operation.moreActions'], { ns: 'plugin' }) } size={triggerSize === 'xs' ? 'xs' : 'md'} className="data-popup-open:bg-state-base-hover" > } /> {showInfo && ( {t(($) => $['detailPanel.operation.info'], { ns: 'plugin' })} )} {showCheckVersionAction && ( {t(($) => $['detailPanel.operation.checkUpdate'], { ns: 'plugin' })} )} {detailUrl && ( {t(($) => $['detailPanel.operation.viewDetail'], { ns: 'plugin' })} )} {onViewReadme && ( {t(($) => $['detailPanel.operation.viewReadme'], { ns: 'plugin' })} )} {showSeparator && } {showRemoveAction && ( {t(($) => $['detailPanel.operation.remove'], { ns: 'plugin' })} )} ) }