Added import tier to members import modal (#17492)
refs https://github.com/TryGhost/Product/issues/3629
This commit is contained in:
parent
dc5cc28036
commit
2fe392c312
@ -1,5 +1,6 @@
|
||||
import Component from '@glimmer/component';
|
||||
import {action} from '@ember/object';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
|
||||
const FIELD_MAPPINGS = [
|
||||
@ -14,7 +15,13 @@ const FIELD_MAPPINGS = [
|
||||
];
|
||||
|
||||
export default class extends Component {
|
||||
@tracked availableFields = FIELD_MAPPINGS;
|
||||
@service feature;
|
||||
@tracked availableFields = [
|
||||
...FIELD_MAPPINGS,
|
||||
...(
|
||||
this.feature.importMemberTier ? [{label: 'Tier', value: 'import_tier'}] : []
|
||||
)
|
||||
];
|
||||
|
||||
get mapTo() {
|
||||
return this.args.mapTo;
|
||||
|
@ -6,6 +6,7 @@ import {isEmpty} from '@ember/utils';
|
||||
@classic
|
||||
export default class MemberImportValidatorService extends Service {
|
||||
@service ajax;
|
||||
@service feature;
|
||||
@service membersUtils;
|
||||
|
||||
@service ghostPaths;
|
||||
@ -22,6 +23,7 @@ export default class MemberImportValidatorService extends Service {
|
||||
* If the data contains 30 rows or fewer, all rows should be validated.
|
||||
*
|
||||
* @param {Array} data JSON objects mapped from CSV file
|
||||
* @param {number} validationSampleSize number of rows to sample
|
||||
*/
|
||||
_sampleData(data, validationSampleSize = 30) {
|
||||
let validatedSet = [{}];
|
||||
@ -86,13 +88,17 @@ export default class MemberImportValidatorService extends Service {
|
||||
'created_at'
|
||||
];
|
||||
|
||||
if (this.feature.importMemberTier) {
|
||||
supportedTypes.push('import_tier');
|
||||
}
|
||||
|
||||
const autoDetectedTypes = [
|
||||
'email'
|
||||
];
|
||||
|
||||
let mapping = {};
|
||||
let i = 0;
|
||||
// loopping through all sampled data until needed data types are detected
|
||||
// looping through all sampled data until needed data types are detected
|
||||
while (i <= (data.length - 1)) {
|
||||
if (mapping.email && mapping.stripe_customer_id) {
|
||||
break;
|
||||
|
@ -55,6 +55,7 @@ const unparse = (members, columns = DEFAULT_COLUMNS.slice()) => {
|
||||
deleted_at: member.deleted_at,
|
||||
labels: labels,
|
||||
tiers: tiers,
|
||||
import_tier: member.import_tier || null,
|
||||
error: member.error || null
|
||||
};
|
||||
});
|
||||
|
@ -21,7 +21,8 @@ const DEFAULT_CSV_HEADER_MAPPING = {
|
||||
created_at: 'created_at',
|
||||
complimentary_plan: 'complimentary_plan',
|
||||
stripe_customer_id: 'stripe_customer_id',
|
||||
labels: 'labels'
|
||||
labels: 'labels',
|
||||
import_tier: 'import_tier'
|
||||
};
|
||||
|
||||
module.exports = class MembersCSVImporter {
|
||||
|
Loading…
Reference in New Issue
Block a user