diff --git a/ghost/admin/app/components/modal-import-members.hbs b/ghost/admin/app/components/modal-import-members.hbs index d663e5a7b5..be41721361 100644 --- a/ghost/admin/app/components/modal-import-members.hbs +++ b/ghost/admin/app/components/modal-import-members.hbs @@ -51,6 +51,27 @@ {{/if}} {{#if this.customizing}} + {{#if this.uploadErrors}} +
+
+ {{svg-jar "warning" class="nudge-top--2 w5 h5 fill-red"}} +
+
+

The import contains errors!

+ +
+
+ {{/if}} + {{#if this.config.enableDeveloperExperiments}}
diff --git a/ghost/admin/app/components/modal-import-members.js b/ghost/admin/app/components/modal-import-members.js index 66ea1968c6..f510ea272b 100644 --- a/ghost/admin/app/components/modal-import-members.js +++ b/ghost/admin/app/components/modal-import-members.js @@ -41,6 +41,16 @@ class MembersFieldMapping { return this._mapping; } + getKeyByValue(searchedValue) { + for (const [key, value] of Object.entries(this._mapping)) { + if (value === searchedValue) { + return key; + } + } + + return null; + } + updateMapping(from, to) { for (const key in this._mapping) { if (this.get(key) === to) { @@ -75,6 +85,7 @@ export default ModalComponent.extend({ importResponse: null, failureMessage: null, validationErrors: null, + uploadErrors: null, labels: null, // Allowed actions @@ -189,6 +200,7 @@ export default ModalComponent.extend({ this.set('fileData', null); this.set('mapping', null); this.set('validationErrors', null); + this.set('uploadErrors', null); this.set('validating', false); this.set('customizing', false); @@ -197,8 +209,13 @@ export default ModalComponent.extend({ }, upload() { - if (this.file) { + if (this.file && this.mapping.getKeyByValue('email')) { this.generateRequest(); + } else { + this.set('uploadErrors', [{ + message: 'Import as "Email" value is missing.', + context: 'The CSV has to contain import as "Email" field.' + }]); } },