mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
- 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
36 lines
851 B
TypeScript
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
|