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
-14
@@ -15,9 +15,6 @@ import { Input } from '@langgenius/dify-ui/input'
|
||||
import { Textarea } from '@langgenius/dify-ui/textarea'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useLocale } from '#i18n'
|
||||
import { getEnterpriseDocUrl } from '@/context/i18n'
|
||||
import { getDocLanguage } from '@/i18n/language'
|
||||
import PermissionPicker from './permission-picker'
|
||||
|
||||
export type PermissionSetModalMode = 'create' | 'edit' | 'view'
|
||||
@@ -47,8 +44,6 @@ const PermissionSetModalBody = ({
|
||||
onSubmit,
|
||||
}: PermissionSetModalBodyProps) => {
|
||||
const { t } = useTranslation(['common', 'permission'])
|
||||
const locale = useLocale()
|
||||
const docLanguage = getDocLanguage(locale)
|
||||
const [name, setName] = useState(initialValues?.name ?? '')
|
||||
const [description, setDescription] = useState(initialValues?.description ?? '')
|
||||
const [permissionKeys, setPermissionKeys] = useState<string[]>(
|
||||
@@ -158,15 +153,6 @@ const PermissionSetModalBody = ({
|
||||
{t(($) => $['api.actionFailed'], { ns: 'common' })}
|
||||
</p>
|
||||
)}
|
||||
<a
|
||||
href={getEnterpriseDocUrl('/use/workspace/permission-reference', docLanguage)}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="me-auto inline-flex items-center gap-1 system-xs-medium text-text-accent hover:underline"
|
||||
>
|
||||
<span>{t(($) => $['permissionSet.learnMore'], { ns: 'permission' })}</span>
|
||||
<span aria-hidden className="i-ri-external-link-line h-3.5 w-3.5" />
|
||||
</a>
|
||||
<Button type="button" variant="secondary" onClick={onClose}>
|
||||
{readonly
|
||||
? t(($) => $['operation.close'], { ns: 'common' })
|
||||
|
||||
+1
-13
@@ -1,12 +1,9 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { STEP_BY_STEP_TOUR_TARGETS } from '@/app/components/step-by-step-tour/target-registry'
|
||||
import { useDocLink } from '@/context/i18n'
|
||||
|
||||
export function Empty() {
|
||||
const { t } = useTranslation(['common'])
|
||||
const docLink = useDocLink()
|
||||
|
||||
return (
|
||||
return (
|
||||
<div
|
||||
className="mb-2 flex flex-col items-start gap-3 rounded-xl bg-background-section p-6"
|
||||
data-step-by-step-tour-target={STEP_BY_STEP_TOUR_TARGETS.integrationCustomEndpointEmpty}
|
||||
@@ -21,15 +18,6 @@ export function Empty() {
|
||||
<div className="system-xs-regular text-text-primary">
|
||||
{t(($) => $['apiBasedExtension.title'], { ns: 'common' })}
|
||||
</div>
|
||||
<a
|
||||
className="flex items-center gap-1 system-xs-regular text-text-accent"
|
||||
href={docLink('/use-dify/workspace/api-extension/api-extension')}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{t(($) => $['apiBasedExtension.link'], { ns: 'common' })}
|
||||
<span aria-hidden className="i-ri-external-link-line size-3" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
+2
-18
@@ -12,12 +12,11 @@ import {
|
||||
DialogHeaderCloseButton,
|
||||
DialogTitle,
|
||||
} from '@langgenius/dify-ui/dialog'
|
||||
import { Field, FieldDescription, FieldError, FieldLabel } from '@langgenius/dify-ui/field'
|
||||
import { Field, FieldError, FieldLabel } from '@langgenius/dify-ui/field'
|
||||
import { Form } from '@langgenius/dify-ui/form'
|
||||
import { Input } from '@langgenius/dify-ui/input'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useDocLink } from '@/context/i18n'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
type ApiBasedExtensionModalProps = {
|
||||
@@ -37,8 +36,7 @@ type ApiBasedExtensionModalProps = {
|
||||
export function ApiBasedExtensionModal(props: ApiBasedExtensionModalProps) {
|
||||
const { open, mode, onOpenChange, onSaved } = props
|
||||
const { t } = useTranslation(['common'])
|
||||
const docLink = useDocLink()
|
||||
const createApiBasedExtensionMutation = useMutation(
|
||||
const createApiBasedExtensionMutation = useMutation(
|
||||
consoleQuery.apiBasedExtension.post.mutationOptions(),
|
||||
)
|
||||
const updateApiBasedExtensionMutation = useMutation(
|
||||
@@ -127,20 +125,6 @@ export function ApiBasedExtensionModal(props: ApiBasedExtensionModalProps) {
|
||||
ns: 'common',
|
||||
})}
|
||||
/>
|
||||
<FieldDescription>
|
||||
<a
|
||||
href={docLink('/use-dify/workspace/api-extension/api-extension')}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex w-fit items-center text-text-accent focus-visible:ring-1 focus-visible:ring-components-input-border-active focus-visible:outline-hidden"
|
||||
>
|
||||
<span
|
||||
className="me-1 i-custom-vender-line-education-book-open-01 size-3"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
{t(($) => $['apiBasedExtension.link'], { ns: 'common' })}
|
||||
</a>
|
||||
</FieldDescription>
|
||||
<FieldError match="valueMissing">
|
||||
{t(($) => $['errorMsg.fieldRequired'], { ns: 'common', field: apiEndpointLabel })}
|
||||
</FieldError>
|
||||
|
||||
+18
-109
@@ -149,9 +149,6 @@ function setup(
|
||||
)
|
||||
return { queryClient, user: userEvent.setup() }
|
||||
}
|
||||
const marketplaceToggle = () =>
|
||||
screen.getByRole('button', { name: 'modelProvider.modelProvider.installDataSource' })
|
||||
|
||||
it.each([false, true])(
|
||||
'shows the empty-state guidance with marketplace enabled=%s',
|
||||
async (enableMarketplace) => {
|
||||
@@ -162,18 +159,11 @@ it.each([false, true])(
|
||||
)
|
||||
expect(await screen.findByText('common.dataSourcePage.installFirst')).toBeInTheDocument()
|
||||
expect(screen.getByRole('searchbox')).toBeInTheDocument()
|
||||
if (enableMarketplace) {
|
||||
expect(await screen.findByText('Recommended Source')).toBeInTheDocument()
|
||||
const link = screen.getByRole('link', { name: 'plugin.marketplace.difyMarketplace' })
|
||||
const url = new URL(link.getAttribute('href')!, window.location.href)
|
||||
expect(url.pathname).toBe('/plugins/datasource')
|
||||
expect(url.searchParams.get('theme')).toBe('light')
|
||||
} else {
|
||||
expect(
|
||||
screen.queryByRole('button', { name: 'modelProvider.modelProvider.installDataSource' }),
|
||||
).not.toBeInTheDocument()
|
||||
expect(api.search).not.toHaveBeenCalled()
|
||||
}
|
||||
expect(
|
||||
screen.queryByRole('button', { name: 'modelProvider.modelProvider.installDataSource' }),
|
||||
).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Recommended Source')).not.toBeInTheDocument()
|
||||
expect(api.search).not.toHaveBeenCalled()
|
||||
await user.click(screen.getByRole('button', { name: /plugin.autoUpdate.autoUpdate/ }))
|
||||
expect(
|
||||
await screen.findByRole('dialog', { name: 'plugin.autoUpdate.autoUpdateSettings' }),
|
||||
@@ -212,105 +202,24 @@ it('filters installed sources, announces result counts, and restores them when s
|
||||
expect(screen.queryByRole('status')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('combines recommendations without installed plugins or duplicates and sends datasource searches to the marketplace', async () => {
|
||||
api.search.mockResolvedValue({
|
||||
data: {
|
||||
plugins: [
|
||||
recommendation,
|
||||
createMarketplacePluginFixture({
|
||||
type: 'bundle',
|
||||
plugin_id: 'bundle',
|
||||
name: 'bundle',
|
||||
label: { 'en-US': 'Plugin Bundle' },
|
||||
}),
|
||||
],
|
||||
total: 2,
|
||||
},
|
||||
})
|
||||
api.collection.mockResolvedValue({
|
||||
data: {
|
||||
plugins: [
|
||||
createMarketplacePluginFixture({
|
||||
plugin_id: 'plugin-1',
|
||||
label: { 'en-US': 'Already Installed' },
|
||||
}),
|
||||
recommendation,
|
||||
],
|
||||
},
|
||||
})
|
||||
it('does not list uninstalled marketplace data sources', async () => {
|
||||
const { user } = setup({ systemFeatures: { enable_marketplace: true } })
|
||||
expect(await screen.findByText('Recommended Source')).toBeInTheDocument()
|
||||
expect(screen.getAllByText('Recommended Source')).toHaveLength(1)
|
||||
expect(screen.queryByText('Already Installed')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Plugin Bundle')).not.toBeInTheDocument()
|
||||
await waitFor(() =>
|
||||
expect(api.search).toHaveBeenCalledWith(
|
||||
'/plugins/search/advanced',
|
||||
expect.objectContaining({
|
||||
body: expect.objectContaining({
|
||||
query: '',
|
||||
category: 'datasource',
|
||||
exclude: ['plugin-1', 'plugin-2'],
|
||||
page_size: 1000,
|
||||
}),
|
||||
}),
|
||||
),
|
||||
)
|
||||
await user.type(screen.getByRole('searchbox'), 'partner')
|
||||
await waitFor(() =>
|
||||
expect(api.search).toHaveBeenLastCalledWith(
|
||||
'/plugins/search/advanced',
|
||||
expect.objectContaining({
|
||||
body: expect.objectContaining({
|
||||
query: 'partner',
|
||||
category: 'datasource',
|
||||
exclude: ['plugin-1', 'plugin-2'],
|
||||
}),
|
||||
}),
|
||||
),
|
||||
)
|
||||
expect(await screen.findByRole('heading', { name: 'Dify Source' })).toBeInTheDocument()
|
||||
expect(
|
||||
screen
|
||||
.getAllByRole('status')
|
||||
.some(
|
||||
(status) =>
|
||||
status.textContent ===
|
||||
'modelProvider.modelProvider.installDataSource: plugin.marketplace.pluginsResult:{"num":1}',
|
||||
),
|
||||
).toBe(true)
|
||||
await user.click(marketplaceToggle())
|
||||
expect(marketplaceToggle()).toHaveAttribute('aria-expanded', 'false')
|
||||
screen.queryByRole('button', { name: 'modelProvider.modelProvider.installDataSource' }),
|
||||
).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Recommended Source')).not.toBeInTheDocument()
|
||||
await user.click(marketplaceToggle())
|
||||
expect(screen.getByText('Recommended Source')).toBeInTheDocument()
|
||||
expect(api.search).not.toHaveBeenCalled()
|
||||
await user.type(screen.getByRole('searchbox'), 'partner')
|
||||
expect(api.search).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it.each(['collection', 'search'] as const)(
|
||||
'keeps recommendations loading until the %s request completes and hides loading when collapsed',
|
||||
async (boundary) => {
|
||||
const response = createDeferred<{
|
||||
data: { plugins: (typeof recommendation)[]; total: number }
|
||||
}>()
|
||||
if (boundary === 'collection') api.collection.mockReturnValueOnce(response.promise)
|
||||
else api.search.mockReturnValueOnce(response.promise)
|
||||
const { user } = setup({ systemFeatures: { enable_marketplace: true } })
|
||||
await screen.findByRole('heading', { name: 'Dify Source' })
|
||||
expect(screen.getByRole('progressbar')).toBeInTheDocument()
|
||||
await user.click(marketplaceToggle())
|
||||
expect(screen.queryByRole('progressbar')).not.toBeInTheDocument()
|
||||
await act(async () => response.resolve({ data: { plugins: [recommendation], total: 1 } }))
|
||||
await user.click(marketplaceToggle())
|
||||
expect(await screen.findByText('Recommended Source')).toBeInTheDocument()
|
||||
},
|
||||
)
|
||||
|
||||
it('opens the embedded marketplace through the supplied action', async () => {
|
||||
const onOpenMarketplace = vi.fn()
|
||||
const { user } = setup({ systemFeatures: { enable_marketplace: true } }, { onOpenMarketplace })
|
||||
await user.click(
|
||||
await screen.findByRole('button', { name: 'plugin.marketplace.difyMarketplace' }),
|
||||
)
|
||||
expect(onOpenMarketplace).toHaveBeenCalledOnce()
|
||||
it('does not offer an official marketplace shortcut from data sources', async () => {
|
||||
setup({ systemFeatures: { enable_marketplace: true } }, { onOpenMarketplace: vi.fn() })
|
||||
await screen.findByRole('heading', { name: 'Dify Source' })
|
||||
expect(
|
||||
screen.queryByRole('button', { name: 'plugin.marketplace.difyMarketplace' }),
|
||||
).not.toBeInTheDocument()
|
||||
expect(
|
||||
screen.queryByRole('link', { name: 'plugin.marketplace.difyMarketplace' }),
|
||||
).not.toBeInTheDocument()
|
||||
|
||||
+1
-12
@@ -8,13 +8,11 @@ import { usePluginsWithLatestVersion } from '@/app/components/plugins/hooks'
|
||||
import { usePluginSettingsAccess } from '@/app/components/plugins/plugin-page/use-reference-setting'
|
||||
import { PluginCategoryEnum } from '@/app/components/plugins/types'
|
||||
import { STEP_BY_STEP_TOUR_TARGETS } from '@/app/components/step-by-step-tour/target-registry'
|
||||
import { useMarketplace } from '@/features/marketplace/client'
|
||||
import { useRenderI18nObject } from '@/hooks/use-i18n'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { useInstalledPluginList, useInvalidateInstalledPluginList } from '@/service/use-plugins'
|
||||
import { UpdateSettingDialog } from '../update-setting-dialog'
|
||||
import Card from './card'
|
||||
import InstallFromMarketplace from './install-from-marketplace'
|
||||
|
||||
type DataSourcePageProps = {
|
||||
layout?: (parts: { body: ReactNode; toolbar: ReactNode }) => ReactNode
|
||||
@@ -52,13 +50,12 @@ function DataSourceListSkeleton() {
|
||||
)
|
||||
}
|
||||
|
||||
const DataSourcePage = ({ layout, onOpenMarketplace, stickyToolbar }: DataSourcePageProps) => {
|
||||
const DataSourcePage = ({ layout, stickyToolbar }: DataSourcePageProps) => {
|
||||
const { t } = useTranslation(['common', 'plugin'])
|
||||
const queryClient = useQueryClient()
|
||||
const renderI18nObject = useRenderI18nObject()
|
||||
const [searchText, setSearchText] = useState('')
|
||||
const { canSetPluginPreferences } = usePluginSettingsAccess()
|
||||
const marketplace = useMarketplace()
|
||||
const { data, isLoading: isDataSourceListLoading } = useQuery(
|
||||
consoleQuery.auth.plugin.datasource.list.get.queryOptions(),
|
||||
)
|
||||
@@ -176,14 +173,6 @@ const DataSourcePage = ({ layout, onOpenMarketplace, stickyToolbar }: DataSource
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{!isDataSourceListLoading && marketplace && (
|
||||
<InstallFromMarketplace
|
||||
marketplace={marketplace}
|
||||
providers={dataSources}
|
||||
searchText={searchText}
|
||||
onOpenMarketplace={onOpenMarketplace}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
|
||||
|
||||
-36
@@ -3,15 +3,12 @@ import type { Plugin } from '@/app/components/plugins/types'
|
||||
import type { MarketplaceLinks } from '@/features/marketplace/links'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { Separator } from '@langgenius/dify-ui/separator'
|
||||
import { useTheme } from 'next-themes'
|
||||
import { memo, useCallback, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
|
||||
import List from '@/app/components/plugins/marketplace/list'
|
||||
import { usePluginSettingsAccess } from '@/app/components/plugins/plugin-page/use-reference-setting'
|
||||
import ProviderCard from '@/app/components/plugins/provider-card'
|
||||
import { PluginCategoryEnum } from '@/app/components/plugins/types'
|
||||
import Link from '@/next/link'
|
||||
import { useMarketplaceAllPlugins } from './hooks'
|
||||
|
||||
type InstallFromMarketplaceProps = {
|
||||
@@ -22,12 +19,10 @@ type InstallFromMarketplaceProps = {
|
||||
}
|
||||
const InstallFromMarketplace = ({
|
||||
marketplace,
|
||||
onOpenMarketplace,
|
||||
providers,
|
||||
searchText,
|
||||
}: InstallFromMarketplaceProps) => {
|
||||
const { t } = useTranslation(['plugin', 'modelProvider'])
|
||||
const { theme } = useTheme()
|
||||
const { canInstallPlugin } = usePluginSettingsAccess()
|
||||
const [collapse, setCollapse] = useState(false)
|
||||
const { plugins: allPlugins, isLoading: isAllPluginsLoading } = useMarketplaceAllPlugins(
|
||||
@@ -67,37 +62,6 @@ const InstallFromMarketplace = ({
|
||||
/>
|
||||
{t(($) => $['modelProvider.installDataSource'], { ns: 'modelProvider' })}
|
||||
</button>
|
||||
<div className="mb-2 flex flex-wrap items-center pt-2">
|
||||
<span className="pe-1 system-sm-regular text-text-tertiary">
|
||||
{t(($) => $['modelProvider.discoverMore'], { ns: 'modelProvider' })}
|
||||
</span>
|
||||
{onOpenMarketplace ? (
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex items-center border-0 bg-transparent p-0 system-sm-medium text-text-accent"
|
||||
onClick={onOpenMarketplace}
|
||||
>
|
||||
{t(($) => $['marketplace.difyMarketplace'], { ns: 'plugin' })}
|
||||
<span
|
||||
className="i-ri-arrow-right-up-line size-4 rtl:-scale-x-100"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</button>
|
||||
) : (
|
||||
<Link
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
href={marketplace.category(PluginCategoryEnum.datasource, { theme })}
|
||||
className="inline-flex items-center system-sm-medium text-text-accent"
|
||||
>
|
||||
{t(($) => $['marketplace.difyMarketplace'], { ns: 'plugin' })}
|
||||
<span
|
||||
className="i-ri-arrow-right-up-line size-4 rtl:-scale-x-100"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{!!searchText.trim() && !isAllPluginsLoading && !collapse && (
|
||||
<div role="status" className="sr-only">
|
||||
|
||||
@@ -13,6 +13,7 @@ import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
|
||||
import { useAtomValue } from 'jotai'
|
||||
import { lazy, Suspense, useRef } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { isOfficialDifyUrl } from '@/utils/official-link'
|
||||
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
|
||||
import BillingPage from '@/app/components/billing/billing-page'
|
||||
import CustomPage from '@/app/components/custom/custom-page'
|
||||
@@ -306,7 +307,7 @@ export default function AccountSetting({
|
||||
{activeItem?.description && (
|
||||
<p className="mt-1 system-sm-regular wrap-break-word whitespace-normal text-text-tertiary">
|
||||
{activeItem.description}
|
||||
{activeItem?.docLink && (
|
||||
{activeItem?.docLink?.href && !isOfficialDifyUrl(activeItem.docLink.href) && (
|
||||
<a
|
||||
href={activeItem.docLink.href}
|
||||
target="_blank"
|
||||
|
||||
+1
-1
@@ -393,7 +393,7 @@ describe('ModelProviderPage', () => {
|
||||
})
|
||||
expect(autoUpdateButton).toBeInTheDocument()
|
||||
expect(systemModelSelector).toBeInTheDocument()
|
||||
expect(screen.getByTestId('install-from-marketplace')).toBeInTheDocument()
|
||||
expect(screen.queryByTestId('install-from-marketplace')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should skip system model settings without plugin preference access', () => {
|
||||
|
||||
@@ -12,7 +12,6 @@ import { useTranslation } from 'react-i18next'
|
||||
import { SearchInput } from '@/app/components/base/search-input'
|
||||
import { usePluginSettingsAccess } from '@/app/components/plugins/plugin-page/use-reference-setting'
|
||||
import { PluginCategoryEnum } from '@/app/components/plugins/types'
|
||||
import { useMarketplace } from '@/features/marketplace/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { UpdateSettingDialog } from '../update-setting-dialog'
|
||||
import { ModelTypeEnum } from './declarations'
|
||||
@@ -102,7 +101,6 @@ const ModelProviderPage = ({
|
||||
}
|
||||
return map
|
||||
}, [latestVersionData, modelProviderPlugins])
|
||||
const marketplace = useMarketplace()
|
||||
const isDefaultModelLoading =
|
||||
isTextGenerationDefaultModelLoading ||
|
||||
isEmbeddingsDefaultModelLoading ||
|
||||
@@ -261,10 +259,7 @@ const ModelProviderPage = ({
|
||||
showEmptyProvider={showEmptyProvider}
|
||||
showConfiguredProviders={showConfiguredProviders}
|
||||
showNotConfiguredProviders={showNotConfiguredProviders}
|
||||
marketplace={marketplace}
|
||||
searchText={searchText}
|
||||
pluginSummaryMap={pluginSummaryMap}
|
||||
onOpenMarketplace={onOpenMarketplace}
|
||||
/>
|
||||
)
|
||||
|
||||
|
||||
-36
@@ -3,15 +3,12 @@ import type { MarketplaceLinks } from '@/features/marketplace/links'
|
||||
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, useEffect, useRef, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
|
||||
import List from '@/app/components/plugins/marketplace/list'
|
||||
import { usePluginSettingsAccess } from '@/app/components/plugins/plugin-page/use-reference-setting'
|
||||
import ProviderCard from '@/app/components/plugins/provider-card'
|
||||
import { PluginCategoryEnum } from '@/app/components/plugins/types'
|
||||
import Link from '@/next/link'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { useMarketplaceAllPlugins } from './hooks'
|
||||
|
||||
@@ -23,12 +20,10 @@ type InstallFromMarketplaceProps = {
|
||||
}
|
||||
const InstallFromMarketplace = ({
|
||||
marketplace,
|
||||
onOpenMarketplace,
|
||||
searchText,
|
||||
stepByStepTourTarget,
|
||||
}: InstallFromMarketplaceProps) => {
|
||||
const { t } = useTranslation(['plugin', 'modelProvider'])
|
||||
const { theme } = useTheme()
|
||||
const { canInstallPlugin } = usePluginSettingsAccess()
|
||||
const [collapse, setCollapse] = useState(false)
|
||||
const [hasEnteredViewport, setHasEnteredViewport] = useState(
|
||||
@@ -114,37 +109,6 @@ const InstallFromMarketplace = ({
|
||||
/>
|
||||
{t(($) => $['modelProvider.installProvider'], { ns: 'modelProvider' })}
|
||||
</button>
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="system-sm-regular text-text-tertiary">
|
||||
{t(($) => $['modelProvider.discoverMore'], { ns: 'modelProvider' })}
|
||||
</span>
|
||||
{onOpenMarketplace ? (
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex items-center border-0 bg-transparent p-0 system-sm-medium text-text-accent"
|
||||
onClick={onOpenMarketplace}
|
||||
>
|
||||
{t(($) => $['marketplace.difyMarketplace'], { ns: 'plugin' })}
|
||||
<span
|
||||
className="i-ri-arrow-right-up-line size-4 [&:dir(rtl)]:-scale-x-100"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</button>
|
||||
) : (
|
||||
<Link
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
href={marketplace.category(PluginCategoryEnum.model, { theme })}
|
||||
className="inline-flex items-center system-sm-medium text-text-accent"
|
||||
>
|
||||
{t(($) => $['marketplace.difyMarketplace'], { ns: 'plugin' })}
|
||||
<span
|
||||
className="i-ri-arrow-right-up-line size-4 [&:dir(rtl)]:-scale-x-100"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{!collapse && shouldLoadMarketplace && !hasLoadedInstalledPluginIds && (
|
||||
<LoadingPlaceholder />
|
||||
|
||||
+4
-1
@@ -1,4 +1,5 @@
|
||||
import type { FC } from 'react'
|
||||
import { isOfficialDifyUrl } from '@/utils/official-link'
|
||||
import type {
|
||||
Credential,
|
||||
CustomConfigurationModelFixedFields,
|
||||
@@ -383,7 +384,9 @@ const ModelModal: FC<ModelModalProps> = ({
|
||||
)}
|
||||
</DialogBody>
|
||||
<DialogFooter>
|
||||
{provider.help && (provider.help.title || provider.help.url) && (
|
||||
{provider.help &&
|
||||
(provider.help.title || provider.help.url) &&
|
||||
!isOfficialDifyUrl(provider.help?.url[language] || provider.help?.url.en_US) && (
|
||||
<a
|
||||
href={provider.help?.url[language] || provider.help?.url.en_US}
|
||||
target="_blank"
|
||||
|
||||
+4
-47
@@ -1,13 +1,11 @@
|
||||
import type { ModelProviderSummaryResponse } from '@dify/contracts/api/console/workspaces/types.gen'
|
||||
import type { FC } from 'react'
|
||||
import type { ModelProviderPluginSummary } from './index'
|
||||
import type { MarketplaceLinks } from '@/features/marketplace/links'
|
||||
import { useSuspenseQuery } from '@tanstack/react-query'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { SkeletonContainer, SkeletonRectangle, SkeletonRow } from '@/app/components/base/skeleton'
|
||||
import { STEP_BY_STEP_TOUR_TARGETS } from '@/app/components/step-by-step-tour/target-registry'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import InstallFromMarketplace from './install-from-marketplace'
|
||||
import ProviderAddedCard from './provider-added-card'
|
||||
import QuotaPanel from './provider-added-card/quota-panel'
|
||||
|
||||
@@ -19,10 +17,7 @@ type ModelProviderPageBodyProps = {
|
||||
showEmptyProvider: boolean
|
||||
showConfiguredProviders: boolean
|
||||
showNotConfiguredProviders: boolean
|
||||
marketplace: MarketplaceLinks | null
|
||||
searchText: string
|
||||
pluginSummaryMap: Map<string, ModelProviderPluginSummary>
|
||||
onOpenMarketplace?: () => void
|
||||
}
|
||||
|
||||
function ModelProviderCardSkeleton() {
|
||||
@@ -58,14 +53,8 @@ function ModelProviderListSkeleton() {
|
||||
)
|
||||
}
|
||||
|
||||
function EmptyProviderState({
|
||||
enableMarketplace,
|
||||
stepByStepTourTarget,
|
||||
}: {
|
||||
enableMarketplace: boolean
|
||||
stepByStepTourTarget?: string
|
||||
}) {
|
||||
const { t } = useTranslation(['plugin', 'modelProvider', 'navigation'])
|
||||
function EmptyProviderState({ stepByStepTourTarget }: { stepByStepTourTarget?: string }) {
|
||||
const { t } = useTranslation(['modelProvider'])
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -79,25 +68,7 @@ function EmptyProviderState({
|
||||
{t(($) => $['modelProvider.emptyProviderTitle'], { ns: 'modelProvider' })}
|
||||
</div>
|
||||
<p className="mt-1 system-xs-regular text-text-tertiary">
|
||||
{enableMarketplace ? (
|
||||
<Trans
|
||||
i18nKey={($) => $['modelProvider.emptyProviderTipWithMarketplace']}
|
||||
ns="modelProvider"
|
||||
components={{
|
||||
marketplace: (
|
||||
<a
|
||||
href="#model-provider-marketplace"
|
||||
aria-label={t(($) => $['marketplace.difyMarketplace'], { ns: 'plugin' })}
|
||||
className="system-xs-medium text-text-accent hover:underline"
|
||||
>
|
||||
{t(($) => $['mainNav.marketplace'], { ns: 'navigation' })}
|
||||
</a>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
t(($) => $['modelProvider.emptyProviderTip'], { ns: 'modelProvider' })
|
||||
)}
|
||||
{t(($) => $['modelProvider.emptyProviderTip'], { ns: 'modelProvider' })}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
@@ -162,10 +133,7 @@ const ModelProviderPageBody: FC<ModelProviderPageBodyProps> = ({
|
||||
showEmptyProvider,
|
||||
showConfiguredProviders,
|
||||
showNotConfiguredProviders,
|
||||
marketplace,
|
||||
searchText,
|
||||
pluginSummaryMap,
|
||||
onOpenMarketplace,
|
||||
}) => {
|
||||
const { t } = useTranslation(['modelProvider'])
|
||||
const { data: deploymentEdition } = useSuspenseQuery({
|
||||
@@ -189,7 +157,6 @@ const ModelProviderPageBody: FC<ModelProviderPageBodyProps> = ({
|
||||
)}
|
||||
{showEmptyProvider && (
|
||||
<EmptyProviderState
|
||||
enableMarketplace={marketplace !== null}
|
||||
stepByStepTourTarget={
|
||||
!showConfiguredProviders && !showNotConfiguredProviders
|
||||
? STEP_BY_STEP_TOUR_TARGETS.integrationModelProviderProduction
|
||||
@@ -221,16 +188,6 @@ const ModelProviderPageBody: FC<ModelProviderPageBodyProps> = ({
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{!isLoadingModelProviders && marketplace && (
|
||||
<div>
|
||||
<InstallFromMarketplace
|
||||
marketplace={marketplace}
|
||||
searchText={searchText}
|
||||
onOpenMarketplace={onOpenMarketplace}
|
||||
stepByStepTourTarget={STEP_BY_STEP_TOUR_TARGETS.integrationModelProviderInstall}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
+3
-4
@@ -522,10 +522,9 @@ describe('workspace credits and marketplace availability', () => {
|
||||
it('keeps marketplace discovery available without installation permission', async () => {
|
||||
await setup({ modelList: [] }, { marketplace: true, installPermission: false })
|
||||
expect(screen.queryByRole('button', { name: /selector.install/ })).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('link', { name: /discoverMoreInMarketplace/ })).toHaveAttribute(
|
||||
'href',
|
||||
expect.stringMatching(/\/plugins\/model$/),
|
||||
)
|
||||
expect(
|
||||
screen.queryByRole('link', { name: /discoverMoreInMarketplace/ }),
|
||||
).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
-41
@@ -5,7 +5,6 @@ import { cn } from '@langgenius/dify-ui/cn'
|
||||
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from '@langgenius/dify-ui/collapsible'
|
||||
import { useId } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PluginCategoryEnum } from '@/app/components/plugins/types'
|
||||
import { modelNameMap, providerLogoMap } from '../utils'
|
||||
|
||||
type MarketplaceSectionProps = {
|
||||
@@ -21,15 +20,12 @@ type MarketplaceSectionProps = {
|
||||
}
|
||||
|
||||
function MarketplaceSection({
|
||||
marketplace,
|
||||
marketplaceProviders,
|
||||
marketplaceCollapsed,
|
||||
installingProvider,
|
||||
canInstallPlugin,
|
||||
theme,
|
||||
onMarketplaceCollapsedChange,
|
||||
onInstallPlugin,
|
||||
onOpenMarketplace,
|
||||
}: MarketplaceSectionProps) {
|
||||
const { t } = useTranslation(['plugin', 'modelProvider'])
|
||||
const headingId = useId()
|
||||
@@ -116,43 +112,6 @@ function MarketplaceSection({
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
<div className="px-1 pb-1">
|
||||
{onOpenMarketplace ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="small"
|
||||
className="h-auto w-full justify-start gap-0.5 px-3 py-1.5 text-start"
|
||||
onClick={onOpenMarketplace}
|
||||
>
|
||||
<span className="flex-1 system-xs-regular text-text-accent">
|
||||
{t(($) => $['modelProvider.selector.discoverMoreInMarketplace'], {
|
||||
ns: 'modelProvider',
|
||||
})}
|
||||
</span>
|
||||
<span
|
||||
className="i-ri-arrow-right-up-line size-3! text-text-accent rtl:-scale-x-100"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</Button>
|
||||
) : (
|
||||
<a
|
||||
className="flex cursor-pointer items-center gap-0.5 rounded-md px-3 py-1.5 outline-hidden focus-visible:ring-2 focus-visible:ring-state-accent-solid"
|
||||
href={marketplace.category(PluginCategoryEnum.model, { theme })}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<span className="flex-1 system-xs-regular text-text-accent">
|
||||
{t(($) => $['modelProvider.selector.discoverMoreInMarketplace'], {
|
||||
ns: 'modelProvider',
|
||||
})}
|
||||
</span>
|
||||
<span
|
||||
className="i-ri-arrow-right-up-line size-3! text-text-accent rtl:-scale-x-100"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</CollapsiblePanel>
|
||||
</Collapsible>
|
||||
</>
|
||||
|
||||
+1
-1
@@ -306,7 +306,7 @@ function Popup({
|
||||
onClick={() => setShowIncompatibleModels((value) => !value)}
|
||||
/>
|
||||
)}
|
||||
{marketplace && (
|
||||
{marketplace && canInstallPlugin && (
|
||||
<MarketplaceSection
|
||||
marketplace={marketplace}
|
||||
marketplaceProviders={marketplaceProviders}
|
||||
|
||||
-14
@@ -15,9 +15,6 @@ import { Input } from '@langgenius/dify-ui/input'
|
||||
import { Textarea } from '@langgenius/dify-ui/textarea'
|
||||
import { useCallback, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useLocale } from '#i18n'
|
||||
import { getEnterpriseDocUrl } from '@/context/i18n'
|
||||
import { getDocLanguage } from '@/i18n/language'
|
||||
import PermissionField from './permission-field'
|
||||
|
||||
export type RoleModalMode = 'create' | 'view' | 'edit'
|
||||
@@ -38,8 +35,6 @@ type RoleModalProps = {
|
||||
|
||||
const RoleModal = ({ mode, open, role, onClose, onSubmit }: RoleModalProps) => {
|
||||
const { t } = useTranslation(['common', 'permission'])
|
||||
const locale = useLocale()
|
||||
const docLanguage = getDocLanguage(locale)
|
||||
const [name, setName] = useState(role?.name ?? '')
|
||||
const [desc, setDesc] = useState(role?.description ?? '')
|
||||
const [permissionKeys, setPermissionKeys] = useState<string[]>(role?.permission_keys ?? [])
|
||||
@@ -116,15 +111,6 @@ const RoleModal = ({ mode, open, role, onClose, onSubmit }: RoleModalProps) => {
|
||||
/>
|
||||
</DialogBody>
|
||||
<DialogFooter>
|
||||
<a
|
||||
href={getEnterpriseDocUrl('/use/workspace/permission-reference', docLanguage)}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="me-auto inline-flex items-center gap-1 system-xs-medium text-text-accent hover:underline"
|
||||
>
|
||||
<span>{t(($) => $['permissionSet.learnMore'], { ns: 'permission' })}</span>
|
||||
<span aria-hidden className="i-ri-external-link-line h-3.5 w-3.5" />
|
||||
</a>
|
||||
<Button variant="secondary" onClick={onClose}>
|
||||
{readonly
|
||||
? t(($) => $['operation.close'], { ns: 'common' })
|
||||
|
||||
@@ -10,9 +10,14 @@ describe('generateMailToLink', () => {
|
||||
|
||||
describe('mailToSupport', () => {
|
||||
it('encodes support context without allowing it to introduce extra query parameters', () => {
|
||||
const result = mailToSupport('user+support@test.com', 'Pro & Team', '1.0.0')
|
||||
const result = mailToSupport(
|
||||
'user+support@test.com',
|
||||
'Pro & Team',
|
||||
'1.0.0',
|
||||
'ops@example.com',
|
||||
)
|
||||
|
||||
expect(result.startsWith('mailto:support@dify.ai?')).toBe(true)
|
||||
expect(result.startsWith('mailto:ops@example.com?')).toBe(true)
|
||||
|
||||
const query = result.split('?')[1]
|
||||
expect(query).toBeDefined()
|
||||
@@ -26,4 +31,8 @@ describe('mailToSupport', () => {
|
||||
expect(body).toContain('Version: 1.0.0')
|
||||
expect([...params.keys()]).toEqual(['subject', 'body'])
|
||||
})
|
||||
|
||||
it('does not fall back to an official support address', () => {
|
||||
expect(mailToSupport('user@example.com', 'Pro', '1.0.0')).toBe('')
|
||||
})
|
||||
})
|
||||
@@ -24,5 +24,6 @@ export const mailToSupport = (
|
||||
Platform:
|
||||
Problem Description:
|
||||
`
|
||||
return generateMailToLink(supportEmailAddress || 'support@dify.ai', subject, body)
|
||||
if (!supportEmailAddress) return ''
|
||||
return generateMailToLink(supportEmailAddress, subject, body)
|
||||
}
|
||||
Reference in new issue
Block a user