2023-09-23 19:30:11 +02:00
|
|
|
import { inject as service } from "@ember/service";
|
|
|
|
import { action, computed } from "@ember/object";
|
2023-09-24 12:58:20 +02:00
|
|
|
import Component from "@glimmer/component";
|
2023-10-09 14:39:10 +02:00
|
|
|
import { tracked } from "@glimmer/tracking";
|
2023-09-23 19:30:11 +02:00
|
|
|
import DiscourseURL from "discourse/lib/url";
|
|
|
|
import I18n from "I18n";
|
|
|
|
|
|
|
|
export default class WizardSubscriptionBadge extends Component {
|
|
|
|
@service subscription;
|
2023-10-09 14:39:10 +02:00
|
|
|
@tracked updating = false;
|
|
|
|
@tracked updateIcon = null;
|
|
|
|
basePath = "/admin/plugins/subscription-client";
|
2023-09-23 19:30:11 +02:00
|
|
|
|
|
|
|
@computed("subscription.subscriptionType")
|
|
|
|
get i18nKey() {
|
2023-09-24 12:58:20 +02:00
|
|
|
return `admin.wizard.subscription.type.${
|
|
|
|
this.subscription.subscriptionType
|
|
|
|
? this.subscription.subscriptionType
|
|
|
|
: "none"
|
|
|
|
}`;
|
|
|
|
}
|
2023-09-23 19:30:11 +02:00
|
|
|
|
|
|
|
@computed("i18nKey")
|
|
|
|
get title() {
|
2023-09-24 14:01:46 +02:00
|
|
|
return `${this.i18nKey}.title`;
|
2023-09-24 12:58:20 +02:00
|
|
|
}
|
2023-09-23 19:30:11 +02:00
|
|
|
|
|
|
|
@computed("i18nKey")
|
|
|
|
get label() {
|
|
|
|
return I18n.t(`${this.i18nKey}.label`);
|
2023-09-24 12:58:20 +02:00
|
|
|
}
|
2023-09-23 19:30:11 +02:00
|
|
|
|
|
|
|
@action
|
|
|
|
click() {
|
|
|
|
DiscourseURL.routeTo(this.subscription.subscriptionLink);
|
2023-09-24 12:58:20 +02:00
|
|
|
}
|
2023-10-09 14:39:10 +02:00
|
|
|
|
|
|
|
@action
|
|
|
|
update() {
|
2023-11-15 15:28:54 +01:00
|
|
|
this.updating = true;
|
|
|
|
this.updateIcon = "check";
|
2023-11-15 16:36:21 +01:00
|
|
|
this.subscription.updateSubscriptionStatus().finally(() => {
|
2023-11-15 15:28:54 +01:00
|
|
|
this.updating = false;
|
|
|
|
setTimeout(() => {
|
|
|
|
this.updateIcon = null;
|
|
|
|
}, 5000);
|
2023-11-15 15:39:42 +01:00
|
|
|
});
|
2023-10-09 14:39:10 +02:00
|
|
|
}
|
2023-11-15 15:39:42 +01:00
|
|
|
}
|