1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

Fix PR comments

This commit is contained in:
Brett Sun 2016-02-05 15:17:59 +01:00
parent 482fa51e9e
commit acd7c0f0a3
6 changed files with 43 additions and 48 deletions

View File

@ -37,7 +37,7 @@ let FileDragAndDropErrorDialog = React.createClass({
getContactUsDetail() { getContactUsDetail() {
return ( return (
<div className='file-drag-and-drop-error'> <div className='file-drag-and-drop-error'>
<h4>Let us help you</h4> <h4>{getLangText('Let us help you')}</h4>
<p>{getLangText('Still having problems? Send us a message.')}</p> <p>{getLangText('Still having problems? Send us a message.')}</p>
{this.getRetryButton('Contact us', true)} {this.getRetryButton('Contact us', true)}
</div> </div>

View File

@ -224,7 +224,7 @@ const ReactS3FineUploader = React.createClass({
csrfToken: getCookie(AppConstants.csrftoken), csrfToken: getCookie(AppConstants.csrftoken),
errorState: { errorState: {
manualRetryAttempt: 0, manualRetryAttempt: 0,
errorClass: undefined errorClass: null
}, },
uploadInProgress: false, uploadInProgress: false,
@ -472,19 +472,19 @@ const ReactS3FineUploader = React.createClass({
const { manualRetryAttempt } = this.state.errorState; const { manualRetryAttempt } = this.state.errorState;
let matchedErrorClass; let matchedErrorClass;
if ('onLine' in window.navigator && !window.navigator.onLine) {
// If the user's offline, this is definitely the most important error to show.
// TODO: use a better mechanism for checking network state, ie. offline.js
matchedErrorClass = ErrorClasses.upload.offline;
} else if (manualRetryAttempt === RETRY_ATTEMPT_TO_SHOW_CONTACT_US) {
// Use the contact us error class if they've retried a number of times // Use the contact us error class if they've retried a number of times
// and are still unsuccessful // and are still unsuccessful
if (manualRetryAttempt === RETRY_ATTEMPT_TO_SHOW_CONTACT_US) {
matchedErrorClass = ErrorClasses.upload.contactUs; matchedErrorClass = ErrorClasses.upload.contactUs;
} else { } else {
matchedErrorClass = testErrorAgainstAll({ type, reason, xhr }); matchedErrorClass = testErrorAgainstAll({ type, reason, xhr });
// If none found, check the internet connection if (!matchedErrorClass) {
// TODO: use a better mechanism for checking network state, ie. offline.js // If none found, show the next error message in the queue for upload errors
if ('onLine' in window.navigator && !window.navigator.onLine) {
matchedErrorClass = ErrorClasses.upload.offline;
} else {
// Otherwise, show the next error message in the queue
matchedErrorClass = ErrorQueueStore.getNextError('upload'); matchedErrorClass = ErrorQueueStore.getNextError('upload');
} }
} }

View File

@ -1,9 +1,10 @@
'use strict'; 'use strict';
import fineUploader from 'fineUploader'; import fineUploader from 'fineUploader';
// Re-export qq.status from FineUploader with an additional online // Re-export qq.status from FineUploader with an additional online
// state that we use to keep track of files from S3. // state that we use to keep track of files from S3.
export const FileStatus = Object.assign(fineUploader.status, { export const FileStatus = Object.assign({}, fineUploader.status, {
ONLINE: 'online' ONLINE: 'online'
}); });
@ -21,7 +22,7 @@ export const formSubmissionValidation = {
file.status != FileStatus.UPLOADED_FAILED file.status != FileStatus.UPLOADED_FAILED
}); });
if (files.length > 0 && files[0].status === FileStatus.UPLOAD_SUCCESSFUL) { if (files.length && files[0].status === FileStatus.UPLOAD_SUCCESSFUL) {
return true; return true;
} else { } else {
return false; return false;
@ -35,13 +36,9 @@ export const formSubmissionValidation = {
* @return {boolean} [description] * @return {boolean} [description]
*/ */
fileOptional(files) { fileOptional(files) {
let uploadingFiles = files.filter((file) => file.status === FileStatus.SUBMITTING); const uploadingFiles = files.filter((file) => file.status === FileStatus.SUBMITTING);
if (uploadingFiles.length === 0) { return uploadFiles.length === 0;
return true;
} else {
return false;
}
} }
}; };
@ -93,7 +90,7 @@ export function displayValidProgressFilesFilter(file) {
*/ */
export function transformAllowedExtensionsToInputAcceptProp(allowedExtensions) { export function transformAllowedExtensionsToInputAcceptProp(allowedExtensions) {
// add a dot in front of the extension // add a dot in front of the extension
let prefixedAllowedExtensions = allowedExtensions.map((ext) => '.' + ext); const prefixedAllowedExtensions = allowedExtensions.map((ext) => '.' + ext);
// generate a comma separated list to add them to the DOM element // generate a comma separated list to add them to the DOM element
// See: http://stackoverflow.com/questions/4328947/limit-file-format-when-using-input-type-file // See: http://stackoverflow.com/questions/4328947/limit-file-format-when-using-input-type-file

View File

@ -179,7 +179,7 @@ function getPrettifiedError(error, errorClass) {
* @return {(object)} Matched error class * @return {(object)} Matched error class
*/ */
function testErrorAgainstAll(error) { function testErrorAgainstAll(error) {
const type = error.type != null ? error.type : 'default'; const type = error.type || 'default';
const errorGroup = ErrorClasses[type]; const errorGroup = ErrorClasses[type];
return Object return Object
@ -198,7 +198,8 @@ function testErrorAgainstAll(error) {
* @return {(object)} Returns the given class if the test succeeds. * @return {(object)} Returns the given class if the test succeeds.
*/ */
function testErrorAgainstClass(error, errorClass) { function testErrorAgainstClass(error, errorClass) {
// Automatically fail classes if no tests present // Automatically fail classes if no tests present, since some of the error classes
// may not have an error to test against.
if (!errorClass.test) { if (!errorClass.test) {
return; return;
} }

View File

@ -223,15 +223,12 @@ export function omitFromObject(obj, filter) {
* By default, applies strict equality using === * By default, applies strict equality using ===
* @return {boolean} True if obj matches the "match" object * @return {boolean} True if obj matches the "match" object
*/ */
export function deepMatchObject(obj, match, testFn) { export function deepMatchObject(obj, match, testFn = (objProp, matchProp) => objProp === matchProp) {
if (typeof match !== 'object') { if (typeof match !== 'object') {
throw new Error('Your specified match argument was not an object'); throw new Error('Your specified match argument was not an object');
} }
if (typeof testFn !== 'function') { if (typeof testFn !== 'function') {
testFn = (objProp, matchProp) => { throw new Error('Your specified test function was not a function');
return objProp === matchProp;
};
} }
return Object return Object
@ -239,7 +236,7 @@ export function deepMatchObject(obj, match, testFn) {
.reduce((result, matchKey) => { .reduce((result, matchKey) => {
if (!result) { return false; } if (!result) { return false; }
const objProp = obj[matchKey]; const objProp = obj && obj[matchKey];
const matchProp = match[matchKey]; const matchProp = match[matchKey];
if (typeof matchProp === 'object') { if (typeof matchProp === 'object') {