mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 10:25:08 +01:00
Update FineUploader utils to use FileStatus
This commit is contained in:
parent
01e3fd5fcd
commit
4821e36189
@ -17,9 +17,7 @@ import AscribeSpinner from '../ascribe_spinner';
|
||||
|
||||
import { getLangText } from '../../utils/lang_utils';
|
||||
import { mergeOptions } from '../../utils/general_utils';
|
||||
import { formSubmissionValidation,
|
||||
displayValidFilesFilter,
|
||||
displayRemovedFilesFilter } from '../ascribe_uploader/react_s3_fine_uploader_utils';
|
||||
import { formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uploader_utils';
|
||||
|
||||
|
||||
let RegisterPieceForm = React.createClass({
|
||||
|
@ -15,8 +15,13 @@ export const formSubmissionValidation = {
|
||||
* @return {boolean}
|
||||
*/
|
||||
atLeastOneUploadedFile(files) {
|
||||
files = files.filter((file) => file.status !== 'deleted' && file.status !== 'canceled');
|
||||
if (files.length > 0 && files[0].status === 'upload successful') {
|
||||
files = files.filter((file) => {
|
||||
return file.status !== FileStatus.DELETED &&
|
||||
file.status !== FileStatus.CANCELED &&
|
||||
file.status != FileStatus.UPLOADED_FAILED
|
||||
});
|
||||
|
||||
if (files.length > 0 && files[0].status === FileStatus.UPLOAD_SUCCESSFUL) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -30,7 +35,7 @@ export const formSubmissionValidation = {
|
||||
* @return {boolean} [description]
|
||||
*/
|
||||
fileOptional(files) {
|
||||
let uploadingFiles = files.filter((file) => file.status === 'submitting');
|
||||
let uploadingFiles = files.filter((file) => file.status === FileStatus.SUBMITTING);
|
||||
|
||||
if (uploadingFiles.length === 0) {
|
||||
return true;
|
||||
@ -41,21 +46,25 @@ export const formSubmissionValidation = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Filter function for filtering all deleted and canceled files
|
||||
* Filter function for filtering all deleted, canceled, and failed files
|
||||
* @param {object} file A file from filesToUpload that has status as a prop.
|
||||
* @return {boolean}
|
||||
*/
|
||||
export function displayValidFilesFilter(file) {
|
||||
return file.status !== 'deleted' && file.status !== 'canceled';
|
||||
return file.status !== FileStatus.DELETED &&
|
||||
file.status !== FileStatus.CANCELED &&
|
||||
file.status !== FileStatus.UPLOAD_FAILED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter function for filtering all files except for deleted and canceled files
|
||||
* Filter function for filtering all files except for deleted, canceled, and failed files
|
||||
* @param {object} file A file from filesToUpload that has status as a prop.
|
||||
* @return {boolean}
|
||||
*/
|
||||
export function displayRemovedFilesFilter(file) {
|
||||
return file.status === 'deleted' || file.status === 'canceled';
|
||||
return file.status === FileStatus.DELETED ||
|
||||
file.status === FileStatus.CANCELED ||
|
||||
file.status === FileStatus.UPLOAD_FAILED;
|
||||
}
|
||||
|
||||
|
||||
@ -65,7 +74,10 @@ export function displayRemovedFilesFilter(file) {
|
||||
* @return {boolean}
|
||||
*/
|
||||
export function displayValidProgressFilesFilter(file) {
|
||||
return file.status !== 'deleted' && file.status !== 'canceled' && file.status !== 'online';
|
||||
return file.status !== FileStatus.DELETED &&
|
||||
file.status !== FileStatus.CANCELED &&
|
||||
file.status !== FileStatus.UPLOAD_FAILED &&
|
||||
file.status !== FileStatus.ONLINE;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user