mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 09:23:13 +01:00
Fix PR comments
This commit is contained in:
parent
482fa51e9e
commit
acd7c0f0a3
@ -37,7 +37,7 @@ let FileDragAndDropErrorDialog = React.createClass({
|
||||
getContactUsDetail() {
|
||||
return (
|
||||
<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>
|
||||
{this.getRetryButton('Contact us', true)}
|
||||
</div>
|
||||
|
@ -224,7 +224,7 @@ const ReactS3FineUploader = React.createClass({
|
||||
csrfToken: getCookie(AppConstants.csrftoken),
|
||||
errorState: {
|
||||
manualRetryAttempt: 0,
|
||||
errorClass: undefined
|
||||
errorClass: null
|
||||
},
|
||||
uploadInProgress: false,
|
||||
|
||||
@ -472,19 +472,19 @@ const ReactS3FineUploader = React.createClass({
|
||||
const { manualRetryAttempt } = this.state.errorState;
|
||||
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
|
||||
// and are still unsuccessful
|
||||
if (manualRetryAttempt === RETRY_ATTEMPT_TO_SHOW_CONTACT_US) {
|
||||
matchedErrorClass = ErrorClasses.upload.contactUs;
|
||||
} else {
|
||||
matchedErrorClass = testErrorAgainstAll({ type, reason, xhr });
|
||||
|
||||
// If none found, check the internet connection
|
||||
// TODO: use a better mechanism for checking network state, ie. offline.js
|
||||
if ('onLine' in window.navigator && !window.navigator.onLine) {
|
||||
matchedErrorClass = ErrorClasses.upload.offline;
|
||||
} else {
|
||||
// Otherwise, show the next error message in the queue
|
||||
if (!matchedErrorClass) {
|
||||
// If none found, show the next error message in the queue for upload errors
|
||||
matchedErrorClass = ErrorQueueStore.getNextError('upload');
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
import fineUploader from 'fineUploader';
|
||||
|
||||
// Re-export qq.status from FineUploader with an additional online
|
||||
// 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'
|
||||
});
|
||||
|
||||
@ -21,7 +22,7 @@ export const formSubmissionValidation = {
|
||||
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;
|
||||
} else {
|
||||
return false;
|
||||
@ -35,13 +36,9 @@ export const formSubmissionValidation = {
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
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 true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return uploadFiles.length === 0;
|
||||
}
|
||||
};
|
||||
|
||||
@ -93,7 +90,7 @@ export function displayValidProgressFilesFilter(file) {
|
||||
*/
|
||||
export function transformAllowedExtensionsToInputAcceptProp(allowedExtensions) {
|
||||
// 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
|
||||
// See: http://stackoverflow.com/questions/4328947/limit-file-format-when-using-input-type-file
|
||||
|
@ -179,7 +179,7 @@ function getPrettifiedError(error, errorClass) {
|
||||
* @return {(object)} Matched error class
|
||||
*/
|
||||
function testErrorAgainstAll(error) {
|
||||
const type = error.type != null ? error.type : 'default';
|
||||
const type = error.type || 'default';
|
||||
const errorGroup = ErrorClasses[type];
|
||||
|
||||
return Object
|
||||
@ -198,7 +198,8 @@ function testErrorAgainstAll(error) {
|
||||
* @return {(object)} Returns the given class if the test succeeds.
|
||||
*/
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
@ -223,15 +223,12 @@ export function omitFromObject(obj, filter) {
|
||||
* By default, applies strict equality using ===
|
||||
* @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') {
|
||||
throw new Error('Your specified match argument was not an object');
|
||||
}
|
||||
|
||||
if (typeof testFn !== 'function') {
|
||||
testFn = (objProp, matchProp) => {
|
||||
return objProp === matchProp;
|
||||
};
|
||||
throw new Error('Your specified test function was not a function');
|
||||
}
|
||||
|
||||
return Object
|
||||
@ -239,7 +236,7 @@ export function deepMatchObject(obj, match, testFn) {
|
||||
.reduce((result, matchKey) => {
|
||||
if (!result) { return false; }
|
||||
|
||||
const objProp = obj[matchKey];
|
||||
const objProp = obj && obj[matchKey];
|
||||
const matchProp = match[matchKey];
|
||||
|
||||
if (typeof matchProp === 'object') {
|
||||
|
Loading…
Reference in New Issue
Block a user