0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2025-02-02 11:27:01 +01:00
discourse-custom-wizard/assets/javascripts/discourse/components/wizard-subscription-badge.js

47 Zeilen
1,1 KiB
JavaScript

import { inject as service } from "@ember/service";
import { action, computed } from "@ember/object";
2023-09-24 11:58:20 +01:00
import Component from "@glimmer/component";
2023-10-09 13:39:10 +01:00
import { tracked } from "@glimmer/tracking";
import I18n from "I18n";
export default class WizardSubscriptionBadge extends Component {
@service subscription;
2023-10-09 13:39:10 +01:00
@tracked updating = false;
@tracked updateIcon = "sync";
2023-10-09 13:39:10 +01:00
basePath = "/admin/plugins/subscription-client";
@computed("subscription.subscriptionType")
get i18nKey() {
2023-09-24 11:58:20 +01:00
return `admin.wizard.subscription.type.${
this.subscription.subscriptionType
? this.subscription.subscriptionType
: "none"
}`;
}
@computed("i18nKey")
get title() {
2023-09-24 13:01:46 +01:00
return `${this.i18nKey}.title`;
2023-09-24 11:58:20 +01:00
}
@computed("i18nKey")
get label() {
return I18n.t(`${this.i18nKey}.label`);
2023-09-24 11:58:20 +01:00
}
@action
click() {
2023-11-17 16:17:10 +01:00
window.open(this.subscription.subscriptionCtaLink, "_blank").focus();
2023-09-24 11:58:20 +01:00
}
2023-10-09 13:39:10 +01:00
@action
update() {
this.updating = true;
this.updateIcon = null;
this.subscription.updateSubscriptionStatus().finally(() => {
this.updateIcon = "sync";
this.updating = false;
2023-11-15 14:39:42 +00:00
});
2023-10-09 13:39:10 +01:00
}
2023-11-15 14:39:42 +00:00
}