dify/web/app/components/header/account-setting/sandbox-provider-page/provider-icon.tsx
yyh 48295e5161
refactor(sandbox-provider): extract shared constants and remove redundant cache invalidation
- Extract PROVIDER_ICONS and PROVIDER_DESCRIPTION_KEYS to constants.ts
- Create shared ProviderIcon component with size and withBorder props
- Remove manual invalidateList() calls from config-modal and switch-modal
  (mutations already invalidate cache in onSuccess)
- Remove unused useInvalidSandboxProviderList hook
2026-01-13 16:18:08 +08:00

36 lines
851 B
TypeScript

import { cn } from '@/utils/classnames'
import { PROVIDER_ICONS } from './constants'
type ProviderIconProps = {
providerType: string
size?: 'sm' | 'md'
withBorder?: boolean
}
const ProviderIcon = ({ providerType, size = 'md', withBorder = false }: ProviderIconProps) => {
const iconSrc = PROVIDER_ICONS[providerType] || PROVIDER_ICONS.e2b
const sizeClass = size === 'sm' ? 'h-4 w-4' : 'h-6 w-6'
if (withBorder) {
return (
<div className={cn('shrink-0 text-clip rounded border-[0.5px] border-divider-subtle', sizeClass)}>
<img
src={iconSrc}
alt={`${providerType} icon`}
className="h-full w-full object-cover"
/>
</div>
)
}
return (
<img
src={iconSrc}
alt={`${providerType} icon`}
className={sizeClass}
/>
)
}
export default ProviderIcon