diff --git a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6
index e19e4917..d1aacfb8 100644
--- a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6
+++ b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6
@@ -15,7 +15,7 @@ import {
import Component from "@ember/component";
import { bind, later } from "@ember/runloop";
import I18n from "I18n";
-import Subscription from "../mixins/subscription";
+import { inject as service } from "@ember/service";
const customFieldActionMap = {
topic: ["create_topic", "send_message"],
@@ -27,8 +27,9 @@ const customFieldActionMap = {
const values = ["present", "true", "false"];
-export default Component.extend(Subscription, {
+export default Component.extend({
classNameBindings: [":mapper-selector", "activeType"],
+ subscription: service(),
showText: computed("activeType", function () {
return this.showInput("text");
@@ -130,7 +131,7 @@ export default Component.extend(Subscription, {
return this.connector === "is";
}),
- @discourseComputed("site.groups", "guestGroup", "subscriptionType")
+ @discourseComputed("site.groups", "guestGroup", "subscription.subscriptionType")
groups(groups, guestGroup, subscriptionType) {
let result = groups;
if (!guestGroup) {
diff --git a/assets/javascripts/discourse/components/wizard-subscription-badge.hbs b/assets/javascripts/discourse/components/wizard-subscription-badge.hbs
new file mode 100644
index 00000000..62a85ba8
--- /dev/null
+++ b/assets/javascripts/discourse/components/wizard-subscription-badge.hbs
@@ -0,0 +1,26 @@
+
+
+ {{label}}
+
\ No newline at end of file
diff --git a/assets/javascripts/discourse/components/wizard-subscription-badge.js b/assets/javascripts/discourse/components/wizard-subscription-badge.js
new file mode 100644
index 00000000..34df9ea4
--- /dev/null
+++ b/assets/javascripts/discourse/components/wizard-subscription-badge.js
@@ -0,0 +1,29 @@
+import { inject as service } from "@ember/service";
+import { action, computed } from "@ember/object";
+import Component from '@glimmer/component';
+import DiscourseURL from "discourse/lib/url";
+import I18n from "I18n";
+
+export default class WizardSubscriptionBadge extends Component {
+ @service subscription;
+
+ @computed("subscription.subscriptionType")
+ get i18nKey() {
+ return `admin.wizard.subscription.type.${this.subscription.subscriptionType ? this.subscription.subscriptionType : "none"}`;
+ };
+
+ @computed("i18nKey")
+ get title() {
+ return I18n.t(`${this.i18nKey}.title`);
+ };
+
+ @computed("i18nKey")
+ get label() {
+ return I18n.t(`${this.i18nKey}.label`);
+ };
+
+ @action
+ click() {
+ DiscourseURL.routeTo(this.subscription.subscriptionLink);
+ };
+};
diff --git a/assets/javascripts/discourse/components/wizard-subscription-badge.js.es6 b/assets/javascripts/discourse/components/wizard-subscription-badge.js.es6
deleted file mode 100644
index 301c618e..00000000
--- a/assets/javascripts/discourse/components/wizard-subscription-badge.js.es6
+++ /dev/null
@@ -1,30 +0,0 @@
-import Component from "@ember/component";
-import discourseComputed from "discourse-common/utils/decorators";
-import Subscription from "../mixins/subscription";
-import DiscourseURL from "discourse/lib/url";
-import I18n from "I18n";
-
-export default Component.extend(Subscription, {
- tagName: "a",
- classNameBindings: [":wizard-subscription-badge", "subscriptionType"],
- attributeBindings: ["title"],
-
- @discourseComputed("subscriptionType")
- i18nKey(type) {
- return `admin.wizard.subscription.type.${type ? type : "none"}`;
- },
-
- @discourseComputed("i18nKey")
- title(i18nKey) {
- return I18n.t(`${i18nKey}.title`);
- },
-
- @discourseComputed("i18nKey")
- label(i18nKey) {
- return I18n.t(`${i18nKey}.label`);
- },
-
- click() {
- DiscourseURL.routeTo(this.subscriptionLink);
- },
-});
diff --git a/assets/javascripts/discourse/components/wizard-subscription-container.js.es6 b/assets/javascripts/discourse/components/wizard-subscription-container.js.es6
index 3a1eac9c..8c750519 100644
--- a/assets/javascripts/discourse/components/wizard-subscription-container.js.es6
+++ b/assets/javascripts/discourse/components/wizard-subscription-container.js.es6
@@ -1,23 +1,24 @@
import Component from "@ember/component";
import discourseComputed from "discourse-common/utils/decorators";
-import Subscription from "../mixins/subscription";
+import { inject as service } from "@ember/service";
-export default Component.extend(Subscription, {
+export default Component.extend({
classNameBindings: [":wizard-subscription-container", "subscribed"],
+ subscription: service(),
- @discourseComputed("subscribed")
+ @discourseComputed("subscription.subscribed")
subscribedIcon(subscribed) {
return subscribed ? "check" : "times";
},
- @discourseComputed("subscribed")
+ @discourseComputed("subscription.subscribed")
subscribedLabel(subscribed) {
return `admin.wizard.subscription.${
subscribed ? "subscribed" : "not_subscribed"
}.label`;
},
- @discourseComputed("subscribed")
+ @discourseComputed("subscription.subscribed")
subscribedTitle(subscribed) {
return `admin.wizard.subscription.${
subscribed ? "subscribed" : "not_subscribed"
diff --git a/assets/javascripts/discourse/components/wizard-subscription-cta.hbs b/assets/javascripts/discourse/components/wizard-subscription-cta.hbs
new file mode 100644
index 00000000..04f5b6a2
--- /dev/null
+++ b/assets/javascripts/discourse/components/wizard-subscription-cta.hbs
@@ -0,0 +1,3 @@
+
+ {{d-icon icon}}{{label}}
+
\ No newline at end of file
diff --git a/assets/javascripts/discourse/components/wizard-subscription-cta.js b/assets/javascripts/discourse/components/wizard-subscription-cta.js
new file mode 100644
index 00000000..ea4990bd
--- /dev/null
+++ b/assets/javascripts/discourse/components/wizard-subscription-cta.js
@@ -0,0 +1,36 @@
+
+import { inject as service } from "@ember/service";
+import { action, computed } from "@ember/object";
+import I18n from "I18n";
+import Component from '@glimmer/component';
+
+export default class WizardSubscriptionCta extends Component {
+ @service subscription;
+
+ @computed("subscription.subscribed")
+ get i18nKey() {
+ return `admin.wizard.subscription.cta.${
+ this.subscription.subscribed ? "subscribed" : "none"
+ }`;
+ };
+
+ @computed("subscription.subscribed")
+ get icon() {
+ return this.subscription.subscribed ? "far-life-ring" : "external-link-alt";
+ };
+
+ @computed("i18nKey")
+ get title() {
+ return I18n.t(`${this.i18nKey}.title`);
+ };
+
+ @computed("i18nKey")
+ get label() {
+ return I18n.t(`${this.i18nKey}.label`);
+ };
+
+ @action
+ click() {
+ window.open(this.subscription.subscriptionCtaLink, "_blank").focus();
+ };
+};
diff --git a/assets/javascripts/discourse/components/wizard-subscription-cta.js.es6 b/assets/javascripts/discourse/components/wizard-subscription-cta.js.es6
deleted file mode 100644
index f483fbe8..00000000
--- a/assets/javascripts/discourse/components/wizard-subscription-cta.js.es6
+++ /dev/null
@@ -1,36 +0,0 @@
-import Component from "@ember/component";
-import discourseComputed from "discourse-common/utils/decorators";
-import Subscription from "../mixins/subscription";
-import I18n from "I18n";
-
-export default Component.extend(Subscription, {
- tagName: "a",
- classNameBindings: [":btn", ":btn-pavilion-support", "subscriptionType"],
- attributeBindings: ["title"],
-
- @discourseComputed("subscribed")
- i18nKey(subscribed) {
- return `admin.wizard.subscription.cta.${
- subscribed ? "subscribed" : "none"
- }`;
- },
-
- @discourseComputed("subscribed")
- icon(subscribed) {
- return subscribed ? "far-life-ring" : "external-link-alt";
- },
-
- @discourseComputed("i18nKey")
- title(i18nKey) {
- return I18n.t(`${i18nKey}.title`);
- },
-
- @discourseComputed("i18nKey")
- label(i18nKey) {
- return I18n.t(`${i18nKey}.label`);
- },
-
- click() {
- window.open(this.subscriptionCtaLink, "_blank").focus();
- },
-});
diff --git a/assets/javascripts/discourse/components/wizard-subscription-selector.js.es6 b/assets/javascripts/discourse/components/wizard-subscription-selector.js.es6
index 351b5782..2c81c34b 100644
--- a/assets/javascripts/discourse/components/wizard-subscription-selector.js.es6
+++ b/assets/javascripts/discourse/components/wizard-subscription-selector.js.es6
@@ -1,5 +1,5 @@
import SingleSelectComponent from "select-kit/components/single-select";
-import Subscription from "../mixins/subscription";
+import { inject as service } from "@ember/service";
import { filterValues } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
import discourseComputed from "discourse-common/utils/decorators";
import I18n from "I18n";
@@ -12,8 +12,9 @@ const nameKey = function (feature, attribute, value) {
}
};
-export default SingleSelectComponent.extend(Subscription, {
+export default SingleSelectComponent.extend({
classNames: ["combo-box", "wizard-subscription-selector"],
+ subscription: service(),
selectKitOptions: {
autoFilterable: false,
@@ -26,13 +27,13 @@ export default SingleSelectComponent.extend(Subscription, {
},
allowedSubscriptionTypes(feature, attribute, value) {
- let attributes = this.subscriptionAttributes[feature];
+ let attributes = this.subscription.subscriptionAttributes[feature];
if (!attributes || !attributes[attribute]) {
return ["none"];
}
let allowedTypes = [];
Object.keys(attributes[attribute]).forEach((subscriptionType) => {
- let values = attributes[attribute][subscriptionType];
+ let values = attributes[attribute][subscription.subscriptionType];
if (values[0] === "*" || values.includes(value)) {
allowedTypes.push(subscriptionType);
}
@@ -44,7 +45,7 @@ export default SingleSelectComponent.extend(Subscription, {
content(feature, attribute) {
return filterValues(this.wizard, feature, attribute)
.map((value) => {
- let allowedSubscriptionTypes = this.allowedSubscriptionTypes(
+ let allowedSubscriptionTypes = this.subscription.allowedSubscriptionTypes(
feature,
attribute,
value
diff --git a/assets/javascripts/discourse/templates/components/wizard-subscription-status.hbs b/assets/javascripts/discourse/components/wizard-subscription-status.hbs
similarity index 100%
rename from assets/javascripts/discourse/templates/components/wizard-subscription-status.hbs
rename to assets/javascripts/discourse/components/wizard-subscription-status.hbs
diff --git a/assets/javascripts/discourse/mixins/subscription.js.es6 b/assets/javascripts/discourse/mixins/subscription.js.es6
deleted file mode 100644
index 426b88a6..00000000
--- a/assets/javascripts/discourse/mixins/subscription.js.es6
+++ /dev/null
@@ -1,48 +0,0 @@
-import Mixin from "@ember/object/mixin";
-import { getOwner } from "discourse-common/lib/get-owner";
-import { readOnly } from "@ember/object/computed";
-import discourseComputed from "discourse-common/utils/decorators";
-
-const PRODUCT_PAGE = "https://custom-wizard.pavilion.tech";
-const SUPPORT_MESSAGE =
- "https://coop.pavilion.tech/new-message?username=support&title=Custom%20Wizard%20Support";
-const MANAGER_CATEGORY =
- "https://discourse.pluginmanager.org/c/discourse-custom-wizard";
-
-export default Mixin.create({
- subscriptionLandingUrl: PRODUCT_PAGE,
- subscriptionClientUrl: "/admin/plugins/subscription-client",
-
- @discourseComputed
- adminWizards() {
- return getOwner(this).lookup("controller:admin-wizards");
- },
-
- subscribed: readOnly("adminWizards.subscribed"),
- subscriptionType: readOnly("adminWizards.subscriptionType"),
- businessSubscription: readOnly("adminWizards.businessSubscription"),
- communitySubscription: readOnly("adminWizards.communitySubscription"),
- standardSubscription: readOnly("adminWizards.standardSubscription"),
- subscriptionAttributes: readOnly("adminWizards.subscriptionAttributes"),
-
- @discourseComputed
- subscriptionLink() {
- return this.subscriptionLandingUrl;
- },
-
- @discourseComputed("subscriptionType")
- subscriptionCtaLink(subscriptionType) {
- switch (subscriptionType) {
- case "none":
- return PRODUCT_PAGE;
- case "standard":
- return SUPPORT_MESSAGE;
- case "business":
- return SUPPORT_MESSAGE;
- case "community":
- return MANAGER_CATEGORY;
- default:
- return PRODUCT_PAGE;
- }
- },
-});
diff --git a/assets/javascripts/discourse/services/subscription.js b/assets/javascripts/discourse/services/subscription.js
new file mode 100644
index 00000000..61790c10
--- /dev/null
+++ b/assets/javascripts/discourse/services/subscription.js
@@ -0,0 +1,41 @@
+import Service from '@ember/service';
+import { getOwner } from "discourse-common/lib/get-owner";
+
+const PRODUCT_PAGE = "https://custom-wizard.pavilion.tech";
+const SUPPORT_MESSAGE =
+ "https://coop.pavilion.tech/new-message?username=support&title=Custom%20Wizard%20Support";
+const MANAGER_CATEGORY =
+ "https://discourse.pluginmanager.org/c/discourse-custom-wizard";
+
+export default class Subscription extends Service {
+ subscriptionLandingUrl = PRODUCT_PAGE;
+ subscribed = this.adminWizards.subscribed;
+ subscriptionType = this.adminWizards.subscriptionType;
+ businessSubscription = this.adminWizards.businessSubscription;
+ communitySubscription = this.adminWizards.communitySubscription;
+ standardSubscription = this.adminWizards.standardSubscription;
+ subscriptionAttributes = this.adminWizards.subscriptionAttributes;
+
+ get adminWizards() {
+ return getOwner(this).lookup("controller:admin-wizards");
+ };
+
+ get subscriptionLink() {
+ return this.subscriptionLandingUrl;
+ };
+
+ get subscriptionCtaLink() {
+ switch (this.subscriptionType) {
+ case "none":
+ return PRODUCT_PAGE;
+ case "standard":
+ return SUPPORT_MESSAGE;
+ case "business":
+ return SUPPORT_MESSAGE;
+ case "community":
+ return MANAGER_CATEGORY;
+ default:
+ return PRODUCT_PAGE;
+ }
+ };
+}
\ No newline at end of file
diff --git a/assets/javascripts/discourse/templates/components/wizard-subscription-badge.hbs b/assets/javascripts/discourse/templates/components/wizard-subscription-badge.hbs
deleted file mode 100644
index baba957c..00000000
--- a/assets/javascripts/discourse/templates/components/wizard-subscription-badge.hbs
+++ /dev/null
@@ -1,24 +0,0 @@
-
-{{label}}
\ No newline at end of file
diff --git a/assets/javascripts/discourse/templates/components/wizard-subscription-cta.hbs b/assets/javascripts/discourse/templates/components/wizard-subscription-cta.hbs
deleted file mode 100644
index cb20df2b..00000000
--- a/assets/javascripts/discourse/templates/components/wizard-subscription-cta.hbs
+++ /dev/null
@@ -1 +0,0 @@
-{{d-icon icon}}{{label}}
\ No newline at end of file