feat(dify): 把本地控制台的中文与去外链改动入库

这些界面改动和专家服务草稿停在工作区,没有随上一笔主分支提交进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-11-23 09:44:09 +08:00
1 parent 9c7c80e194
commit c2cb845a32
211 files changed
+3030 -2794

No files matched your search

@@ -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()
@@ -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 &&