mirror of
https://github.com/langgenius/dify.git
synced 2026-03-08 17:07:35 +08:00
fix(sandbox-provider): align frontend types with backend API after refactor
Remove label, description, and icon fields from SandboxProvider type as they are no longer returned by the backend API. Use i18n translations to display provider labels instead of relying on API response data.
This commit is contained in:
@ -14,7 +14,7 @@ import {
|
||||
useDeleteSandboxProviderConfig,
|
||||
useSaveSandboxProviderConfig,
|
||||
} from '@/service/use-sandbox-provider'
|
||||
import { PROVIDER_DOC_LINKS, SANDBOX_FIELD_CONFIGS } from './constants'
|
||||
import { PROVIDER_DOC_LINKS, PROVIDER_LABEL_KEYS, SANDBOX_FIELD_CONFIGS } from './constants'
|
||||
import ProviderIcon from './provider-icon'
|
||||
|
||||
type ConfigModalProps = {
|
||||
@ -98,7 +98,9 @@ const ConfigModal = ({
|
||||
</h3>
|
||||
<div className="flex items-center gap-2">
|
||||
<ProviderIcon providerType={provider.provider_type} size="sm" withBorder />
|
||||
<span className="system-md-regular text-text-secondary">{provider.label}</span>
|
||||
<span className="system-md-regular text-text-secondary">
|
||||
{t(PROVIDER_LABEL_KEYS[provider.provider_type as keyof typeof PROVIDER_LABEL_KEYS] ?? 'sandboxProvider.e2b.label', { ns: 'common' })}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -119,7 +121,7 @@ const ConfigModal = ({
|
||||
rel="noopener noreferrer"
|
||||
className="system-xs-regular inline-flex items-center gap-1 text-text-accent hover:underline"
|
||||
>
|
||||
{t('sandboxProvider.configModal.readDocLink', { ns: 'common', provider: provider.label })}
|
||||
{t('sandboxProvider.configModal.readDocLink', { ns: 'common', provider: t(PROVIDER_LABEL_KEYS[provider.provider_type as keyof typeof PROVIDER_LABEL_KEYS] ?? 'sandboxProvider.e2b.label', { ns: 'common' }) })}
|
||||
<RiExternalLinkLine className="h-3 w-3" />
|
||||
</a>
|
||||
)}
|
||||
|
||||
@ -7,6 +7,13 @@ export const PROVIDER_ICONS: Record<string, string> = {
|
||||
local: '/sandbox-providers/local.svg',
|
||||
}
|
||||
|
||||
export const PROVIDER_LABEL_KEYS = {
|
||||
e2b: 'sandboxProvider.e2b.label',
|
||||
daytona: 'sandboxProvider.daytona.label',
|
||||
docker: 'sandboxProvider.docker.label',
|
||||
local: 'sandboxProvider.local.label',
|
||||
} as const
|
||||
|
||||
export const PROVIDER_DESCRIPTION_KEYS = {
|
||||
e2b: 'sandboxProvider.e2b.description',
|
||||
daytona: 'sandboxProvider.daytona.description',
|
||||
|
||||
@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import Button from '@/app/components/base/button'
|
||||
import Indicator from '@/app/components/header/indicator'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { PROVIDER_DESCRIPTION_KEYS } from './constants'
|
||||
import { PROVIDER_DESCRIPTION_KEYS, PROVIDER_LABEL_KEYS } from './constants'
|
||||
import ProviderIcon from './provider-icon'
|
||||
|
||||
type ProviderCardProps = {
|
||||
@ -45,7 +45,7 @@ const ProviderCard = ({
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="system-md-semibold text-text-primary">
|
||||
{provider.label}
|
||||
{t(PROVIDER_LABEL_KEYS[provider.provider_type as keyof typeof PROVIDER_LABEL_KEYS] ?? 'sandboxProvider.e2b.label', { ns: 'common' })}
|
||||
</span>
|
||||
{provider.is_system_configured && !provider.is_tenant_configured && (
|
||||
<span className="system-2xs-medium rounded-[5px] border border-divider-deep px-[5px] py-[3px] text-text-tertiary">
|
||||
|
||||
@ -7,6 +7,7 @@ import Button from '@/app/components/base/button'
|
||||
import Modal from '@/app/components/base/modal'
|
||||
import { useToastContext } from '@/app/components/base/toast'
|
||||
import { useActivateSandboxProvider } from '@/service/use-sandbox-provider'
|
||||
import { PROVIDER_LABEL_KEYS } from './constants'
|
||||
|
||||
type SwitchModalProps = {
|
||||
provider: SandboxProvider
|
||||
@ -57,7 +58,7 @@ const SwitchModal = ({
|
||||
<Trans
|
||||
i18nKey="sandboxProvider.switchModal.confirmText"
|
||||
ns="common"
|
||||
values={{ provider: provider.label }}
|
||||
values={{ provider: t(PROVIDER_LABEL_KEYS[provider.provider_type as keyof typeof PROVIDER_LABEL_KEYS] ?? 'sandboxProvider.e2b.label', { ns: 'common' }) }}
|
||||
components={{ bold: <span className="system-sm-semibold" /> }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -5,9 +5,6 @@ export type ConfigSchema = {
|
||||
|
||||
export type SandboxProvider = {
|
||||
provider_type: string
|
||||
label: string
|
||||
description: string
|
||||
icon: string
|
||||
is_system_configured: boolean
|
||||
is_tenant_configured: boolean
|
||||
is_active: boolean
|
||||
|
||||
Reference in New Issue
Block a user