mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
Updated members' import file validation logic
no issue - The invalid file type error should be shown on the very first step of import and should not allow proceeding without selecting a correct file.
This commit is contained in:
parent
5a87520712
commit
a849ddda18
@ -39,7 +39,7 @@ export default ModalComponent.extend({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
importDisabled: computed('file', function () {
|
importDisabled: computed('file', function () {
|
||||||
return !this.file || !(this._validate(this.file));
|
return !this.file || !(this._validateFileType(this.file));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
formData: computed('file', function () {
|
formData: computed('file', function () {
|
||||||
@ -80,18 +80,15 @@ export default ModalComponent.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
fileSelected(fileList, resetInput) {
|
fileSelected(fileList) {
|
||||||
let [file] = Array.from(fileList);
|
let [file] = Array.from(fileList);
|
||||||
let validationResult = this._validate(file);
|
let validationResult = this._validateFileType(file);
|
||||||
|
|
||||||
this.set('file', file);
|
|
||||||
|
|
||||||
if (validationResult !== true) {
|
if (validationResult !== true) {
|
||||||
this._uploadFailed(validationResult);
|
this._uploadFailed(validationResult);
|
||||||
|
} else {
|
||||||
if (resetInput) {
|
this.set('file', file);
|
||||||
resetInput();
|
this.set('failureMessage', null);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -222,7 +219,7 @@ export default ModalComponent.extend({
|
|||||||
this.set('failureMessage', message);
|
this.set('failureMessage', message);
|
||||||
},
|
},
|
||||||
|
|
||||||
_validate(file) {
|
_validateFileType(file) {
|
||||||
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
|
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
|
||||||
let extensions = this.extensions;
|
let extensions = this.extensions;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user