Refined members import modal

no refs.
- fixed title logic
- fixed stripe validation message
This commit is contained in:
Peter Zimon 2020-07-09 12:11:30 +02:00
parent cf2f12e046
commit c611f65f53
3 changed files with 12 additions and 11 deletions

View File

@ -2,12 +2,12 @@
<h1> <h1>
{{#if this.summary}} {{#if this.summary}}
Import complete{{unless this.importResponse.invalid.count "!"}} Import complete{{unless this.importResponse.invalid.count "!"}}
{{/if}}
{{#if this.uploading}}
Importing members
{{else}} {{else}}
Import members {{#if this.uploading}}
Importing members
{{else}}
Import members
{{/if}}
{{/if}} {{/if}}
</h1> </h1>
</header> </header>
@ -110,7 +110,7 @@
{{#if this.config.enableDeveloperExperiments}} {{#if this.config.enableDeveloperExperiments}}
<ul class="ma0 pa0 mt4 list bt b--whitegrey"> <ul class="ma0 pa0 mt4 list bt b--whitegrey">
{{#each this.importResponse.invalid.errors as |error|}} {{#each this.importResponse.invalid.errors as |error|}}
<li class="gh-members-import-errormessage">{{error.message}} <span class="fw6">({{format-number error.count}})</span></li> <li class="gh-members-import-errormessage">{{error.message}} <span class="fw4">({{format-number error.count}})</span></li>
{{/each}} {{/each}}
</ul> </ul>
{{/if}} {{/if}}

View File

@ -3,6 +3,7 @@ import Service, {inject as service} from '@ember/service';
import validator from 'validator'; import validator from 'validator';
import {formatNumber} from 'ghost-admin/helpers/format-number'; import {formatNumber} from 'ghost-admin/helpers/format-number';
import {isEmpty} from '@ember/utils'; import {isEmpty} from '@ember/utils';
import {pluralize} from 'ember-inflector';
export default Service.extend({ export default Service.extend({
ajax: service(), ajax: service(),
@ -32,8 +33,8 @@ export default Service.extend({
if (!this.membersUtils.isStripeEnabled) { if (!this.membersUtils.isStripeEnabled) {
validationErrors.push(new MemberImportError({ validationErrors.push(new MemberImportError({
message: `Missing Stripe connection (${formatNumber(totalCount)})`, message: `Missing Stripe connection`,
context: `Stripe customers won't be imported. You need to <a href="#/settings/labs">connect to Stripe</a> to import stripe customers.`, context: `${formatNumber(totalCount)} ${pluralize(totalCount, 'Stripe customer', {withoutCount: true})} won't be imported. You need to <a href="#/settings/labs">connect to Stripe</a> to import Stripe customers.`,
type: 'warning' type: 'warning'
})); }));
} else { } else {
@ -49,7 +50,7 @@ export default Service.extend({
if (duplicateCount) { if (duplicateCount) {
validationErrors.push(new MemberImportError({ validationErrors.push(new MemberImportError({
message: `Duplicate Stripe ID (${formatNumber(duplicateCount)})`, message: `Duplicate Stripe ID <span class="fw4">(${formatNumber(duplicateCount)})</span>`,
type: 'warning' type: 'warning'
})); }));
} }
@ -65,7 +66,7 @@ export default Service.extend({
if (emptyCount) { if (emptyCount) {
validationErrors.push(new MemberImportError({ validationErrors.push(new MemberImportError({
message: `Missing email address (${formatNumber(emptyCount)})`, message: `Missing email address <span class="fw4">(${formatNumber(emptyCount)})</span>`,
type: 'warning' type: 'warning'
})); }));
} }

View File

@ -57,7 +57,7 @@ describe('Integration: Service: member-import-validator', function () {
}]); }]);
expect(validationErrors.length).to.equal(1); expect(validationErrors.length).to.equal(1);
expect(validationErrors[0].message).to.equal('Missing Stripe connection (1)'); expect(validationErrors[0].message).to.equal('Missing Stripe connection');
expect(mapping.email).to.equal('email'); expect(mapping.email).to.equal('email');
expect(mapping.stripe_customer_id).to.equal('stripe_customer_id'); expect(mapping.stripe_customer_id).to.equal('stripe_customer_id');
}); });