1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

Refined pre-validation of members import

no issues.
- removes email and Stripe duplicate customer ID check to focus validation that might affect the whole dataset
- applies visual style and refines copy
This commit is contained in:
Peter Zimon 2020-06-18 10:30:15 +02:00
parent 6e97fbd995
commit 823437c1a6
3 changed files with 11 additions and 19 deletions

View file

@ -42,13 +42,9 @@
<div class="failed flex items-start gh-members-upload-errorcontainer gh-members-upload-warningmessage"> <div class="failed flex items-start gh-members-upload-errorcontainer gh-members-upload-warningmessage">
<div class="mr2">{{svg-jar "warning" class="nudge-top--2 w5 h5 fill-yellow-d1"}}</div> <div class="mr2">{{svg-jar "warning" class="nudge-top--2 w5 h5 fill-yellow-d1"}}</div>
<div> <div>
<p class="ma0 pa0 gh-members-import-errorheading"><span class="fw6">Warning!</span> There are some problems with the CSV data. You can still import it but data loss might occur.</p> {{#each validationErrors as |error|}}
<button type="button" class="gh-btn gh-btn-text gh-btn-warningdetails regular" {{action (toggle "errorDetailsOpen" this)}}><span>Details</span></button> <p class="ma0 pa0 gh-members-import-errorheading">{{{error.message}}}</p>
{{#liquid-if this.errorDetailsOpen}} {{/each}}
{{#each validationErrors as |error|}}
<p class="ma0 pa0 gh-members-import-errordetailtext">{{error.message}}</p>
{{/each}}
{{/liquid-if}}
</div> </div>
</div> </div>
{{/if}} {{/if}}

View file

@ -37,28 +37,18 @@ export default Service.extend({
} }
// check can be done on whole set as it won't be too slow // check can be done on whole set as it won't be too slow
let emailValidation = this._checkEmails(data);
if (emailValidation !== true) {
validationResults.push(new MemberImportError('Emails in provided data don\'t appear to be valid email addresses.'));
}
const hasStripeId = this._containsRecordsWithStripeId(validatedSet); const hasStripeId = this._containsRecordsWithStripeId(validatedSet);
if (hasStripeId) { if (hasStripeId) {
// check can be done on whole set as it won't be too slow // check can be done on whole set as it won't be too slow
if (!this.membersUtils.isStripeEnabled) { if (!this.membersUtils.isStripeEnabled) {
validationResults.push(new MemberImportError(`You need to connect to Stripe first to import Stripe data.`)); validationResults.push(new MemberImportError(`You need to <a href="#/settings/labs">connect to Stripe</a> to import Stripe customers.`));
} else { } else {
let stripeSeverValidation = await this._checkStripeServer(validatedSet); let stripeSeverValidation = await this._checkStripeServer(validatedSet);
if (stripeSeverValidation !== true) { if (stripeSeverValidation !== true) {
validationResults.push(new MemberImportError('Stripe customer IDs exist in the data, but we could not find such customer in connected Stripe account')); validationResults.push(new MemberImportError(`The CSV contains Stripe customers from a different Stripe account. Make sure you're connected to the correct <a href="#/settings/labs">Stripe account</a>.`));
} }
} }
let hasDuplicateStripeIds = this._hasDuplicateStripeIds(data);
if (hasDuplicateStripeIds === true) {
validationResults.push(new MemberImportError('Members with same Stripe customer IDs will not be imported.'));
}
} }
if (validationResults.length) { if (validationResults.length) {

View file

@ -423,12 +423,18 @@ textarea.gh-member-details-textarea {
border-radius: 4px; border-radius: 4px;
padding: 8px; padding: 8px;
margin-bottom: 20px; margin-bottom: 20px;
color: var(--middarkgrey);
} }
.gh-members-upload-warningmessage { .gh-members-upload-warningmessage {
border-left: 4px solid var(--yellow); border-left: 4px solid var(--yellow);
} }
.gh-members-upload-warningmessage p a {
color: color-mod(var(--yellow) l(-12%));
text-decoration: underline;
}
.gh-members-upload-errormessage { .gh-members-upload-errormessage {
border-left: 4px solid var(--red); border-left: 4px solid var(--red);
} }