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:
parent
482fa51e9e
commit
acd7c0f0a3
@ -191,9 +191,9 @@ let FileDragAndDrop = React.createClass({
|
|||||||
const hasFiles = filesToUpload
|
const hasFiles = filesToUpload
|
||||||
.filter((file) => {
|
.filter((file) => {
|
||||||
return file.status !== FileStatus.DELETED &&
|
return file.status !== FileStatus.DELETED &&
|
||||||
file.status !== FileStatus.CANCELED &&
|
file.status !== FileStatus.CANCELED &&
|
||||||
file.status !== FileStatus.UPLOAD_FAILED &&
|
file.status !== FileStatus.UPLOAD_FAILED &&
|
||||||
file.size !== -1;
|
file.size !== -1;
|
||||||
})
|
})
|
||||||
.length > 0;
|
.length > 0;
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ let FileDragAndDrop = React.createClass({
|
|||||||
let hasError = showError && errorClass && failedFiles.length > 0;
|
let hasError = showError && errorClass && failedFiles.length > 0;
|
||||||
|
|
||||||
// if !== -2: triggers a FileDragAndDrop-global spinner
|
// if !== -2: triggers a FileDragAndDrop-global spinner
|
||||||
if(hashingProgress !== -2) {
|
if (hashingProgress !== -2) {
|
||||||
return (
|
return (
|
||||||
<div className="file-drag-and-drop-hashing-dialog">
|
<div className="file-drag-and-drop-hashing-dialog">
|
||||||
<p>{getLangText('Computing hash(es)... This may take a few minutes.')}</p>
|
<p>{getLangText('Computing hash(es)... This may take a few minutes.')}</p>
|
||||||
|
@ -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>
|
||||||
|
@ -208,7 +208,7 @@ const ReactS3FineUploader = React.createClass({
|
|||||||
messages: {
|
messages: {
|
||||||
unsupportedBrowser: '<h3>' + getLangText('Upload is not functional in IE7 as IE7 has no support for CORS!') + '</h3>'
|
unsupportedBrowser: '<h3>' + getLangText('Upload is not functional in IE7 as IE7 has no support for CORS!') + '</h3>'
|
||||||
},
|
},
|
||||||
formatFileName: function(name){// fix maybe
|
formatFileName: function(name) { // fix maybe
|
||||||
if (name !== undefined && name.length > 26) {
|
if (name !== undefined && name.length > 26) {
|
||||||
name = name.slice(0, 15) + '...' + name.slice(-15);
|
name = name.slice(0, 15) + '...' + name.slice(-15);
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
// Use the contact us error class if they've retried a number of times
|
if ('onLine' in window.navigator && !window.navigator.onLine) {
|
||||||
// and are still unsuccessful
|
// If the user's offline, this is definitely the most important error to show.
|
||||||
if (manualRetryAttempt === RETRY_ATTEMPT_TO_SHOW_CONTACT_US) {
|
// 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
|
||||||
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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1030,14 +1030,14 @@ const ReactS3FineUploader = React.createClass({
|
|||||||
|
|
||||||
const filesToDisplay = filesToUpload.filter((file) => {
|
const filesToDisplay = filesToUpload.filter((file) => {
|
||||||
return file.status !== FileStatus.DELETED &&
|
return file.status !== FileStatus.DELETED &&
|
||||||
file.status !== FileStatus.CANCELED &&
|
file.status !== FileStatus.CANCELED &&
|
||||||
file.status !== FileStatus.UPLOAD_FAILED &&
|
file.status !== FileStatus.UPLOAD_FAILED &&
|
||||||
file.size !== -1;
|
file.size !== -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ((enableLocalHashing && !uploadMethod) || !areAssetsEditable ||
|
if ((enableLocalHashing && !uploadMethod) || !areAssetsEditable ||
|
||||||
(showErrorPrompt && errorState.errorClass) ||
|
(showErrorPrompt && errorState.errorClass) ||
|
||||||
(!multiple && filesToDisplay.length > 0)) {
|
(!multiple && filesToDisplay.length > 0)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -1047,7 +1047,7 @@ const ReactS3FineUploader = React.createClass({
|
|||||||
getAllowedExtensions() {
|
getAllowedExtensions() {
|
||||||
const { validation } = this.props;
|
const { validation } = this.props;
|
||||||
|
|
||||||
if(validation && validation.allowedExtensions && validation.allowedExtensions.length > 0) {
|
if (validation && validation.allowedExtensions && validation.allowedExtensions.length > 0) {
|
||||||
return transformAllowedExtensionsToInputAcceptProp(validation.allowedExtensions);
|
return transformAllowedExtensionsToInputAcceptProp(validation.allowedExtensions);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -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'
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -17,11 +18,11 @@ export const formSubmissionValidation = {
|
|||||||
atLeastOneUploadedFile(files) {
|
atLeastOneUploadedFile(files) {
|
||||||
files = files.filter((file) => {
|
files = files.filter((file) => {
|
||||||
return file.status !== FileStatus.DELETED &&
|
return file.status !== FileStatus.DELETED &&
|
||||||
file.status !== FileStatus.CANCELED &&
|
file.status !== FileStatus.CANCELED &&
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -52,8 +49,8 @@ export const formSubmissionValidation = {
|
|||||||
*/
|
*/
|
||||||
export function displayValidFilesFilter(file) {
|
export function displayValidFilesFilter(file) {
|
||||||
return file.status !== FileStatus.DELETED &&
|
return file.status !== FileStatus.DELETED &&
|
||||||
file.status !== FileStatus.CANCELED &&
|
file.status !== FileStatus.CANCELED &&
|
||||||
file.status !== FileStatus.UPLOAD_FAILED;
|
file.status !== FileStatus.UPLOAD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,8 +60,8 @@ export function displayValidFilesFilter(file) {
|
|||||||
*/
|
*/
|
||||||
export function displayRemovedFilesFilter(file) {
|
export function displayRemovedFilesFilter(file) {
|
||||||
return file.status === FileStatus.DELETED ||
|
return file.status === FileStatus.DELETED ||
|
||||||
file.status === FileStatus.CANCELED ||
|
file.status === FileStatus.CANCELED ||
|
||||||
file.status === FileStatus.UPLOAD_FAILED;
|
file.status === FileStatus.UPLOAD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,9 +72,9 @@ export function displayRemovedFilesFilter(file) {
|
|||||||
*/
|
*/
|
||||||
export function displayValidProgressFilesFilter(file) {
|
export function displayValidProgressFilesFilter(file) {
|
||||||
return file.status !== FileStatus.DELETED &&
|
return file.status !== FileStatus.DELETED &&
|
||||||
file.status !== FileStatus.CANCELED &&
|
file.status !== FileStatus.CANCELED &&
|
||||||
file.status !== FileStatus.UPLOAD_FAILED &&
|
file.status !== FileStatus.UPLOAD_FAILED &&
|
||||||
file.status !== FileStatus.ONLINE;
|
file.status !== FileStatus.ONLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -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
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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') {
|
||||||
|
Loading…
Reference in New Issue
Block a user