0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-26 19:10:29 +01:00
discourse-custom-wizard/assets/javascripts/discourse/controllers/admin-wizards-pro.js.es6

63 Zeilen
1,7 KiB
Text

import Controller from "@ember/controller";
import discourseComputed from "discourse-common/utils/decorators";
import CustomWizardPro from "../models/custom-wizard-pro";
import { alias } from "@ember/object/computed";
export default Controller.extend({
messageUrl: "https://thepavilion.io/t/3652",
2021-09-07 14:13:01 +02:00
messageType: "info",
messageKey: null,
2021-09-07 14:13:01 +02:00
showSubscription: alias("model.authentication.active"),
setup() {
2021-09-07 14:13:01 +02:00
const authentication = this.get("model.authentication");
const subscription = this.get("model.subscription");
const subscribed = subscription && subscription.active;
const authenticated = authentication && authentication.active;
if (!subscribed) {
2021-09-07 14:13:01 +02:00
this.set("messageKey", authenticated ? "not_subscribed" : "authorize");
} else {
2021-09-07 14:13:01 +02:00
this.set(
"messageKey",
!authenticated
? "subscription_expiring"
: subscribed
? "subscription_active"
: "subscription_inactive"
);
}
},
2021-09-07 14:13:01 +02:00
@discourseComputed("model.server")
messageOpts(server) {
return { server };
},
actions: {
unauthorize() {
2021-09-07 14:13:01 +02:00
this.set("unauthorizing", true);
2021-09-07 14:13:01 +02:00
CustomWizardPro.unauthorize()
.then((result) => {
if (result.success) {
this.setProperties({
messageKey: "unauthorized",
messageType: "warn",
"model.authentication": null,
"model.subscription": null,
});
} else {
this.setProperties({
messageKey: "unauthorize_failed",
messageType: "error",
});
}
})
.finally(() => {
this.set("unauthorizing", false);
});
},
},
});