From e0e059667088d7c8a19e97fefc7624b98296319e Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Wed, 28 May 2025 11:43:24 +0200 Subject: [PATCH 1/3] DEV: [gjs-codemod] Convert all templates to gjs --- Gemfile.lock | 38 +- .../discourse/components/campaign-banner.gjs | 399 +++++++++ .../discourse/components/campaign-banner.hbs | 176 ---- .../discourse/components/campaign-banner.js | 205 ----- .../components/create-coupon-form.gjs | 92 ++ .../components/create-coupon-form.hbs | 50 -- .../components/create-coupon-form.js | 35 - .../discourse/components/login-required.gjs | 16 + .../discourse/components/login-required.hbs | 8 - ...payment-options.js => payment-options.gjs} | 18 + .../discourse/components/payment-options.hbs | 13 - .../discourse/components/payment-plan.gjs | 57 ++ .../discourse/components/payment-plan.hbs | 24 - .../discourse/components/payment-plan.js | 25 - .../discourse/components/product-item.gjs | 64 ++ .../discourse/components/product-item.hbs | 53 -- .../discourse/components/product-item.js | 5 - .../{product-list.js => product-list.gjs} | 12 + .../discourse/components/product-list.hbs | 7 - .../{subscribe-card.js => subscribe-card.gjs} | 4 + .../discourse/components/subscribe-card.hbs | 1 - .../subscriptions-campaign.gjs | 19 + .../subscriptions-campaign.hbs | 1 - .../subscriptions-campaign.js | 12 - .../subscriptions-campaign-topic-footer.gjs | 21 + .../subscriptions-campaign-topic-footer.hbs | 1 - .../subscriptions-campaign-topic-footer.js | 9 - .../subscriptions-campaign-sidebar.gjs | 17 + .../subscriptions-campaign-sidebar.hbs | 1 - .../subscriptions-campaign-sidebar.js | 10 - .../connectors/user-main-nav/billing.gjs | 19 + .../connectors/user-main-nav/billing.hbs | 6 - ...lugins-discourse-subscriptions-coupons.gjs | 74 ++ ...lugins-discourse-subscriptions-coupons.hbs | 61 -- ...gins-discourse-subscriptions-dashboard.gjs | 84 ++ ...gins-discourse-subscriptions-dashboard.hbs | 64 -- ...ns-discourse-subscriptions-plans-index.gjs | 44 + ...ns-discourse-subscriptions-plans-index.hbs | 32 - ...discourse-subscriptions-products-index.gjs | 90 ++ ...discourse-subscriptions-products-index.hbs | 74 -- ...subscriptions-products-show-plans-show.gjs | 185 ++++ ...subscriptions-products-show-plans-show.hbs | 165 ---- ...-discourse-subscriptions-products-show.gjs | 195 ++++ ...-discourse-subscriptions-products-show.hbs | 161 ---- ...ugins-discourse-subscriptions-products.gjs | 3 + ...ugins-discourse-subscriptions-products.hbs | 1 - ...-discourse-subscriptions-subscriptions.gjs | 105 +++ ...-discourse-subscriptions-subscriptions.hbs | 90 -- .../admin/plugins-discourse-subscriptions.gjs | 62 ++ .../admin/plugins-discourse-subscriptions.hbs | 53 -- .../discourse/templates/subscribe.gjs | 18 + .../discourse/templates/subscribe.hbs | 11 - .../discourse/templates/subscribe/index.gjs | 16 + .../discourse/templates/subscribe/index.hbs | 5 - .../discourse/templates/subscribe/show.gjs | 151 ++++ .../discourse/templates/subscribe/show.hbs | 129 --- .../discourse/templates/subscriptions.gjs | 14 + .../discourse/templates/subscriptions.hbs | 7 - .../discourse/templates/user/billing.gjs | 35 + .../discourse/templates/user/billing.hbs | 25 - .../templates/user/billing/index.gjs | 3 + .../templates/user/billing/index.hbs | 1 - .../templates/user/billing/payments.gjs | 31 + .../templates/user/billing/payments.hbs | 22 - .../user/billing/subscriptions/card.gjs | 28 + .../user/billing/subscriptions/card.hbs | 16 - .../user/billing/subscriptions/index.gjs | 70 ++ .../user/billing/subscriptions/index.hbs | 55 -- assets/stylesheets/common/campaign.scss | 15 +- assets/stylesheets/common/layout.scss | 8 +- assets/stylesheets/common/subscribe.scss | 2 +- package.json | 8 +- pnpm-lock.yaml | 832 +++++++++--------- 73 files changed, 2390 insertions(+), 2073 deletions(-) create mode 100644 assets/javascripts/discourse/components/campaign-banner.gjs delete mode 100644 assets/javascripts/discourse/components/campaign-banner.hbs delete mode 100644 assets/javascripts/discourse/components/campaign-banner.js create mode 100644 assets/javascripts/discourse/components/create-coupon-form.gjs delete mode 100644 assets/javascripts/discourse/components/create-coupon-form.hbs delete mode 100644 assets/javascripts/discourse/components/create-coupon-form.js create mode 100644 assets/javascripts/discourse/components/login-required.gjs delete mode 100644 assets/javascripts/discourse/components/login-required.hbs rename assets/javascripts/discourse/components/{payment-options.js => payment-options.gjs} (58%) delete mode 100644 assets/javascripts/discourse/components/payment-options.hbs create mode 100644 assets/javascripts/discourse/components/payment-plan.gjs delete mode 100644 assets/javascripts/discourse/components/payment-plan.hbs delete mode 100644 assets/javascripts/discourse/components/payment-plan.js create mode 100644 assets/javascripts/discourse/components/product-item.gjs delete mode 100644 assets/javascripts/discourse/components/product-item.hbs delete mode 100644 assets/javascripts/discourse/components/product-item.js rename assets/javascripts/discourse/components/{product-list.js => product-list.gjs} (50%) delete mode 100644 assets/javascripts/discourse/components/product-list.hbs rename assets/javascripts/discourse/components/{subscribe-card.js => subscribe-card.gjs} (92%) delete mode 100644 assets/javascripts/discourse/components/subscribe-card.hbs create mode 100644 assets/javascripts/discourse/connectors/above-main-container/subscriptions-campaign.gjs delete mode 100644 assets/javascripts/discourse/connectors/above-main-container/subscriptions-campaign.hbs delete mode 100644 assets/javascripts/discourse/connectors/above-main-container/subscriptions-campaign.js create mode 100644 assets/javascripts/discourse/connectors/after-topic-footer-buttons/subscriptions-campaign-topic-footer.gjs delete mode 100644 assets/javascripts/discourse/connectors/after-topic-footer-buttons/subscriptions-campaign-topic-footer.hbs delete mode 100644 assets/javascripts/discourse/connectors/after-topic-footer-buttons/subscriptions-campaign-topic-footer.js create mode 100644 assets/javascripts/discourse/connectors/before-topic-list/subscriptions-campaign-sidebar.gjs delete mode 100644 assets/javascripts/discourse/connectors/before-topic-list/subscriptions-campaign-sidebar.hbs delete mode 100644 assets/javascripts/discourse/connectors/before-topic-list/subscriptions-campaign-sidebar.js create mode 100644 assets/javascripts/discourse/connectors/user-main-nav/billing.gjs delete mode 100644 assets/javascripts/discourse/connectors/user-main-nav/billing.hbs create mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-coupons.gjs delete mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-coupons.hbs create mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-dashboard.gjs delete mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-dashboard.hbs create mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-plans-index.gjs delete mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-plans-index.hbs create mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-index.gjs delete mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-index.hbs create mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show-plans-show.gjs delete mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show-plans-show.hbs create mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show.gjs delete mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show.hbs create mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products.gjs delete mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products.hbs create mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-subscriptions.gjs delete mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-subscriptions.hbs create mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions.gjs delete mode 100644 assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions.hbs create mode 100644 assets/javascripts/discourse/templates/subscribe.gjs delete mode 100644 assets/javascripts/discourse/templates/subscribe.hbs create mode 100644 assets/javascripts/discourse/templates/subscribe/index.gjs delete mode 100644 assets/javascripts/discourse/templates/subscribe/index.hbs create mode 100644 assets/javascripts/discourse/templates/subscribe/show.gjs delete mode 100644 assets/javascripts/discourse/templates/subscribe/show.hbs create mode 100644 assets/javascripts/discourse/templates/subscriptions.gjs delete mode 100644 assets/javascripts/discourse/templates/subscriptions.hbs create mode 100644 assets/javascripts/discourse/templates/user/billing.gjs delete mode 100644 assets/javascripts/discourse/templates/user/billing.hbs create mode 100644 assets/javascripts/discourse/templates/user/billing/index.gjs delete mode 100644 assets/javascripts/discourse/templates/user/billing/index.hbs create mode 100644 assets/javascripts/discourse/templates/user/billing/payments.gjs delete mode 100644 assets/javascripts/discourse/templates/user/billing/payments.hbs create mode 100644 assets/javascripts/discourse/templates/user/billing/subscriptions/card.gjs delete mode 100644 assets/javascripts/discourse/templates/user/billing/subscriptions/card.hbs create mode 100644 assets/javascripts/discourse/templates/user/billing/subscriptions/index.gjs delete mode 100644 assets/javascripts/discourse/templates/user/billing/subscriptions/index.hbs diff --git a/Gemfile.lock b/Gemfile.lock index daac450e..66e72ffb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -20,30 +20,31 @@ GEM securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) - ast (2.4.2) + ast (2.4.3) base64 (0.2.0) benchmark (0.4.0) bigdecimal (3.1.9) concurrent-ruby (1.3.5) - connection_pool (2.5.0) - drb (2.2.1) + connection_pool (2.5.3) + drb (2.2.3) i18n (1.14.7) concurrent-ruby (~> 1.0) - json (2.10.2) - language_server-protocol (3.17.0.4) + json (2.12.2) + language_server-protocol (3.17.0.5) lint_roller (1.1.0) - logger (1.6.6) + logger (1.7.0) minitest (5.25.5) - parallel (1.26.3) - parser (3.3.7.1) + parallel (1.27.0) + parser (3.3.8.0) ast (~> 2.4.1) racc prettier_print (1.2.1) + prism (1.4.0) racc (1.8.1) - rack (3.1.12) + rack (3.1.15) rainbow (3.1.1) regexp_parser (2.10.0) - rubocop (1.74.0) + rubocop (1.75.7) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -51,11 +52,12 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.38.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.38.1) - parser (>= 3.3.1.0) + rubocop-ast (1.44.1) + parser (>= 3.3.7.2) + prism (~> 1.4) rubocop-capybara (2.22.1) lint_roller (~> 1.1) rubocop (~> 1.72, >= 1.72.1) @@ -71,13 +73,13 @@ GEM rubocop-factory_bot (2.27.1) lint_roller (~> 1.1) rubocop (~> 1.72, >= 1.72.1) - rubocop-rails (2.30.3) + rubocop-rails (2.32.0) activesupport (>= 4.2.0) lint_roller (~> 1.1) rack (>= 1.1) - rubocop (>= 1.72.1, < 2.0) - rubocop-ast (>= 1.38.0, < 2.0) - rubocop-rspec (3.5.0) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) + rubocop-rspec (3.6.0) lint_roller (~> 1.1) rubocop (~> 1.72, >= 1.72.1) rubocop-rspec_rails (2.31.0) @@ -104,4 +106,4 @@ DEPENDENCIES translations-manager! BUNDLED WITH - 2.6.6 + 2.6.9 diff --git a/assets/javascripts/discourse/components/campaign-banner.gjs b/assets/javascripts/discourse/components/campaign-banner.gjs new file mode 100644 index 00000000..b1398c7d --- /dev/null +++ b/assets/javascripts/discourse/components/campaign-banner.gjs @@ -0,0 +1,399 @@ +import Component from "@ember/component"; +import { concat } from "@ember/helper"; +import { action } from "@ember/object"; +import { equal } from "@ember/object/computed"; +import { LinkTo } from "@ember/routing"; +import { later } from "@ember/runloop"; +import { service } from "@ember/service"; +import { classNameBindings } from "@ember-decorators/component"; +import { observes } from "@ember-decorators/object"; +import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner"; +import DButton from "discourse/components/d-button"; +import avatar from "discourse/helpers/avatar"; +import icon from "discourse/helpers/d-icon"; +import htmlSafe from "discourse/helpers/html-safe"; +import { ajax } from "discourse/lib/ajax"; +import { setting } from "discourse/lib/computed"; +import discourseComputed from "discourse/lib/decorators"; +import { i18n } from "discourse-i18n"; +import formatCurrency from "../helpers/format-currency"; + +const SIDEBAR_BODY_CLASS = "subscription-campaign-sidebar"; + +@classNameBindings("isGoalMet:goal-met") +export default class CampaignBanner extends Component { + @service router; + + dismissed = false; + loading = false; + + @setting("discourse_subscriptions_campaign_banner_shadow_color") + dropShadowColor; + + @setting("discourse_subscriptions_campaign_banner_bg_image") + backgroundImageUrl; + + @equal( + "siteSettings.discourse_subscriptions_campaign_banner_location", + "Sidebar" + ) + isSidebar; + + @setting("discourse_subscriptions_campaign_subscribers") subscribers; + + @equal("siteSettings.discourse_subscriptions_campaign_type", "Subscribers") + subscriberGoal; + + @setting("discourse_subscriptions_currency") currency; + + @setting("discourse_subscriptions_campaign_amount_raised") amountRaised; + + @setting("discourse_subscriptions_campaign_goal") goalTarget; + + @setting("discourse_subscriptions_campaign_product") product; + + @setting("discourse_subscriptions_pricing_table_enabled") pricingTableEnabled; + + @setting("discourse_subscriptions_campaign_show_contributors") + showContributors; + + init() { + super.init(...arguments); + + this.set("contributors", []); + + // add background-image url to stylesheet + if (this.backgroundImageUrl) { + const backgroundUrl = `url(${this.backgroundImageUrl}`.replace(/\\/g, ""); + if ( + document.documentElement.style.getPropertyValue( + "--campaign-background-image" + ) !== backgroundUrl + ) { + document.documentElement.style.setProperty( + "--campaign-background-image", + backgroundUrl + ); + } + } + + if (this.currentUser && this.showContributors) { + return ajax("/s/contributors", { method: "get" }).then((result) => { + this.setProperties({ + contributors: result, + loading: false, + }); + }); + } + } + + didInsertElement() { + super.didInsertElement(...arguments); + if (this.isSidebar && this.shouldShow && !this.site.mobileView) { + document.body.classList.add(SIDEBAR_BODY_CLASS); + } else { + document.body.classList.remove(SIDEBAR_BODY_CLASS); + } + + // makes sure to only play animation once, & not repeat on reload + if (this.isGoalMet) { + const successAnimationKey = this.keyValueStore.get( + "campaign_success_animation" + ); + + if (!successAnimationKey) { + later(() => { + this.keyValueStore.set({ + key: "campaign_success_animation", + value: Date.now(), + }); + document.body.classList.add("success-animation-off"); + }, 7000); + } else { + document.body.classList.add("success-animation-off"); + } + } + } + + willDestroyElement() { + super.willDestroyElement(...arguments); + document.body.classList.remove(SIDEBAR_BODY_CLASS); + } + + @discourseComputed("backgroundImageUrl") + bannerInfoStyle(backgroundImageUrl) { + if (!backgroundImageUrl) { + return ""; + } + + return `background-image: linear-gradient( + 0deg, + rgba(var(--secondary-rgb), 0.75) 0%, + rgba(var(--secondary-rgb), 0.75) 100%), + var(--campaign-background-image); + background-size: cover; + background-repeat: no-repeat;`; + } + + @discourseComputed( + "router.currentRouteName", + "currentUser", + "siteSettings.discourse_subscriptions_campaign_enabled", + "visible" + ) + shouldShow(currentRoute, currentUser, enabled, visible) { + // do not show on admin or subscriptions pages + const showOnRoute = + currentRoute !== "discovery.s" && + !currentRoute.split(".")[0].includes("admin") && + currentRoute.split(".")[0] !== "subscribe" && + currentRoute.split(".")[0] !== "subscriptions"; + + if (!this.site.show_campaign_banner) { + return false; + } + + // make sure not to render above main container when inside a topic + if ( + this.connectorName === "above-main-container" && + currentRoute.includes("topic") + ) { + return false; + } + + return showOnRoute && currentUser && enabled && visible; + } + + @observes("dismissed") + _updateBodyClasses() { + if (this.dismissed) { + document.body.classList.remove(SIDEBAR_BODY_CLASS); + } + } + + @discourseComputed("dismissed") + visible(dismissed) { + const dismissedBannerKey = this.keyValueStore.get( + "dismissed_campaign_banner" + ); + const threeMonths = 2628000000 * 3; + + const bannerDismissedTime = new Date(dismissedBannerKey); + const now = Date.now(); + + return ( + (!dismissedBannerKey || now - bannerDismissedTime > threeMonths) && + !dismissed + ); + } + + @discourseComputed + subscribeRoute() { + if (this.pricingTableEnabled) { + return "subscriptions"; + } + return "subscribe"; + } + + @discourseComputed + isGoalMet() { + const currentVolume = this.subscriberGoal + ? this.subscribers + : this.amountRaised; + return currentVolume >= this.goalTarget; + } + + @action + dismissBanner() { + this.set("dismissed", true); + this.keyValueStore.set({ + key: "dismissed_campaign_banner", + value: Date.now(), + }); + } + + +} diff --git a/assets/javascripts/discourse/components/campaign-banner.hbs b/assets/javascripts/discourse/components/campaign-banner.hbs deleted file mode 100644 index d062e010..00000000 --- a/assets/javascripts/discourse/components/campaign-banner.hbs +++ /dev/null @@ -1,176 +0,0 @@ -{{#if this.shouldShow}} -
- - -
- {{#if this.isGoalMet}} -

- {{i18n "discourse_subscriptions.campaign.success_title"}} -

- -

- {{i18n "discourse_subscriptions.campaign.success_body"}} -

- {{else}} -

- {{i18n "discourse_subscriptions.campaign.title"}} -

- -

- {{i18n "discourse_subscriptions.campaign.body"}} -

- - {{#if this.product}} - - {{d-icon "far-heart"}} - {{d-icon "heart" class="hover-heart"}} - {{i18n "discourse_subscriptions.campaign.button"}} - - {{else}} - - {{d-icon "far-heart"}} - {{d-icon "heart" class="hover-heart"}} - {{i18n "discourse_subscriptions.campaign.button"}} - - {{/if}} - {{/if}} -
- -
- {{#if this.isGoalMet}} -
-
-
-
- -
- - {{#if this.subscriberGoal}} -

- {{html-safe - (i18n - "discourse_subscriptions.campaign.goal_comparison" - current=this.subscribers - goal=this.goalTarget - ) - }} - {{i18n "discourse_subscriptions.campaign.subscribers"}} -

- {{else}} -

- {{html-safe - (i18n - "discourse_subscriptions.campaign.goal_comparison" - current=(format-currency this.currency this.amountRaised) - goal=(format-currency this.currency this.goalTarget) - ) - }} - {{i18n "discourse_subscriptions.campaign.raised"}} -

- - {{#if this.showContributors}} - -
-

- - {{i18n - "discourse_subscriptions.campaign.recent_contributors" - }} - -

- -
- {{#each this.contributors as |contributor|}} - {{avatar - contributor - avatarTemplatePath="avatar_template" - usernamePath="username" - namePath="name" - imageSize="small" - }} - {{/each}} -
-
-
- {{/if}} - {{/if}} - {{else}} - {{#if this.subscriberGoal}} - - -

- {{html-safe - (i18n - "discourse_subscriptions.campaign.goal_comparison" - current=this.subscribers - goal=this.goalTarget - ) - }} - {{i18n "discourse_subscriptions.campaign.subscribers"}} -

- {{else}} - - -

- {{html-safe - (i18n - "discourse_subscriptions.campaign.goal_comparison" - current=(format-currency this.currency this.amountRaised) - goal=(format-currency this.currency this.goalTarget) - ) - }} - {{i18n "discourse_subscriptions.campaign.raised"}} -

- {{/if}} - - {{#if this.showContributors}} - -
-

- - {{i18n - "discourse_subscriptions.campaign.recent_contributors" - }} - -

- -
- {{#each this.contributors as |contributor|}} - {{avatar - contributor - avatarTemplatePath="avatar_template" - usernamePath="username" - namePath="name" - imageSize="small" - }} - {{/each}} -
-
-
- {{/if}} - {{/if}} -
-
-{{/if}} \ No newline at end of file diff --git a/assets/javascripts/discourse/components/campaign-banner.js b/assets/javascripts/discourse/components/campaign-banner.js deleted file mode 100644 index 41116a69..00000000 --- a/assets/javascripts/discourse/components/campaign-banner.js +++ /dev/null @@ -1,205 +0,0 @@ -import Component from "@ember/component"; -import { action } from "@ember/object"; -import { equal } from "@ember/object/computed"; -import { later } from "@ember/runloop"; -import { service } from "@ember/service"; -import { classNameBindings } from "@ember-decorators/component"; -import { observes } from "@ember-decorators/object"; -import { ajax } from "discourse/lib/ajax"; -import { setting } from "discourse/lib/computed"; -import discourseComputed from "discourse/lib/decorators"; - -const SIDEBAR_BODY_CLASS = "subscription-campaign-sidebar"; - -@classNameBindings("isGoalMet:goal-met") -export default class CampaignBanner extends Component { - @service router; - - dismissed = false; - loading = false; - - @setting("discourse_subscriptions_campaign_banner_shadow_color") - dropShadowColor; - - @setting("discourse_subscriptions_campaign_banner_bg_image") - backgroundImageUrl; - - @equal( - "siteSettings.discourse_subscriptions_campaign_banner_location", - "Sidebar" - ) - isSidebar; - - @setting("discourse_subscriptions_campaign_subscribers") subscribers; - - @equal("siteSettings.discourse_subscriptions_campaign_type", "Subscribers") - subscriberGoal; - - @setting("discourse_subscriptions_currency") currency; - - @setting("discourse_subscriptions_campaign_amount_raised") amountRaised; - - @setting("discourse_subscriptions_campaign_goal") goalTarget; - - @setting("discourse_subscriptions_campaign_product") product; - - @setting("discourse_subscriptions_pricing_table_enabled") pricingTableEnabled; - - @setting("discourse_subscriptions_campaign_show_contributors") - showContributors; - - init() { - super.init(...arguments); - - this.set("contributors", []); - - // add background-image url to stylesheet - if (this.backgroundImageUrl) { - const backgroundUrl = `url(${this.backgroundImageUrl}`.replace(/\\/g, ""); - if ( - document.documentElement.style.getPropertyValue( - "--campaign-background-image" - ) !== backgroundUrl - ) { - document.documentElement.style.setProperty( - "--campaign-background-image", - backgroundUrl - ); - } - } - - if (this.currentUser && this.showContributors) { - return ajax("/s/contributors", { method: "get" }).then((result) => { - this.setProperties({ - contributors: result, - loading: false, - }); - }); - } - } - - didInsertElement() { - super.didInsertElement(...arguments); - if (this.isSidebar && this.shouldShow && !this.site.mobileView) { - document.body.classList.add(SIDEBAR_BODY_CLASS); - } else { - document.body.classList.remove(SIDEBAR_BODY_CLASS); - } - - // makes sure to only play animation once, & not repeat on reload - if (this.isGoalMet) { - const successAnimationKey = this.keyValueStore.get( - "campaign_success_animation" - ); - - if (!successAnimationKey) { - later(() => { - this.keyValueStore.set({ - key: "campaign_success_animation", - value: Date.now(), - }); - document.body.classList.add("success-animation-off"); - }, 7000); - } else { - document.body.classList.add("success-animation-off"); - } - } - } - - willDestroyElement() { - super.willDestroyElement(...arguments); - document.body.classList.remove(SIDEBAR_BODY_CLASS); - } - - @discourseComputed("backgroundImageUrl") - bannerInfoStyle(backgroundImageUrl) { - if (!backgroundImageUrl) { - return ""; - } - - return `background-image: linear-gradient( - 0deg, - rgba(var(--secondary-rgb), 0.75) 0%, - rgba(var(--secondary-rgb), 0.75) 100%), - var(--campaign-background-image); - background-size: cover; - background-repeat: no-repeat;`; - } - - @discourseComputed( - "router.currentRouteName", - "currentUser", - "siteSettings.discourse_subscriptions_campaign_enabled", - "visible" - ) - shouldShow(currentRoute, currentUser, enabled, visible) { - // do not show on admin or subscriptions pages - const showOnRoute = - currentRoute !== "discovery.s" && - !currentRoute.split(".")[0].includes("admin") && - currentRoute.split(".")[0] !== "subscribe" && - currentRoute.split(".")[0] !== "subscriptions"; - - if (!this.site.show_campaign_banner) { - return false; - } - - // make sure not to render above main container when inside a topic - if ( - this.connectorName === "above-main-container" && - currentRoute.includes("topic") - ) { - return false; - } - - return showOnRoute && currentUser && enabled && visible; - } - - @observes("dismissed") - _updateBodyClasses() { - if (this.dismissed) { - document.body.classList.remove(SIDEBAR_BODY_CLASS); - } - } - - @discourseComputed("dismissed") - visible(dismissed) { - const dismissedBannerKey = this.keyValueStore.get( - "dismissed_campaign_banner" - ); - const threeMonths = 2628000000 * 3; - - const bannerDismissedTime = new Date(dismissedBannerKey); - const now = Date.now(); - - return ( - (!dismissedBannerKey || now - bannerDismissedTime > threeMonths) && - !dismissed - ); - } - - @discourseComputed - subscribeRoute() { - if (this.pricingTableEnabled) { - return "subscriptions"; - } - return "subscribe"; - } - - @discourseComputed - isGoalMet() { - const currentVolume = this.subscriberGoal - ? this.subscribers - : this.amountRaised; - return currentVolume >= this.goalTarget; - } - - @action - dismissBanner() { - this.set("dismissed", true); - this.keyValueStore.set({ - key: "dismissed_campaign_banner", - value: Date.now(), - }); - } -} diff --git a/assets/javascripts/discourse/components/create-coupon-form.gjs b/assets/javascripts/discourse/components/create-coupon-form.gjs new file mode 100644 index 00000000..136394e9 --- /dev/null +++ b/assets/javascripts/discourse/components/create-coupon-form.gjs @@ -0,0 +1,92 @@ +import Component, { Input } from "@ember/component"; +import { fn } from "@ember/helper"; +import { action } from "@ember/object"; +import DButton from "discourse/components/d-button"; +import discourseComputed from "discourse/lib/decorators"; +import { i18n } from "discourse-i18n"; +import ComboBox from "select-kit/components/combo-box"; + +export default class CreateCouponForm extends Component { + discountType = "amount"; + discount = null; + promoCode = null; + active = false; + + @discourseComputed + discountTypes() { + return [ + { id: "amount", name: "Amount" }, + { id: "percent", name: "Percent" }, + ]; + } + + @action + createNewCoupon() { + const createParams = { + promo: this.promoCode, + discount_type: this.discountType, + discount: this.discount, + active: this.active, + }; + + this.create(createParams); + } + + @action + cancelCreate() { + this.cancel(); + } + + +} diff --git a/assets/javascripts/discourse/components/create-coupon-form.hbs b/assets/javascripts/discourse/components/create-coupon-form.hbs deleted file mode 100644 index 0ed548b9..00000000 --- a/assets/javascripts/discourse/components/create-coupon-form.hbs +++ /dev/null @@ -1,50 +0,0 @@ -
-
-

- - -

- -

- - - -

- -

- - -

-
- - - - -
\ No newline at end of file diff --git a/assets/javascripts/discourse/components/create-coupon-form.js b/assets/javascripts/discourse/components/create-coupon-form.js deleted file mode 100644 index 07ce4874..00000000 --- a/assets/javascripts/discourse/components/create-coupon-form.js +++ /dev/null @@ -1,35 +0,0 @@ -import Component from "@ember/component"; -import { action } from "@ember/object"; -import discourseComputed from "discourse/lib/decorators"; - -export default class CreateCouponForm extends Component { - discountType = "amount"; - discount = null; - promoCode = null; - active = false; - - @discourseComputed - discountTypes() { - return [ - { id: "amount", name: "Amount" }, - { id: "percent", name: "Percent" }, - ]; - } - - @action - createNewCoupon() { - const createParams = { - promo: this.promoCode, - discount_type: this.discountType, - discount: this.discount, - active: this.active, - }; - - this.create(createParams); - } - - @action - cancelCreate() { - this.cancel(); - } -} diff --git a/assets/javascripts/discourse/components/login-required.gjs b/assets/javascripts/discourse/components/login-required.gjs new file mode 100644 index 00000000..538dcb1f --- /dev/null +++ b/assets/javascripts/discourse/components/login-required.gjs @@ -0,0 +1,16 @@ +import DButton from "discourse/components/d-button"; +import routeAction from "discourse/helpers/route-action"; +import { i18n } from "discourse-i18n"; + +const LoginRequired = ; + +export default LoginRequired; diff --git a/assets/javascripts/discourse/components/login-required.hbs b/assets/javascripts/discourse/components/login-required.hbs deleted file mode 100644 index 59f3de8b..00000000 --- a/assets/javascripts/discourse/components/login-required.hbs +++ /dev/null @@ -1,8 +0,0 @@ -

{{i18n "discourse_subscriptions.subscribe.unauthenticated"}}

- - \ No newline at end of file diff --git a/assets/javascripts/discourse/components/payment-options.js b/assets/javascripts/discourse/components/payment-options.gjs similarity index 58% rename from assets/javascripts/discourse/components/payment-options.js rename to assets/javascripts/discourse/components/payment-options.gjs index cd160a7e..e63b7ec9 100644 --- a/assets/javascripts/discourse/components/payment-options.js +++ b/assets/javascripts/discourse/components/payment-options.gjs @@ -1,6 +1,8 @@ import Component from "@ember/component"; import { action } from "@ember/object"; import discourseComputed from "discourse/lib/decorators"; +import { i18n } from "discourse-i18n"; +import PaymentPlan from "./payment-plan"; export default class PaymentOptions extends Component { @discourseComputed("plans") @@ -21,4 +23,20 @@ export default class PaymentOptions extends Component { clickPlan(plan) { this.set("selectedPlan", plan.id); } + + } diff --git a/assets/javascripts/discourse/components/payment-options.hbs b/assets/javascripts/discourse/components/payment-options.hbs deleted file mode 100644 index 623495d5..00000000 --- a/assets/javascripts/discourse/components/payment-options.hbs +++ /dev/null @@ -1,13 +0,0 @@ -

- {{i18n "discourse_subscriptions.plans.select"}} -

- - \ No newline at end of file diff --git a/assets/javascripts/discourse/components/payment-plan.gjs b/assets/javascripts/discourse/components/payment-plan.gjs new file mode 100644 index 00000000..376bdaa5 --- /dev/null +++ b/assets/javascripts/discourse/components/payment-plan.gjs @@ -0,0 +1,57 @@ +import Component from "@ember/component"; +import { concat } from "@ember/helper"; +import { action } from "@ember/object"; +import { tagName } from "@ember-decorators/component"; +import DButton from "discourse/components/d-button"; +import concatClass from "discourse/helpers/concat-class"; +import discourseComputed from "discourse/lib/decorators"; +import { i18n } from "discourse-i18n"; +import formatCurrency from "../helpers/format-currency"; + +const RECURRING = "recurring"; + +@tagName("") +export default class PaymentPlan extends Component { + @discourseComputed("selectedPlan") + selectedClass(planId) { + return planId === this.plan.id ? "btn-primary" : ""; + } + + @discourseComputed("plan.type") + recurringPlan(type) { + return type === RECURRING; + } + + @action + planClick() { + this.clickPlan(this.plan); + return false; + } + + +} diff --git a/assets/javascripts/discourse/components/payment-plan.hbs b/assets/javascripts/discourse/components/payment-plan.hbs deleted file mode 100644 index a367b342..00000000 --- a/assets/javascripts/discourse/components/payment-plan.hbs +++ /dev/null @@ -1,24 +0,0 @@ - - - {{#if this.recurringPlan}} - {{i18n - (concat - "discourse_subscriptions.plans.interval.adverb." - this.plan.recurring.interval - ) - }} - {{else}} - {{i18n "discourse_subscriptions.one_time_payment"}} - {{/if}} - - - - {{format-currency this.plan.currency this.plan.amountDollars}} - - \ No newline at end of file diff --git a/assets/javascripts/discourse/components/payment-plan.js b/assets/javascripts/discourse/components/payment-plan.js deleted file mode 100644 index 8e9323fb..00000000 --- a/assets/javascripts/discourse/components/payment-plan.js +++ /dev/null @@ -1,25 +0,0 @@ -import Component from "@ember/component"; -import { action } from "@ember/object"; -import { tagName } from "@ember-decorators/component"; -import discourseComputed from "discourse/lib/decorators"; - -const RECURRING = "recurring"; - -@tagName("") -export default class PaymentPlan extends Component { - @discourseComputed("selectedPlan") - selectedClass(planId) { - return planId === this.plan.id ? "btn-primary" : ""; - } - - @discourseComputed("plan.type") - recurringPlan(type) { - return type === RECURRING; - } - - @action - planClick() { - this.clickPlan(this.plan); - return false; - } -} diff --git a/assets/javascripts/discourse/components/product-item.gjs b/assets/javascripts/discourse/components/product-item.gjs new file mode 100644 index 00000000..0bf3a21c --- /dev/null +++ b/assets/javascripts/discourse/components/product-item.gjs @@ -0,0 +1,64 @@ +import Component from "@ember/component"; +import { LinkTo } from "@ember/routing"; +import { classNames } from "@ember-decorators/component"; +import htmlSafe from "discourse/helpers/html-safe"; +import { i18n } from "discourse-i18n"; + +@classNames("product") +export default class ProductItem extends Component { + +} diff --git a/assets/javascripts/discourse/components/product-item.hbs b/assets/javascripts/discourse/components/product-item.hbs deleted file mode 100644 index 90b3b3cb..00000000 --- a/assets/javascripts/discourse/components/product-item.hbs +++ /dev/null @@ -1,53 +0,0 @@ -

{{this.product.name}}

- -

- {{html-safe this.product.description}} -

- -{{#if this.isLoggedIn}} -
- {{#if this.product.repurchaseable}} - - {{i18n "discourse_subscriptions.subscribe.title"}} - - - {{#if this.product.subscribed}} - - {{i18n "discourse_subscriptions.subscribe.view_past"}} - - {{/if}} - {{else}} - {{#if this.product.subscribed}} - - ✓ - {{i18n "discourse_subscriptions.subscribe.purchased"}} - - - - {{i18n "discourse_subscriptions.subscribe.go_to_billing"}} - - {{else}} - - {{i18n "discourse_subscriptions.subscribe.title"}} - - {{/if}} - {{/if}} -
-{{/if}} \ No newline at end of file diff --git a/assets/javascripts/discourse/components/product-item.js b/assets/javascripts/discourse/components/product-item.js deleted file mode 100644 index 11670294..00000000 --- a/assets/javascripts/discourse/components/product-item.js +++ /dev/null @@ -1,5 +0,0 @@ -import Component from "@ember/component"; -import { classNames } from "@ember-decorators/component"; - -@classNames("product") -export default class ProductItem extends Component {} diff --git a/assets/javascripts/discourse/components/product-list.js b/assets/javascripts/discourse/components/product-list.gjs similarity index 50% rename from assets/javascripts/discourse/components/product-list.js rename to assets/javascripts/discourse/components/product-list.gjs index 4c112b9d..09160b4c 100644 --- a/assets/javascripts/discourse/components/product-list.js +++ b/assets/javascripts/discourse/components/product-list.gjs @@ -2,6 +2,8 @@ import Component from "@ember/component"; import { isEmpty } from "@ember/utils"; import { classNames } from "@ember-decorators/component"; import discourseComputed from "discourse/lib/decorators"; +import { i18n } from "discourse-i18n"; +import ProductItem from "./product-item"; @classNames("product-list") export default class ProductList extends Component { @@ -9,4 +11,14 @@ export default class ProductList extends Component { emptyProducts(products) { return isEmpty(products); } + + } diff --git a/assets/javascripts/discourse/components/product-list.hbs b/assets/javascripts/discourse/components/product-list.hbs deleted file mode 100644 index 1f374268..00000000 --- a/assets/javascripts/discourse/components/product-list.hbs +++ /dev/null @@ -1,7 +0,0 @@ -{{#if this.emptyProducts}} -

{{i18n "discourse_subscriptions.subscribe.no_products"}}

-{{else}} - {{#each this.products as |product|}} - - {{/each}} -{{/if}} \ No newline at end of file diff --git a/assets/javascripts/discourse/components/subscribe-card.js b/assets/javascripts/discourse/components/subscribe-card.gjs similarity index 92% rename from assets/javascripts/discourse/components/subscribe-card.js rename to assets/javascripts/discourse/components/subscribe-card.gjs index cfd77ca5..bdee6787 100644 --- a/assets/javascripts/discourse/components/subscribe-card.js +++ b/assets/javascripts/discourse/components/subscribe-card.gjs @@ -28,4 +28,8 @@ export default class SubscribeCard extends Component { didDestroyElement() { super.didDestroyElement(...arguments); } + + } diff --git a/assets/javascripts/discourse/components/subscribe-card.hbs b/assets/javascripts/discourse/components/subscribe-card.hbs deleted file mode 100644 index 96e4b590..00000000 --- a/assets/javascripts/discourse/components/subscribe-card.hbs +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/assets/javascripts/discourse/connectors/above-main-container/subscriptions-campaign.gjs b/assets/javascripts/discourse/connectors/above-main-container/subscriptions-campaign.gjs new file mode 100644 index 00000000..c0265d0c --- /dev/null +++ b/assets/javascripts/discourse/connectors/above-main-container/subscriptions-campaign.gjs @@ -0,0 +1,19 @@ +import Component from "@ember/component"; +import { classNames, tagName } from "@ember-decorators/component"; +import CampaignBanner from "../../components/campaign-banner"; + +@tagName("div") +@classNames("above-main-container-outlet", "subscriptions-campaign") +export default class SubscriptionsCampaign extends Component { + static shouldRender(args, context) { + const { siteSettings } = context; + const mobileView = context.site.mobileView; + const bannerLocation = + siteSettings.discourse_subscriptions_campaign_banner_location; + return ( + bannerLocation === "Top" || (bannerLocation === "Sidebar" && mobileView) + ); + } + + +} diff --git a/assets/javascripts/discourse/connectors/above-main-container/subscriptions-campaign.hbs b/assets/javascripts/discourse/connectors/above-main-container/subscriptions-campaign.hbs deleted file mode 100644 index a467e54a..00000000 --- a/assets/javascripts/discourse/connectors/above-main-container/subscriptions-campaign.hbs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/javascripts/discourse/connectors/above-main-container/subscriptions-campaign.js b/assets/javascripts/discourse/connectors/above-main-container/subscriptions-campaign.js deleted file mode 100644 index 3906052a..00000000 --- a/assets/javascripts/discourse/connectors/above-main-container/subscriptions-campaign.js +++ /dev/null @@ -1,12 +0,0 @@ -export default { - shouldRender(args, component) { - const { siteSettings } = component; - const mobileView = component.site.mobileView; - const bannerLocation = - siteSettings.discourse_subscriptions_campaign_banner_location; - - return ( - bannerLocation === "Top" || (bannerLocation === "Sidebar" && mobileView) - ); - }, -}; diff --git a/assets/javascripts/discourse/connectors/after-topic-footer-buttons/subscriptions-campaign-topic-footer.gjs b/assets/javascripts/discourse/connectors/after-topic-footer-buttons/subscriptions-campaign-topic-footer.gjs new file mode 100644 index 00000000..5a169402 --- /dev/null +++ b/assets/javascripts/discourse/connectors/after-topic-footer-buttons/subscriptions-campaign-topic-footer.gjs @@ -0,0 +1,21 @@ +import Component from "@ember/component"; +import { classNames, tagName } from "@ember-decorators/component"; +import CampaignBanner from "../../components/campaign-banner"; + +@tagName("span") +@classNames( + "after-topic-footer-buttons-outlet", + "subscriptions-campaign-topic-footer" +) +export default class SubscriptionsCampaignTopicFooter extends Component { + static shouldRender(args, context) { + const { siteSettings } = context; + const bannerLocation = + siteSettings.discourse_subscriptions_campaign_banner_location; + return bannerLocation === "Top" || bannerLocation === "Sidebar"; + } + + +} diff --git a/assets/javascripts/discourse/connectors/after-topic-footer-buttons/subscriptions-campaign-topic-footer.hbs b/assets/javascripts/discourse/connectors/after-topic-footer-buttons/subscriptions-campaign-topic-footer.hbs deleted file mode 100644 index 20fea519..00000000 --- a/assets/javascripts/discourse/connectors/after-topic-footer-buttons/subscriptions-campaign-topic-footer.hbs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/javascripts/discourse/connectors/after-topic-footer-buttons/subscriptions-campaign-topic-footer.js b/assets/javascripts/discourse/connectors/after-topic-footer-buttons/subscriptions-campaign-topic-footer.js deleted file mode 100644 index d1bb3a47..00000000 --- a/assets/javascripts/discourse/connectors/after-topic-footer-buttons/subscriptions-campaign-topic-footer.js +++ /dev/null @@ -1,9 +0,0 @@ -export default { - shouldRender(args, component) { - const { siteSettings } = component; - const bannerLocation = - siteSettings.discourse_subscriptions_campaign_banner_location; - - return bannerLocation === "Top" || bannerLocation === "Sidebar"; - }, -}; diff --git a/assets/javascripts/discourse/connectors/before-topic-list/subscriptions-campaign-sidebar.gjs b/assets/javascripts/discourse/connectors/before-topic-list/subscriptions-campaign-sidebar.gjs new file mode 100644 index 00000000..fa4f0eb5 --- /dev/null +++ b/assets/javascripts/discourse/connectors/before-topic-list/subscriptions-campaign-sidebar.gjs @@ -0,0 +1,17 @@ +import Component from "@ember/component"; +import { classNames, tagName } from "@ember-decorators/component"; +import CampaignBanner from "../../components/campaign-banner"; + +@tagName("div") +@classNames("before-topic-list-outlet", "subscriptions-campaign-sidebar") +export default class SubscriptionsCampaignSidebar extends Component { + static shouldRender(args, context) { + const { siteSettings } = context; + const mobileView = context.site.mobileView; + const bannerLocation = + siteSettings.discourse_subscriptions_campaign_banner_location; + return bannerLocation === "Sidebar" && !mobileView; + } + + +} diff --git a/assets/javascripts/discourse/connectors/before-topic-list/subscriptions-campaign-sidebar.hbs b/assets/javascripts/discourse/connectors/before-topic-list/subscriptions-campaign-sidebar.hbs deleted file mode 100644 index 04bcb5a0..00000000 --- a/assets/javascripts/discourse/connectors/before-topic-list/subscriptions-campaign-sidebar.hbs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/javascripts/discourse/connectors/before-topic-list/subscriptions-campaign-sidebar.js b/assets/javascripts/discourse/connectors/before-topic-list/subscriptions-campaign-sidebar.js deleted file mode 100644 index 85868274..00000000 --- a/assets/javascripts/discourse/connectors/before-topic-list/subscriptions-campaign-sidebar.js +++ /dev/null @@ -1,10 +0,0 @@ -export default { - shouldRender(args, component) { - const { siteSettings } = component; - const mobileView = component.site.mobileView; - const bannerLocation = - siteSettings.discourse_subscriptions_campaign_banner_location; - - return bannerLocation === "Sidebar" && !mobileView; - }, -}; diff --git a/assets/javascripts/discourse/connectors/user-main-nav/billing.gjs b/assets/javascripts/discourse/connectors/user-main-nav/billing.gjs new file mode 100644 index 00000000..380760d6 --- /dev/null +++ b/assets/javascripts/discourse/connectors/user-main-nav/billing.gjs @@ -0,0 +1,19 @@ +import Component from "@ember/component"; +import { LinkTo } from "@ember/routing"; +import { classNames, tagName } from "@ember-decorators/component"; +import icon from "discourse/helpers/d-icon"; +import { i18n } from "discourse-i18n"; +import userViewingSelf from "../../helpers/user-viewing-self"; + +@tagName("li") +@classNames("user-main-nav-outlet", "billing") +export default class Billing extends Component { + +} diff --git a/assets/javascripts/discourse/connectors/user-main-nav/billing.hbs b/assets/javascripts/discourse/connectors/user-main-nav/billing.hbs deleted file mode 100644 index 34c8a87b..00000000 --- a/assets/javascripts/discourse/connectors/user-main-nav/billing.hbs +++ /dev/null @@ -1,6 +0,0 @@ -{{#if (user-viewing-self this.model)}} - - {{d-icon "far-credit-card"}} - {{i18n "discourse_subscriptions.navigation.billing"}} - -{{/if}} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-coupons.gjs b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-coupons.gjs new file mode 100644 index 00000000..fda82b38 --- /dev/null +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-coupons.gjs @@ -0,0 +1,74 @@ +import { Input } from "@ember/component"; +import { fn } from "@ember/helper"; +import { on } from "@ember/modifier"; +import RouteTemplate from "ember-route-template"; +import DButton from "discourse/components/d-button"; +import { i18n } from "discourse-i18n"; +import CreateCouponForm from "../../components/create-coupon-form"; + +export default RouteTemplate( + +); diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-coupons.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-coupons.hbs deleted file mode 100644 index 09da58d3..00000000 --- a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-coupons.hbs +++ /dev/null @@ -1,61 +0,0 @@ -{{#if this.model.unconfigured}} -

{{i18n "discourse_subscriptions.admin.unconfigured"}}

-

- - {{i18n "discourse_subscriptions.admin.on_meta"}} - -

-{{else}} - {{#if this.model}} - - - - - - - - - - {{#each this.model as |coupon|}} - - - - - - - - {{/each}} - -
{{i18n "discourse_subscriptions.admin.coupons.code"}}{{i18n "discourse_subscriptions.admin.coupons.discount"}}{{i18n "discourse_subscriptions.admin.coupons.times_redeemed"}}{{i18n "discourse_subscriptions.admin.coupons.active"}}{{i18n "discourse_subscriptions.admin.coupons.actions"}}
{{coupon.code}}{{coupon.discount}}{{coupon.times_redeemed}} - - - -
- {{/if}} - - {{#unless this.creating}} - - {{/unless}} - - {{#if this.creating}} - - {{/if}} -{{/if}} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-dashboard.gjs b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-dashboard.gjs new file mode 100644 index 00000000..4e5cba0a --- /dev/null +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-dashboard.gjs @@ -0,0 +1,84 @@ +import { array, fn } from "@ember/helper"; +import { on } from "@ember/modifier"; +import { LinkTo } from "@ember/routing"; +import RouteTemplate from "ember-route-template"; +import LoadMore from "discourse/components/load-more"; +import formatDuration from "discourse/helpers/format-duration"; +import htmlSafe from "discourse/helpers/html-safe"; +import { i18n } from "discourse-i18n"; + +export default RouteTemplate( + +); diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-dashboard.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-dashboard.hbs deleted file mode 100644 index e372c428..00000000 --- a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-dashboard.hbs +++ /dev/null @@ -1,64 +0,0 @@ -

{{i18n "discourse_subscriptions.admin.dashboard.title"}}

- - - {{#if this.model}} - - - - - - - - - - - - {{#each this.model as |payment|}} - - - - - - - - {{/each}} - -
- {{i18n "discourse_subscriptions.admin.dashboard.table.head.user"}} - - {{i18n - "discourse_subscriptions.admin.dashboard.table.head.payment_intent" - }} - - {{i18n - "discourse_subscriptions.admin.dashboard.table.head.receipt_email" - }} - - {{i18n "created"}} - - {{i18n "discourse_subscriptions.admin.dashboard.table.head.amount"}} -
- - {{payment.username}} - - - - {{html-safe payment.payment_intent_id}} - - {{payment.receipt_email}}{{html-safe (format-duration payment.created_at_age)}}{{payment.amount_currency}}
- {{/if}} -
\ No newline at end of file diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-plans-index.gjs b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-plans-index.gjs new file mode 100644 index 00000000..6f827310 --- /dev/null +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-plans-index.gjs @@ -0,0 +1,44 @@ +import { fn } from "@ember/helper"; +import RouteTemplate from "ember-route-template"; +import DButton from "discourse/components/d-button"; +import routeAction from "discourse/helpers/route-action"; +import { i18n } from "discourse-i18n"; + +export default RouteTemplate( + +); diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-plans-index.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-plans-index.hbs deleted file mode 100644 index c64e2535..00000000 --- a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-plans-index.hbs +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - {{#each this.model as |plan|}} - - - - - - - - {{/each}} - -
{{i18n "discourse_subscriptions.admin.plans.plan.plan_id"}}{{i18n "discourse_subscriptions.admin.plans.plan.nickname.title"}}{{i18n "discourse_subscriptions.admin.plans.plan.interval"}}{{i18n "discourse_subscriptions.admin.plans.plan.amount"}}
{{plan.id}}{{plan.nickname}}{{plan.interval}}{{plan.unit_amount}} - - -
\ No newline at end of file diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-index.gjs b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-index.gjs new file mode 100644 index 00000000..9637a8bb --- /dev/null +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-index.gjs @@ -0,0 +1,90 @@ +import { LinkTo } from "@ember/routing"; +import RouteTemplate from "ember-route-template"; +import DButton from "discourse/components/d-button"; +import icon from "discourse/helpers/d-icon"; +import routeAction from "discourse/helpers/route-action"; +import { i18n } from "discourse-i18n"; +import formatUnixDate from "../../helpers/format-unix-date"; + +export default RouteTemplate( + +); diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-index.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-index.hbs deleted file mode 100644 index 5b2cd16f..00000000 --- a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-index.hbs +++ /dev/null @@ -1,74 +0,0 @@ -{{#if this.model.unconfigured}} -

{{i18n "discourse_subscriptions.admin.unconfigured"}}

-

- - {{i18n "discourse_subscriptions.admin.on_meta"}} - -

-{{else}} -

- - {{d-icon "plus"}} - - {{i18n "discourse_subscriptions.admin.products.operations.new"}} - - -

- - {{#if this.model}} - - - - - - - - - - - {{#each this.model as |product|}} - - - - - - - - {{/each}} - -
- {{i18n "discourse_subscriptions.admin.products.product.name"}} - - {{i18n "discourse_subscriptions.admin.products.product.created_at"}} - - {{i18n "discourse_subscriptions.admin.products.product.updated_at"}} - - {{i18n "discourse_subscriptions.admin.products.product.active"}} -
{{product.name}}{{format-unix-date product.created}}{{format-unix-date product.updated}}{{product.active}} -
- - {{d-icon "far-pen-to-square"}} - - - -
-
- {{else}} -

- {{i18n "discourse_subscriptions.admin.products.product_help"}} -

- {{/if}} -{{/if}} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show-plans-show.gjs b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show-plans-show.gjs new file mode 100644 index 00000000..66bd4d09 --- /dev/null +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show-plans-show.gjs @@ -0,0 +1,185 @@ +import { Input } from "@ember/component"; +import { fn } from "@ember/helper"; +import { on } from "@ember/modifier"; +import RouteTemplate from "ember-route-template"; +import DButton from "discourse/components/d-button"; +import { i18n } from "discourse-i18n"; +import ComboBox from "select-kit/components/combo-box"; + +export default RouteTemplate( + +); diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show-plans-show.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show-plans-show.hbs deleted file mode 100644 index c3d02600..00000000 --- a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show-plans-show.hbs +++ /dev/null @@ -1,165 +0,0 @@ -

{{i18n "discourse_subscriptions.admin.plans.title"}}

- -
-

- - - -

- -

- - - - -

- {{i18n "discourse_subscriptions.admin.plans.plan.nickname_help"}} -
-

- -

- - - - -

- {{i18n "discourse_subscriptions.admin.plans.plan.group_help"}} -
-

- -

- - - {{#if this.planFieldDisabled}} - - {{else}} - - {{/if}} - - -

- -

- - - {{#if this.planFieldDisabled}} - - {{else}} - - {{/if}} -

- - {{#if this.model.plan.isRecurring}} -

- - - {{#if this.planFieldDisabled}} - - {{else}} - - {{/if}} -

- -

- - - - -

- {{i18n "discourse_subscriptions.admin.plans.plan.trial_help"}} -
-

- {{/if}} - -

- - -

-
- -
-
- -

- {{i18n "discourse_subscriptions.admin.plans.operations.create_help"}} -

- -
- {{#if this.model.plan.isNew}} - - {{else}} - - {{/if}} -
-
\ No newline at end of file diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show.gjs b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show.gjs new file mode 100644 index 00000000..517b8289 --- /dev/null +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-subscriptions-products-show.gjs @@ -0,0 +1,195 @@ +import { Input, Textarea } from "@ember/component"; +import { array } from "@ember/helper"; +import { LinkTo } from "@ember/routing"; +import RouteTemplate from "ember-route-template"; +import DButton from "discourse/components/d-button"; +import icon from "discourse/helpers/d-icon"; +import { i18n } from "discourse-i18n"; +import formatCurrency from "../../helpers/format-currency"; +import formatUnixDate from "../../helpers/format-unix-date"; + +export default RouteTemplate( +