feat(dify): 把本地控制台的中文与去外链改动入库
这些界面改动和专家服务草稿停在工作区,没有随上一笔主分支提交进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
9c7c80e194
commit
c2cb845a32
211 files changed
+3030
-2794
No files matched your search
@@ -5,7 +5,6 @@ import * as React from 'react'
|
||||
import { useMemo } from 'react'
|
||||
import { Trans } from 'react-i18next'
|
||||
import { useTranslation } from '#i18n'
|
||||
import Link from '@/next/link'
|
||||
|
||||
type DeprecationNoticeProps = {
|
||||
status: 'deleted' | 'active'
|
||||
@@ -32,7 +31,6 @@ const DeprecationNotice: FC<DeprecationNoticeProps> = ({
|
||||
status,
|
||||
deprecatedReason,
|
||||
alternativePluginId,
|
||||
alternativePluginURL,
|
||||
className,
|
||||
}) => {
|
||||
const { t } = useTranslation(['plugin'])
|
||||
@@ -58,14 +56,7 @@ const DeprecationNotice: FC<DeprecationNoticeProps> = ({
|
||||
i18nKey={($) => $[`${i18nPrefix}.fullMessage`]}
|
||||
ns="plugin"
|
||||
components={{
|
||||
CustomLink: (
|
||||
<Link
|
||||
href={alternativePluginURL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="underline"
|
||||
/>
|
||||
),
|
||||
CustomLink: <span />,
|
||||
}}
|
||||
values={{
|
||||
deprecatedReason: deprecatedReasonKey
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { visibleAuthorName } from '@/utils/visible-author'
|
||||
|
||||
type Props = Readonly<{
|
||||
className?: string
|
||||
@@ -8,15 +9,16 @@ type Props = Readonly<{
|
||||
}>
|
||||
|
||||
const OrgInfo = ({ className, orgName, packageName, packageNameClassName }: Props) => {
|
||||
const label = visibleAuthorName(orgName)
|
||||
return (
|
||||
<div className={cn('flex h-4 min-w-0 items-center gap-0.5', className)}>
|
||||
{orgName && (
|
||||
{label && (
|
||||
<>
|
||||
<span
|
||||
className="min-w-0 shrink truncate system-xs-regular text-text-tertiary"
|
||||
title={orgName}
|
||||
title={label}
|
||||
>
|
||||
{orgName}
|
||||
{label}
|
||||
</span>
|
||||
<span className="shrink-0 system-xs-regular text-text-quaternary">/</span>
|
||||
</>
|
||||
|
||||
@@ -10,6 +10,7 @@ import useTheme from '@/hooks/use-theme'
|
||||
import { renderI18nObject } from '@/i18n/metadata'
|
||||
import { Theme } from '@/types/app'
|
||||
import { formatNumber } from '@/utils/format'
|
||||
import { visibleAuthorName } from '@/utils/visible-author'
|
||||
import Partner from '../base/badges/partner'
|
||||
import Verified from '../base/badges/verified'
|
||||
import Icon from '../card/base/card-icon'
|
||||
@@ -92,6 +93,7 @@ const Card = ({
|
||||
const { t } = useTranslation(['plugin'])
|
||||
const { categoriesMap } = useCategories(true)
|
||||
const { category, type, name, org, label, brief, icon, icon_dark, verified, from } = payload
|
||||
const publicOrg = visibleAuthorName(org)
|
||||
const badges = payload.badges ?? []
|
||||
const { theme } = useTheme()
|
||||
const activeIcon = theme === Theme.dark && icon_dark ? icon_dark : icon
|
||||
@@ -146,15 +148,15 @@ const Card = ({
|
||||
{titleLeft}
|
||||
</div>
|
||||
<div className="flex h-4 min-w-0 items-center gap-2 system-xs-regular text-text-tertiary">
|
||||
{org && (
|
||||
{publicOrg && (
|
||||
<div className="flex min-w-0 items-center gap-1">
|
||||
<span className="shrink-0 lowercase">
|
||||
{t(($) => $['marketplace.by'], { ns: 'plugin' })}
|
||||
</span>
|
||||
<span className="truncate">{org}</span>
|
||||
<span className="truncate">{publicOrg}</span>
|
||||
</div>
|
||||
)}
|
||||
{org && payload.install_count !== undefined && (
|
||||
{publicOrg && payload.install_count !== undefined && (
|
||||
<span className="shrink-0 text-text-quaternary">·</span>
|
||||
)}
|
||||
{payload.install_count !== undefined && (
|
||||
|
||||
+6
-16
@@ -247,17 +247,13 @@ describe('DifyCreatorProfile', () => {
|
||||
expect(new URL(src).searchParams.get('installed')).toBe('false')
|
||||
})
|
||||
it.each(['COMMUNITY', 'ENTERPRISE'] as const)(
|
||||
'links %s creator inventory to official details',
|
||||
'keeps %s creator inventory inside the app',
|
||||
(edition) => {
|
||||
deploymentState.deploymentEdition = edition
|
||||
renderWithNuqs(<DifyCreatorProfile loadedProfile={loadedProfile} locale="en-US" />)
|
||||
for (const name of ['Deep Research', 'Research Template']) {
|
||||
const link = screen.getByRole('link', { name })
|
||||
const url = new URL(link.getAttribute('href')!)
|
||||
expect(url.origin).toBe('https://marketplace.dify.ai')
|
||||
expect(url.searchParams.get('source')).toBe(window.location.origin)
|
||||
expect(link).toHaveAttribute('target', '_blank')
|
||||
expect(link).toHaveAttribute('rel', 'noopener noreferrer')
|
||||
expect(screen.queryByRole('link', { name })).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name })).toBeInTheDocument()
|
||||
}
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
|
||||
},
|
||||
@@ -268,7 +264,7 @@ describe('DifyCreatorProfile', () => {
|
||||
})
|
||||
|
||||
it.each(['COMMUNITY', 'ENTERPRISE'] as const)(
|
||||
'opens %s creator search results externally',
|
||||
'opens %s creator search results in the app',
|
||||
async (edition) => {
|
||||
deploymentState.deploymentEdition = edition
|
||||
const open = vi.spyOn(window, 'open').mockReturnValue(null)
|
||||
@@ -278,14 +274,8 @@ describe('DifyCreatorProfile', () => {
|
||||
)
|
||||
await user.type(searchInput(), 'search')
|
||||
await user.click(await screen.findByRole('option', { name: /Search result/ }))
|
||||
expect(open).toHaveBeenCalledTimes(1)
|
||||
expect(new URL(String(open.mock.calls[0]![0])).pathname).toBe('/plugin/dify/search_result')
|
||||
await user.clear(searchInput())
|
||||
await user.type(searchInput(), 'template')
|
||||
await user.click(await screen.findByRole('option', { name: /Research Template/ }))
|
||||
expect(open).toHaveBeenCalledTimes(2)
|
||||
expect(new URL(String(open.mock.calls[1]![0])).pathname).toBe('/template/dify/template-one')
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
|
||||
expect(open).not.toHaveBeenCalled()
|
||||
expect(await screen.findByRole('dialog')).toBeInTheDocument()
|
||||
expect(onUrlUpdate).not.toHaveBeenCalled()
|
||||
},
|
||||
)
|
||||
|
||||
+9
-4
@@ -5,6 +5,8 @@ import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { useTranslation } from '#i18n'
|
||||
import Partner from '@/app/components/plugins/base/badges/partner'
|
||||
import Verified from '@/app/components/plugins/base/badges/verified'
|
||||
import { isOfficialDifyUrl } from '@/utils/official-link'
|
||||
import { visibleAuthorName } from '@/utils/visible-author'
|
||||
import PublisherAvatar from './publisher-avatar'
|
||||
|
||||
type CreatorSidebarProps = {
|
||||
@@ -29,6 +31,7 @@ function SocialIcon({ platform }: { platform: CreatorSocialPlatform }) {
|
||||
export default function CreatorSidebar({ profile }: CreatorSidebarProps) {
|
||||
const { t } = useTranslation(['plugin'])
|
||||
const isOrganization = profile.kind === 'organization'
|
||||
const displayName = visibleAuthorName(profile.displayName)
|
||||
const isPartner = profile.badges.includes('partner')
|
||||
const isVerified = profile.badges.includes('verified')
|
||||
|
||||
@@ -36,7 +39,7 @@ export default function CreatorSidebar({ profile }: CreatorSidebarProps) {
|
||||
<div className="relative flex min-w-0 flex-col gap-4 pt-11 md:w-[234px] md:pt-12">
|
||||
<PublisherAvatar
|
||||
avatarUrl={profile.avatarUrl}
|
||||
name={profile.displayName}
|
||||
name={displayName}
|
||||
isOrganization={isOrganization}
|
||||
size={100}
|
||||
className={cn(
|
||||
@@ -47,7 +50,9 @@ export default function CreatorSidebar({ profile }: CreatorSidebarProps) {
|
||||
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex flex-wrap items-center gap-1">
|
||||
<h1 className="title-2xl-semi-bold text-text-primary">{profile.displayName}</h1>
|
||||
{displayName ? (
|
||||
<h1 className="title-2xl-semi-bold text-text-primary">{displayName}</h1>
|
||||
) : null}
|
||||
{isOrganization && (
|
||||
<span className="rounded-[5px] border border-divider-deep bg-components-badge-bg-dimm px-1.5 py-0.5 system-2xs-medium text-text-tertiary uppercase">
|
||||
{t(($) => $['marketplace.creatorProfile.organization'], { ns: 'plugin' })}
|
||||
@@ -75,7 +80,7 @@ export default function CreatorSidebar({ profile }: CreatorSidebarProps) {
|
||||
</p>
|
||||
)}
|
||||
|
||||
{profile.email && (
|
||||
{profile.email && !isOfficialDifyUrl(`mailto:${profile.email}`) && (
|
||||
<a
|
||||
href={`mailto:${profile.email}`}
|
||||
className="flex min-w-0 items-center gap-1.5 py-1 system-sm-regular text-text-secondary outline-hidden hover:text-text-accent focus-visible:rounded-sm focus-visible:ring-2 focus-visible:ring-state-accent-solid"
|
||||
@@ -94,7 +99,7 @@ export default function CreatorSidebar({ profile }: CreatorSidebarProps) {
|
||||
<div className="h-px min-w-0 flex-1 bg-gradient-to-r from-divider-regular to-transparent" />
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
{profile.socialLinks.map((link) => (
|
||||
{profile.socialLinks.filter((link) => !isOfficialDifyUrl(link.href)).map((link) => (
|
||||
<a
|
||||
key={link.href}
|
||||
href={link.href}
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useState } from 'react'
|
||||
import { useTranslation } from '#i18n'
|
||||
import Link from '@/next/link'
|
||||
import HomeCatalogTabs from '../home/home-catalog-tabs'
|
||||
import HomeGuide from '../home/home-guide'
|
||||
import { MarketplaceSearchAutocomplete } from '../home/marketplace-search-autocomplete'
|
||||
import { MarketplaceLogo } from '../marketplace-logo'
|
||||
|
||||
@@ -51,12 +50,7 @@ export default function CreatorProfileHeader({
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex min-w-0 flex-1 items-center justify-end gap-2.5">
|
||||
<div className="hidden md:block">
|
||||
<HomeGuide isMarketplacePlatform={false} />
|
||||
</div>
|
||||
{actions}
|
||||
</div>
|
||||
<div className="flex min-w-0 flex-1 items-center justify-end gap-2.5">{actions}</div>
|
||||
</header>
|
||||
)
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
'use client'
|
||||
|
||||
import type { MotionValue } from 'motion/react'
|
||||
import { Separator } from '@langgenius/dify-ui/separator'
|
||||
import { motion, useMotionValue, useSpring, useTransform } from 'motion/react'
|
||||
import { useEffect, useLayoutEffect, useRef } from 'react'
|
||||
import { useLocale, useTranslation } from '#i18n'
|
||||
import { DifyLogo } from '@/app/components/base/logo/dify-logo'
|
||||
import { SubmitRequestMenu } from '@/app/components/plugins/plugin-page/nav-operations'
|
||||
import { MARKETPLACE_CONTAINER_ID } from '../constants'
|
||||
import PluginTypeSwitch from '../plugin-type-switch'
|
||||
import { MarketplaceSearchInput } from '../search-input'
|
||||
@@ -239,10 +237,6 @@ const Description = ({
|
||||
</div>
|
||||
</div>
|
||||
<MarketplaceSearchInput className="w-64 shrink-0" />
|
||||
<div className="flex h-full shrink-0 items-center justify-end gap-4 pr-3.5 pl-4">
|
||||
<Separator decorative orientation="vertical" className="mx-0 h-4" />
|
||||
<SubmitRequestMenu dividerAfterFirst />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vite-plus/test'
|
||||
import { createMarketplacePluginFixture } from '@/test/fixtures/plugin'
|
||||
import MarketplaceLocalDetail from '../local-detail'
|
||||
|
||||
const plugin = createMarketplacePluginFixture()
|
||||
|
||||
describe('MarketplaceLocalDetail', () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
|
||||
it('shows the plugin tools from the marketplace detail payload', async () => {
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn(async () => ({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
plugin: {
|
||||
introduction: '# Perplexity overview',
|
||||
latest_version: '1.0.10',
|
||||
tool: {
|
||||
tools: [
|
||||
{
|
||||
identity: {
|
||||
name: 'perplexity',
|
||||
label: { en_US: 'Perplexity Search' },
|
||||
description: { en_US: 'Search the web' },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
})),
|
||||
)
|
||||
|
||||
render(
|
||||
<MarketplaceLocalDetail
|
||||
open
|
||||
isInstalled={false}
|
||||
plugin={plugin}
|
||||
title="Plugin A · detail"
|
||||
onOpenChange={vi.fn()}
|
||||
/>,
|
||||
)
|
||||
|
||||
expect(screen.getByRole('dialog', { name: /Plugin A/ })).toBeInTheDocument()
|
||||
expect(await screen.findByText('Perplexity Search')).toBeInTheDocument()
|
||||
expect(screen.getByText('Search the web')).toBeInTheDocument()
|
||||
expect(await screen.findByText('Perplexity overview')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
@@ -7,7 +7,9 @@ import { useCallback, useEffect, useRef } from 'react'
|
||||
import { useLocale, useTranslation } from '#i18n'
|
||||
import { useOptionalPluginInstallPermission } from '@/app/components/plugins/install-plugin/hooks/use-plugin-install-permission'
|
||||
import { marketplaceLinks } from '@/features/marketplace/links'
|
||||
import { isOfficialDifyUrl } from '@/utils/official-link'
|
||||
import MarketplaceDetailDialogFrame from './frame'
|
||||
import MarketplaceLocalDetail from './local-detail'
|
||||
import { useSilentMarketplaceInstall } from './use-silent-install'
|
||||
|
||||
const MARKETPLACE_INSTALL_MESSAGE_TYPE = 'dify-marketplace:install-plugin'
|
||||
@@ -137,6 +139,18 @@ function MarketplaceDetailDialog({
|
||||
})
|
||||
const title = `${pluginLabel} · ${detailLabel}`
|
||||
|
||||
if (isOfficialDifyUrl(detailURL)) {
|
||||
return (
|
||||
<MarketplaceLocalDetail
|
||||
open={open}
|
||||
plugin={plugin}
|
||||
title={title}
|
||||
isInstalled={isInstalled}
|
||||
onOpenChange={onOpenChange}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
if (!open) {
|
||||
return (
|
||||
<MarketplaceDetailDialogFrame
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
'use client'
|
||||
|
||||
import type { Plugin } from '@/app/components/plugins/types'
|
||||
import { Button } from '@langgenius/dify-ui/button'
|
||||
import { Dialog, DialogClose, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog'
|
||||
import { IconButton } from '@langgenius/dify-ui/icon-button'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useTranslation } from '#i18n'
|
||||
import { Markdown } from '@/app/components/base/markdown'
|
||||
import { useOptionalPluginInstallPermission } from '@/app/components/plugins/install-plugin/hooks/use-plugin-install-permission'
|
||||
import InstallFromMarketplace from '@/app/components/plugins/install-plugin/install-from-marketplace'
|
||||
import { getPluginIconInMarketplace } from '@/app/components/plugins/marketplace/utils'
|
||||
import { useGetLanguage } from '@/context/i18n'
|
||||
import { getMarketplaceApiUrl } from '@/features/marketplace/api'
|
||||
import { renderI18nObject } from '@/i18n/metadata'
|
||||
|
||||
type ToolIdentity = {
|
||||
name?: string
|
||||
label?: Record<string, string>
|
||||
description?: Record<string, string>
|
||||
}
|
||||
|
||||
type PluginDetailPayload = {
|
||||
introduction?: string
|
||||
latest_version?: string
|
||||
install_count?: number
|
||||
tool?: {
|
||||
tools?: Array<{ identity?: ToolIdentity }>
|
||||
}
|
||||
}
|
||||
|
||||
type MarketplaceLocalDetailProps = {
|
||||
open: boolean
|
||||
plugin: Plugin
|
||||
title: string
|
||||
isInstalled: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
}
|
||||
|
||||
const readPluginDetail = (payload: unknown): PluginDetailPayload | null => {
|
||||
if (!payload || typeof payload !== 'object') return null
|
||||
const data = 'data' in payload ? payload.data : payload
|
||||
if (!data || typeof data !== 'object') return null
|
||||
const plugin = 'plugin' in data ? data.plugin : data
|
||||
if (!plugin || typeof plugin !== 'object') return null
|
||||
return plugin as PluginDetailPayload
|
||||
}
|
||||
|
||||
export default function MarketplaceLocalDetail({
|
||||
open,
|
||||
plugin,
|
||||
title,
|
||||
isInstalled,
|
||||
onOpenChange,
|
||||
}: MarketplaceLocalDetailProps) {
|
||||
const { t } = useTranslation(['common', 'plugin', 'tools'])
|
||||
const locale = useGetLanguage()
|
||||
const { canInstallPlugin } = useOptionalPluginInstallPermission()
|
||||
const [detail, setDetail] = useState<PluginDetailPayload | null>(null)
|
||||
const [failed, setFailed] = useState(false)
|
||||
const [showInstall, setShowInstall] = useState(false)
|
||||
const label = renderI18nObject(plugin.label, locale) || plugin.name
|
||||
const brief = renderI18nObject(plugin.brief, locale)
|
||||
const introduction = detail?.introduction?.trim() || ''
|
||||
const tools = (detail?.tool?.tools ?? [])
|
||||
.map((tool) => {
|
||||
const identity = tool.identity
|
||||
const name = renderI18nObject(identity?.label, locale) || identity?.name || ''
|
||||
const description = renderI18nObject(identity?.description, locale)
|
||||
return name ? { name, description } : null
|
||||
})
|
||||
.filter((tool): tool is { name: string; description: string } => tool !== null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
|
||||
const controller = new AbortController()
|
||||
const url = getMarketplaceApiUrl(
|
||||
`plugins/${encodeURIComponent(plugin.org)}/${encodeURIComponent(plugin.name)}`,
|
||||
)
|
||||
setDetail(null)
|
||||
setFailed(false)
|
||||
|
||||
void fetch(url, { signal: controller.signal })
|
||||
.then(async (response) => {
|
||||
if (!response.ok) throw new Error('plugin detail unavailable')
|
||||
return readPluginDetail(await response.json())
|
||||
})
|
||||
.then((next) => {
|
||||
if (!next) throw new Error('plugin detail unavailable')
|
||||
setDetail(next)
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
if (error instanceof DOMException && error.name === 'AbortError') return
|
||||
setFailed(true)
|
||||
})
|
||||
|
||||
return () => controller.abort()
|
||||
}, [open, plugin.name, plugin.org])
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="flex max-h-[min(800px,calc(100dvh-48px))] w-[min(760px,calc(100vw-48px))] flex-col overflow-hidden">
|
||||
<div className="flex items-start gap-3 px-6 pt-5 pe-14">
|
||||
<img
|
||||
src={getPluginIconInMarketplace(plugin)}
|
||||
alt=""
|
||||
className="size-12 shrink-0 rounded-xl border border-divider-subtle bg-background-default-subtle object-cover"
|
||||
/>
|
||||
<div className="min-w-0">
|
||||
<DialogTitle className="system-md-semibold text-text-primary">{label}</DialogTitle>
|
||||
<p className="mt-1 system-xs-regular text-text-tertiary">
|
||||
{plugin.org} / {plugin.name}
|
||||
{detail?.latest_version ? ` · ${detail.latest_version}` : ''}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<DialogClose
|
||||
render={
|
||||
<IconButton
|
||||
aria-label={t(($) => $['operation.close'], { ns: 'common' })}
|
||||
size="lg"
|
||||
className="absolute top-5 right-5"
|
||||
onClick={() => onOpenChange(false)}
|
||||
>
|
||||
<span aria-hidden className="i-ri-close-line size-4" />
|
||||
</IconButton>
|
||||
}
|
||||
/>
|
||||
<div className="min-h-0 flex-1 overflow-y-auto px-6 py-5">
|
||||
{brief && <p className="mb-4 system-sm-regular text-text-secondary">{brief}</p>}
|
||||
{tools.length > 0 && (
|
||||
<section className="mb-5">
|
||||
<h3 className="mb-2 system-xs-medium text-text-tertiary">
|
||||
{t(($) => $['mcp.toolsNum'], { ns: 'tools', count: tools.length })}
|
||||
</h3>
|
||||
<ul className="flex flex-col gap-2">
|
||||
{tools.map((tool) => (
|
||||
<li
|
||||
key={tool.name}
|
||||
className="rounded-xl border border-divider-subtle bg-background-section-burn px-3 py-2"
|
||||
>
|
||||
<p className="system-sm-medium text-text-primary">{tool.name}</p>
|
||||
{tool.description && (
|
||||
<p className="mt-0.5 system-xs-regular text-text-tertiary">
|
||||
{tool.description}
|
||||
</p>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
{introduction ? (
|
||||
<Markdown content={introduction} />
|
||||
) : (
|
||||
failed && (
|
||||
<p className="system-sm-regular text-text-tertiary">
|
||||
{t(($) => $['readmeInfo.failedToFetch'], { ns: 'plugin' })}
|
||||
</p>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
{canInstallPlugin && !isInstalled && (
|
||||
<div className="flex justify-end border-t border-divider-subtle px-6 py-4">
|
||||
<Button onClick={() => setShowInstall(true)}>
|
||||
{t(($) => $['detailPanel.operation.install'], { ns: 'plugin' })}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<span className="sr-only">{title}</span>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
{showInstall && (
|
||||
<InstallFromMarketplace
|
||||
manifest={plugin}
|
||||
uniqueIdentifier={plugin.latest_package_identifier}
|
||||
onClose={() => setShowInstall(false)}
|
||||
onSuccess={() => {
|
||||
setShowInstall(false)
|
||||
onOpenChange(false)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
+2
-12
@@ -208,19 +208,9 @@ describe('EmbeddedMarketplaceSearch', () => {
|
||||
const option = await screen.findByRole('option')
|
||||
if (interaction === 'mouse') await user.click(option)
|
||||
else await user.keyboard('{ArrowDown}{Enter}')
|
||||
expect(open).toHaveBeenCalledTimes(1)
|
||||
const [href, target, features] = open.mock.calls[0]!
|
||||
const url = new URL(String(href))
|
||||
expect(url.origin).toBe('https://marketplace.dify.ai')
|
||||
expect(url.pathname).toBe(
|
||||
kind === 'plugin' ? '/plugin/langgenius/google-search' : '/template/dify/template-1',
|
||||
)
|
||||
expect(url.searchParams.get('source')).toBe(window.location.origin)
|
||||
expect(target).toBe('_blank')
|
||||
expect(features).toBe('noopener,noreferrer')
|
||||
expect(input).toHaveValue('search')
|
||||
expect(open).not.toHaveBeenCalled()
|
||||
expect(onUrlUpdate).not.toHaveBeenCalled()
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
|
||||
expect(await screen.findByRole('dialog')).toBeInTheDocument()
|
||||
},
|
||||
)
|
||||
})
|
||||
+5
-29
@@ -47,37 +47,13 @@ describe('HomeHeader', () => {
|
||||
mocks.marketplaceUrlPrefix = 'https://marketplace.dify.ai'
|
||||
})
|
||||
|
||||
it('keeps Creator Center and docs in the in-app header', () => {
|
||||
it('does not link the header to Creator Center or the official guide', () => {
|
||||
render(<HomeHeader isMarketplacePlatform={false} />)
|
||||
|
||||
expect(screen.getByRole('link', { name: 'marketplace.home.creatorCenter' })).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: /marketplace\.home\.guide/ })).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('links Creator Center alongside the docs dropdown', () => {
|
||||
render(<HomeHeader isMarketplacePlatform />)
|
||||
|
||||
const creatorCenterLink = screen.getByRole('link', { name: 'marketplace.home.creatorCenter' })
|
||||
expect(screen.getByRole('button', { name: /marketplace\.home\.guide/ })).toBeInTheDocument()
|
||||
|
||||
expect(creatorCenterLink).toHaveAttribute('href', 'https://creators.dify.ai/')
|
||||
expect(creatorCenterLink).toHaveAttribute('target', '_blank')
|
||||
expect(creatorCenterLink).toHaveAttribute('rel', 'noopener noreferrer')
|
||||
|
||||
// Creator Center must be a single interactive element, not a link-wrapped button.
|
||||
expect(creatorCenterLink.querySelector('button')).toBeNull()
|
||||
expect(screen.queryByRole('link', { name: 'marketplace.home.guide' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('links Creator Center to the staging Creators site in staging', () => {
|
||||
mocks.marketplaceUrlPrefix = 'https://marketplace-staging.dify.dev'
|
||||
|
||||
render(<HomeHeader isMarketplacePlatform />)
|
||||
|
||||
expect(screen.getByRole('link', { name: 'marketplace.home.creatorCenter' })).toHaveAttribute(
|
||||
'href',
|
||||
'https://creators-staging.dify.dev/',
|
||||
)
|
||||
expect(
|
||||
screen.queryByRole('link', { name: 'marketplace.home.creatorCenter' }),
|
||||
).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: /marketplace\.home\.guide/ })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('selects neither catalog tab on non-catalog pages', () => {
|
||||
|
||||
+21
-54
@@ -220,21 +220,14 @@ describe('HomeTrending', () => {
|
||||
|
||||
expect(screen.getByRole('heading', { name: 'Dify v1.9 new launch' })).toBeInTheDocument()
|
||||
const blogSlide = screen.getByRole('group', { name: 'Dify Updates' })
|
||||
const blogLink = within(blogSlide).getByRole('link', {
|
||||
name: /^plugin\.marketplace\.home\.trendingReadMoreAbout/,
|
||||
})
|
||||
expect(blogLink).toHaveAttribute('href', 'https://dify.ai/blog')
|
||||
expect(within(blogSlide).getAllByRole('link')).toHaveLength(1)
|
||||
expect(within(blogSlide).queryByRole('link')).not.toBeInTheDocument()
|
||||
expect(
|
||||
within(blogLink).getByRole('heading', { name: 'Dify v1.9 new launch' }),
|
||||
within(blogSlide).getByRole('heading', { name: 'Dify v1.9 new launch' }),
|
||||
).toBeInTheDocument()
|
||||
|
||||
await user.click(screen.getByRole('button', { name: 'Duck Duck Go' }))
|
||||
|
||||
expect(screen.getByRole('link', { name: 'DuckDuckGo plugin' })).toHaveAttribute(
|
||||
'href',
|
||||
'https://marketplace.dify.ai/plugin/langgenius/duckduckgo',
|
||||
)
|
||||
expect(screen.queryByRole('link', { name: 'DuckDuckGo plugin' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders the delivered blog cover instead of bundled art', () => {
|
||||
@@ -255,10 +248,8 @@ describe('HomeTrending', () => {
|
||||
|
||||
render(<HomeTrending banners={[blogBanner]} isMarketplacePlatform page="plugins" />)
|
||||
|
||||
const blogLink = screen.getByRole('link', {
|
||||
name: /^plugin\.marketplace\.home\.trendingReadMoreAbout/,
|
||||
})
|
||||
expect(blogLink.querySelector('img')?.getAttribute('src')).toContain(
|
||||
const blogSlide = screen.getByRole('group', { name: 'Research' })
|
||||
expect(blogSlide.querySelector('img')?.getAttribute('src')).toContain(
|
||||
'/api/v1/banners/images/banners/trust-cover.png',
|
||||
)
|
||||
})
|
||||
@@ -266,10 +257,8 @@ describe('HomeTrending', () => {
|
||||
it('omits blog cover art when the payload has no cover_image', () => {
|
||||
render(<HomeTrending banners={[banners[1]!]} isMarketplacePlatform page="plugins" />)
|
||||
|
||||
const blogLink = screen.getByRole('link', {
|
||||
name: /^plugin\.marketplace\.home\.trendingReadMoreAbout/,
|
||||
})
|
||||
expect(blogLink.querySelector('img')).toBeNull()
|
||||
const blogSlide = screen.getByRole('group', { name: 'Dify Updates' })
|
||||
expect(blogSlide.querySelector('img')).toBeNull()
|
||||
})
|
||||
|
||||
it('keeps only the selected slide in the accessibility tree', async () => {
|
||||
@@ -999,34 +988,22 @@ describe('HomeTrending', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('tracks whole-slide blog and event links as frame clicks', async () => {
|
||||
it('does not link official blog and event banners', async () => {
|
||||
const user = userEvent.setup()
|
||||
|
||||
render(<HomeTrending banners={banners} isMarketplacePlatform page="plugins" />)
|
||||
|
||||
await user.click(screen.getByRole('button', { name: 'Dify Updates' }))
|
||||
await user.click(
|
||||
screen.getByRole('link', { name: /^plugin\.marketplace\.home\.trendingReadMoreAbout/ }),
|
||||
)
|
||||
|
||||
expect(mockTrackEvent).toHaveBeenCalledWith('marketplace_banner_click', {
|
||||
banner_id: 'blog',
|
||||
sort: 1,
|
||||
page: 'plugins',
|
||||
language: 'en',
|
||||
style_type: 'blog',
|
||||
})
|
||||
expect(
|
||||
screen.queryByRole('link', { name: /^plugin\.marketplace\.home\.trendingReadMoreAbout/ }),
|
||||
).not.toBeInTheDocument()
|
||||
|
||||
await user.click(screen.getByRole('button', { name: 'Duck Duck Go' }))
|
||||
await user.click(screen.getByRole('link', { name: 'DuckDuckGo plugin' }))
|
||||
|
||||
expect(mockTrackEvent).toHaveBeenCalledWith('marketplace_banner_click', {
|
||||
banner_id: 'event',
|
||||
sort: 2,
|
||||
page: 'plugins',
|
||||
language: 'en',
|
||||
style_type: 'event',
|
||||
})
|
||||
expect(screen.queryByRole('link', { name: 'DuckDuckGo plugin' })).not.toBeInTheDocument()
|
||||
expect(mockTrackEvent).not.toHaveBeenCalledWith(
|
||||
'marketplace_banner_click',
|
||||
expect.objectContaining({ style_type: 'blog' }),
|
||||
)
|
||||
})
|
||||
|
||||
it('does not render banner slides whose CMS link is not http(s) or relative', () => {
|
||||
@@ -1083,7 +1060,7 @@ describe('HomeTrending', () => {
|
||||
}
|
||||
})
|
||||
it.each(['COMMUNITY', 'ENTERPRISE'] as const)(
|
||||
'links %s recommendations directly to the official site',
|
||||
'keeps %s recommendations inside the app',
|
||||
(edition) => {
|
||||
const mixedBanner: PluginBanner = {
|
||||
id: 'mixed',
|
||||
@@ -1116,20 +1093,10 @@ describe('HomeTrending', () => {
|
||||
<HomeTrending banners={[mixedBanner]} isMarketplacePlatform={false} page="plugins" />,
|
||||
{ systemFeatures: { deployment_edition: edition } },
|
||||
)
|
||||
const links = [
|
||||
screen.getByRole('link', { name: 'Dropbox' }),
|
||||
screen.getByRole('link', { name: 'Support Bot' }),
|
||||
]
|
||||
expect(new URL(links[0]!.getAttribute('href')!).pathname).toBe('/plugin/langgenius/dropbox')
|
||||
expect(new URL(links[1]!.getAttribute('href')!).pathname).toBe('/template/aisa-team/tpl-1')
|
||||
for (const link of links)
|
||||
expect(new URL(link.getAttribute('href')!).origin).toBe('https://marketplace.dify.ai')
|
||||
for (const link of links) {
|
||||
expect(link).toHaveAttribute('target', '_blank')
|
||||
expect(new URL(link.getAttribute('href')!).searchParams.get('source')).toBe(
|
||||
window.location.origin,
|
||||
)
|
||||
}
|
||||
expect(screen.getByRole('button', { name: 'Dropbox' })).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: 'Support Bot' })).toBeInTheDocument()
|
||||
expect(screen.queryByRole('link', { name: 'Dropbox' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('link', { name: 'Support Bot' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
|
||||
},
|
||||
)
|
||||
|
||||
@@ -5,12 +5,14 @@ import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { useTranslation } from '#i18n'
|
||||
import Link from '@/next/link'
|
||||
import { trackMarketplaceSiteEvent } from '@/utils/marketplace-site-track'
|
||||
import { isOfficialDifyUrl } from '@/utils/official-link'
|
||||
import { useCreatorCenterUrl } from '../creator-center-url'
|
||||
|
||||
export default function HomeCreatorCenter() {
|
||||
const { t } = useTranslation(['plugin'])
|
||||
const creatorCenterUrl = useCreatorCenterUrl()
|
||||
const label = t(($) => $['marketplace.home.creatorCenter'])
|
||||
if (!creatorCenterUrl || isOfficialDifyUrl(creatorCenterUrl)) return null
|
||||
|
||||
return (
|
||||
<Link
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
import type { HomeCatalogTab, HomeCatalogTabLabels } from './home-catalog-tabs'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import Link from '@/next/link'
|
||||
import { MarketplaceLogo } from '../marketplace-logo'
|
||||
import HomeCatalogTabs from './home-catalog-tabs'
|
||||
import { HOME_HEADER_HEIGHT_PX } from './home-constants'
|
||||
// HomeCreatorCenter stays in its own client module: it derives styles via
|
||||
// buttonVariants(), which cannot be invoked inside this server component.
|
||||
import HomeCreatorCenter from './home-creator-center'
|
||||
import HomeGuide from './home-guide'
|
||||
import { HomeStickyCatalogTabs } from './home-sticky-state-provider'
|
||||
import styles from './home-sticky.module.css'
|
||||
|
||||
@@ -53,15 +48,6 @@ const HomeHeader = ({
|
||||
</div>
|
||||
|
||||
<div className="flex h-full min-w-0 flex-1 items-center justify-end gap-2.5">
|
||||
<div
|
||||
className={cn(
|
||||
'flex min-w-0 items-center gap-2.5',
|
||||
isMarketplacePlatform && styles.standaloneHeaderActions,
|
||||
)}
|
||||
>
|
||||
<HomeCreatorCenter />
|
||||
<HomeGuide isMarketplacePlatform={isMarketplacePlatform} />
|
||||
</div>
|
||||
{actions}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
+47
-20
@@ -12,7 +12,7 @@ import type {
|
||||
import type { MarketplaceBannerPage } from './banners'
|
||||
import type { Plugin } from '@/app/components/plugins/types'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { useState } from 'react'
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { useTranslation } from '#i18n'
|
||||
import { trackEvent } from '@/app/components/base/amplitude'
|
||||
import Partner from '@/app/components/plugins/base/badges/partner'
|
||||
@@ -29,6 +29,8 @@ import Link from '@/next/link'
|
||||
import { useRouter } from '@/next/navigation'
|
||||
import { fetchPluginInfoFromMarketPlace } from '@/service/plugins'
|
||||
import { resolveEmoji } from '@/utils/emoji'
|
||||
import { isOfficialDifyUrl } from '@/utils/official-link'
|
||||
import { visibleAuthorName } from '@/utils/visible-author'
|
||||
import {
|
||||
rememberMarketplaceSiteReferrer,
|
||||
trackMarketplaceSiteEvent,
|
||||
@@ -151,7 +153,7 @@ const getLocalCardHref = (card: BannerRecommendCard) => {
|
||||
const getCardHref = (card: BannerRecommendCard, isMarketplacePlatform: boolean) => {
|
||||
if (isMarketplacePlatform) return getLocalCardHref(card)
|
||||
const deliveryHref = card.link ? sanitizeMarketplaceHref(card.link) : null
|
||||
if (deliveryHref) return deliveryHref
|
||||
if (deliveryHref && !isOfficialDifyUrl(deliveryHref)) return deliveryHref
|
||||
|
||||
return getLocalCardHref(card)
|
||||
}
|
||||
@@ -255,7 +257,7 @@ function trackRecommendCardClick(
|
||||
function RecommendCardFace({ card }: { card: BannerRecommendCard }) {
|
||||
const { t } = useTranslation(['plugin'])
|
||||
const iconURL = resolveMarketplaceAssetUrl(card.icon_url)
|
||||
const creator = getCardCreator(card)
|
||||
const creator = visibleAuthorName(getCardCreator(card))
|
||||
const isPartner = card.badges?.includes('partner')
|
||||
const isVerified = card.badges?.includes('verified')
|
||||
|
||||
@@ -581,6 +583,36 @@ function TrendingRecommendationSlide({
|
||||
)
|
||||
}
|
||||
|
||||
function SlideFrame({
|
||||
href,
|
||||
className,
|
||||
label,
|
||||
onClick,
|
||||
children,
|
||||
}: {
|
||||
href: string | null
|
||||
className: string
|
||||
label: string
|
||||
onClick: () => void
|
||||
children: ReactNode
|
||||
}) {
|
||||
if (!href) return <div className={className}>{children}</div>
|
||||
|
||||
const opensInNewTab = /^https?:\/\//.test(href)
|
||||
return (
|
||||
<Link
|
||||
href={href}
|
||||
target={opensInNewTab ? '_blank' : undefined}
|
||||
rel={opensInNewTab ? 'noopener noreferrer' : undefined}
|
||||
aria-label={label}
|
||||
className={className}
|
||||
onClick={onClick}
|
||||
>
|
||||
{children}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
function BlogBannerSlide({
|
||||
banner,
|
||||
isMarketplacePlatform,
|
||||
@@ -591,21 +623,18 @@ function BlogBannerSlide({
|
||||
page: MarketplaceBannerPage
|
||||
}) {
|
||||
const { t } = useTranslation(['plugin'])
|
||||
const href = sanitizeMarketplaceHref(banner.content.link)
|
||||
if (!href) return null
|
||||
const opensInNewTab = /^https?:\/\//.test(href)
|
||||
const sanitized = sanitizeMarketplaceHref(banner.content.link)
|
||||
if (!sanitized || isOfficialDifyUrl(sanitized)) return null
|
||||
const coverSrc = resolveMarketplaceAssetUrl(banner.content.cover_image)
|
||||
|
||||
return (
|
||||
<Link
|
||||
href={href}
|
||||
target={opensInNewTab ? '_blank' : undefined}
|
||||
rel={opensInNewTab ? 'noopener noreferrer' : undefined}
|
||||
<SlideFrame
|
||||
href={sanitized}
|
||||
onClick={() => {
|
||||
trackEvent('marketplace_banner_click', getBannerFrameProps(banner, page))
|
||||
trackMarketplaceBannerClick(banner)
|
||||
}}
|
||||
aria-label={t(($) => $['marketplace.home.trendingReadMoreAbout'], {
|
||||
label={t(($) => $['marketplace.home.trendingReadMoreAbout'], {
|
||||
title: banner.content.blog_title,
|
||||
})}
|
||||
className={cn(
|
||||
@@ -693,7 +722,7 @@ function BlogBannerSlide({
|
||||
)}
|
||||
/>
|
||||
) : null}
|
||||
</Link>
|
||||
</SlideFrame>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -706,8 +735,8 @@ function ImageBannerSlide({
|
||||
isMarketplacePlatform: boolean
|
||||
page: MarketplaceBannerPage
|
||||
}) {
|
||||
const href = sanitizeMarketplaceHref(banner.content.link)
|
||||
if (!href) return null
|
||||
const sanitized = sanitizeMarketplaceHref(banner.content.link)
|
||||
if (!sanitized || isOfficialDifyUrl(sanitized)) return null
|
||||
const resolved = resolveEventAdBannerImageSrcs({
|
||||
desktop: resolveMarketplaceAssetUrl(banner.content.images.desktop),
|
||||
tablet: resolveMarketplaceAssetUrl(banner.content.images.tablet) || undefined,
|
||||
@@ -715,15 +744,13 @@ function ImageBannerSlide({
|
||||
})
|
||||
|
||||
return (
|
||||
<Link
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
<SlideFrame
|
||||
href={sanitized}
|
||||
onClick={() => {
|
||||
trackEvent('marketplace_banner_click', getBannerFrameProps(banner, page))
|
||||
trackMarketplaceBannerClick(banner)
|
||||
}}
|
||||
aria-label={banner.content.alt_text || banner.title}
|
||||
label={banner.content.alt_text || banner.title}
|
||||
className={cn(
|
||||
'block h-[200px] w-full overflow-hidden rounded-2xl outline-hidden focus-visible:ring-2 focus-visible:ring-state-accent-solid',
|
||||
isMarketplacePlatform && styles.imageSlide,
|
||||
@@ -751,7 +778,7 @@ function ImageBannerSlide({
|
||||
className="size-full object-cover object-left"
|
||||
/>
|
||||
</picture>
|
||||
</Link>
|
||||
</SlideFrame>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -31,6 +31,7 @@ import { getPluginDetailPath, getTemplateDetailPath } from '@/features/marketpla
|
||||
import { renderI18nObject } from '@/i18n/metadata'
|
||||
import { marketplaceQuery } from '@/service/marketplace'
|
||||
import { markMarketplaceSiteSearch } from '@/utils/marketplace-site-track'
|
||||
import { visibleAuthorName } from '@/utils/visible-author'
|
||||
import { getPluginIconInMarketplace } from '../utils'
|
||||
|
||||
type MarketplaceSearchScope = 'all' | 'plugins' | 'templates'
|
||||
@@ -80,7 +81,7 @@ const toTemplateSuggestion = (template: MarketplaceTemplate): MarketplaceSuggest
|
||||
id: `template:${template.id}`,
|
||||
kind: 'template',
|
||||
label: template.template_name,
|
||||
meta: template.publisher_handle || template.publisher_unique_handle || '',
|
||||
meta: visibleAuthorName(template.publisher_handle || template.publisher_unique_handle),
|
||||
selection: { kind: 'template', template },
|
||||
})
|
||||
|
||||
@@ -90,7 +91,7 @@ const toPluginSuggestion = (plugin: MarketplacePlugin, locale: string): Marketpl
|
||||
id: `plugin:${plugin.org}/${plugin.name}`,
|
||||
kind: 'plugin',
|
||||
label: getPluginText(plugin.label, locale) || plugin.name,
|
||||
meta: plugin.org,
|
||||
meta: visibleAuthorName(plugin.org),
|
||||
selection: { kind: 'plugin', plugin },
|
||||
})
|
||||
|
||||
|
||||
+4
-15
@@ -154,24 +154,13 @@ describe('CardWrapper', () => {
|
||||
})
|
||||
|
||||
it.each(['COMMUNITY', 'ENTERPRISE'] as const)(
|
||||
'links %s plugin details to the official site while preserving direct installation',
|
||||
'opens %s plugin details in the app while preserving direct installation',
|
||||
async (edition) => {
|
||||
const user = userEvent.setup()
|
||||
renderCardWrapper({ showInstallButton: true }, edition)
|
||||
const card = screen.getByRole('link', { name: 'Plugin A' })
|
||||
const url = new URL(card.getAttribute('href')!)
|
||||
expect(url.origin).toBe('https://marketplace.dify.ai')
|
||||
expect(url.pathname).toBe('/plugin/dify/plugin-a')
|
||||
expect(url.searchParams.get('source')).toBe(window.location.origin)
|
||||
expect(url.searchParams.get('theme')).toBe('dark')
|
||||
expect(card).toHaveAttribute('target', '_blank')
|
||||
expect(card).toHaveAttribute('rel', 'noopener noreferrer')
|
||||
expect(
|
||||
screen.getByRole('link', { name: 'plugin.detailPanel.operation.detail' }),
|
||||
).toHaveAttribute('href', url.toString())
|
||||
expect(screen.queryByTitle(detailTitle)).not.toBeInTheDocument()
|
||||
await user.click(screen.getByRole('button', { name: 'plugin.detailPanel.operation.install' }))
|
||||
expect(await screen.findByRole('dialog', { name: installTitle })).toBeInTheDocument()
|
||||
expect(screen.queryByRole('link', { name: 'Plugin A' })).not.toBeInTheDocument()
|
||||
await user.click(screen.getByRole('button', { name: 'Plugin A' }))
|
||||
expect(await screen.findByRole('dialog', { name: detailTitle })).toBeInTheDocument()
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
+3
-8
@@ -168,14 +168,9 @@ describe('ListWithCollection', () => {
|
||||
/>,
|
||||
)
|
||||
|
||||
const partnerLink = screen.getByRole('link', { name: 'plugin.marketplace.becomePartner' })
|
||||
|
||||
expect(partnerLink).toHaveAttribute(
|
||||
'href',
|
||||
'https://share-na2.hsforms.com/1NiS4r9lsSqGcuNBB77DeEQ40s9fk',
|
||||
)
|
||||
expect(partnerLink).toHaveAttribute('target', '_blank')
|
||||
expect(partnerLink).toHaveAttribute('rel', 'noopener noreferrer')
|
||||
expect(
|
||||
screen.queryByRole('link', { name: 'plugin.marketplace.becomePartner' }),
|
||||
).not.toBeInTheDocument()
|
||||
expect(
|
||||
screen.getAllByText(/^(?:Plugin (?:One|Two)|Partner Plugin|Featured Plugin)$/),
|
||||
).toHaveLength(2)
|
||||
|
||||
@@ -12,6 +12,7 @@ import { useOptionalPluginInstallPermission } from '@/app/components/plugins/ins
|
||||
import InstallFromMarketplace from '@/app/components/plugins/install-plugin/install-from-marketplace'
|
||||
import { useGetLanguage } from '@/context/i18n'
|
||||
import { getPluginDetailPath } from '@/features/marketplace/links'
|
||||
import { isOfficialDifyUrl } from '@/utils/official-link'
|
||||
import { renderI18nObject } from '@/i18n/metadata'
|
||||
import Link from '@/next/link'
|
||||
import { trackMarketplaceSiteCardClick } from '@/utils/marketplace-site-track'
|
||||
@@ -31,8 +32,8 @@ const CardWrapperContent = ({
|
||||
isInstalled = false,
|
||||
linkToMarketplaceDetail = false,
|
||||
section = 'list',
|
||||
externalDetailHref,
|
||||
}: CardWrapperProps & { externalDetailHref?: string }) => {
|
||||
detailHref: externalDetailHref,
|
||||
}: CardWrapperProps & { detailHref?: string }) => {
|
||||
const { t } = useTranslation(['plugin'])
|
||||
const locale = useGetLanguage()
|
||||
const [
|
||||
@@ -46,6 +47,8 @@ const CardWrapperContent = ({
|
||||
const { canInstallPlugin } = useOptionalPluginInstallPermission()
|
||||
const { getTagLabel } = useTags()
|
||||
const pluginLabel = renderI18nObject(plugin.label, locale) || plugin.name
|
||||
const detailHref =
|
||||
externalDetailHref && !isOfficialDifyUrl(externalDetailHref) ? externalDetailHref : undefined
|
||||
|
||||
// Memoize tag labels to prevent recreating array on every render
|
||||
const tagLabels = useMemo(
|
||||
@@ -96,9 +99,9 @@ const CardWrapperContent = ({
|
||||
className="group relative cursor-pointer rounded-xl"
|
||||
data-marketplace-card={plugin.plugin_id}
|
||||
>
|
||||
{externalDetailHref ? (
|
||||
{detailHref ? (
|
||||
<a
|
||||
href={externalDetailHref}
|
||||
href={detailHref}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
aria-label={pluginLabel}
|
||||
@@ -128,9 +131,9 @@ const CardWrapperContent = ({
|
||||
? t(($) => $['task.installed'], { ns: 'plugin' })
|
||||
: t(($) => $['detailPanel.operation.install'], { ns: 'plugin' })}
|
||||
</Button>
|
||||
{externalDetailHref ? (
|
||||
{detailHref ? (
|
||||
<a
|
||||
href={externalDetailHref}
|
||||
href={detailHref}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={buttonVariants({
|
||||
@@ -152,7 +155,7 @@ const CardWrapperContent = ({
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{!externalDetailHref && (
|
||||
{!detailHref && (
|
||||
<MarketplaceDetailDialog
|
||||
isInstalled={isInstalled}
|
||||
open={isShowMarketplaceDetail}
|
||||
@@ -174,7 +177,7 @@ const CardWrapperContent = ({
|
||||
|
||||
function DifyCardWrapper(props: CardWrapperProps) {
|
||||
const navigation = useMarketplaceDetailNavigation()
|
||||
return <CardWrapperContent {...props} externalDetailHref={navigation.pluginHref(props.plugin)} />
|
||||
return <CardWrapperContent {...props} detailHref={navigation.pluginHref(props.plugin)} />
|
||||
}
|
||||
|
||||
function CardWrapperComponent(props: CardWrapperProps) {
|
||||
|
||||
+1
-32
@@ -6,13 +6,12 @@ import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { useEffect, useId, useMemo, useRef, useState } from 'react'
|
||||
import { useLocale, useTranslation } from '#i18n'
|
||||
import { getPluginLanguage } from '@/i18n/metadata'
|
||||
import { trackMarketplaceSiteEvent } from '@/utils/marketplace-site-track'
|
||||
import { useMarketplaceMoreClick } from '../atoms'
|
||||
import { MARKETPLACE_CONTAINER_ID } from '../constants'
|
||||
import { buildCarouselPages } from '../utils'
|
||||
import CardWrapper from './card-wrapper'
|
||||
import Carousel from './carousel'
|
||||
import { BECOME_PARTNER_URL, GRID_CLASS, PARTNER_COLLECTION_NAMES } from './collection-constants'
|
||||
import { GRID_CLASS, PARTNER_COLLECTION_NAMES } from './collection-constants'
|
||||
import styles from './partner-header.module.css'
|
||||
import { useCarouselItemsPerPage } from './use-carousel-items-per-page'
|
||||
|
||||
@@ -211,36 +210,6 @@ const CollectionSection = ({
|
||||
) : (
|
||||
collection.description[getPluginLanguage(locale)]
|
||||
)}
|
||||
{isPartnersCollection && (
|
||||
<>
|
||||
<span className={cn(styles.partnerSeparator, 'text-divider-regular')}>|</span>
|
||||
<a
|
||||
href={BECOME_PARTNER_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={cn(
|
||||
styles.partnerAction,
|
||||
'flex items-center gap-x-0.5 text-text-accent hover:underline',
|
||||
)}
|
||||
onClick={() => {
|
||||
trackMarketplaceSiteEvent('marketplace_creator_partner_click', {
|
||||
click_target: 'Become a Partner',
|
||||
})
|
||||
}}
|
||||
>
|
||||
<span className={styles.partnerActionLabel}>
|
||||
{t(($) => $['marketplace.becomePartner'], { ns: 'plugin' })}
|
||||
</span>
|
||||
<span
|
||||
aria-hidden
|
||||
className={cn(
|
||||
styles.partnerActionIcon,
|
||||
'i-ri-external-link-line size-3 [&:dir(rtl)]:-scale-x-100',
|
||||
)}
|
||||
/>
|
||||
</a>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{collection.searchable && !hasMultiplePages && (
|
||||
|
||||
+9
-21
@@ -132,7 +132,7 @@ describe('TemplateCard', () => {
|
||||
}),
|
||||
)
|
||||
expect(mockPush).toHaveBeenCalledWith('/apps?template-id=template%2Fone')
|
||||
expect(screen.getByText('dify')).toBeInTheDocument()
|
||||
expect(screen.queryByText('dify')).not.toBeInTheDocument()
|
||||
expect(screen.getByText('1.2k')).toBeInTheDocument()
|
||||
expect(screen.getByText('Verified by a Dify partner')).toBeInTheDocument()
|
||||
})
|
||||
@@ -156,32 +156,20 @@ describe('TemplateCard', () => {
|
||||
expect(screen.getByRole('dialog')).toBeInTheDocument()
|
||||
})
|
||||
it.each(['COMMUNITY', 'ENTERPRISE'] as const)(
|
||||
'opens %s template links outside Dify without changing the catalog route',
|
||||
(edition) => {
|
||||
'opens %s template details in the app',
|
||||
async (edition) => {
|
||||
const user = userEvent.setup()
|
||||
deploymentState.deploymentEdition = edition
|
||||
;(window as unknown as Window).happyDOM.setURL(
|
||||
'https://ai.njueai.com:8443/templates?q=research',
|
||||
)
|
||||
const before = window.location.href
|
||||
render(
|
||||
<TemplateDetailRouteProvider>
|
||||
<TemplateCard partnerText="Partner" template={template} />
|
||||
</TemplateDetailRouteProvider>,
|
||||
)
|
||||
const link = screen.getByRole('link', { name: template.template_name })
|
||||
const url = new URL(link.getAttribute('href')!)
|
||||
expect(url.origin).toBe('https://marketplace.dify.ai')
|
||||
expect(url.pathname).toBe('/template/dify/template%2Fone')
|
||||
expect(Object.fromEntries(url.searchParams)).toEqual({
|
||||
source: window.location.origin,
|
||||
language: 'en-US',
|
||||
theme: 'dark',
|
||||
})
|
||||
expect(link).toHaveAttribute('target', '_blank')
|
||||
expect(link).toHaveAttribute('rel', 'noopener noreferrer')
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
|
||||
expect(document.querySelector('iframe')).toBeNull()
|
||||
expect(window.location.href).toBe(before)
|
||||
expect(
|
||||
screen.queryByRole('link', { name: template.template_name }),
|
||||
).not.toBeInTheDocument()
|
||||
await user.click(screen.getByRole('button', { name: template.template_name }))
|
||||
expect(screen.getByRole('dialog')).toBeInTheDocument()
|
||||
},
|
||||
)
|
||||
})
|
||||
+3
-8
@@ -113,7 +113,7 @@ describe('TemplateDetailRouteProvider', () => {
|
||||
expect(window.location.pathname).toBe('/templates/marketing')
|
||||
})
|
||||
it.each(['COMMUNITY', 'ENTERPRISE'] as const)(
|
||||
'replaces a legacy %s template detail URL with its official detail',
|
||||
'keeps a legacy %s template detail inside the app',
|
||||
(edition) => {
|
||||
deploymentState.deploymentEdition = edition
|
||||
window.history.replaceState(window.history.state, '', `/templates/dify/${id}`)
|
||||
@@ -123,13 +123,8 @@ describe('TemplateDetailRouteProvider', () => {
|
||||
<span>catalog</span>
|
||||
</TemplateDetailRouteProvider>,
|
||||
)
|
||||
expect(replace).toHaveBeenCalledOnce()
|
||||
const url = new URL(replace.mock.calls[0]![0])
|
||||
expect(url.origin).toBe('https://marketplace.dify.ai')
|
||||
expect(url.pathname).toBe(`/template/dify/${id}`)
|
||||
expect(url.searchParams.get('source')).toBe(window.location.origin)
|
||||
expect(url.searchParams.has('view')).toBe(false)
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
|
||||
expect(replace).not.toHaveBeenCalled()
|
||||
expect(screen.getByRole('dialog')).toBeInTheDocument()
|
||||
replace.mockRestore()
|
||||
},
|
||||
)
|
||||
|
||||
@@ -12,6 +12,8 @@ import {
|
||||
} from '@/features/marketplace/api'
|
||||
import { useRouter } from '@/next/navigation'
|
||||
import { formatNumberAbbreviated } from '@/utils/format'
|
||||
import { isOfficialDifyUrl } from '@/utils/official-link'
|
||||
import { visibleAuthorName } from '@/utils/visible-author'
|
||||
import { useMarketplaceDetailNavigation } from '../use-detail-navigation'
|
||||
import TemplateDetailDialog from './template-detail-dialog'
|
||||
import { useOptionalTemplateDetailRoute } from './use-optional-template-detail-route'
|
||||
@@ -30,8 +32,9 @@ export default function TemplateCard({ template, className, partnerText }: Templ
|
||||
const externalHref = navigation.templateHref(template)
|
||||
const templateDetailRoute = useOptionalTemplateDetailRoute()
|
||||
const [isDetailOpen, { setTrue: showDetail, setFalse: hideDetail }] = useBoolean(false)
|
||||
const publisher =
|
||||
template.publisher_handle || template.publisher_unique_handle || template.creator_email || ''
|
||||
const publisher = visibleAuthorName(
|
||||
template.publisher_handle || template.publisher_unique_handle || template.creator_email,
|
||||
)
|
||||
const visiblePlugins = template.deps_plugins?.slice(0, MAX_VISIBLE_PLUGIN_DEPENDENCIES) ?? []
|
||||
const remainingPluginCount = Math.max(
|
||||
0,
|
||||
@@ -60,7 +63,7 @@ export default function TemplateCard({ template, className, partnerText }: Templ
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{externalHref ? (
|
||||
{externalHref && !isOfficialDifyUrl(externalHref) ? (
|
||||
<a
|
||||
href={externalHref}
|
||||
target="_blank"
|
||||
|
||||
+1
-35
@@ -7,13 +7,8 @@ import type {
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { useId } from 'react'
|
||||
import Link from '@/next/link'
|
||||
import { trackMarketplaceSiteEvent } from '@/utils/marketplace-site-track'
|
||||
import Carousel from '../list/carousel'
|
||||
import {
|
||||
BECOME_PARTNER_URL,
|
||||
GRID_CLASS,
|
||||
PARTNER_COLLECTION_NAMES,
|
||||
} from '../list/collection-constants'
|
||||
import { GRID_CLASS, PARTNER_COLLECTION_NAMES } from '../list/collection-constants'
|
||||
import styles from '../list/partner-header.module.css'
|
||||
import { useCarouselItemsPerPage } from '../list/use-carousel-items-per-page'
|
||||
import TemplateCard from './template-card'
|
||||
@@ -44,7 +39,6 @@ function getViewMoreHref(collection: MarketplaceTemplateCollection) {
|
||||
}
|
||||
|
||||
export default function TemplateCollectionList({
|
||||
becomePartnerText,
|
||||
collections,
|
||||
locale,
|
||||
partnerText,
|
||||
@@ -95,34 +89,6 @@ export default function TemplateCollectionList({
|
||||
) : (
|
||||
getTemplateCollectionText(collection.description, locale)
|
||||
)}
|
||||
{isPartnerCollection && (
|
||||
<>
|
||||
<span className={cn(styles.partnerSeparator, 'text-divider-regular')}>|</span>
|
||||
<a
|
||||
href={BECOME_PARTNER_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={cn(
|
||||
styles.partnerAction,
|
||||
'flex items-center gap-x-0.5 text-text-accent hover:underline',
|
||||
)}
|
||||
onClick={() => {
|
||||
trackMarketplaceSiteEvent('marketplace_creator_partner_click', {
|
||||
click_target: 'Become a Partner',
|
||||
})
|
||||
}}
|
||||
>
|
||||
<span className={styles.partnerActionLabel}>{becomePartnerText}</span>
|
||||
<span
|
||||
aria-hidden
|
||||
className={cn(
|
||||
styles.partnerActionIcon,
|
||||
'i-ri-external-link-line size-3 [&:dir(rtl)]:-scale-x-100',
|
||||
)}
|
||||
/>
|
||||
</a>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{collection.searchable && (
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import type { MarketplacePlugin, MarketplaceTemplate } from '@dify/contracts/marketplace'
|
||||
import { useAtomValue } from 'jotai'
|
||||
import { useTheme } from 'next-themes'
|
||||
import { useSyncExternalStore } from 'react'
|
||||
import { useLocale } from '#i18n'
|
||||
import { marketplaceLinks } from '@/features/marketplace/links'
|
||||
import { deploymentEditionAtom } from '@/features/system-features/state'
|
||||
|
||||
const subscribe = () => () => {}
|
||||
const getOrigin = () => window.location.origin
|
||||
const getServerOrigin = () => ''
|
||||
|
||||
type PluginDetail = Pick<MarketplacePlugin, 'org' | 'name' | 'type'>
|
||||
type TemplateDetail = Pick<
|
||||
@@ -18,39 +8,15 @@ type TemplateDetail = Pick<
|
||||
'id' | 'publisher_handle' | 'publisher_unique_handle'
|
||||
>
|
||||
|
||||
// Only Dify entrypoints use this hook. Standalone Marketplace components must
|
||||
// not depend on the Console's deployment state or query its system features.
|
||||
// Local deployments stay inside the console. Plugin and template details open
|
||||
// in-app instead of marketplace.dify.ai or creators.dify.ai.
|
||||
export function useMarketplaceDetailNavigation() {
|
||||
const edition = useAtomValue(deploymentEditionAtom)
|
||||
const language = useLocale()
|
||||
const { resolvedTheme } = useTheme()
|
||||
const source = useSyncExternalStore(subscribe, getOrigin, getServerOrigin)
|
||||
const opensExternally = edition === 'COMMUNITY' || edition === 'ENTERPRISE'
|
||||
|
||||
const detailParams = { language, theme: resolvedTheme }
|
||||
const pluginHref = (plugin: PluginDetail) =>
|
||||
opensExternally && plugin.type !== 'bundle'
|
||||
? marketplaceLinks.officialPluginDetail(plugin, detailParams, source)
|
||||
: undefined
|
||||
const templateHref = (template: TemplateDetail) =>
|
||||
opensExternally
|
||||
? marketplaceLinks.officialTemplateDetail(template, detailParams, source)
|
||||
: undefined
|
||||
|
||||
// Search selections are commands, so open synchronously within the gesture.
|
||||
// Ordinary cards use the href directly to retain native link behavior.
|
||||
const open = (href: string | undefined) => {
|
||||
if (!href) return false
|
||||
window.open(href, '_blank', 'noopener,noreferrer')
|
||||
return true
|
||||
}
|
||||
|
||||
return {
|
||||
source,
|
||||
opensExternally,
|
||||
pluginHref,
|
||||
templateHref,
|
||||
openPlugin: (plugin: PluginDetail) => open(pluginHref(plugin)),
|
||||
openTemplate: (template: TemplateDetail) => open(templateHref(template)),
|
||||
source: '',
|
||||
opensExternally: false,
|
||||
pluginHref: (_plugin: PluginDetail) => undefined as string | undefined,
|
||||
templateHref: (_template: TemplateDetail) => undefined as string | undefined,
|
||||
openPlugin: (_plugin: PluginDetail) => false,
|
||||
openTemplate: (_template: TemplateDetail) => false,
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import { useBoolean } from 'ahooks'
|
||||
import * as React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { toast } from '@/app/notifications'
|
||||
import { useDocLink } from '@/context/i18n'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { getErrorMessage } from '@/utils/error-message'
|
||||
import EndpointCard from './endpoint-card'
|
||||
@@ -25,8 +24,7 @@ type EndpointListContentProps = Readonly<{
|
||||
|
||||
const EndpointListContent = ({ declaration, detail }: EndpointListContentProps) => {
|
||||
const { t } = useTranslation(['common', 'plugin'])
|
||||
const docLink = useDocLink()
|
||||
const pluginUniqueID = detail.plugin_unique_identifier
|
||||
const pluginUniqueID = detail.plugin_unique_identifier
|
||||
const showTopBorder = detail.declaration.tool
|
||||
const { data } = useQuery(
|
||||
consoleQuery.workspaces.current.endpoints.list.plugin.get.queryOptions({
|
||||
@@ -82,15 +80,6 @@ const EndpointListContent = ({ declaration, detail }: EndpointListContentProps)
|
||||
<div className="system-xs-regular text-text-tertiary">
|
||||
{t(($) => $['detailPanel.endpointsTip'], { ns: 'plugin' })}
|
||||
</div>
|
||||
<a
|
||||
href={docLink('/develop-plugin/getting-started/getting-started-dify-plugin')}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex cursor-pointer items-center gap-1 system-xs-regular text-text-accent"
|
||||
>
|
||||
<span aria-hidden className="i-ri-book-open-line size-3" />
|
||||
{t(($) => $['detailPanel.endpointsDocLink'], { ns: 'plugin' })}
|
||||
</a>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
|
||||
@@ -26,6 +26,7 @@ import * as React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Form from '@/app/components/header/account-setting/model-provider-page/model-modal/Form'
|
||||
import { useRenderI18nObject } from '@/hooks/use-i18n'
|
||||
import { isOfficialDifyUrl } from '@/utils/official-link'
|
||||
import { FormTypeEnum } from '../../header/account-setting/model-provider-page/declarations'
|
||||
import { ReadmeEntrance } from '../readme-panel/entrance'
|
||||
|
||||
@@ -214,7 +215,7 @@ const EndpointModal = ({
|
||||
validating={false}
|
||||
inputClassName="bg-components-input-bg-normal hover:bg-components-input-bg-hover"
|
||||
fieldMoreInfo={(item) =>
|
||||
item.url ? (
|
||||
item.url && !isOfficialDifyUrl(item.url) ? (
|
||||
<a
|
||||
href={item.url}
|
||||
target="_blank"
|
||||
|
||||
@@ -12,9 +12,6 @@ import {
|
||||
MenuTrigger,
|
||||
} from '@langgenius/dify-ui/menu'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useLocale } from '#i18n'
|
||||
import { useMarketplace } from '@/features/marketplace/client'
|
||||
import useTheme from '@/hooks/use-theme'
|
||||
import { PluginSource } from '../types'
|
||||
|
||||
type OperationMenuProps = Readonly<
|
||||
@@ -37,7 +34,6 @@ type OperationMenuProps = Readonly<
|
||||
|
||||
export function OperationMenu({
|
||||
source,
|
||||
marketplacePlugin,
|
||||
repo,
|
||||
onInfo,
|
||||
onCheckVersion,
|
||||
@@ -53,18 +49,9 @@ export function OperationMenu({
|
||||
showRemove = true,
|
||||
}: OperationMenuProps) {
|
||||
const { t } = useTranslation(['plugin'])
|
||||
const marketplace = useMarketplace()
|
||||
const locale = useLocale()
|
||||
const { theme } = useTheme()
|
||||
const showInfo = source === PluginSource.github
|
||||
const showCheckVersionAction = showCheckVersion && source === PluginSource.github
|
||||
const detailUrl = !marketplace
|
||||
? undefined
|
||||
: source === PluginSource.marketplace && marketplacePlugin
|
||||
? marketplace.plugin(marketplacePlugin, { language: locale, theme })
|
||||
: source === PluginSource.github && repo
|
||||
? `https://github.com/${repo}`
|
||||
: undefined
|
||||
const detailUrl = source === PluginSource.github && repo ? `https://github.com/${repo}` : undefined
|
||||
const showRemoveAction = showRemove
|
||||
const showSeparator = showRemoveAction && (!!detailUrl || !!onViewReadme)
|
||||
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
import type { Node } from 'reactflow'
|
||||
import { isOfficialDifyUrl } from '@/utils/official-link'
|
||||
import type { AppSelectorValue } from '@/app/components/plugins/plugin-detail-panel/app-selector'
|
||||
import type { ToolFormSchema } from '@/app/components/tools/utils/to-form-schema'
|
||||
import type { NodeOutPutVar, ValueSelector } from '@/app/components/workflow/types'
|
||||
@@ -331,7 +332,7 @@ export function ReasoningConfigForm({
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{url && (
|
||||
{url && !isOfficialDifyUrl(url) && (
|
||||
<a
|
||||
href={url}
|
||||
target="_blank"
|
||||
|
||||
@@ -260,19 +260,12 @@ const PluginItem: FC<Props> = ({
|
||||
</>
|
||||
)}
|
||||
{source === PluginSource.marketplace && marketplace && (
|
||||
<>
|
||||
<a
|
||||
href={marketplace.plugin({ org: author, name }, { theme })}
|
||||
target="_blank"
|
||||
className="relative z-20 flex items-center gap-0.5"
|
||||
>
|
||||
<div className="system-2xs-medium-uppercase text-text-tertiary">
|
||||
{t(($) => $.from, { ns: 'plugin' })}{' '}
|
||||
<span className="text-text-secondary">marketplace</span>
|
||||
</div>
|
||||
<RiArrowRightUpLine className="size-3 text-text-secondary" />
|
||||
</a>
|
||||
</>
|
||||
<div className="relative z-20 flex items-center gap-0.5">
|
||||
<div className="system-2xs-medium-uppercase text-text-tertiary">
|
||||
{t(($) => $.from, { ns: 'plugin' })}{' '}
|
||||
<span className="text-text-secondary">marketplace</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{source === PluginSource.local && (
|
||||
<>
|
||||
|
||||
+11
-20
@@ -136,10 +136,9 @@ it.each([Category.trigger, Category.agent, Category.extension])(
|
||||
},
|
||||
expect.anything(),
|
||||
)
|
||||
const link = screen.getByRole('link', { name: 'plugin.marketplace.difyMarketplace' })
|
||||
const url = new URL(link.getAttribute('href')!, window.location.origin)
|
||||
expect(url.pathname).toBe(`/plugins/${category}`)
|
||||
expect(url.searchParams.get('theme')).toBe('light')
|
||||
expect(
|
||||
screen.queryByRole('link', { name: 'plugin.marketplace.difyMarketplace' }),
|
||||
).not.toBeInTheDocument()
|
||||
},
|
||||
)
|
||||
|
||||
@@ -170,21 +169,13 @@ it('shows provider information and opens the selected package in the real instal
|
||||
})
|
||||
|
||||
it.each(['CLOUD', 'COMMUNITY', 'ENTERPRISE'] as const)(
|
||||
'links provider details to the appropriate destination for %s',
|
||||
async (edition) => {
|
||||
setup({}, { systemFeatures: { deployment_edition: edition, rbac_enabled: true } })
|
||||
'keeps %s provider details inside the app',
|
||||
async (_edition) => {
|
||||
setup({}, { systemFeatures: { deployment_edition: _edition, rbac_enabled: true } })
|
||||
const card = within(await screen.findByRole('article', { name: 'Calendar' }))
|
||||
const link = card.getByRole('link', { name: 'plugin.detailPanel.operation.detail Calendar' })
|
||||
const url = new URL(link.getAttribute('href')!, window.location.origin)
|
||||
expect(url.pathname).toBe(`${edition === 'CLOUD' ? '/plugins' : '/plugin'}/langgenius/calendar`)
|
||||
expect(url.searchParams.get('language')).toBe('en-US')
|
||||
expect(url.searchParams.get('theme')).toBe('light')
|
||||
if (edition !== 'CLOUD') {
|
||||
expect(url.origin).toBe('https://marketplace.dify.ai')
|
||||
expect(url.searchParams.get('source')).toBe(window.location.origin)
|
||||
}
|
||||
expect(link).toHaveAttribute('target', '_blank')
|
||||
expect(link).toHaveAttribute('rel', 'noopener noreferrer')
|
||||
expect(
|
||||
card.queryByRole('link', { name: 'plugin.detailPanel.operation.detail Calendar' }),
|
||||
).not.toBeInTheDocument()
|
||||
},
|
||||
)
|
||||
|
||||
@@ -192,8 +183,8 @@ it('keeps provider details available but hides installation without workspace pe
|
||||
setup({}, { workspacePermissionKeys: [] })
|
||||
const card = within(await screen.findByRole('article', { name: 'Calendar' }))
|
||||
expect(
|
||||
card.getByRole('link', { name: 'plugin.detailPanel.operation.detail Calendar' }),
|
||||
).toBeVisible()
|
||||
card.queryByRole('link', { name: 'plugin.detailPanel.operation.detail Calendar' }),
|
||||
).not.toBeInTheDocument()
|
||||
expect(
|
||||
card.queryByRole('button', { name: /plugin.detailPanel.operation.install/ }),
|
||||
).not.toBeInTheDocument()
|
||||
|
||||
+14
-12
@@ -265,7 +265,7 @@ describe('Plugin list panel', () => {
|
||||
expect(screen.queryByRole('button', { name: 'Rag Plugin' })).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: /Search Builtin/ })).toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: /Rag Builtin/ })).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('region', { name: 'Tool marketplace' })).toHaveTextContent('search')
|
||||
expect(screen.queryByRole('region', { name: 'Tool marketplace' })).not.toBeInTheDocument()
|
||||
expect(requests.list).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ query: expect.objectContaining({ tags: ['search'] }) }),
|
||||
)
|
||||
@@ -314,14 +314,16 @@ describe('Plugin list panel', () => {
|
||||
supportsTags: false,
|
||||
},
|
||||
])(
|
||||
'keeps the $category catalog browsable without install permission and hides unsupported filters',
|
||||
'shows the $category empty state without an uninstalled marketplace catalog',
|
||||
async ({ category, empty, target, supportsTags }) => {
|
||||
await renderPanel({ fixedCategory: category, canInstall: false })
|
||||
expect(screen.getByText(`plugin.list.${empty}`)).toBeInTheDocument()
|
||||
expect(screen.getByRole('region', { name: `${category} marketplace` })).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByRole('link', { name: 'plugin.marketplace.difyMarketplace' }),
|
||||
).toHaveAttribute('href', `#plugin-category-marketplace-${category}`)
|
||||
screen.queryByRole('region', { name: `${category} marketplace` }),
|
||||
).not.toBeInTheDocument()
|
||||
expect(
|
||||
screen.queryByRole('link', { name: 'plugin.marketplace.difyMarketplace' }),
|
||||
).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: 'plugin.allCategories' })).not.toBeInTheDocument()
|
||||
expect(!!screen.queryByRole('button', { name: 'common.tag.tags' })).toBe(supportsTags)
|
||||
expect(document.querySelector(getStepByStepTourTargetSelector(target))).toContainElement(
|
||||
@@ -356,13 +358,13 @@ describe('Plugin list panel', () => {
|
||||
expect(requests.list).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ query: { page: 1, page_size: 30, language: 'en_US' } }),
|
||||
)
|
||||
expect(screen.getByRole('region', { name: `${category} marketplace` })).not.toHaveTextContent(
|
||||
'search',
|
||||
)
|
||||
expect(
|
||||
screen.queryByRole('region', { name: `${category} marketplace` }),
|
||||
).not.toBeInTheDocument()
|
||||
},
|
||||
)
|
||||
|
||||
it('debounces search changes and filters installed and builtin tools while forwarding marketplace search', async () => {
|
||||
it('debounces search changes and filters installed and builtin tools', async () => {
|
||||
vi.useFakeTimers({ shouldAdvanceTime: true })
|
||||
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime })
|
||||
plugins = [
|
||||
@@ -381,7 +383,7 @@ describe('Plugin list panel', () => {
|
||||
expect(screen.queryByRole('button', { name: 'Alpha Plugin' })).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: /Beta Builtin/ })).toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: /Alpha Builtin/ })).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('region', { name: 'Tool marketplace' })).toHaveTextContent('beta')
|
||||
expect(screen.queryByRole('region', { name: 'Tool marketplace' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('offers manual pagination on the standalone plugin page and appends the returned cards', async () => {
|
||||
@@ -459,7 +461,7 @@ describe('Plugin list panel', () => {
|
||||
expect(screen.queryByRole('region', { name: 'Plugin details' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps category marketplace search available without presenting a no-installation prompt for unmatched searches', async () => {
|
||||
it('hides the uninstalled marketplace catalog when a category search has no installed match', async () => {
|
||||
plugins = [createPlugin('trigger', 'Trigger Plugin', [], PluginCategoryEnum.trigger)]
|
||||
await renderPanel(
|
||||
{ fixedCategory: PluginCategoryEnum.trigger },
|
||||
@@ -468,7 +470,7 @@ describe('Plugin list panel', () => {
|
||||
expect(screen.queryByRole('button', { name: 'Trigger Plugin' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('plugin.list.noTriggerFound')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('plugin.list.noInstalled')).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('region', { name: 'trigger marketplace' })).toHaveTextContent('missing')
|
||||
expect(screen.queryByRole('region', { name: 'trigger marketplace' })).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import { Button } from '@langgenius/dify-ui/button'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { Separator } from '@langgenius/dify-ui/separator'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useTheme } from 'next-themes'
|
||||
import { useCallback, useMemo, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
|
||||
@@ -16,7 +15,6 @@ import List from '@/app/components/plugins/marketplace/list'
|
||||
import { useMarketplacePlugins } from '@/app/components/plugins/marketplace/query'
|
||||
import { usePluginSettingsAccess } from '@/app/components/plugins/plugin-page/use-reference-setting'
|
||||
import ProviderCard from '@/app/components/plugins/provider-card'
|
||||
import Link from '@/next/link'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { getCategoryMarketplaceId } from './category-marketplace'
|
||||
|
||||
@@ -34,7 +32,6 @@ const CategoryMarketplacePanel = ({
|
||||
tags?: string[]
|
||||
}) => {
|
||||
const { t } = useTranslation(['common', 'plugin', 'workflow', 'modelProvider'])
|
||||
const { theme } = useTheme()
|
||||
const { canInstallPlugin } = usePluginSettingsAccess()
|
||||
const [collapsed, setCollapsed] = useState(false)
|
||||
const {
|
||||
@@ -74,7 +71,6 @@ const CategoryMarketplacePanel = ({
|
||||
[data, installedPluginIds],
|
||||
)
|
||||
|
||||
const marketplaceLink = marketplace.category(category, { theme })
|
||||
const showInstalledPluginIdsError = hasInstalledPluginIdsError && !hasLoadedInstalledPluginIds
|
||||
const showLoading = isLoadingInstalledPluginIds || !!(marketplaceSearchParams && isPending)
|
||||
const cardRender = useCallback(
|
||||
@@ -112,23 +108,6 @@ const CategoryMarketplacePanel = ({
|
||||
/>
|
||||
{t(($) => $['list.source.marketplace'], { ns: 'plugin' })}
|
||||
</button>
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="system-sm-regular text-text-tertiary">
|
||||
{t(($) => $['modelProvider.discoverMore'], { ns: 'modelProvider' })}
|
||||
</span>
|
||||
<Link
|
||||
className="inline-flex items-center system-sm-medium text-text-accent"
|
||||
href={marketplaceLink}
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{t(($) => $['marketplace.difyMarketplace'], { ns: 'plugin' })}
|
||||
<span
|
||||
aria-hidden
|
||||
className="i-ri-arrow-right-up-line size-4 [&:dir(rtl)]:-scale-x-100"
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
{!collapsed && (
|
||||
<div>
|
||||
|
||||
@@ -5,7 +5,6 @@ import { Button } from '@langgenius/dify-ui/button'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
|
||||
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'
|
||||
@@ -24,8 +23,7 @@ function DebugInfo({
|
||||
triggerVariant = 'secondary',
|
||||
}: DebugInfoProps) {
|
||||
const { t } = useTranslation(['plugin'])
|
||||
const docLink = useDocLink()
|
||||
const { data: info, isLoading } = useDebugKey()
|
||||
const { data: info, isLoading } = useDebugKey()
|
||||
const title = t(($) => $[`${i18nPrefix}.title`], { ns: 'plugin' })
|
||||
const trigger = triggerContent ?? <span aria-hidden className="i-ri-bug-line size-4" />
|
||||
const triggerClassNames = cn(
|
||||
@@ -56,28 +54,7 @@ function DebugInfo({
|
||||
}
|
||||
/>
|
||||
<PopoverContent side="top" align="start" className="border-0 bg-transparent p-0 shadow-none">
|
||||
<PluginSidecarPanel
|
||||
title={title}
|
||||
footer={
|
||||
<div className="flex w-full shrink-0 flex-col items-start">
|
||||
<div className="flex w-full shrink-0 items-center justify-end gap-2 px-4 pt-2 pb-4">
|
||||
<div className="flex min-w-0 flex-1 items-center gap-1">
|
||||
<a
|
||||
href={docLink(
|
||||
'/develop-plugin/features-and-specs/plugin-types/remote-debug-a-plugin',
|
||||
)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex cursor-pointer items-center gap-1 rounded-xs system-xs-regular text-text-accent focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
|
||||
>
|
||||
<span>{t(($) => $[`${i18nPrefix}.viewDocs`], { ns: 'plugin' })}</span>
|
||||
<span aria-hidden className="i-ri-arrow-right-up-line size-3" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<PluginSidecarPanel title={title}>
|
||||
<div className="flex w-full shrink-0 flex-col items-start justify-center gap-1 px-4 py-2">
|
||||
<KeyValueItem label="Port" value={`${info.host}:${info.port}`} />
|
||||
<KeyValueItem
|
||||
|
||||
@@ -15,6 +15,7 @@ import { Fragment, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useDocLink } from '@/context/i18n'
|
||||
import { marketplaceLinks } from '@/features/marketplace/links'
|
||||
import { isOfficialDifyUrl } from '@/utils/official-link'
|
||||
|
||||
type GuideMenuItemProps = {
|
||||
href: string
|
||||
@@ -111,7 +112,9 @@ export function SubmitRequestMenuView({ dividerAfterFirst, docLink }: SubmitRequ
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<MenuContent className="min-w-50">
|
||||
{options.map((option, index) => (
|
||||
{options
|
||||
.filter((option) => option.href && !isOfficialDifyUrl(option.href))
|
||||
.map((option, index) => (
|
||||
<Fragment key={option.href}>
|
||||
{dividerAfterFirst && index === 1 && <MenuSeparator className="my-1" />}
|
||||
<GuideMenuItem
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import type { RefObject } from 'react'
|
||||
import type { PluginDetail } from '../types'
|
||||
import type { EmbeddedMarketplaceCategory } from './category-marketplace'
|
||||
import type { PluginPageContentInset } from './content-inset'
|
||||
import type { Collection } from '@/app/components/tools/types'
|
||||
import type { MarketplaceLinks } from '@/features/marketplace/links'
|
||||
import { Button } from '@langgenius/dify-ui/button'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import {
|
||||
@@ -17,9 +15,7 @@ import { useEffect, useRef } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
|
||||
import IntegrationsToolProviderCard from '@/app/components/integrations/tool-provider-card'
|
||||
import { BuiltinMarketplacePanel } from '@/app/components/tools/marketplace/builtin-marketplace-panel'
|
||||
import CategoryEmptyState from './category-empty-state'
|
||||
import CategoryMarketplacePanel from './category-marketplace-panel'
|
||||
import List from './list'
|
||||
|
||||
type PluginsPanelResultsProps = {
|
||||
@@ -27,28 +23,22 @@ type PluginsPanelResultsProps = {
|
||||
canDeletePlugin: boolean
|
||||
canUpdatePlugin: boolean
|
||||
categoryEmptyState?: EmbeddedMarketplaceCategory
|
||||
categoryMarketplace?: EmbeddedMarketplaceCategory
|
||||
containerRef: RefObject<HTMLDivElement | null>
|
||||
contentFrameClassName: string
|
||||
contentInset: PluginPageContentInset
|
||||
currentBuiltinToolID?: string
|
||||
firstBuiltinToolTarget?: string
|
||||
firstPluginTarget?: string
|
||||
filteredBuiltinTools: Collection[]
|
||||
filteredList: Array<PluginDetail & { latest_version: string }>
|
||||
hasToolMarketplacePanel: boolean
|
||||
marketplace: MarketplaceLinks | null
|
||||
hasVisibleBuiltinTools: boolean
|
||||
hasVisiblePlugins: boolean
|
||||
hasEmbeddedMarketplace: boolean
|
||||
isFetching: boolean
|
||||
isLastPage: boolean
|
||||
keywords: string
|
||||
loadNextPage: () => void
|
||||
onSelectBuiltinTool: (id: string) => void
|
||||
scrollAreaLabel?: string
|
||||
showCategoryEmptyState: boolean
|
||||
tagFilterValue: string[]
|
||||
}
|
||||
|
||||
const PluginsPanelResults = ({
|
||||
@@ -56,28 +46,22 @@ const PluginsPanelResults = ({
|
||||
canDeletePlugin,
|
||||
canUpdatePlugin,
|
||||
categoryEmptyState,
|
||||
categoryMarketplace,
|
||||
containerRef,
|
||||
contentFrameClassName,
|
||||
contentInset,
|
||||
currentBuiltinToolID,
|
||||
firstBuiltinToolTarget,
|
||||
firstPluginTarget,
|
||||
filteredBuiltinTools,
|
||||
filteredList,
|
||||
hasToolMarketplacePanel,
|
||||
marketplace,
|
||||
hasVisibleBuiltinTools,
|
||||
hasVisiblePlugins,
|
||||
hasEmbeddedMarketplace,
|
||||
isFetching,
|
||||
isLastPage,
|
||||
keywords,
|
||||
loadNextPage,
|
||||
onSelectBuiltinTool,
|
||||
scrollAreaLabel,
|
||||
showCategoryEmptyState,
|
||||
tagFilterValue,
|
||||
}: PluginsPanelResultsProps) => {
|
||||
const { t } = useTranslation(['common', 'plugin', 'workflow'])
|
||||
const loadMoreAnchorRef = useRef<HTMLDivElement>(null)
|
||||
@@ -144,10 +128,7 @@ const PluginsPanelResults = ({
|
||||
className={cn('flex min-h-full flex-col', hasEmbeddedMarketplace && 'pt-1')}
|
||||
>
|
||||
{showCategoryEmptyState && categoryEmptyState && (
|
||||
<CategoryEmptyState
|
||||
category={categoryEmptyState}
|
||||
showMarketplaceLink={!!categoryMarketplace}
|
||||
/>
|
||||
<CategoryEmptyState category={categoryEmptyState} showMarketplaceLink={false} />
|
||||
)}
|
||||
{(hasVisiblePlugins || hasVisibleBuiltinTools) && (
|
||||
<List
|
||||
@@ -190,23 +171,6 @@ const PluginsPanelResults = ({
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{marketplace && hasToolMarketplacePanel && (
|
||||
<BuiltinMarketplacePanel
|
||||
marketplace={marketplace}
|
||||
containerRef={containerRef}
|
||||
contentInset={contentInset}
|
||||
keywords={keywords}
|
||||
tagFilterValue={tagFilterValue}
|
||||
/>
|
||||
)}
|
||||
{marketplace && categoryMarketplace && (
|
||||
<CategoryMarketplacePanel
|
||||
marketplace={marketplace}
|
||||
category={categoryMarketplace}
|
||||
searchText={keywords}
|
||||
tags={categoryMarketplace === 'trigger' ? tagFilterValue : []}
|
||||
/>
|
||||
)}
|
||||
</ScrollAreaContent>
|
||||
</ScrollAreaViewport>
|
||||
<ScrollAreaScrollbar>
|
||||
|
||||
@@ -12,7 +12,6 @@ import PluginDetailPanel from '@/app/components/plugins/plugin-detail-panel'
|
||||
import { STEP_BY_STEP_TOUR_TARGETS } from '@/app/components/step-by-step-tour/target-registry'
|
||||
import ProviderDetail from '@/app/components/tools/provider/detail'
|
||||
import { useGetLanguage } from '@/context/i18n'
|
||||
import { useMarketplace } from '@/features/marketplace/client'
|
||||
import { renderI18nObject } from '@/i18n/metadata'
|
||||
import {
|
||||
normalizePluginCategoryListLanguage,
|
||||
@@ -105,7 +104,6 @@ const PluginsPanel = ({
|
||||
: undefined,
|
||||
[filters.searchQuery, filters.tags, isIntegrationCategoryPage, locale, supportsTagFilter],
|
||||
)
|
||||
const marketplace = useMarketplace()
|
||||
const {
|
||||
data: pluginList,
|
||||
isLoading: isPluginListLoading,
|
||||
@@ -192,8 +190,6 @@ const PluginsPanel = ({
|
||||
}, [currentBuiltinToolID, filteredBuiltinTools])
|
||||
|
||||
const handleDetailHide = () => setSelectedItem(undefined)
|
||||
const hasToolMarketplacePanel = marketplace !== null && isToolIntegrationPage
|
||||
const categoryMarketplace = marketplace && hasEmbeddedMarketplace ? fixedCategory : undefined
|
||||
const contentPaddingClassName = pluginPageContentInsetClassNames[contentInset]
|
||||
const contentFrameClassName = cn(
|
||||
pluginPageContentFrameClassNames[contentInset],
|
||||
@@ -246,15 +242,11 @@ const PluginsPanel = ({
|
||||
{isPluginListLoading && <PluginListSkeleton contentFrameClassName={contentFrameClassName} />}
|
||||
{!isPluginListLoading && (
|
||||
<>
|
||||
{hasVisiblePlugins ||
|
||||
hasVisibleBuiltinTools ||
|
||||
hasToolMarketplacePanel ||
|
||||
hasEmbeddedMarketplace ? (
|
||||
{hasVisiblePlugins || hasVisibleBuiltinTools || hasEmbeddedMarketplace ? (
|
||||
<PluginsPanelResults
|
||||
autoLoadNextPage={isIntegrationCategoryPage}
|
||||
containerRef={containerRef}
|
||||
contentFrameClassName={contentFrameClassName}
|
||||
contentInset={contentInset}
|
||||
currentBuiltinToolID={currentBuiltinToolID}
|
||||
firstBuiltinToolTarget={
|
||||
isToolIntegrationPage
|
||||
@@ -268,22 +260,17 @@ const PluginsPanel = ({
|
||||
}
|
||||
filteredBuiltinTools={filteredBuiltinTools}
|
||||
filteredList={filteredList}
|
||||
hasToolMarketplacePanel={hasToolMarketplacePanel}
|
||||
marketplace={marketplace}
|
||||
hasVisibleBuiltinTools={hasVisibleBuiltinTools}
|
||||
hasVisiblePlugins={hasVisiblePlugins}
|
||||
hasEmbeddedMarketplace={hasEmbeddedMarketplace}
|
||||
isFetching={isFetching}
|
||||
isLastPage={isLastPage}
|
||||
keywords={filters.searchQuery}
|
||||
loadNextPage={loadNextPage}
|
||||
scrollAreaLabel={scrollAreaLabel}
|
||||
onSelectBuiltinTool={(id) => setSelectedItem({ type: 'builtinTool', id })}
|
||||
tagFilterValue={filters.tags}
|
||||
canDeletePlugin={canDeletePlugin}
|
||||
canUpdatePlugin={canUpdatePlugin}
|
||||
categoryEmptyState={hasEmbeddedMarketplace ? fixedCategory : undefined}
|
||||
categoryMarketplace={categoryMarketplace}
|
||||
showCategoryEmptyState={
|
||||
hasEmbeddedMarketplace &&
|
||||
!isFilteringCategory &&
|
||||
|
||||
@@ -2,18 +2,16 @@
|
||||
import type { FC } from 'react'
|
||||
import type { Plugin } from './types'
|
||||
import type { MarketplaceLinks } from '@/features/marketplace/links'
|
||||
import { Button, buttonVariants } from '@langgenius/dify-ui/button'
|
||||
import { Button } from '@langgenius/dify-ui/button'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { useBoolean } from 'ahooks'
|
||||
import { useTheme } from 'next-themes'
|
||||
import * as React from 'react'
|
||||
import { useId, useMemo } from 'react'
|
||||
import { useId } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useLocale } from '#i18n'
|
||||
import usePluginInstallPermission from '@/app/components/plugins/install-plugin/hooks/use-plugin-install-permission'
|
||||
import InstallFromMarketplace from '@/app/components/plugins/install-plugin/install-from-marketplace'
|
||||
import { useMarketplaceDetailNavigation } from '@/app/components/plugins/marketplace/use-detail-navigation'
|
||||
import { useRenderI18nObject } from '@/hooks/use-i18n'
|
||||
import { visibleAuthorName } from '@/utils/visible-author'
|
||||
import Badge from '../base/badge'
|
||||
import Icon from './card/base/card-icon'
|
||||
import Description from './card/base/description'
|
||||
@@ -25,23 +23,18 @@ type Props = Readonly<{
|
||||
payload: Plugin
|
||||
}>
|
||||
|
||||
const ProviderCardComponent: FC<Props> = ({ className, marketplace, payload }) => {
|
||||
const ProviderCardComponent: FC<Props> = ({ className, payload }) => {
|
||||
const getValueFromI18nObject = useRenderI18nObject()
|
||||
const { t } = useTranslation(['plugin'])
|
||||
const { theme } = useTheme()
|
||||
const [
|
||||
isShowInstallFromMarketplace,
|
||||
{ setTrue: showInstallFromMarketplace, setFalse: hideInstallFromMarketplace },
|
||||
] = useBoolean(false)
|
||||
const { canInstallPlugin } = usePluginInstallPermission()
|
||||
const { org, label } = payload
|
||||
const publicOrg = visibleAuthorName(org)
|
||||
const pluginLabel = getValueFromI18nObject(label)
|
||||
const titleId = useId()
|
||||
const locale = useLocale()
|
||||
const navigation = useMarketplaceDetailNavigation()
|
||||
|
||||
// Memoize the marketplace link params to prevent unnecessary re-renders
|
||||
const marketplaceLinkParams = useMemo(() => ({ language: locale, theme }), [locale, theme])
|
||||
|
||||
return (
|
||||
<article
|
||||
@@ -67,8 +60,10 @@ const ProviderCardComponent: FC<Props> = ({ className, marketplace, payload }) =
|
||||
</div>
|
||||
<div className="mb-1 flex h-4 items-center justify-between">
|
||||
<div className="flex items-center">
|
||||
<div className="system-xs-regular text-text-tertiary">{org}</div>
|
||||
<div className="mx-2 system-xs-regular text-text-quaternary">·</div>
|
||||
{publicOrg ? (
|
||||
<div className="system-xs-regular text-text-tertiary">{publicOrg}</div>
|
||||
) : null}
|
||||
{publicOrg ? <div className="mx-2 system-xs-regular text-text-quaternary">·</div> : null}
|
||||
<DownloadCount downloadCount={payload.install_count || 0} />
|
||||
</div>
|
||||
</div>
|
||||
@@ -84,8 +79,8 @@ const ProviderCardComponent: FC<Props> = ({ className, marketplace, payload }) =
|
||||
<Badge key={tag.name} text={tag.name} />
|
||||
))}
|
||||
</div>
|
||||
<div className="pointer-events-none absolute inset-x-0 bottom-0 flex items-center gap-2 rounded-xl bg-linear-to-tr from-components-panel-on-panel-item-bg to-background-gradient-mask-transparent p-4 pt-4 opacity-0 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100">
|
||||
{canInstallPlugin && (
|
||||
{canInstallPlugin && (
|
||||
<div className="pointer-events-none absolute inset-x-0 bottom-0 flex items-center gap-2 rounded-xl bg-linear-to-tr from-components-panel-on-panel-item-bg to-background-gradient-mask-transparent p-4 pt-4 opacity-0 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100">
|
||||
<Button
|
||||
aria-label={`${t(($) => $['detailPanel.operation.install'], { ns: 'plugin' })} ${pluginLabel}`}
|
||||
className="grow"
|
||||
@@ -94,20 +89,8 @@ const ProviderCardComponent: FC<Props> = ({ className, marketplace, payload }) =
|
||||
>
|
||||
{t(($) => $['detailPanel.operation.install'], { ns: 'plugin' })}
|
||||
</Button>
|
||||
)}
|
||||
<a
|
||||
aria-label={`${t(($) => $['detailPanel.operation.detail'], { ns: 'plugin' })} ${pluginLabel}`}
|
||||
href={
|
||||
navigation.pluginHref(payload) ?? marketplace.plugin(payload, marketplaceLinkParams)
|
||||
}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={cn(buttonVariants({ variant: 'secondary' }), 'grow gap-0.5')}
|
||||
>
|
||||
{t(($) => $['detailPanel.operation.detail'], { ns: 'plugin' })}
|
||||
<span className="i-ri-arrow-right-up-line size-4" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{isShowInstallFromMarketplace && (
|
||||
<InstallFromMarketplace
|
||||
manifest={payload}
|
||||
|
||||
+6
-2
@@ -7,6 +7,7 @@ import Icon from '@/app/components/plugins/card/base/card-icon'
|
||||
import { useGetLanguage } from '@/context/i18n'
|
||||
import { getMarketplacePluginIconUrl } from '@/features/marketplace/api'
|
||||
import { renderI18nObject } from '@/i18n/metadata'
|
||||
import { visibleAuthorName } from '@/utils/visible-author'
|
||||
|
||||
type Props = Readonly<{
|
||||
payload: PluginDetail
|
||||
@@ -18,7 +19,8 @@ const ToolItem: FC<Props> = ({ payload, isChecked, onCheckChange }) => {
|
||||
const language = useGetLanguage()
|
||||
|
||||
const { plugin_id, declaration } = payload
|
||||
const { label, author: org } = declaration
|
||||
const { label, author } = declaration
|
||||
const org = visibleAuthorName(author)
|
||||
return (
|
||||
<div className="flex w-full items-center gap-1 rounded-lg py-1 pr-2 pl-3 select-none hover:bg-state-base-hover">
|
||||
<div className="flex min-w-0 grow items-center gap-2 pr-2">
|
||||
@@ -26,7 +28,9 @@ const ToolItem: FC<Props> = ({ payload, isChecked, onCheckChange }) => {
|
||||
<div className="min-w-0 truncate system-sm-medium text-text-secondary">
|
||||
{renderI18nObject(label, language)}
|
||||
</div>
|
||||
<div className="min-w-0 truncate system-xs-regular text-text-quaternary">{org}</div>
|
||||
{org ? (
|
||||
<div className="min-w-0 truncate system-xs-regular text-text-quaternary">{org}</div>
|
||||
) : null}
|
||||
</div>
|
||||
<Checkbox
|
||||
checked={isChecked}
|
||||
|
||||
Reference in new issue
Block a user