2022-01-31 21:26:12 +03:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import {inject as service} from '@ember/service';
|
2022-02-09 13:49:38 +03:00
|
|
|
import {task} from 'ember-concurrency';
|
2022-01-31 21:26:12 +03:00
|
|
|
|
2022-03-14 13:52:04 +03:00
|
|
|
export default class ArchiveTierModal extends Component {
|
2022-01-31 21:26:12 +03:00
|
|
|
@service notifications;
|
|
|
|
@service router;
|
|
|
|
|
|
|
|
get isActive() {
|
2022-05-11 20:11:54 +03:00
|
|
|
const {tier} = this.args.data;
|
|
|
|
return !!tier.active;
|
2022-01-31 21:26:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@task({drop: true})
|
|
|
|
*archiveTierTask() {
|
2022-05-11 20:11:54 +03:00
|
|
|
const {tier, onArchive} = this.args.data;
|
|
|
|
tier.active = false;
|
|
|
|
tier.visibility = 'none';
|
2022-01-31 21:26:12 +03:00
|
|
|
|
|
|
|
try {
|
2022-05-11 20:11:54 +03:00
|
|
|
yield tier.save();
|
2022-03-09 10:35:07 +03:00
|
|
|
onArchive?.();
|
2022-05-11 20:11:54 +03:00
|
|
|
return tier;
|
2022-01-31 21:26:12 +03:00
|
|
|
} catch (error) {
|
|
|
|
if (error) {
|
|
|
|
this.notifications.showAPIError(error, {key: 'tier.archive.failed'});
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
this.args.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|