<commit_before>import React from 'react'
import cx from 'classnames'
import { Link } from 'react-router'
import get from 'lodash/get'

import { TableCell } from 'cozy-ui/transpiled/react/Table'
import MidEllipsis from 'cozy-ui/transpiled/react/MidEllipsis'
import Icon from 'cozy-ui/transpiled/react/Icon'
import AppIcon from 'cozy-ui/transpiled/react/AppIcon'
import CarbonCopyIcon from 'cozy-ui/transpiled/react/Icons/CarbonCopy'

import RenameInput from 'drive/web/modules/drive/RenameInput'
import { isDirectory } from 'drive/web/modules/drive/files'
import { CozyFile } from 'models'

import styles from 'drive/styles/filelist.styl'

const FileName = ({
  attributes,
  isRenaming,
  interactive,
  withFilePath,
  isMobile,
  formattedSize,
  formattedUpdatedAt,
  refreshFolderContent,
  isInSyncFromSharing
}) => {
  const classes = cx(
    styles['fil-content-cell'],
    styles['fil-content-file'],
    { [styles['fil-content-file-openable']]: !isRenaming && interactive },
    { [styles['fil-content-row-disabled']]: isInSyncFromSharing }
  )
  const { filename, extension } = CozyFile.splitFilename(attributes)
  const isCarbonCopy = get(attributes, 'metadata.carbonCopy')
  const isElectronicSafe = get(attributes, 'metadata.electronicSafe')

  return (
    <TableCell className={classes}>
      {isRenaming ? (
        <RenameInput
          file={attributes}
          refreshFolderContent={refreshFolderContent}
        />
      ) : (
        <div className={styles['fil-file']}>
          <div className={styles['fil-file-filename']}>
            <div className={styles['fil-file-filename-wrapper']}>
              <div
                data-test-id="fil-file-filename-and-ext"
                className={styles['fil-file-filename-and-ext']}
              >
                {filename}
                {extension && (
                  <span className={styles['fil-content-ext']}>{extension}</span>
                )}
              </div>
            </div>
          </div>
          {withFilePath &&
            attributes.displayedPath &&
            (isMobile ? (
              <MidEllipsis
                className={styles['fil-file-path']}
                text={attributes.displayedPath}
              />
            ) : (
              <Link
                to={`/folder/${attributes.dir_id}`}
                className={styles['fil-file-path']}
              >
                <MidEllipsis text={attributes.displayedPath} />
              </Link>
            ))}
          {!withFilePath &&
            (isDirectory(attributes) || (
              <div className={styles['fil-file-infos']}>
                {`${formattedUpdatedAt}${
                  formattedSize ? ` - ${formattedSize}` : ''
                }`}
                {(isCarbonCopy || isElectronicSafe) && ' - '}
                {isCarbonCopy && (
                  <Icon
                    icon={CarbonCopyIcon}
                    className={`u-mr-half ${styles['fil-file-infos--icon']}`}
                  />
                )}
                {isElectronicSafe && (
                  <AppIcon
                    app={attributes.cozyMetadata.uploadedBy.slug}
                    className={styles['fil-file-infos--icon']}
                  />
                )}
              </div>
            ))}
        </div>
      )}
    </TableCell>
  )
}

export default FileName<commit_msg>fix: Show connector icon for carbonCopy certification on mobile<commit_after>import React from 'react'
import cx from 'classnames'
import { Link } from 'react-router'
import get from 'lodash/get'

import { TableCell } from 'cozy-ui/transpiled/react/Table'
import MidEllipsis from 'cozy-ui/transpiled/react/MidEllipsis'
import Icon from 'cozy-ui/transpiled/react/Icon'
import AppIcon from 'cozy-ui/transpiled/react/AppIcon'
import CarbonCopyIcon from 'cozy-ui/transpiled/react/Icons/CarbonCopy'

import RenameInput from 'drive/web/modules/drive/RenameInput'
import { isDirectory } from 'drive/web/modules/drive/files'
import { CozyFile } from 'models'

import styles from 'drive/styles/filelist.styl'

const CertificationsIcons = ({ attributes }) => {
  const isCarbonCopy = get(attributes, 'metadata.carbonCopy')
  const isElectronicSafe = get(attributes, 'metadata.electronicSafe')

  return (
    <>
      {(isCarbonCopy || isElectronicSafe) && ' - '}
      {isCarbonCopy &&
        (isElectronicSafe ? (
          <Icon
            icon={CarbonCopyIcon}
            className={`u-mr-half ${styles['fil-file-infos--icon']}`}
          />
        ) : (
          <AppIcon
            app={attributes.cozyMetadata.uploadedBy.slug}
            className={styles['fil-file-infos--icon']}
          />
        ))}
      {isElectronicSafe && (
        <AppIcon
          app={attributes.cozyMetadata.uploadedBy.slug}
          className={styles['fil-file-infos--icon']}
        />
      )}
    </>
  )
}

const FileName = ({
  attributes,
  isRenaming,
  interactive,
  withFilePath,
  isMobile,
  formattedSize,
  formattedUpdatedAt,
  refreshFolderContent,
  isInSyncFromSharing
}) => {
  const classes = cx(
    styles['fil-content-cell'],
    styles['fil-content-file'],
    { [styles['fil-content-file-openable']]: !isRenaming && interactive },
    { [styles['fil-content-row-disabled']]: isInSyncFromSharing }
  )
  const { filename, extension } = CozyFile.splitFilename(attributes)

  return (
    <TableCell className={classes}>
      {isRenaming ? (
        <RenameInput
          file={attributes}
          refreshFolderContent={refreshFolderContent}
        />
      ) : (
        <div className={styles['fil-file']}>
          <div className={styles['fil-file-filename']}>
            <div className={styles['fil-file-filename-wrapper']}>
              <div
                data-test-id="fil-file-filename-and-ext"
                className={styles['fil-file-filename-and-ext']}
              >
                {filename}
                {extension && (
                  <span className={styles['fil-content-ext']}>{extension}</span>
                )}
              </div>
            </div>
          </div>
          {withFilePath &&
            attributes.displayedPath &&
            (isMobile ? (
              <MidEllipsis
                className={styles['fil-file-path']}
                text={attributes.displayedPath}
              />
            ) : (
              <Link
                to={`/folder/${attributes.dir_id}`}
                className={styles['fil-file-path']}
              >
                <MidEllipsis text={attributes.displayedPath} />
              </Link>
            ))}
          {!withFilePath &&
            (isDirectory(attributes) || (
              <div className={styles['fil-file-infos']}>
                {`${formattedUpdatedAt}${
                  formattedSize ? ` - ${formattedSize}` : ''
                }`}
                <CertificationsIcons attributes={attributes} />
              </div>
            ))}
        </div>
      )}
    </TableCell>
  )
}

export default FileName
{'fraction_non_alphanumeric': 0.13505419281232173, 'fraction_numerical': 0.0, 'mean_word_length': 1.9306310071040536, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1079482', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1979, 'n_words': 305}