'use client' import type { ReactNode } from 'react' import type { DocPathWithoutLang } from '@/types/doc-paths' import { DropdownMenu, DropdownMenuContent, DropdownMenuLinkItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '@langgenius/dify-ui/dropdown-menu' import { IconButton } from '@langgenius/dify-ui/icon-button' import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip' import { Fragment, useState } from 'react' import { useTranslation } from 'react-i18next' import { MARKETPLACE_URL_PREFIX } from '@/config' import { useDocLink } from '@/context/i18n' type DropdownItemProps = { href: string icon: ReactNode text: string } function DropdownItem({ href, icon, text }: DropdownItemProps) { return ( {icon} {text} ) } type OptionLabelKey = | 'requestAPlugin' | 'pluginDevelopmentGuide' | 'pluginPublishGuide' | 'templatePublishingGuide' function getOptions(docLink: (path: DocPathWithoutLang) => string): { href: string icon: ReactNode labelKey: OptionLabelKey }[] { return [ { href: 'https://github.com/langgenius/dify-plugins/issues/new?template=plugin_request.yaml', icon: , labelKey: 'requestAPlugin', }, { href: docLink('/develop-plugin/getting-started/getting-started-dify-plugin'), icon: , labelKey: 'pluginDevelopmentGuide', }, { href: docLink('/develop-plugin/publishing/marketplace-listing/release-overview'), icon: , labelKey: 'pluginPublishGuide', }, { href: MARKETPLACE_URL_PREFIX.replace('marketplace', 'creators'), icon: , labelKey: 'templatePublishingGuide', }, ] } type SubmitRequestDropdownProps = { dividerAfterFirst?: boolean } type SubmitRequestDropdownMenuProps = SubmitRequestDropdownProps & { docLink: (path: DocPathWithoutLang) => string } // Presentational dropdown. Callers that cannot use useDocLink() -- standalone // Marketplace SSR -- pass a locale-composed docLink instead. export function SubmitRequestDropdownMenu({ dividerAfterFirst, docLink, }: SubmitRequestDropdownMenuProps) { const { t } = useTranslation() const [open, setOpen] = useState(false) const options = getOptions(docLink) const guideLabel = t(($) => $['marketplace.home.guide'], { ns: 'plugin' }) return ( } /> } /> {guideLabel} {options.map((option, index) => ( {dividerAfterFirst && index === 1 && } $[option.labelKey], { ns: 'plugin' })} /> ))} ) } export function SubmitRequestDropdown({ dividerAfterFirst }: SubmitRequestDropdownProps) { const docLink = useDocLink() return }