Ghost/ghost/admin/app/components/modals/tiers/unarchive.js
Rishabh 498efd00cb Refined tiers list to switch to active list on unarchive
refs https://github.com/TryGhost/Team/issues/1252

- on unarchiving a tier, we switch back to active tier list instead of staying back on archived list
2022-02-02 16:24:20 +05:30

32 lines
829 B
JavaScript

import Component from '@glimmer/component';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency-decorators';
export default class UnarchiveTierModalComponent extends Component {
@service notifications;
@service router;
get isActive() {
const {product} = this.args.data;
return !!product.active;
}
@task({drop: true})
*unarchiveTask() {
const {product, onUnarchive} = this.args.data;
product.active = true;
try {
yield product.save();
onUnarchive?.();
return product;
} catch (error) {
if (error) {
this.notifications.showAPIError(error, {key: 'tier.unarchive.failed'});
}
} finally {
this.args.close();
}
}
}