Skip to content

Commit fb66754

Browse files
authored
Merge pull request #2728 from appirio-tech/hotfix/CS_enable_file_upload_for_managers_only
[HotFix]Allowing upload of files only if files subSection is present in templ…
2 parents 748881e + 0dbd350 commit fb66754

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/projects/detail/containers/ProjectInfoContainer.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class ProjectInfoContainer extends React.Component {
129129
const { duration } = this.state
130130
const { project, currentMemberRole, isSuperUser, phases, feeds,
131131
hideInfo, hideLinks, hideMembers, onChannelClick, activeChannelId, productsTimelines,
132-
isManageUser, phasesTopics, isProjectPlan, isProjectProcessing } = this.props
132+
isManageUser, phasesTopics, isProjectPlan, isProjectProcessing, projectTemplates } = this.props
133133
let directLinks = null
134134
// check if direct links need to be added
135135
const isMemberOrCopilot = _.indexOf([PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER], currentMemberRole) > -1
@@ -206,6 +206,14 @@ class ProjectInfoContainer extends React.Component {
206206
}))
207207

208208
const attachmentsStorePath = `${PROJECT_ATTACHMENTS_FOLDER}/${project.id}/`
209+
let enableFileUpload = true
210+
if(project.version !== 'v2') {
211+
const templateId = _.get(project, 'templateId')
212+
const projectTemplate = _.find(projectTemplates, template => template.id === templateId)
213+
enableFileUpload = _.some(projectTemplate.scope.sections, section => {
214+
return _.some(section.subSections, subSection => subSection.id === 'files')
215+
})
216+
}
209217

210218
return (
211219
<div>
@@ -236,7 +244,7 @@ class ProjectInfoContainer extends React.Component {
236244
<FileLinksMenu
237245
links={attachments}
238246
title="Latest files"
239-
canAdd
247+
canAdd={enableFileUpload}
240248
onAddNewLink={this.onAddFile}
241249
onAddAttachment={this.onAddAttachment}
242250
moreText="view all files"
@@ -276,6 +284,10 @@ ProjectInfoContainer.PropTypes = {
276284
isProjectProcessing: PropTypes.bool,
277285
}
278286

287+
const mapStateToProps = ({templates }) => ({
288+
projectTemplates : templates.projectTemplates,
289+
})
290+
279291
const mapDispatchToProps = { updateProject, deleteProject, addProjectAttachment, loadDashboardFeeds, loadPhaseFeed }
280292

281-
export default connect(null, mapDispatchToProps)(ProjectInfoContainer)
293+
export default connect(mapStateToProps, mapDispatchToProps)(ProjectInfoContainer)

0 commit comments

Comments
 (0)