From 8650b0497cbfb739d3e67417340919783697da3d Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Mon, 15 Feb 2016 15:48:49 +0100 Subject: [PATCH] Clean up components using the uploader in preparation for move to ascribe/react-components --- .eslintignore | 6 ++--- .../ascribe_detail/further_details.js | 8 +++---- .../further_details_fileuploader.js | 12 +++++----- .../ascribe_forms/form_create_contract.js | 8 +++---- .../ascribe_forms/form_register_piece.js | 20 +++++++++-------- .../ascribe_forms/input_fineuploader.js | 22 +++++++++---------- .../contract_settings_update_button.js | 10 ++++----- .../pr_forms/pr_register_piece_form.js | 10 ++++----- .../ascribe_detail/prize_piece_container.js | 4 ++-- .../cyland_additional_data_form.js | 6 ++--- .../market_additional_data_form.js | 6 ++--- 11 files changed, 57 insertions(+), 55 deletions(-) diff --git a/.eslintignore b/.eslintignore index 6a87a8a8..6037e1f7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,8 +1,8 @@ . +server.js gulpfile.js -node_modules +node_modules/* js/**/__tests__ -server.js -js/components/ascribe_uploader/vendor \ No newline at end of file +js/components/ascribe_uploader/vendor diff --git a/js/components/ascribe_detail/further_details.js b/js/components/ascribe_detail/further_details.js index 69b605bc..5ed394ec 100644 --- a/js/components/ascribe_detail/further_details.js +++ b/js/components/ascribe_detail/further_details.js @@ -45,13 +45,13 @@ let FurtherDetails = React.createClass({ GlobalNotificationActions.appendGlobalNotification(notification); }, - submitFile(file) { + onSubmitFile(file) { this.setState({ otherDataKey: file.key }); }, - setIsUploadReady(isReady) { + setIsUploaderValidated(isReady) { this.setState({ isUploadReady: isReady }); @@ -87,8 +87,8 @@ let FurtherDetails = React.createClass({ pieceId={pieceId} />
diff --git a/js/components/ascribe_forms/form_create_contract.js b/js/components/ascribe_forms/form_create_contract.js index cbdd12c3..40a62e5b 100644 --- a/js/components/ascribe_forms/form_create_contract.js +++ b/js/components/ascribe_forms/form_create_contract.js @@ -39,7 +39,7 @@ let CreateContractForm = React.createClass({ }; }, - setIsUploadReady(isReady) { + setIsUploaderValidated(isReady) { this.setState({ isUploadReady: isReady }); @@ -52,7 +52,7 @@ let CreateContractForm = React.createClass({ this.refs.form.reset(); }, - submitFile({ originalName }) { + onSubmitFile({ originalName }) { this.setState({ contractName: originalName }); @@ -70,7 +70,7 @@ let CreateContractForm = React.createClass({ name="blob" label={getLangText('Contract file (*.pdf only, max. 50MB per contract)')}> diff --git a/js/components/ascribe_forms/form_register_piece.js b/js/components/ascribe_forms/form_register_piece.js index 97e89c3d..b858c1ce 100644 --- a/js/components/ascribe_forms/form_register_piece.js +++ b/js/components/ascribe_forms/form_register_piece.js @@ -63,7 +63,7 @@ let RegisterPieceForm = React.createClass({ * of each uploader in the component * @param {string} uploaderKey Name of the uploader's key to track */ - setIsUploadReady(uploaderKey) { + setIsUploaderValidated(uploaderKey) { return (isUploadReady) => { // See documentation of `FormSubmitButton` for more detailed information // on this. @@ -78,7 +78,7 @@ let RegisterPieceForm = React.createClass({ // Manually we need to set the ready state for `thumbnailKeyReady` back // to `true` as `ReactS3Fineuploader`'s `reset` method triggers - // `setIsUploadReady` with `false` + // `setIsUploaderValidated` with `false` this.refs.submitButton.setReadyStateForKey('thumbnailKeyReady', true); this.setState({ digitalWorkFile: null }); } else { @@ -97,9 +97,11 @@ let RegisterPieceForm = React.createClass({ ); }, - handleThumbnailValidationFailed(thumbnailFile) { - // If the validation fails, set the thumbnail as submittable since its optional - this.refs.submitButton.setReadyStateForKey('thumbnailKeyReady', true); + handleThumbnailValidationFailed(thumbnailFile, error) { + if (error.type !== ValidationErrors.EXTRA_FILES) { + // If the validation fails, set the thumbnail as submittable since its optional + this.refs.submitButton.setReadyStateForKey('thumbnailKeyReady', true); + } }, isThumbnailDialogExpanded() { @@ -169,13 +171,13 @@ let RegisterPieceForm = React.createClass({ url: ApiUrls.blob_digitalworks }} validation={validationTypes.registerWork} - setIsUploadReady={this.setIsUploadReady('digitalWorkKeyReady')} + setIsUploaderValidated={this.setIsUploaderValidated('digitalWorkKeyReady')} isReadyForFormSubmission={formSubmissionValidation.atLeastOneUploadedFile} isFineUploaderActive={isFineUploaderActive} disabled={!isFineUploaderEditable} enableLocalHashing={hashLocally} uploadMethod={location.query.method} - handleChangedFile={this.handleChangedDigitalWork} + onStatusChange={this.handleChangedDigitalWork} showErrorPrompt /> + onStatusChange={onStatusChange} /> ); } }); diff --git a/js/components/ascribe_settings/contract_settings_update_button.js b/js/components/ascribe_settings/contract_settings_update_button.js index dc652b9b..69705667 100644 --- a/js/components/ascribe_settings/contract_settings_update_button.js +++ b/js/components/ascribe_settings/contract_settings_update_button.js @@ -24,7 +24,7 @@ let ContractSettingsUpdateButton = React.createClass({ contract: React.PropTypes.object }, - submitFile(file) { + onSubmitFile(file) { // override the blob with the key's value const contract = Object.assign(this.props.contract, { blob: file.key }); @@ -45,13 +45,13 @@ let ContractSettingsUpdateButton = React.createClass({ const notification = new GlobalNotificationModel(getLangText('Latest contract failed to load'), 'danger', 5000); GlobalNotificationActions.appendGlobalNotification(notification); - return Promise.reject(err); + throw err; }); }, (err) => { const notification = new GlobalNotificationModel(getLangText('Contract could not be updated'), 'danger', 5000); GlobalNotificationActions.appendGlobalNotification(notification); - return Promise.reject(err); + throw err; }) .catch(console.logGlobal); }, @@ -73,7 +73,7 @@ let ContractSettingsUpdateButton = React.createClass({ sizeLimit: validationTypes.additionalData.sizeLimit, allowedExtensions: ['pdf'] }} - setIsUploadReady={() =>{/* So that ReactS3FineUploader is not complaining */}} + setIsUploaderValidated={() =>{/* So that ReactS3FineUploader is not complaining */}} signature={{ endpoint: AppConstants.serverUrl + 's3/signature/', customHeaders: { @@ -93,7 +93,7 @@ let ContractSettingsUpdateButton = React.createClass({ plural: getLangText('UPDATE') }} isReadyForFormSubmission={formSubmissionValidation.atLeastOneUploadedFile} - submitFile={this.submitFile} /> + onSubmitFile={this.onSubmitFile} /> ); } }); diff --git a/js/components/whitelabel/prize/portfolioreview/components/pr_forms/pr_register_piece_form.js b/js/components/whitelabel/prize/portfolioreview/components/pr_forms/pr_register_piece_form.js index 205a5634..e79e879a 100644 --- a/js/components/whitelabel/prize/portfolioreview/components/pr_forms/pr_register_piece_form.js +++ b/js/components/whitelabel/prize/portfolioreview/components/pr_forms/pr_register_piece_form.js @@ -150,7 +150,7 @@ const PRRegisterPieceForm = React.createClass({ * of each uploader in the component * @param {string} uploaderKey Name of the uploader's key to track */ - setIsUploadReady(uploaderKey) { + setIsUploaderValidated(uploaderKey) { return (isUploadReady) => { this.setState({ [uploaderKey]: isUploadReady @@ -297,7 +297,7 @@ const PRRegisterPieceForm = React.createClass({ {}} - setIsUploadReady={() => {}} + onSubmitFile={() => {}} + setIsUploaderValidated={() => {}} isReadyForFormSubmission={() => {}} editable={false} overrideForm={true} diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_forms/cyland_additional_data_form.js b/js/components/whitelabel/wallet/components/cyland/cyland_forms/cyland_additional_data_form.js index c41caa76..56b4f456 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_forms/cyland_additional_data_form.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_forms/cyland_additional_data_form.js @@ -65,7 +65,7 @@ let CylandAdditionalDataForm = React.createClass({ }, - setIsUploadReady(isReady) { + setIsUploaderValidated(isReady) { this.setState({ isUploadReady: isReady }); @@ -185,8 +185,8 @@ let CylandAdditionalDataForm = React.createClass({