mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 09:23:13 +01:00
Cancel dragged invalid file with proper messaging
This commit is contained in:
parent
4dd701a414
commit
80b4e22435
@ -518,16 +518,26 @@ const ReactS3FineUploader = React.createClass({
|
||||
},
|
||||
|
||||
isFileValid(file) {
|
||||
if (file.size > this.props.validation.sizeLimit) {
|
||||
const fileSizeInMegaBytes = this.props.validation.sizeLimit / 1000000;
|
||||
let { validation, onValidationFailed } = this.props;
|
||||
|
||||
if (file.size > validation.sizeLimit) {
|
||||
const fileSizeInMegaBytes = validation.sizeLimit / 1000000;
|
||||
|
||||
const notification = new GlobalNotificationModel(getLangText('A file you submitted is bigger than ' + fileSizeInMegaBytes + 'MB.'), 'danger', 5000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
|
||||
if (typeof this.props.onValidationFailed === 'function') {
|
||||
this.props.onValidationFailed(file);
|
||||
if (typeof onValidationFailed === 'function') {
|
||||
onValidationFailed(file);
|
||||
}
|
||||
|
||||
return false;
|
||||
} else if (validation.allowedExtensions.indexOf(file.type) === -1) {
|
||||
|
||||
const prettyAllowedExtensions = validation.allowedExtensions.join(', ');
|
||||
|
||||
const notification = new GlobalNotificationModel(getLangText(`The file you've submitted is of an invalid file format: Valid format(s): ${prettyAllowedExtensions}`), 'danger', 5000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
@ -7,6 +7,8 @@
|
||||
position: fixed;
|
||||
transition: .2s bottom cubic-bezier(.77, 0, .175, 1);
|
||||
width: 100%;
|
||||
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.ascribe-global-notification-off {
|
||||
@ -37,6 +39,8 @@
|
||||
right: -50em;
|
||||
transition: 1s right ease;
|
||||
|
||||
z-index: 9999;
|
||||
|
||||
> div {
|
||||
padding: .75em 1.5em;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user