mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
31 lines
786 B
JavaScript
31 lines
786 B
JavaScript
|
import Component from '@glimmer/component';
|
||
|
import {inject as service} from '@ember/service';
|
||
|
import {task} from 'ember-concurrency-decorators';
|
||
|
|
||
|
export default class ArchiveTierModalComponent extends Component {
|
||
|
@service notifications;
|
||
|
@service router;
|
||
|
|
||
|
get isActive() {
|
||
|
const {product} = this.args.data;
|
||
|
return !!product.active;
|
||
|
}
|
||
|
|
||
|
@task({drop: true})
|
||
|
*archiveTierTask() {
|
||
|
const {product} = this.args.data;
|
||
|
product.active = false;
|
||
|
|
||
|
try {
|
||
|
yield product.save();
|
||
|
return product;
|
||
|
} catch (error) {
|
||
|
if (error) {
|
||
|
this.notifications.showAPIError(error, {key: 'tier.archive.failed'});
|
||
|
}
|
||
|
} finally {
|
||
|
this.args.close();
|
||
|
}
|
||
|
}
|
||
|
}
|