2022-03-16 12:33:34 +01:00
|
|
|
import Controller from "@ember/controller";
|
|
|
|
import { or } from "@ember/object/computed";
|
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
|
|
|
|
|
|
const reasons = {
|
|
|
|
noWizard: "none",
|
|
|
|
requiresLogin: "requires_login",
|
|
|
|
notPermitted: "not_permitted",
|
2022-03-16 12:46:16 +01:00
|
|
|
completed: "completed",
|
|
|
|
};
|
2022-03-16 12:33:34 +01:00
|
|
|
|
|
|
|
export default Controller.extend({
|
2022-03-16 12:46:16 +01:00
|
|
|
noAccess: or("noWizard", "requiresLogin", "notPermitted", "completed"),
|
2022-03-16 12:33:34 +01:00
|
|
|
|
2022-03-16 12:46:16 +01:00
|
|
|
@discourseComputed("noAccessReason")
|
2022-03-16 12:33:34 +01:00
|
|
|
noAccessI18nKey(reason) {
|
2022-03-16 12:46:16 +01:00
|
|
|
return reason ? `wizard.${reasons[reason]}` : "wizard.none";
|
2022-03-16 12:33:34 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
@discourseComputed
|
|
|
|
noAccessReason() {
|
2022-03-16 12:46:16 +01:00
|
|
|
return Object.keys(reasons).find((reason) => this.get(reason));
|
|
|
|
},
|
2022-03-16 12:33:34 +01:00
|
|
|
});
|