Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.7 KB
Raw Blame
import type { ReactNode } from 'react'
import { cn } from '@langgenius/dify-ui/cn'
import { useTranslation } from 'react-i18next'

type MemberItemProps = {
  disabled?: boolean
  leftIcon: ReactNode
  name: string
  email: string
  isSelected: boolean
  isMe?: boolean
  onClick?: () => void
}

const MemberItem = ({
  disabled = false,
  leftIcon,
  name,
  email,
  isSelected,
  isMe = false,
  onClick,
}: MemberItemProps) => {
  const { t } = useTranslation(['datasetSettings'])

  const content = (
    <>
      {leftIcon}
      <div className="min-w-0 grow">
        <div className="truncate system-sm-medium text-text-secondary">
          {name}
          {isMe && (
            <span className="system-xs-regular text-text-tertiary">
              {t(($) => $['form.me'], { ns: 'datasetSettings' })}
            </span>
          )}
        </div>
        <div className="truncate system-xs-regular text-text-tertiary">{email}</div>
      </div>
      {isSelected && (
        <span
          aria-hidden="true"
          className={cn('i-ri-check-line size-4 shrink-0 text-text-accent', isMe && 'opacity-30')}
        />
      )}
    </>
  )

  if (isMe) {
    return <div className="flex items-center gap-2 rounded-lg py-1 ps-2 pe-2.5">{content}</div>
  }

  return (
    <button
      type="button"
      disabled={disabled}
      className="flex w-full cursor-pointer touch-manipulation items-center gap-2 rounded-lg border-none bg-transparent py-1 ps-2 pe-2.5 text-start outline-hidden hover:bg-state-base-hover focus-visible:ring-2 focus-visible:ring-state-accent-solid"
      aria-pressed={isSelected}
      onClick={onClick}
    >
      {content}
    </button>
  )
}

export default MemberItem