diff --git a/web/app/components/base/user-avatar-list/index.tsx b/web/app/components/base/user-avatar-list/index.tsx new file mode 100644 index 0000000000..5b3724bd58 --- /dev/null +++ b/web/app/components/base/user-avatar-list/index.tsx @@ -0,0 +1,65 @@ +import type { FC } from 'react' +import { memo } from 'react' +import Avatar from '@/app/components/base/avatar' + +type User = { + id: string + name: string + avatar_url?: string | null +} + +type UserAvatarListProps = { + users: User[] + maxVisible?: number + size?: number + className?: string + showCount?: boolean +} + +export const UserAvatarList: FC = memo(({ + users, + maxVisible = 3, + size = 24, + className = '', + showCount = true, +}) => { + if (!users.length) return null + + const shouldShowCount = showCount && users.length > maxVisible + const actualMaxVisible = shouldShowCount ? Math.max(1, maxVisible - 1) : maxVisible + const visibleUsers = users.slice(0, actualMaxVisible) + const remainingCount = users.length - actualMaxVisible + + return ( +
+ {visibleUsers.map((user, index) => ( +
+ +
+ ))} + {shouldShowCount && remainingCount > 0 && ( +
+ +{remainingCount} +
+ )} +
+ ) +}) + +UserAvatarList.displayName = 'UserAvatarList' diff --git a/web/app/components/workflow/panel/comments-panel/index.tsx b/web/app/components/workflow/panel/comments-panel/index.tsx index 0c79b55f9f..cdea73557a 100644 --- a/web/app/components/workflow/panel/comments-panel/index.tsx +++ b/web/app/components/workflow/panel/comments-panel/index.tsx @@ -3,7 +3,7 @@ import { RiCheckLine, RiCheckboxCircleFill, RiCheckboxCircleLine, RiCloseLine, R import { useStore } from '@/app/components/workflow/store' import type { WorkflowCommentList } from '@/service/workflow-comment' import { useWorkflowComment } from '@/app/components/workflow/hooks/use-workflow-comment' -import Avatar from '@/app/components/base/avatar' +import { UserAvatarList } from '@/app/components/base/user-avatar-list' import cn from '@/utils/classnames' import { ControlMode } from '@/app/components/workflow/types' import { resolveWorkflowComment } from '@/service/workflow-comment' @@ -114,59 +114,23 @@ const CommentsPanel = () => { onClick={() => handleSelect(c)} >
- {/* Participants stacked avatars above creator name */} - {(() => { - const creator = { - id: c.created_by, - name: c.created_by_account?.name || 'User', - avatar_url: c.created_by_account?.avatar_url || null, - } - const collaborators = (c.participants || []).filter(p => p.id !== creator.id) - const all = [creator, ...collaborators] - if (!all.length) return null - const shouldShowCount = all.length >= 4 - const maxVisible = shouldShowCount ? 2 : 3 - const visibleUsers = all.slice(0, maxVisible) - const remainingCount = all.length - maxVisible - return ( -
-
- {visibleUsers.map((p, index) => ( -
- -
- ))} - {remainingCount > 0 && ( -
- +{remainingCount} -
- )} -
-
- {c.resolved ? ( - - ) : ( - handleResolve(c)} - /> - )} -
-
- ) - })()} +
+ +
+ {c.resolved ? ( + + ) : ( + handleResolve(c)} + /> + )} +
+
{/* Header row: creator + time */}