From a849ddda187e7f19a7f04ce1e467bd038d0e5a15 Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Sat, 6 Jun 2020 00:48:09 +1200 Subject: [PATCH] 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. --- .../app/components/modal-import-members.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ghost/admin/app/components/modal-import-members.js b/ghost/admin/app/components/modal-import-members.js index 1194b9f6d3..6986c4d8a9 100644 --- a/ghost/admin/app/components/modal-import-members.js +++ b/ghost/admin/app/components/modal-import-members.js @@ -39,7 +39,7 @@ export default ModalComponent.extend({ }), importDisabled: computed('file', function () { - return !this.file || !(this._validate(this.file)); + return !this.file || !(this._validateFileType(this.file)); }), formData: computed('file', function () { @@ -80,18 +80,15 @@ export default ModalComponent.extend({ }, actions: { - fileSelected(fileList, resetInput) { + fileSelected(fileList) { let [file] = Array.from(fileList); - let validationResult = this._validate(file); - - this.set('file', file); + let validationResult = this._validateFileType(file); if (validationResult !== true) { this._uploadFailed(validationResult); - - if (resetInput) { - resetInput(); - } + } else { + this.set('file', file); + this.set('failureMessage', null); } }, @@ -222,7 +219,7 @@ export default ModalComponent.extend({ this.set('failureMessage', message); }, - _validate(file) { + _validateFileType(file) { let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name); let extensions = this.extensions;