From 542af4cf1665f9802da66831cbaa19c39b17f821 Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Wed, 15 May 2024 11:44:27 -0600 Subject: [PATCH] FIX: Campaign banner should link to pricing table when enabled (#212) If the new pricing table is enabled the campaign banner should link to the pricing table route. --- .../discourse/components/campaign-banner.hbs | 2 +- .../discourse/components/campaign-banner.js | 12 ++++++++++- spec/system/pricing_table_spec.rb | 21 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/discourse/components/campaign-banner.hbs b/assets/javascripts/discourse/components/campaign-banner.hbs index c58e075c..d0d4043f 100644 --- a/assets/javascripts/discourse/components/campaign-banner.hbs +++ b/assets/javascripts/discourse/components/campaign-banner.hbs @@ -36,7 +36,7 @@ {{else}} {{d-icon "far-heart"}} diff --git a/assets/javascripts/discourse/components/campaign-banner.js b/assets/javascripts/discourse/components/campaign-banner.js index 41e34f89..8e76362f 100644 --- a/assets/javascripts/discourse/components/campaign-banner.js +++ b/assets/javascripts/discourse/components/campaign-banner.js @@ -32,6 +32,7 @@ export default Component.extend({ amountRaised: setting("discourse_subscriptions_campaign_amount_raised"), goalTarget: setting("discourse_subscriptions_campaign_goal"), product: setting("discourse_subscriptions_campaign_product"), + pricingTableEnabled: setting("discourse_subscriptions_pricing_table_enabled"), showContributors: setting( "discourse_subscriptions_campaign_show_contributors" ), @@ -126,7 +127,8 @@ export default Component.extend({ const showOnRoute = currentRoute !== "discovery.s" && !currentRoute.split(".")[0].includes("admin") && - currentRoute.split(".")[0] !== "subscribe"; + currentRoute.split(".")[0] !== "subscribe" && + currentRoute.split(".")[0] !== "subscriptions"; if (!this.site.show_campaign_banner) { return false; @@ -166,6 +168,14 @@ export default Component.extend({ ); }, + @discourseComputed + subscribeRoute() { + if (this.pricingTableEnabled) { + return "subscriptions"; + } + return "subscribe"; + }, + @discourseComputed isGoalMet() { const currentVolume = this.subscriberGoal diff --git a/spec/system/pricing_table_spec.rb b/spec/system/pricing_table_spec.rb index 9c0666ee..880bc7d1 100644 --- a/spec/system/pricing_table_spec.rb +++ b/spec/system/pricing_table_spec.rb @@ -40,6 +40,16 @@ expect(uri.path).to eq("/s/subscriptions") end + it "Links to the pricing table page from the campaign banner" do + sign_in(admin) + SiteSetting.discourse_subscriptions_campaign_enabled = true + visit("/") + + link = find(".campaign-banner-info-button") + uri = URI.parse(link[:href]) + expect(uri.path).to eq("/s/subscriptions") + end + it "Links to the old page when disabled" do sign_in(admin) SiteSetting.discourse_subscriptions_pricing_table_enabled = false @@ -50,6 +60,17 @@ expect(uri.path).to eq("/s") end + it "Links to the old page from the campaign banner when disabled" do + sign_in(admin) + SiteSetting.discourse_subscriptions_pricing_table_enabled = false + SiteSetting.discourse_subscriptions_campaign_enabled = true + visit("/") + + link = find(".campaign-banner-info-button") + uri = URI.parse(link[:href]) + expect(uri.path).to eq("/s") + end + it "Old subscribe page still works when disabled" do sign_in(admin) SiteSetting.discourse_subscriptions_pricing_table_enabled = false