mirror of
https://github.com/langgenius/dify.git
synced 2026-05-07 02:46:32 +08: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>
68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import type { FC, ReactNode } from 'react'
|
|
import type { PluginStatus } from '@/app/components/plugins/types'
|
|
import type { Locale } from '@/i18n-config'
|
|
import PluginItem from './plugin-item'
|
|
|
|
type PluginSectionProps = {
|
|
title: string
|
|
count: number
|
|
plugins: PluginStatus[]
|
|
getIconUrl: (icon: string) => string
|
|
language: Locale
|
|
statusIcon: ReactNode
|
|
defaultStatusText: ReactNode
|
|
statusClassName?: string
|
|
headerAction?: ReactNode
|
|
renderItemAction?: (plugin: PluginStatus) => ReactNode
|
|
onClearSingle?: (taskId: string, pluginId: string) => void
|
|
}
|
|
|
|
const PluginSection: FC<PluginSectionProps> = ({
|
|
title,
|
|
count,
|
|
plugins,
|
|
getIconUrl,
|
|
language,
|
|
statusIcon,
|
|
defaultStatusText,
|
|
statusClassName,
|
|
headerAction,
|
|
renderItemAction,
|
|
onClearSingle,
|
|
}) => {
|
|
if (plugins.length === 0)
|
|
return null
|
|
|
|
return (
|
|
<>
|
|
<div className="sticky top-0 flex h-7 items-center justify-between px-2 pt-1 system-sm-semibold-uppercase text-text-secondary">
|
|
{title}
|
|
{' '}
|
|
(
|
|
{count}
|
|
)
|
|
{headerAction}
|
|
</div>
|
|
<div className="max-h-[300px] overflow-x-hidden overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
|
{plugins.map(plugin => (
|
|
<PluginItem
|
|
key={plugin.plugin_unique_identifier}
|
|
plugin={plugin}
|
|
getIconUrl={getIconUrl}
|
|
language={language}
|
|
statusIcon={statusIcon}
|
|
statusText={plugin.message || defaultStatusText}
|
|
statusClassName={statusClassName}
|
|
action={renderItemAction?.(plugin)}
|
|
onClear={onClearSingle
|
|
? () => onClearSingle(plugin.taskId, plugin.plugin_unique_identifier)
|
|
: undefined}
|
|
/>
|
|
))}
|
|
</div>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default PluginSection
|