/** * * Li * */ import React from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; import { CopyToClipboard } from 'react-copy-to-clipboard'; import cn from 'classnames'; import FileIcon from 'components/FileIcon'; import IcoContainer from 'components/IcoContainer'; import PopUpWarning from 'components/PopUpWarning'; import styles from './styles.scss'; class Li extends React.Component { state = { isOpen: false, copied: false }; componentDidUpdate(prevProps, prevState) { if (prevState.copied !== this.state.copied && this.state.copied) { setTimeout(() => { this.setState({ copied: false }); }, 3000); } } handleClick = (e) => { e.preventDefault(); this.refs.aTag.click(); } handleDelete = (e) => { e.preventDefault(); this.context.deleteData(this.props.item); } renderLiCopied = () => (
  • ); render() { const { item } = this.props; if (this.state.copied) { return this.renderLiCopied(); } const icons = [ { icoType: item.private ? 'lock' : 'unlock', onClick: () => {}, }, { icoType: 'eye', onClick: this.handleClick, }, { icoType: 'trash', onClick: () => this.setState({ isOpen: true }), }, ]; return ( this.setState({copied: true})}>
  • {Object.keys(item).map((value, key) => { if (key === 0) { return ; } if (value !== 'url') { return (
    {item[value]}
    ); } return })}
    this.setState({ isOpen: false })} />
  • ); } } Li.contextTypes = { deleteData: PropTypes.func.isRequired, }; Li.defaultProps = { item: { type: 'pdf', hash: '1234', name: 'avatar.pdf', updated: '20/11/2017 19:29:54', size: '24 B', relatedTo: 'John Doe', }, }; Li.proptypes = { item: PropTypes.object, }; export default Li;