From 123d54e78cf7e17334ae3b7ed510ff85511b2b42 Mon Sep 17 00:00:00 2001 From: Maksym Mykhailenko Date: Thu, 9 Nov 2017 12:14:58 +0800 Subject: [PATCH] issue #1289 - added date and user tooltip to FileListItem component --- src/components/FileList/FileList.scss | 11 ++++++++++ src/components/FileList/FileListItem.jsx | 20 +++++++++++++++-- src/config/constants.js | 5 ++++- .../detail/components/FileListContainer.jsx | 22 ++++++++++++++++--- 4 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/components/FileList/FileList.scss b/src/components/FileList/FileList.scss index 4bcc6158b..79f8f5009 100644 --- a/src/components/FileList/FileList.scss +++ b/src/components/FileList/FileList.scss @@ -59,6 +59,17 @@ font-size: 15px; color: $tc-gray-60; margin-left: auto; + text-align: right; + + .Tooltip { + line-height: 100%; + } + + .date { + font-size: 9px; + line-height: normal; + margin-top: 5px; + } } .edit-icons { diff --git a/src/components/FileList/FileListItem.jsx b/src/components/FileList/FileListItem.jsx index 96377f0a6..d9fdf13c3 100644 --- a/src/components/FileList/FileListItem.jsx +++ b/src/components/FileList/FileListItem.jsx @@ -1,7 +1,10 @@ import _ from 'lodash' import React, {PropTypes} from 'react' import filesize from 'filesize' -import { Icons } from 'appirio-tech-react-components' +import moment from 'moment' +import { Icons, Tooltip } from 'appirio-tech-react-components' +import UserWithName from '../User/UserWithName' +import { TOOLTIP_DEFAULT_DELAY } from '../../config/constants' const { TrashIcon, CloseIcon, EditIcon, SaveIcon } = Icons @@ -88,13 +91,22 @@ export default class FileListItem extends React.Component { } renderReadOnly() { - const {title, downloadUrl, description, size, isEditable} = this.props + const {title, downloadUrl, description, size, isEditable, updatedAt, createdAt, createdByUser, updatedByUser} = this.props + return (

{title}

{filesize(size)} + +
+

{moment(updatedAt || createdAt).format('MMM DD, YYYY')}

+
+
+ +
+
{isEditable &&
@@ -136,6 +148,10 @@ FileListItem.propTypes = { size: PropTypes.number.isRequired, contentType: PropTypes.string, isEditable: PropTypes.bool, + updatedAt: PropTypes.string, + createdAt: PropTypes.string.isRequired, + updatedByUser: PropTypes.object, + createdByUser: PropTypes.object.isRequired, /** * Callback fired when a save button is clicked diff --git a/src/config/constants.js b/src/config/constants.js index 120a32549..70a5eb4bd 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -264,4 +264,7 @@ export const NEW_PROJECT_PATH = '/new-project' // Analytics constants export const GA_CLICK_ID = '_gclid' -export const GA_CLIENT_ID = '_gacid' \ No newline at end of file +export const GA_CLIENT_ID = '_gacid' + +// ToolTip +export const TOOLTIP_DEFAULT_DELAY = 300 // in ms diff --git a/src/projects/detail/components/FileListContainer.jsx b/src/projects/detail/components/FileListContainer.jsx index 95f578e5d..2d95b9786 100644 --- a/src/projects/detail/components/FileListContainer.jsx +++ b/src/projects/detail/components/FileListContainer.jsx @@ -38,8 +38,18 @@ class FileListContainer extends Component { } render() { - const { files, projectId } = this.props + const { files, projectId, allMembers } = this.props const storePath = `${PROJECT_ATTACHMENTS_FOLDER}/${projectId}/` + files.forEach(file => { + if (allMembers[file.updatedBy]) { + file.updatedByUser = allMembers[file.updatedBy] + } + + if (allMembers[file.createdBy]) { + file.createdByUser = allMembers[file.createdBy] + } + }) + return (
@@ -51,10 +61,16 @@ class FileListContainer extends Component { const mapDispatchToProps = {addProjectAttachment, updateProjectAttachment, removeProjectAttachment} +const mapStateToProps = ({ members }) => { + return { + allMembers : members.members + } +} FileListContainer.propTypes = { projectId: PropTypes.number.isRequired, - files: PropTypes.arrayOf(PropTypes.object).isRequired + files: PropTypes.arrayOf(PropTypes.object).isRequired, + allMembers: PropTypes.object.isRequired } -export default connect(null, mapDispatchToProps)(FileListContainer) +export default connect(mapStateToProps, mapDispatchToProps)(FileListContainer)