mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
only display hashing toggle on user permissions
This commit is contained in:
parent
b105e77009
commit
d52a89cd3e
@ -174,7 +174,7 @@ let FileUploader = React.createClass({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
localHashing={false} />
|
enableLocalHashing={true} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -30,7 +30,7 @@ let FileDragAndDrop = React.createClass({
|
|||||||
areAssetsDownloadable: React.PropTypes.bool,
|
areAssetsDownloadable: React.PropTypes.bool,
|
||||||
areAssetsEditable: React.PropTypes.bool,
|
areAssetsEditable: React.PropTypes.bool,
|
||||||
|
|
||||||
localHashing: React.PropTypes.bool,
|
enableLocalHashing: React.PropTypes.bool,
|
||||||
|
|
||||||
// triggers a FileDragAndDrop-global spinner
|
// triggers a FileDragAndDrop-global spinner
|
||||||
hashingProgress: React.PropTypes.number,
|
hashingProgress: React.PropTypes.number,
|
||||||
@ -177,7 +177,7 @@ let FileDragAndDrop = React.createClass({
|
|||||||
multipleFiles={this.props.multiple}
|
multipleFiles={this.props.multiple}
|
||||||
hasFiles={hasFiles}
|
hasFiles={hasFiles}
|
||||||
onClick={this.handleOnClick}
|
onClick={this.handleOnClick}
|
||||||
localHashing={this.props.localHashing}/>
|
enableLocalHashing={this.props.enableLocalHashing}/>
|
||||||
<FileDragAndDropPreviewIterator
|
<FileDragAndDropPreviewIterator
|
||||||
files={this.props.filesToUpload}
|
files={this.props.filesToUpload}
|
||||||
handleDeleteFile={this.handleDeleteFile}
|
handleDeleteFile={this.handleDeleteFile}
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Router from 'react-router';
|
import Router from 'react-router';
|
||||||
|
|
||||||
import ButtonLink from 'react-router-bootstrap/lib/ButtonLink';
|
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
|
||||||
let Link = Router.Link;
|
let Link = Router.Link;
|
||||||
@ -14,7 +12,7 @@ let FileDragAndDropDialog = React.createClass({
|
|||||||
hasFiles: React.PropTypes.bool,
|
hasFiles: React.PropTypes.bool,
|
||||||
multipleFiles: React.PropTypes.bool,
|
multipleFiles: React.PropTypes.bool,
|
||||||
onClick: React.PropTypes.func,
|
onClick: React.PropTypes.func,
|
||||||
localHashing: React.PropTypes.bool
|
enableLocalHashing: React.PropTypes.bool
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [Router.State],
|
mixins: [Router.State],
|
||||||
@ -25,7 +23,7 @@ let FileDragAndDropDialog = React.createClass({
|
|||||||
if(this.props.hasFiles) {
|
if(this.props.hasFiles) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
if(!queryParams.method) {
|
if(this.props.enableLocalHashing && !queryParams.method) {
|
||||||
|
|
||||||
let queryParamsHash = Object.assign({}, queryParams);
|
let queryParamsHash = Object.assign({}, queryParams);
|
||||||
queryParamsHash.method = 'hash';
|
queryParamsHash.method = 'hash';
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React from 'react/addons';
|
import React from 'react/addons';
|
||||||
|
import Router from 'react-router';
|
||||||
import Raven from 'raven-js';
|
import Raven from 'raven-js';
|
||||||
import Q from 'q';
|
import Q from 'q';
|
||||||
|
|
||||||
@ -106,9 +107,14 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
// the file in the browser using md5 and then uploading the resulting text document instead
|
// the file in the browser using md5 and then uploading the resulting text document instead
|
||||||
// of the actual file.
|
// of the actual file.
|
||||||
// This boolean essentially enables that behavior
|
// This boolean essentially enables that behavior
|
||||||
localHashing: React.PropTypes.bool
|
enableLocalHashing: React.PropTypes.bool,
|
||||||
|
|
||||||
|
// automatically injected by React-Router
|
||||||
|
query: React.PropTypes.object
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mixins: [Router.State],
|
||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
return {
|
return {
|
||||||
autoUpload: true,
|
autoUpload: true,
|
||||||
@ -167,10 +173,10 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
// since the csrf header is defined in this component's props,
|
|
||||||
// everytime the csrf cookie is changed we'll need to reinitalize
|
|
||||||
// fineuploader and update the actual csrf token
|
|
||||||
componentWillUpdate() {
|
componentWillUpdate() {
|
||||||
|
// since the csrf header is defined in this component's props,
|
||||||
|
// everytime the csrf cookie is changed we'll need to reinitalize
|
||||||
|
// fineuploader and update the actual csrf token
|
||||||
let potentiallyNewCSRFToken = getCookie(AppConstants.csrftoken);
|
let potentiallyNewCSRFToken = getCookie(AppConstants.csrftoken);
|
||||||
if(this.state.csrfToken !== potentiallyNewCSRFToken) {
|
if(this.state.csrfToken !== potentiallyNewCSRFToken) {
|
||||||
this.setState({
|
this.setState({
|
||||||
@ -511,8 +517,11 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
|
|
||||||
// As mentioned already in the propTypes declaration, in some instances we need to calculate the
|
// As mentioned already in the propTypes declaration, in some instances we need to calculate the
|
||||||
// md5 hash of a file locally and just upload a txt file containing that hash.
|
// md5 hash of a file locally and just upload a txt file containing that hash.
|
||||||
// This if statement essentially takes care of that solution.
|
//
|
||||||
if(this.props.localHashing) {
|
// In the view this only happens when the user is allowed to do local hashing as well
|
||||||
|
// as when the correct query parameter is present in the url ('hash' and not 'upload')
|
||||||
|
let queryParams = this.getQuery();
|
||||||
|
if(this.props.enableLocalHashing && queryParams && queryParams.method === 'hash') {
|
||||||
|
|
||||||
let convertedFilePromises = [];
|
let convertedFilePromises = [];
|
||||||
let overallFileSize = 0;
|
let overallFileSize = 0;
|
||||||
@ -704,7 +713,7 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
areAssetsEditable={this.props.areAssetsEditable}
|
areAssetsEditable={this.props.areAssetsEditable}
|
||||||
dropzoneInactive={!this.props.areAssetsEditable || !this.props.multiple && this.state.filesToUpload.filter((file) => file.status !== 'deleted' && file.status !== 'canceled' && file.size !== -1).length > 0}
|
dropzoneInactive={!this.props.areAssetsEditable || !this.props.multiple && this.state.filesToUpload.filter((file) => file.status !== 'deleted' && file.status !== 'canceled' && file.size !== -1).length > 0}
|
||||||
hashingProgress={this.state.hashingProgress}
|
hashingProgress={this.state.hashingProgress}
|
||||||
localHashing={this.props.localHashing} />
|
enableLocalHashing={this.props.enableLocalHashing} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user