mirror of
https://github.com/langgenius/dify.git
synced 2026-05-08 00:02:34 -04:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: CodingOnStar <hanxujiang@dify.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jerryzai <jerryzh8710@protonmail.com> Co-authored-by: NVIDIAN <speedy.hpc@hotmail.com> Co-authored-by: ai-hpc <ai-hpc@users.noreply.github.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: Junghwan <70629228+shaun0927@users.noreply.github.com> Co-authored-by: HeYinKazune <70251095+HeYin-OS@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import type { FC, ReactNode } from 'react'
|
|
import type { PluginStatus } from '@/app/components/plugins/types'
|
|
import type { Locale } from '@/i18n-config'
|
|
import CardIcon from '@/app/components/plugins/card/base/card-icon'
|
|
|
|
type PluginItemProps = {
|
|
plugin: PluginStatus
|
|
getIconUrl: (icon: string) => string
|
|
language: Locale
|
|
statusIcon: ReactNode
|
|
statusText: ReactNode
|
|
statusClassName?: string
|
|
action?: ReactNode
|
|
onClear?: () => void
|
|
}
|
|
|
|
const PluginItem: FC<PluginItemProps> = ({
|
|
plugin,
|
|
getIconUrl,
|
|
language,
|
|
statusIcon,
|
|
statusText,
|
|
statusClassName,
|
|
action,
|
|
onClear,
|
|
}) => {
|
|
return (
|
|
<div className="group/item flex gap-1 rounded-lg p-2 hover:bg-state-base-hover">
|
|
<div className="relative shrink-0 self-start">
|
|
<CardIcon
|
|
size="small"
|
|
src={getIconUrl(plugin.icon)}
|
|
/>
|
|
<div className="absolute -right-0.5 -bottom-0.5 z-10">
|
|
{statusIcon}
|
|
</div>
|
|
</div>
|
|
<div className="flex min-w-0 grow flex-col gap-0.5 px-1">
|
|
<div className="truncate system-sm-medium text-text-secondary">
|
|
{plugin.labels[language]}
|
|
</div>
|
|
<div className={`min-w-0 system-xs-regular break-words ${statusClassName || 'text-text-tertiary'}`}>
|
|
{statusText}
|
|
</div>
|
|
{action}
|
|
</div>
|
|
{onClear && (
|
|
<button
|
|
type="button"
|
|
className="invisible flex h-6 w-6 shrink-0 items-center justify-center self-start rounded-md group-hover/item:visible hover:bg-state-base-hover-alt"
|
|
onClick={onClear}
|
|
>
|
|
<span className="i-ri-close-line h-4 w-4 text-text-tertiary" />
|
|
</button>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default PluginItem
|