Skip to content

Commit 865349c

Browse files
committed
bug #3273 Show Created By for files and links list in Assets Library 6
1 parent 568c5f4 commit 865349c

File tree

1 file changed

+44
-29
lines changed

1 file changed

+44
-29
lines changed

src/projects/detail/containers/AssetsInfoContainer.jsx

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class AssetsInfoContainer extends React.Component {
6969
!_.isEqual(nextProps.attachmentsAwaitingPermission, this.props.attachmentsAwaitingPermission) ||
7070
!_.isEqual(nextProps.attachmentPermissions, this.props.attachmentPermissions) ||
7171
!_.isEqual(nextProps.isSharingAttachment, this.props.isSharingAttachment) ||
72+
!_.isEqual(nextProps.assetsMembers, this.props.assetsMembers) ||
7273
!_.isEqual(nextState.activeAssetsType, this.state.activeAssetsType) ||
7374
!_.isEqual(nextState.ifModalOpen, this.state.ifModalOpen)
7475
}
@@ -394,22 +395,9 @@ class AssetsInfoContainer extends React.Component {
394395
}
395396
}
396397

397-
render() {
398-
const { project, currentMemberRole, isSuperUser, phases, feeds,
399-
isManageUser, phasesTopics, projectTemplates, hideLinks,
400-
attachmentsAwaitingPermission, addProjectAttachment, discardAttachments, attachmentPermissions,
401-
changeAttachmentPermission, projectMembers, loggedInUser, isSharingAttachment, canAccessPrivatePosts, loadMembers, assetsMembers } = this.props
402-
const { ifModalOpen } = this.state
403-
404-
const canManageLinks = !!currentMemberRole || isSuperUser
405-
406-
let devices = []
407-
const primaryTarget = _.get(project, 'details.appDefinition.primaryTarget')
408-
if (primaryTarget && !primaryTarget.seeAttached) {
409-
devices.push(primaryTarget.value)
410-
} else {
411-
devices = _.get(project, 'details.devices', [])
412-
}
398+
getLinksAndAttachments() {
399+
const { project, isSuperUser, phases, feeds,
400+
isManageUser, phasesTopics, canAccessPrivatePosts } = this.props
413401

414402
let attachments = project.attachments
415403
// merges the product attachments to show in the links menu
@@ -456,16 +444,6 @@ class AssetsInfoContainer extends React.Component {
456444
})
457445
)
458446

459-
const attachmentsStorePath = `${PROJECT_ATTACHMENTS_FOLDER}/${project.id}/`
460-
let enableFileUpload = true
461-
if(project.version !== 'v2') {
462-
const templateId = _.get(project, 'templateId')
463-
const projectTemplate = _.find(projectTemplates, template => template.id === templateId)
464-
enableFileUpload = _.some(projectTemplate.scope.sections, section => {
465-
return _.some(section.subSections, subSection => subSection.id === 'files')
466-
})
467-
}
468-
469447
// extract links from posts
470448
const topicLinks = this.extractLinksFromPosts(feeds)
471449
const publicTopicLinks = topicLinks.filter(link => link.tag !== PROJECT_FEED_TYPE_MESSAGES)
@@ -487,6 +465,16 @@ class AssetsInfoContainer extends React.Component {
487465
...this.extractAttachmentLinksFromPosts(phaseFeeds)
488466
]
489467

468+
return ({
469+
links,
470+
attachments,
471+
})
472+
}
473+
474+
componentDidMount() {
475+
const {loadMembers } = this.props
476+
const {links, attachments} = this.getLinksAndAttachments()
477+
490478
let tmpUserIds = []
491479
let userIds = []
492480
_.forEach(links, link => {
@@ -504,9 +492,36 @@ class AssetsInfoContainer extends React.Component {
504492
userIds = _.union(userIds, [_.parseInt(userId)])
505493
})
506494
_.remove(userIds, i => !i)
507-
const missingUsers = _.filter(userIds, userId => !_.find(assetsMembers, am => am.userId === userId))
508-
if (missingUsers.length) {
509-
loadMembers(missingUsers)
495+
496+
loadMembers(userIds)
497+
}
498+
499+
render() {
500+
const { project, currentMemberRole, isSuperUser, projectTemplates, hideLinks,
501+
attachmentsAwaitingPermission, addProjectAttachment, discardAttachments, attachmentPermissions,
502+
changeAttachmentPermission, projectMembers, loggedInUser, isSharingAttachment, assetsMembers } = this.props
503+
const { ifModalOpen } = this.state
504+
505+
const canManageLinks = !!currentMemberRole || isSuperUser
506+
507+
let devices = []
508+
const primaryTarget = _.get(project, 'details.appDefinition.primaryTarget')
509+
if (primaryTarget && !primaryTarget.seeAttached) {
510+
devices.push(primaryTarget.value)
511+
} else {
512+
devices = _.get(project, 'details.devices', [])
513+
}
514+
515+
const {links, attachments} = this.getLinksAndAttachments()
516+
517+
const attachmentsStorePath = `${PROJECT_ATTACHMENTS_FOLDER}/${project.id}/`
518+
let enableFileUpload = true
519+
if(project.version !== 'v2') {
520+
const templateId = _.get(project, 'templateId')
521+
const projectTemplate = _.find(projectTemplates, template => template.id === templateId)
522+
enableFileUpload = _.some(projectTemplate.scope.sections, section => {
523+
return _.some(section.subSections, subSection => subSection.id === 'files')
524+
})
510525
}
511526

512527
const assetsData = []

0 commit comments

Comments
 (0)