All files / src/Upload Upload.js

100% Statements 4/4
100% Branches 10/10
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76                                                19x 19x                                                                                   1x 1x              
import React from 'react';
import { defaultProps } from './props/defaultProps';
import { propTypes } from './props/propTypes';
import { Icon } from '@zohodesk/icons';
import { Container, Box } from '@zohodesk/components/lib/Layout';
import Image from '../Image/Image';
import style from './Upload.module.css';
export default class Upload extends React.Component {
  render() {
    let {
      isPreview,
      tooltip,
      dataId,
      dataSelectorId,
      progressValue,
      onClick,
      iconName,
      fileSize,
      imgSrc,
      isPreviewType,
      onRemove,
      size,
      getRef,
      palette
    } = this.props;
    return (
      <Container
        isInline
        className={`${style.container} ${style[palette]} ${style[size]} ${isPreview ? style.preview : ''}
`}
        dataId={dataId}
        data-title={tooltip}
        isCover={false}
        eleRef={getRef}
        dataSelectorId={dataSelectorId}
      >
        <>
          {isPreview ? (
            <div data-id={`${dataId}_attachLoading`} data-test-id={`${dataId}_attachLoading`} className={style.loader} style={{ width: `${progressValue}%` }} />
          ) : null}
          {isPreviewType ? (
            <>
              <Image
                src={imgSrc}
                className={`${style.uploadimage} `}
                alt='Uploaded Image'
                dataId={`${dataId}_fileName`}
              />
              <div className={style.overlay} onClick={onClick}></div>
            </>
          ) : (
            <Box className={style.attachInfo} onClick={onClick} dataId={`${dataId}_openNewTab`}>
              <Icon name={iconName} iconClass={style.fileIcon} />
              <div className={style.attachsize}>{fileSize}</div>
            </Box>
          )}
        </>
 
        {typeof onRemove !== 'undefined' && onRemove != null ? (
          <span className={style.uploadclose} onClick={onRemove} data-id={`${dataId}_deleteUpload`} data-test-id={`${dataId}_deleteUpload`}>
            <Icon name='ZD-close' isBold />
          </span>
        ) : null}
      </Container>
    );
  }
}
Upload.propTypes = propTypes;
Upload.defaultProps = defaultProps;
 
// if (__DOCS__) {
//   Upload.docs = {
//     componentGroup: 'Upload'
//   };
// }