dify/web/features/agent-v2/agent-detail/logs/components/source-icon.tsx
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

33 lines
1.0 KiB
TypeScript

import type {
AgentIconType,
AgentLogSourceResponse,
} from '@dify/contracts/api/console/agent/types.gen'
import AppIcon from '@/app/components/base/app-icon'
const getLogSourceImageUrl = (source?: AgentLogSourceResponse | null) =>
source?.app_icon_type === 'image' || source?.app_icon_type === 'link'
? source.app_icon
: undefined
const getLogSourceIconType = (source?: AgentLogSourceResponse | null) => {
const imageUrl = getLogSourceImageUrl(source)
return (imageUrl ? 'image' : source?.app_icon_type) as AgentIconType | null | undefined
}
export function LogSourceIcon({ source }: { source?: AgentLogSourceResponse | null }) {
if (!source)
return <span aria-hidden className="i-ri-apps-2-line size-5 shrink-0 text-text-quaternary" />
return (
<AppIcon
size="xs"
rounded
iconType={getLogSourceIconType(source)}
icon={source.app_icon ?? undefined}
background={source.app_icon_background}
imageUrl={getLogSourceImageUrl(source)}
className="size-5 text-sm"
/>
)
}