Skip to content

Commit 0637ed1

Browse files
committed
#436: Cannot Drag and Drop Image to Upload Area in Banner, Slide in Safari, IE11 - Removed added validation type, changed isFileAllowed function
1 parent f581977 commit 0637ed1

File tree

2 files changed

+8
-36
lines changed

2 files changed

+8
-36
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element/image-uploader.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,16 @@ define([
8282
},
8383

8484
/**
85-
* Checks if extension of provided file is allowed.
85+
* Checks if provided file is allowed to be uploaded.
8686
* {@inheritDoc}
8787
*/
88-
isExtensionAllowed: function (file) {
89-
var fileExtensions = this.getAllowedFileExtensionsInCommaDelimitedFormat(),
90-
fileExtensionMessage = this.translations.allowedFileTypes + ':\t' + fileExtensions;
91-
return validator('validate-file-extension', file.name, this.allowedExtensions, fileExtensionMessage);
88+
isFileAllowed: function () {
89+
var result = this._super();
90+
91+
if (!result.passed && result.rule === 'validate-file-type') {
92+
result.message += ('\t' + this.translations.allowedFileTypes + ':\t' + this.getAllowedFileExtensionsInCommaDelimitedFormat());
93+
}
94+
return result;
9295
},
9396

9497
/**

app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element/validator-rules-mixin.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,6 @@ define([
124124
return !!style.width.length;
125125
}
126126

127-
/**
128-
* Validate file extension.
129-
*
130-
* @param {String} name
131-
* @param {String} types
132-
* @returns {Boolean}
133-
*/
134-
function validateFileExtension(name, types) {
135-
var extension = name.split('.').pop().toLowerCase();
136-
137-
if (types && typeof types === 'string') {
138-
types = types.split(' ');
139-
}
140-
141-
return !types || !types.length || ~types.indexOf(extension);
142-
}
143-
144127
return function (validator) {
145128
var requiredInputRule = validator.getRule('required-entry');
146129

@@ -271,20 +254,6 @@ define([
271254
$.mage.__('Please enter a valid number or calculation: Valid numbers must have an extension (px, %, pt, vh). Calculations must have white space around the + and - operators and cannot divide by zero.')//eslint-disable-line max-len
272255
);
273256

274-
validator.addRule(
275-
'validate-file-extension',
276-
function (name, types, additionalMessage) {
277-
this.fileTypeErrorMessage = $.mage.__('We don\'t recognize or support this file extension type.');
278-
if (additionalMessage) {
279-
this.fileTypeErrorMessage += ('\t' + additionalMessage);
280-
}
281-
return validateFileExtension(name, types);
282-
},
283-
function () {
284-
return this.fileTypeErrorMessage;
285-
}
286-
);
287-
288257
validateObjectField(validator, 'validate-number');
289258
validateObjectField(validator, 'less-than-equals-to');
290259
validateObjectField(validator, 'greater-than-equals-to');

0 commit comments

Comments
 (0)