Skip to content

Commit 06d58f3

Browse files
authored
Merge pull request #2722 from appirio-tech/hotfix/disable_file_upload_for_non-managers_CS
Allowing upload of files only if files subSection is present in template
2 parents 1058a16 + 712e015 commit 06d58f3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/projects/detail/containers/ProjectInfoContainer.js

Lines changed: 11 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,11 @@ class ProjectInfoContainer extends React.Component {
206206
}))
207207

208208
const attachmentsStorePath = `${PROJECT_ATTACHMENTS_FOLDER}/${project.id}/`
209+
const templateId = _.get(project, 'templateId')
210+
const projectTemplate = _.find(projectTemplates, pt => pt.id === templateId)
211+
const subSectionsTemplate = projectTemplate.scope.sections[0].subSections
212+
//Allowing upload of files only if files subSection is present in template
213+
const shouldUploadFiles = _.some(subSectionsTemplate, st => st.id === 'files')
209214

210215
return (
211216
<div>
@@ -236,7 +241,7 @@ class ProjectInfoContainer extends React.Component {
236241
<FileLinksMenu
237242
links={attachments}
238243
title="Latest files"
239-
canAdd
244+
canAdd={shouldUploadFiles}
240245
onAddNewLink={this.onAddFile}
241246
onAddAttachment={this.onAddAttachment}
242247
moreText="view all files"
@@ -275,7 +280,10 @@ ProjectInfoContainer.PropTypes = {
275280
isProjectPlan: PropTypes.bool,
276281
isProjectProcessing: PropTypes.bool,
277282
}
283+
const mapStateToProps = ({templates }) => ({
284+
projectTemplates : templates.projectTemplates,
285+
})
278286

279287
const mapDispatchToProps = { updateProject, deleteProject, addProjectAttachment, loadDashboardFeeds, loadPhaseFeed }
280288

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

0 commit comments

Comments
 (0)