mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-02 08:13:34 +03:00
a199e87201
no issue - updated single member delete modal copy + design layout - swapped switch to regular checkbox + applied red color to it - set button label based on checkbox state
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
import ModalComponent from 'ghost-admin/components/modal-base';
|
|
import {alias} from '@ember/object/computed';
|
|
import {computed} from '@ember/object';
|
|
import {reads} from '@ember/object/computed';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default ModalComponent.extend({
|
|
membersStats: service(),
|
|
|
|
shouldCancelSubscriptions: false,
|
|
|
|
// Allowed actions
|
|
confirm: () => {},
|
|
|
|
member: alias('model'),
|
|
|
|
cancelSubscriptions: reads('shouldCancelSubscriptions'),
|
|
|
|
hasActiveStripeSubscriptions: computed('member', function () {
|
|
let subscriptions = this.member.get('stripe');
|
|
|
|
if (!subscriptions || subscriptions.length === 0) {
|
|
return false;
|
|
}
|
|
|
|
let firstActiveStripeSubscription = subscriptions.find((subscription) => {
|
|
return subscription.status === 'active' || subscription.status === 'trialing';
|
|
});
|
|
|
|
return firstActiveStripeSubscription !== undefined;
|
|
}),
|
|
|
|
actions: {
|
|
confirm() {
|
|
this.deleteMember.perform();
|
|
},
|
|
|
|
toggleShouldCancelSubscriptions() {
|
|
this.set('shouldCancelSubscriptions', !this.shouldCancelSubscriptions);
|
|
}
|
|
},
|
|
|
|
deleteMember: task(function* () {
|
|
try {
|
|
yield this.confirm(this.shouldCancelSubscriptions);
|
|
this.membersStats.invalidate();
|
|
} finally {
|
|
this.send('closeModal');
|
|
}
|
|
}).drop()
|
|
});
|