Skip to content

Commit

Permalink
Merge pull request #3 from appirio-tech/disable-delete
Browse files Browse the repository at this point in the history
Add disable option for deleting uploaded files
  • Loading branch information
samsep committed Feb 10, 2016
2 parents bf8ae44 + fcf446d commit cc842b1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/FileUploader/FileUploader.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ FileUploader = ({ multiple, onChange, loading, dragAndDrop, disableClick }) ->
if loading
<Loader />
}
<UploadedFilesContainer/>
<UploadedFilesContainer disabled={disableClick} />

<div className={ dzContainerClassNames }>
<Dropzone multiple={multiple} onDrop={onChange} className="Dropzone" disableClick={disableClick}>
Expand Down
13 changes: 9 additions & 4 deletions components/UploadedFile/UploadedFile.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require './UploadedFileStyles'
React = require 'react'
classnames = require 'classnames'

UploadedFile = ({ status, preview, progress, fileName, enableCaptions, captions, onDelete }) ->
UploadedFile = ({ status, preview, progress, fileName, enableCaptions, captions, onDelete, disabled }) ->
<div className="UploadedFile">
<main className="flex column middle center" >
{
Expand Down Expand Up @@ -37,9 +37,14 @@ UploadedFile = ({ status, preview, progress, fileName, enableCaptions, captions,
<p className="file-name">{ fileName }</p>
{
unless status == 'uploading'
<button className="clean" type="button" onClick={onDelete}>
<div className="icon cross"/>
</button>
if disabled
<button className="clean" type="button" disabled>
<div className="icon cross"/>
</button>
else
<button className="clean" type="button" onClick={onDelete}>
<div className="icon cross"/>
</button>
}
</div>

Expand Down
3 changes: 2 additions & 1 deletion components/UploadedFiles/UploadedFiles.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require './UploadedFilesStyles'
React = require 'react'
UploadedFile = require '../UploadedFile/UploadedFile'

UploadedFiles = ({ files, onDelete, enableCaptions }) ->
UploadedFiles = ({ files, onDelete, enableCaptions, disabled }) ->
<ul className="UploadedFiles flex wrap">
{
files?.map (file, i) ->
Expand All @@ -27,6 +27,7 @@ UploadedFiles = ({ files, onDelete, enableCaptions }) ->
enableCaptions={enableCaptions}
captions={captions}
onDelete={onDeleteProxy}
disabled={disabled}
/>
</li>
}
Expand Down
4 changes: 3 additions & 1 deletion components/UploadedFiles/UploadedFilesContainer.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ container =
dispatch : PropTypes.func.isRequired
files : PropTypes.array.isRequired
enableCaptions: PropTypes.bool
disabled : PropTypes.bool

onDelete: (file) ->
this.props.dispatch deleteAttachment file
Expand All @@ -45,12 +46,13 @@ container =
dispatch getAttachments { id, assetType, category }

render: ->
{ files, enableCaptions } = this.props
{ files, enableCaptions, disabled } = this.props

createElement UploadedFiles,
files : files
onDelete : this.onDelete
enableCaptions: enableCaptions
disabled : disabled

module.exports = connect(mapStateToProps)(createClass(container))

0 comments on commit cc842b1

Please sign in to comment.