mirror of
https://github.com/langgenius/dify.git
synced 2026-04-15 18:06:36 +08:00
chore: fix import avatar error
This commit is contained in:
parent
53277d77c9
commit
f46c45dd11
@ -5,7 +5,6 @@ import type { HtmlContentProps } from '@/app/components/base/popover'
|
|||||||
import type { Tag } from '@/app/components/base/tag-management/constant'
|
import type { Tag } from '@/app/components/base/tag-management/constant'
|
||||||
import type { CreateAppModalProps } from '@/app/components/explore/create-app-modal'
|
import type { CreateAppModalProps } from '@/app/components/explore/create-app-modal'
|
||||||
import type { EnvironmentVariable } from '@/app/components/workflow/types'
|
import type { EnvironmentVariable } from '@/app/components/workflow/types'
|
||||||
import type { WorkflowOnlineUser } from '@/models/app'
|
|
||||||
import type { App } from '@/types/app'
|
import type { App } from '@/types/app'
|
||||||
import { RiBuildingLine, RiGlobalLine, RiLockLine, RiMoreFill, RiVerifiedBadgeLine } from '@remixicon/react'
|
import { RiBuildingLine, RiGlobalLine, RiLockLine, RiMoreFill, RiVerifiedBadgeLine } from '@remixicon/react'
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
@ -27,7 +26,6 @@ import {
|
|||||||
AlertDialogDescription,
|
AlertDialogDescription,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from '@/app/components/base/ui/alert-dialog'
|
} from '@/app/components/base/ui/alert-dialog'
|
||||||
import { UserAvatarList } from '@/app/components/base/user-avatar-list'
|
|
||||||
import { toast } from '@/app/components/base/ui/toast'
|
import { toast } from '@/app/components/base/ui/toast'
|
||||||
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
|
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
|
||||||
import { useAppContext } from '@/context/app-context'
|
import { useAppContext } from '@/context/app-context'
|
||||||
@ -68,10 +66,9 @@ const AccessControl = dynamic(() => import('@/app/components/app/app-access-cont
|
|||||||
type AppCardProps = {
|
type AppCardProps = {
|
||||||
app: App
|
app: App
|
||||||
onRefresh?: () => void
|
onRefresh?: () => void
|
||||||
onlineUsers?: WorkflowOnlineUser[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AppCard = ({ app, onRefresh, onlineUsers = [] }: AppCardProps) => {
|
const AppCard = ({ app, onRefresh }: AppCardProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const deleteAppNameInputId = useId()
|
const deleteAppNameInputId = useId()
|
||||||
const systemFeatures = useGlobalPublicStore(s => s.systemFeatures)
|
const systemFeatures = useGlobalPublicStore(s => s.systemFeatures)
|
||||||
@ -363,19 +360,6 @@ const AppCard = ({ app, onRefresh, onlineUsers = [] }: AppCardProps) => {
|
|||||||
return `${t('segment.editedAt', { ns: 'datasetDocuments' })} ${timeText}`
|
return `${t('segment.editedAt', { ns: 'datasetDocuments' })} ${timeText}`
|
||||||
}, [app.updated_at, app.created_at, t])
|
}, [app.updated_at, app.created_at, t])
|
||||||
|
|
||||||
const onlineUserAvatars = useMemo(() => {
|
|
||||||
if (!onlineUsers.length)
|
|
||||||
return []
|
|
||||||
|
|
||||||
return onlineUsers
|
|
||||||
.map(user => ({
|
|
||||||
id: user.user_id || user.sid || '',
|
|
||||||
name: user.username || 'User',
|
|
||||||
avatar_url: user.avatar || undefined,
|
|
||||||
}))
|
|
||||||
.filter(user => !!user.id)
|
|
||||||
}, [onlineUsers])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
@ -428,11 +412,6 @@ const AppCard = ({ app, onRefresh, onlineUsers = [] }: AppCardProps) => {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
{onlineUserAvatars.length > 0 && (
|
|
||||||
<UserAvatarList users={onlineUserAvatars} maxVisible={3} size={20} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="title-wrapper h-[90px] px-[14px] text-xs leading-normal text-text-tertiary">
|
<div className="title-wrapper h-[90px] px-[14px] text-xs leading-normal text-text-tertiary">
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
|
import type { AvatarSize } from '@/app/components/base/ui/avatar'
|
||||||
import { memo } from 'react'
|
import { memo } from 'react'
|
||||||
import Avatar from '@/app/components/base/avatar'
|
import Avatar from '@/app/components/base/ui/avatar'
|
||||||
import { getUserColor } from '@/app/components/workflow/collaboration/utils/user-color'
|
import { getUserColor } from '@/app/components/workflow/collaboration/utils/user-color'
|
||||||
import { useAppContext } from '@/context/app-context'
|
import { useAppContext } from '@/context/app-context'
|
||||||
|
|
||||||
@ -13,15 +14,26 @@ type User = {
|
|||||||
type UserAvatarListProps = {
|
type UserAvatarListProps = {
|
||||||
users: User[]
|
users: User[]
|
||||||
maxVisible?: number
|
maxVisible?: number
|
||||||
size?: number
|
size?: AvatarSize
|
||||||
className?: string
|
className?: string
|
||||||
showCount?: boolean
|
showCount?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const avatarSizeToPx: Record<AvatarSize, number> = {
|
||||||
|
'xxs': 16,
|
||||||
|
'xs': 20,
|
||||||
|
'sm': 24,
|
||||||
|
'md': 32,
|
||||||
|
'lg': 36,
|
||||||
|
'xl': 40,
|
||||||
|
'2xl': 48,
|
||||||
|
'3xl': 64,
|
||||||
|
}
|
||||||
|
|
||||||
export const UserAvatarList: FC<UserAvatarListProps> = memo(({
|
export const UserAvatarList: FC<UserAvatarListProps> = memo(({
|
||||||
users,
|
users,
|
||||||
maxVisible = 3,
|
maxVisible = 3,
|
||||||
size = 24,
|
size = 'sm',
|
||||||
className = '',
|
className = '',
|
||||||
showCount = true,
|
showCount = true,
|
||||||
}) => {
|
}) => {
|
||||||
@ -64,8 +76,8 @@ export const UserAvatarList: FC<UserAvatarListProps> = memo(({
|
|||||||
className="flex items-center justify-center rounded-full bg-gray-500 text-[10px] leading-none text-white ring-2 ring-components-panel-bg"
|
className="flex items-center justify-center rounded-full bg-gray-500 text-[10px] leading-none text-white ring-2 ring-components-panel-bg"
|
||||||
style={{
|
style={{
|
||||||
zIndex: 0,
|
zIndex: 0,
|
||||||
width: size,
|
width: avatarSizeToPx[size],
|
||||||
height: size,
|
height: avatarSizeToPx[size],
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
+
|
+
|
||||||
|
|||||||
@ -221,7 +221,7 @@ export const CommentIcon: FC<CommentIconProps> = memo(({ comment, onClick, isAct
|
|||||||
<UserAvatarList
|
<UserAvatarList
|
||||||
users={participants}
|
users={participants}
|
||||||
maxVisible={3}
|
maxVisible={3}
|
||||||
size={24}
|
size="sm"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -35,7 +35,7 @@ vi.mock('@/context/app-context', () => ({
|
|||||||
}),
|
}),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
vi.mock('@/app/components/base/avatar', () => ({
|
vi.mock('@/app/components/base/ui/avatar', () => ({
|
||||||
default: ({ name }: { name: string }) => <div data-testid="avatar">{name}</div>,
|
default: ({ name }: { name: string }) => <div data-testid="avatar">{name}</div>,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import type { FC, PointerEvent as ReactPointerEvent } from 'react'
|
import type { FC, PointerEvent as ReactPointerEvent } from 'react'
|
||||||
import { memo, useCallback, useEffect, useRef, useState } from 'react'
|
import { memo, useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import Avatar from '@/app/components/base/avatar'
|
import Avatar from '@/app/components/base/ui/avatar'
|
||||||
import { useAppContext } from '@/context/app-context'
|
import { useAppContext } from '@/context/app-context'
|
||||||
import { cn } from '@/utils/classnames'
|
import { cn } from '@/utils/classnames'
|
||||||
import { MentionInput } from './mention-input'
|
import { MentionInput } from './mention-input'
|
||||||
@ -153,7 +153,7 @@ export const CommentInput: FC<CommentInputProps> = memo(({
|
|||||||
<Avatar
|
<Avatar
|
||||||
avatar={userProfile.avatar_url}
|
avatar={userProfile.avatar_url}
|
||||||
name={userProfile.name}
|
name={userProfile.name}
|
||||||
size={24}
|
size="sm"
|
||||||
className="block size-full rounded-full"
|
className="block size-full rounded-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -38,7 +38,7 @@ const CommentPreview: FC<CommentPreviewProps> = ({ comment, onClick }) => {
|
|||||||
<UserAvatarList
|
<UserAvatarList
|
||||||
users={participants}
|
users={participants}
|
||||||
maxVisible={3}
|
maxVisible={3}
|
||||||
size={24}
|
size="sm"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -17,9 +17,9 @@ import {
|
|||||||
import { createPortal } from 'react-dom'
|
import { createPortal } from 'react-dom'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import Textarea from 'react-textarea-autosize'
|
import Textarea from 'react-textarea-autosize'
|
||||||
import Avatar from '@/app/components/base/avatar'
|
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import EnterKey from '@/app/components/base/icons/src/public/common/EnterKey'
|
import EnterKey from '@/app/components/base/icons/src/public/common/EnterKey'
|
||||||
|
import Avatar from '@/app/components/base/ui/avatar'
|
||||||
import { useParams } from '@/next/navigation'
|
import { useParams } from '@/next/navigation'
|
||||||
import { fetchMentionableUsers } from '@/service/workflow-comment'
|
import { fetchMentionableUsers } from '@/service/workflow-comment'
|
||||||
import { cn } from '@/utils/classnames'
|
import { cn } from '@/utils/classnames'
|
||||||
@ -636,7 +636,7 @@ const MentionInputInner = forwardRef<HTMLTextAreaElement, MentionInputProps>(({
|
|||||||
<Avatar
|
<Avatar
|
||||||
avatar={user.avatar_url || null}
|
avatar={user.avatar_url || null}
|
||||||
name={user.name}
|
name={user.name}
|
||||||
size={24}
|
size="sm"
|
||||||
className="shrink-0"
|
className="shrink-0"
|
||||||
/>
|
/>
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
|
|||||||
@ -6,9 +6,9 @@ import { RiArrowDownSLine, RiArrowUpSLine, RiCheckboxCircleFill, RiCheckboxCircl
|
|||||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useReactFlow, useViewport } from 'reactflow'
|
import { useReactFlow, useViewport } from 'reactflow'
|
||||||
import Avatar from '@/app/components/base/avatar'
|
|
||||||
import Divider from '@/app/components/base/divider'
|
import Divider from '@/app/components/base/divider'
|
||||||
import InlineDeleteConfirm from '@/app/components/base/inline-delete-confirm'
|
import InlineDeleteConfirm from '@/app/components/base/inline-delete-confirm'
|
||||||
|
import Avatar from '@/app/components/base/ui/avatar'
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
@ -127,7 +127,7 @@ const ThreadMessage: FC<{
|
|||||||
<Avatar
|
<Avatar
|
||||||
name={authorName}
|
name={authorName}
|
||||||
avatar={avatarUrl || null}
|
avatar={avatarUrl || null}
|
||||||
size={24}
|
size="sm"
|
||||||
className={cn('h-8 w-8 rounded-full')}
|
className={cn('h-8 w-8 rounded-full')}
|
||||||
backgroundColor={userColor}
|
backgroundColor={userColor}
|
||||||
/>
|
/>
|
||||||
@ -558,7 +558,7 @@ export const CommentThread: FC<CommentThreadProps> = memo(({
|
|||||||
<Avatar
|
<Avatar
|
||||||
name={reply.created_by_account?.name || t('comments.fallback.user', { ns: 'workflow' })}
|
name={reply.created_by_account?.name || t('comments.fallback.user', { ns: 'workflow' })}
|
||||||
avatar={reply.created_by_account?.avatar_url || null}
|
avatar={reply.created_by_account?.avatar_url || null}
|
||||||
size={24}
|
size="sm"
|
||||||
className="h-8 w-8 rounded-full"
|
className="h-8 w-8 rounded-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -607,7 +607,7 @@ export const CommentThread: FC<CommentThreadProps> = memo(({
|
|||||||
<Avatar
|
<Avatar
|
||||||
avatar={userProfile?.avatar_url || null}
|
avatar={userProfile?.avatar_url || null}
|
||||||
name={userProfile?.name || t('you', { ns: 'common' })}
|
name={userProfile?.name || t('you', { ns: 'common' })}
|
||||||
size={24}
|
size="sm"
|
||||||
className="h-8 w-8"
|
className="h-8 w-8"
|
||||||
/>
|
/>
|
||||||
<div className="flex-1 rounded-xl border border-components-chat-input-border bg-components-panel-bg-blur p-[2px] shadow-sm">
|
<div className="flex-1 rounded-xl border border-components-chat-input-border bg-components-panel-bg-blur p-[2px] shadow-sm">
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import type { OnlineUser } from '../collaboration/types/collaboration'
|
|||||||
import { ChevronDownIcon } from '@heroicons/react/20/solid'
|
import { ChevronDownIcon } from '@heroicons/react/20/solid'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useReactFlow } from 'reactflow'
|
import { useReactFlow } from 'reactflow'
|
||||||
import Avatar from '@/app/components/base/avatar'
|
import Avatar from '@/app/components/base/ui/avatar'
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
@ -134,7 +134,7 @@ const OnlineUsers = () => {
|
|||||||
<Avatar
|
<Avatar
|
||||||
name={user.username || 'User'}
|
name={user.username || 'User'}
|
||||||
avatar={getAvatarUrl(user)}
|
avatar={getAvatarUrl(user)}
|
||||||
size={24}
|
size="sm"
|
||||||
className="ring-1 ring-components-panel-bg"
|
className="ring-1 ring-components-panel-bg"
|
||||||
backgroundColor={userColor}
|
backgroundColor={userColor}
|
||||||
/>
|
/>
|
||||||
@ -204,7 +204,7 @@ const OnlineUsers = () => {
|
|||||||
<Avatar
|
<Avatar
|
||||||
name={user.username || 'User'}
|
name={user.username || 'User'}
|
||||||
avatar={getAvatarUrl(user)}
|
avatar={getAvatarUrl(user)}
|
||||||
size={24}
|
size="sm"
|
||||||
backgroundColor={userColor}
|
backgroundColor={userColor}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -509,7 +509,7 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||||||
<UserAvatarList
|
<UserAvatarList
|
||||||
users={viewingUsers}
|
users={viewingUsers}
|
||||||
maxVisible={3}
|
maxVisible={3}
|
||||||
size={24}
|
size="sm"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -279,7 +279,7 @@ const BaseNode: FC<BaseNodeProps> = ({
|
|||||||
<UserAvatarList
|
<UserAvatarList
|
||||||
users={viewingUsers}
|
users={viewingUsers}
|
||||||
maxVisible={3}
|
maxVisible={3}
|
||||||
size={24}
|
size="sm"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -150,7 +150,7 @@ const CommentsPanel = () => {
|
|||||||
<UserAvatarList
|
<UserAvatarList
|
||||||
users={c.participants}
|
users={c.participants}
|
||||||
maxVisible={3}
|
maxVisible={3}
|
||||||
size={24}
|
size="sm"
|
||||||
/>
|
/>
|
||||||
<div className="ml-2 flex items-center">
|
<div className="ml-2 flex items-center">
|
||||||
{c.resolved
|
{c.resolved
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user