'use client' import type { ReactNode } from 'react' import type { DocPathWithoutLang } from '@/types/doc-paths' import { Button } from '@langgenius/dify-ui/button' import { cn } from '@langgenius/dify-ui/cn' import { DropdownMenu, DropdownMenuContent, DropdownMenuLinkItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '@langgenius/dify-ui/dropdown-menu' 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 } export function SubmitRequestDropdown({ dividerAfterFirst, }: SubmitRequestDropdownProps) { const { t } = useTranslation() const [open, setOpen] = useState(false) const docLink = useDocLink() const options = getOptions(docLink) return ( )} /> {options.map((option, index) => ( {dividerAfterFirst && index === 1 && ( )} ))} ) }