diff --git a/assets/javascripts/discourse/components/wizard-subscription-selector.js.es6 b/assets/javascripts/discourse/components/wizard-subscription-selector.js.es6 index 445a7e37..b7203c30 100644 --- a/assets/javascripts/discourse/components/wizard-subscription-selector.js.es6 +++ b/assets/javascripts/discourse/components/wizard-subscription-selector.js.es6 @@ -60,10 +60,9 @@ export default SingleSelectComponent.extend({ name: I18n.t(nameKey(feature, attribute, value)), subscriptionRequired, }; - if (subscriptionRequired) { let subscribed = allowedSubscriptionTypes.includes( - this.subscriptionType + this.subscription.subscriptionType ); let selectorKey = subscribed ? "subscribed" : "not_subscribed"; let selectorLabel = `admin.wizard.subscription.${selectorKey}.selector`; diff --git a/assets/javascripts/discourse/services/subscription.js b/assets/javascripts/discourse/services/subscription.js index fe9ba715..801f5e0f 100644 --- a/assets/javascripts/discourse/services/subscription.js +++ b/assets/javascripts/discourse/services/subscription.js @@ -2,7 +2,6 @@ import Service from "@ember/service"; import { tracked } from "@glimmer/tracking"; import { ajax } from "discourse/lib/ajax"; import { popupAjaxError } from "discourse/lib/ajax-error"; -import { equal } from "@ember/object/computed"; const PRODUCT_PAGE = "https://custom-wizard.pavilion.tech"; const SUPPORT_MESSAGE = @@ -30,9 +29,9 @@ export default class SubscriptionService extends Service { this.subscribed = result.subscribed; this.subscriptionType = result.subscription_type; this.subscriptionAttributes = result.subscription_attributes; - this.businessSubscription = equal(this.subscriptionType, "business"); - this.communitySubscription = equal(this.subscriptionType, "community"); - this.standardSubscription = equal(this.subscriptionType, "standard"); + this.businessSubscription = this.subscriptionType === "business"; + this.communitySubscription = this.subscriptionType === "community"; + this.standardSubscription = this.subscriptionType === "standard"; }) .catch(popupAjaxError); } diff --git a/test/javascripts/acceptance/admin-custom-fields-unsubscribed-test.js b/test/javascripts/acceptance/admin-custom-fields-unsubscribed-test.js index 4a305344..c84bff45 100644 --- a/test/javascripts/acceptance/admin-custom-fields-unsubscribed-test.js +++ b/test/javascripts/acceptance/admin-custom-fields-unsubscribed-test.js @@ -10,6 +10,7 @@ import { getCustomFields, getUnsubscribedAdminWizards, getWizard, + getSuppliers, } from "../helpers/admin-wizard"; import { Promise } from "rsvp"; @@ -19,7 +20,6 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) { custom_wizard_enabled: true, available_locales: JSON.stringify([{ name: "English", value: "en" }]), }); - needs.pretender((server, helper) => { server.get("/admin/wizards/wizard", () => { return helper.response(getWizard); @@ -36,6 +36,9 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) { server.delete("/admin/wizards/custom-fields/topic_custom_field", () => { return helper.response({ success: "OK" }); }); + server.get("/admin/plugins/subscription-client/suppliers", () => { + return helper.response(getSuppliers); + }); }); async function selectTypeAndSerializerAndFillInName( diff --git a/test/javascripts/acceptance/admin-logs-test.js b/test/javascripts/acceptance/admin-logs-test.js index d3489dee..c6a52073 100644 --- a/test/javascripts/acceptance/admin-logs-test.js +++ b/test/javascripts/acceptance/admin-logs-test.js @@ -6,6 +6,7 @@ import { getUnsubscribedAdminWizards, getWizard, getWizardTestingLog, + getSuppliers, } from "../helpers/admin-wizard"; acceptance("Admin | Logs", function (needs) { @@ -29,6 +30,9 @@ acceptance("Admin | Logs", function (needs) { server.get("/admin/wizards/wizard", () => { return helper.response(getWizard); }); + server.get("/admin/plugins/subscription-client/suppliers", () => { + return helper.response(getSuppliers); + }); }); test("viewing logs fields tab", async (assert) => { await visit("/admin/wizards/logs"); diff --git a/test/javascripts/acceptance/admin-manager-test.js b/test/javascripts/acceptance/admin-manager-test.js index 92bb2c43..29cb2e93 100644 --- a/test/javascripts/acceptance/admin-manager-test.js +++ b/test/javascripts/acceptance/admin-manager-test.js @@ -5,6 +5,7 @@ import { getUnsubscribedAdminWizards, getWizard, getWizardTestingLog, + getSuppliers, } from "../helpers/admin-wizard"; import { Promise } from "rsvp"; @@ -33,6 +34,9 @@ acceptance("Admin | Manager", function (needs) { failures: [], }); }); + server.get("/admin/plugins/subscription-client/suppliers", () => { + return helper.response(getSuppliers); + }); }); async function waitForDestructionAndResetMessage() { await waitUntil( diff --git a/test/javascripts/acceptance/admin-submissions-test.js b/test/javascripts/acceptance/admin-submissions-test.js index 767e190c..dd0c3ce2 100644 --- a/test/javascripts/acceptance/admin-submissions-test.js +++ b/test/javascripts/acceptance/admin-submissions-test.js @@ -7,6 +7,7 @@ import { getUnsubscribedAdminWizards, getWizard, getWizardSubmissions, + getSuppliers, } from "../helpers/admin-wizard"; acceptance("Admin | Submissions", function (needs) { diff --git a/test/javascripts/acceptance/admin-wizards-api-test.js b/test/javascripts/acceptance/admin-wizards-api-test.js index ff59e65f..21256b8d 100644 --- a/test/javascripts/acceptance/admin-wizards-api-test.js +++ b/test/javascripts/acceptance/admin-wizards-api-test.js @@ -8,6 +8,7 @@ import { getNewApi, getWizard, putNewApi, + getSuppliers, } from "../helpers/admin-wizard"; acceptance("Admin | API tab", function (needs) { @@ -45,6 +46,9 @@ acceptance("Admin | API tab", function (needs) { server.get("/admin/wizards/api/new_api", () => { return helper.response(getNewApi); }); + server.get("/admin/plugins/subscription-client/suppliers", () => { + return helper.response(getSuppliers); + }); }); test("Visit API tab and fill data", async function (assert) { diff --git a/test/javascripts/acceptance/admin-wizards-business-subscription-test.js b/test/javascripts/acceptance/admin-wizards-business-subscription-test.js index ac0ef279..0fd885a6 100644 --- a/test/javascripts/acceptance/admin-wizards-business-subscription-test.js +++ b/test/javascripts/acceptance/admin-wizards-business-subscription-test.js @@ -12,6 +12,7 @@ import { getCreatedWizard, getCustomFields, getWizard, + getSuppliers, } from "../helpers/admin-wizard"; acceptance("Admin | Custom Wizard Business Subscription", function (needs) { @@ -49,6 +50,9 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) { server.get("/admin/wizards/wizard/new_wizard_for_testing", () => { return helper.response(getCreatedWizard); }); + server.get("/admin/plugins/subscription-client/suppliers", () => { + return helper.response(getSuppliers); + }); }); test("Displaying all tabs including API", async (assert) => { diff --git a/test/javascripts/acceptance/admin-wizards-standard-subscription-test.js b/test/javascripts/acceptance/admin-wizards-standard-subscription-test.js index 790bf5d9..bd506ded 100644 --- a/test/javascripts/acceptance/admin-wizards-standard-subscription-test.js +++ b/test/javascripts/acceptance/admin-wizards-standard-subscription-test.js @@ -12,6 +12,7 @@ import { getCustomFields, getStandardAdminWizard, getWizard, + getSuppliers, } from "../helpers/admin-wizard"; acceptance("Admin | Custom Wizard Standard Subscription", function (needs) { @@ -49,6 +50,9 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) { server.get("/admin/wizards/wizard/new_wizard_for_testing", () => { return helper.response(getCreatedWizard); }); + server.get("/admin/plugins/subscription-client/suppliers", () => { + return helper.response(getSuppliers); + }); }); test("Displaying all tabs except API", async (assert) => { diff --git a/test/javascripts/acceptance/admin-wizards-unsuscribed-test.js b/test/javascripts/acceptance/admin-wizards-unsubscribed-test.js similarity index 99% rename from test/javascripts/acceptance/admin-wizards-unsuscribed-test.js rename to test/javascripts/acceptance/admin-wizards-unsubscribed-test.js index 2948c2e8..127c4f57 100644 --- a/test/javascripts/acceptance/admin-wizards-unsuscribed-test.js +++ b/test/javascripts/acceptance/admin-wizards-unsubscribed-test.js @@ -14,6 +14,7 @@ import { getUniqueWizard, getUnsubscribedAdminWizards, getWizard, + getSuppliers, } from "../helpers/admin-wizard"; acceptance("Admin | Custom Wizard Unsubscribed", function (needs) { @@ -54,6 +55,9 @@ acceptance("Admin | Custom Wizard Unsubscribed", function (needs) { server.get("/admin/wizards/wizard/unique_wizard", () => { return helper.response(getUniqueWizard); }); + server.get("/admin/plugins/subscription-client/suppliers", () => { + return helper.response(getSuppliers); + }); }); async function appendText(selector, text) { diff --git a/test/javascripts/helpers/admin-wizard.js b/test/javascripts/helpers/admin-wizard.js index 7585b956..03e7d495 100644 --- a/test/javascripts/helpers/admin-wizard.js +++ b/test/javascripts/helpers/admin-wizard.js @@ -914,15 +914,19 @@ const putNewApi = { log: [], }, }; + const getSuppliers = { "suppliers": [ - { "id": 1, - "name": "Pavilion", - "authorized": false, - "authorized_at": null, - "user": null } + { + "id": 1, + "name": "Pavilion", + "authorized": false, + "authorized_at": null, + "user": null + } ] }; + export { getWizard, getUnsubscribedAdminWizards,