From 6c6e4021538a227690f7990fdb0ad7982a9aac2d Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Fri, 17 Nov 2023 16:17:10 +0100 Subject: [PATCH 1/5] Update subscription admin ux --- .../components/wizard-subscription-badge.hbs | 22 ++--- .../components/wizard-subscription-badge.js | 3 +- .../components/wizard-subscription-cta.hbs | 7 -- .../components/wizard-subscription-cta.js | 34 ------- .../components/wizard-subscription-status.hbs | 3 +- .../discourse/services/subscription.js | 7 +- assets/stylesheets/common/admin.scss | 89 ++++++------------- .../stylesheets/common/admin/variables.scss | 2 + config/locales/client.en.yml | 18 ++-- ...dmin-wizards-business-subscription-test.js | 4 - ...dmin-wizards-standard-subscription-test.js | 4 - .../admin-wizards-unsubscribed-test.js | 6 +- 12 files changed, 50 insertions(+), 149 deletions(-) delete mode 100644 assets/javascripts/discourse/components/wizard-subscription-cta.hbs delete mode 100644 assets/javascripts/discourse/components/wizard-subscription-cta.js diff --git a/assets/javascripts/discourse/components/wizard-subscription-badge.hbs b/assets/javascripts/discourse/components/wizard-subscription-badge.hbs index dee4724f..992504bb 100644 --- a/assets/javascripts/discourse/components/wizard-subscription-badge.hbs +++ b/assets/javascripts/discourse/components/wizard-subscription-badge.hbs @@ -1,3 +1,14 @@ + + {{#if this.updating}} + {{loading-spinner size="small"}} + {{/if}} + {{d-icon "pavilion-logo"}} {{this.label}} - - - {{#if this.updating}} - {{loading-spinner size="small"}} - {{/if}} \ 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 index e103c95b..be14b6f8 100644 --- a/assets/javascripts/discourse/components/wizard-subscription-badge.js +++ b/assets/javascripts/discourse/components/wizard-subscription-badge.js @@ -2,7 +2,6 @@ import { inject as service } from "@ember/service"; import { action, computed } from "@ember/object"; import Component from "@glimmer/component"; import { tracked } from "@glimmer/tracking"; -import DiscourseURL from "discourse/lib/url"; import I18n from "I18n"; export default class WizardSubscriptionBadge extends Component { @@ -32,7 +31,7 @@ export default class WizardSubscriptionBadge extends Component { @action click() { - DiscourseURL.routeTo(this.subscription.subscriptionLink); + window.open(this.subscription.subscriptionCtaLink, "_blank").focus(); } @action diff --git a/assets/javascripts/discourse/components/wizard-subscription-cta.hbs b/assets/javascripts/discourse/components/wizard-subscription-cta.hbs deleted file mode 100644 index 945eb90c..00000000 --- a/assets/javascripts/discourse/components/wizard-subscription-cta.hbs +++ /dev/null @@ -1,7 +0,0 @@ - \ 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 deleted file mode 100644 index 47b2f382..00000000 --- a/assets/javascripts/discourse/components/wizard-subscription-cta.js +++ /dev/null @@ -1,34 +0,0 @@ -import { inject as service } from "@ember/service"; -import { action, computed } from "@ember/object"; -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 `${this.i18nKey}.title`; - } - - @computed("i18nKey") - get label() { - return `${this.i18nKey}.label`; - } - - @action - click() { - window.open(this.subscription.subscriptionCtaLink, "_blank").focus(); - } -} diff --git a/assets/javascripts/discourse/components/wizard-subscription-status.hbs b/assets/javascripts/discourse/components/wizard-subscription-status.hbs index a5c69a1b..5309558c 100644 --- a/assets/javascripts/discourse/components/wizard-subscription-status.hbs +++ b/assets/javascripts/discourse/components/wizard-subscription-status.hbs @@ -1,4 +1,5 @@
+ {{#if authorized}} {{conditional-loading-spinner size="small" condition=unauthorizing}} {{/if}} - -
\ No newline at end of file diff --git a/assets/javascripts/discourse/services/subscription.js b/assets/javascripts/discourse/services/subscription.js index 08ea5278..499e734c 100644 --- a/assets/javascripts/discourse/services/subscription.js +++ b/assets/javascripts/discourse/services/subscription.js @@ -7,7 +7,7 @@ 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"; + "https://coop.pavilion.tech/c/support/discourse-custom-wizard"; export default class SubscriptionService extends Service { @tracked subscribed = false; @@ -16,7 +16,6 @@ export default class SubscriptionService extends Service { @tracked communitySubscription = false; @tracked standardSubscription = false; @tracked subscriptionAttributes = {}; - subscriptionLandingUrl = PRODUCT_PAGE; async init() { super.init(...arguments); @@ -49,10 +48,6 @@ export default class SubscriptionService extends Service { this.standardSubscription = this.subscriptionType === "standard"; } - get subscriptionLink() { - return this.subscriptionLandingUrl; - } - get subscriptionCtaLink() { switch (this.subscriptionType) { case "none": diff --git a/assets/stylesheets/common/admin.scss b/assets/stylesheets/common/admin.scss index f8722c2d..f188ee1d 100644 --- a/assets/stylesheets/common/admin.scss +++ b/assets/stylesheets/common/admin.scss @@ -823,25 +823,6 @@ $error: #ef1700; vertical-align: middle; } -.btn.btn-pavilion-support { - background: var(--pavilion-primary); - color: var(--pavilion-secondary); - - .d-icon { - color: var(--pavilion-secondary); - } - - &:hover, - &:focus { - background: darken($pavilion_primary, 5%); - - &[href], - svg.d-icon { - color: darken($pavilion_secondary, 10%); - } - } -} - .wizard-subscription-container { width: 100%; padding: 1em; @@ -877,35 +858,40 @@ $error: #ef1700; padding: 0.5em 0.65em; background-color: rgba($primary-medium, 0.05); border: 1.5px solid rgba($primary-medium, 0.5); - color: $primary-medium; + color: var(--secondary); - &:hover { - color: $primary-medium; - } - - svg { + svg.d-icon-pavilion-logo { width: 15px; height: 15px; margin-right: 0.45em; margin-bottom: 0.15em; + color: var(--secondary); + } + + &.none { + background-color: var(--subscription-none); + border: 1.5px solid var(--subscription-none); } &.standard { - background-color: rgba($subscription_standard, 0.05); - border: 1.5px solid rgba($subscription_standard, 0.5); - color: $subscription_standard; + background-color: var(--subscription-standard); + border: 1.5px solid var(--subscription-standard); } &.business { - background-color: $subscription_business; - border: 1.5px solid $subscription_business; - color: $secondary; + background-color: var(--subscription-business); + border: 1.5px solid var(--subscription-business); } &.community { - background-color: $subscription_community; - border: 1.5px solid $pavilion_primary; - color: $pavilion_primary; + background-color: var(--subscription-community); + border: 1.5px solid var(--pavilion-primary); + color: var(--pavilion-primary); + + &:hover, + svg { + color: var(--pavilion-primary); + } } .d-icon { @@ -942,42 +928,23 @@ $error: #ef1700; height: 34px; } - .btn-pavilion-support { - &:hover { - color: var(--pavilion-secondary); - } - } - .wizard-subscription-badge { margin-right: 5px; svg { margin-right: 0.45em; } - &.none { - svg { - color: #919191; - } - } - &.community, - &.standard, - &.business { - svg { - color: #fff; - } - } - } - - .loading-container { - svg, - div { - vertical-align: -moz-middle-with-baseline; - vertical-align: -webkit-baseline-middle; - margin-right: 3px; - } } .btn-primary { margin-right: 5px; } + + .deauthorize { + background-color: var(--secondary); + + &:hover { + color: var(--primary); + } + } } } diff --git a/assets/stylesheets/common/admin/variables.scss b/assets/stylesheets/common/admin/variables.scss index 33a67c2d..8b263fd5 100644 --- a/assets/stylesheets/common/admin/variables.scss +++ b/assets/stylesheets/common/admin/variables.scss @@ -2,6 +2,7 @@ $pavilion_primary: #3c1c8c; $pavilion_secondary: #ffffff; $pavilion_warning: rgb(243, 163, 61); +$subscription_none: $pavilion_primary; $subscription_standard: $pavilion_primary; $subscription_business: #333; $subscription_community: #fff; @@ -10,6 +11,7 @@ $subscription_community: #fff; --pavilion-primary: #{$pavilion_primary}; --pavilion-secondary: #{$pavilion_secondary}; --pavilion-warning: #{$pavilion_warning}; + --subscription-none: #{$subscription_none}; --subscription-standard: #{$subscription_standard}; --subscription-business: #{$subscription_business}; --subscription-community: #{$subscription_community}; diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 0a088855..e5704cde 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -549,7 +549,7 @@ en: label: Authorize title: Authorize your subscription on this site deauthorize: - label: deauthorize + label: Deauthorize title: Deauthorize your subscription on this site update: title: "Update subscription status" @@ -563,25 +563,17 @@ en: selector: not subscribed type: none: - label: Not Subscribed + label: Subscribe title: There is no Custom Wizard subscription active on this forum. business: - label: Business + label: Support title: There is a Custom Wizard Business subscription active on this forum. standard: - label: Standard + label: Support title: There is a Custom Wizard Standard subscription active on this forum. community: - label: Community - title: There is a Custom Wizard Community subscription active on this forum. - cta: - none: - label: Get a Subscription - title: Get a subscription for this forum. - subscribed: label: Support - title: Get support for your subscription. - + title: There is a Custom Wizard Community subscription active on this forum. wizard_js: group: diff --git a/test/javascripts/acceptance/admin-wizards-business-subscription-test.js b/test/javascripts/acceptance/admin-wizards-business-subscription-test.js index ea8cbac2..5a17a023 100644 --- a/test/javascripts/acceptance/admin-wizards-business-subscription-test.js +++ b/test/javascripts/acceptance/admin-wizards-business-subscription-test.js @@ -71,10 +71,6 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) { ); assert.strictEqual( query("button.wizard-subscription-badge span").innerText.trim(), - "Business" - ); - assert.strictEqual( - query("button.btn-pavilion-support span").innerText.trim(), "Support" ); }); diff --git a/test/javascripts/acceptance/admin-wizards-standard-subscription-test.js b/test/javascripts/acceptance/admin-wizards-standard-subscription-test.js index 0670e703..ffed5287 100644 --- a/test/javascripts/acceptance/admin-wizards-standard-subscription-test.js +++ b/test/javascripts/acceptance/admin-wizards-standard-subscription-test.js @@ -71,10 +71,6 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) { ); assert.strictEqual( query("button.wizard-subscription-badge span").innerText.trim(), - "Standard" - ); - assert.strictEqual( - query("button.btn-pavilion-support span").innerText.trim(), "Support" ); }); diff --git a/test/javascripts/acceptance/admin-wizards-unsubscribed-test.js b/test/javascripts/acceptance/admin-wizards-unsubscribed-test.js index 52038d5e..6c34a935 100644 --- a/test/javascripts/acceptance/admin-wizards-unsubscribed-test.js +++ b/test/javascripts/acceptance/admin-wizards-unsubscribed-test.js @@ -84,11 +84,7 @@ acceptance("Admin | Custom Wizard Unsubscribed", function (needs) { ); assert.strictEqual( query("button.wizard-subscription-badge span").innerText.trim(), - "Not Subscribed" - ); - assert.strictEqual( - query("button.btn-pavilion-support span").innerText.trim(), - "Get a Subscription" + "Subscribe" ); }); From 191aa08a29177e3893f3f8188218ec032cd2e07e Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Fri, 17 Nov 2023 16:18:52 +0100 Subject: [PATCH 2/5] Bump version --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 99789ebc..e618128f 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # name: discourse-custom-wizard # about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more. -# version: 2.5.1 +# version: 2.5.2 # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos # url: https://github.com/paviliondev/discourse-custom-wizard # contact_emails: development@pavilion.tech From 741491aa48bcdc802b3b2a0b387809d3d140fafa Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Fri, 17 Nov 2023 17:28:58 +0100 Subject: [PATCH 3/5] Change authorize/deauthorize to connect/disconnect --- config/locales/client.en.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index e5704cde..fa5c9deb 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -167,13 +167,13 @@ en: destroy_complete: Destruction complete subscription: documentation: Check out the subscription documentation - authorize: "Authorize this forum to use your Custom Wizard subscription plan on %{server}." - not_subscribed: "You've authorized, but are not currently subscribed to a Custom Wizard plan on %{server}." + authorize: "Connect this forum to use your Custom Wizard subscription plan on %{server}." + not_subscribed: "You've connected, but are not currently subscribed to a Custom Wizard plan on %{server}." subscription_expiring: "Your subscription is active, but will expire in the next 48 hours." subscription_active: "Your subscription is active." subscription_inactive: "Your subscription is inactive on this forum. Read more in the documentation." - unauthorized: "You're unauthorized. If you have a subscription, it will become inactive in the next 48 hours." - unauthorize_failed: Failed to unauthorize. + unauthorized: "You're not connected. If you have a subscription, it will become inactive in the next 48 hours." + unauthorize_failed: Failed to disconnect. submissions: select: "Select a wizard to see its submissions" viewing: "You're viewing the submissions of the %{wizardName}" @@ -546,11 +546,11 @@ en: subscription: title: Subscriber Features authorize: - label: Authorize - title: Authorize your subscription on this site + label: Connect + title: Connect your subscription to this site deauthorize: - label: Deauthorize - title: Deauthorize your subscription on this site + label: Disconnect + title: Disconnect your subscription from this site update: title: "Update subscription status" subscribed: From bda35c4a32efd4d9f52320996738ffbbeab2c3a2 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Mon, 4 Dec 2023 15:42:16 +0100 Subject: [PATCH 4/5] DEV: improve send message spec Check that only one notification is being sent --- spec/components/custom_wizard/action_spec.rb | 34 ++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/spec/components/custom_wizard/action_spec.rb b/spec/components/custom_wizard/action_spec.rb index b867cced..fb0a9e51 100644 --- a/spec/components/custom_wizard/action_spec.rb +++ b/spec/components/custom_wizard/action_spec.rb @@ -254,11 +254,14 @@ describe CustomWizard::Action do end it '#send_message' do + Jobs.run_immediately! + + target_user = Fabricate(:user) + + send_message['recipient'][0]['output'][0] = target_user.username wizard_template['actions'] << send_message update_template(wizard_template) - User.create(username: 'angus1', email: "angus1@email.com") - wizard = CustomWizard::Builder.new(@template[:id], user).build wizard.create_updater(wizard.steps[0].id, {}).update wizard.create_updater(wizard.steps[1].id, {}).update @@ -274,18 +277,29 @@ describe CustomWizard::Action do ) expect(topic.exists?).to eq(true) - expect(topic.first.topic_allowed_users.first.user.username).to eq('angus1') + expect(topic.first.topic_allowed_users.first.user.username).to eq(target_user.username) expect(post.exists?).to eq(true) + expect(target_user.reload.notifications.count).to eq(1) end it '#send_message allows using multiple targets' do + Jobs.run_immediately! + + user1 = Fabricate(:user) + user2 = Fabricate(:user) + group1 = Fabricate(:group) + group2 = Fabricate(:group) + + send_message_multi['recipient'][0]['output'] = [ + user1.username, + user2.username, + group1.name, + group2.name + ] wizard_template['actions'] << send_message_multi update_template(wizard_template) + update_template(wizard_template) - User.create(username: 'angus1', email: "angus1@email.com") - User.create(username: 'faiz', email: "faiz@email.com") - Group.create(name: "cool_group") - Group.create(name: 'cool_group_1') wizard = CustomWizard::Builder.new(@template[:id], user).build wizard.create_updater(wizard.steps[0].id, {}).update wizard.create_updater(wizard.steps[1].id, {}).update @@ -301,9 +315,11 @@ describe CustomWizard::Action do ) expect(topic.exists?).to eq(true) - expect(topic.first.all_allowed_users.map(&:username)).to include('angus1', 'faiz') - expect(topic.first.allowed_groups.map(&:name)).to include('cool_group', 'cool_group_1') + expect(topic.first.all_allowed_users.map(&:username)).to include(user1.username, user2.username) + expect(topic.first.allowed_groups.map(&:name)).to include(group1.name, group2.name) expect(post.exists?).to eq(true) + expect(user1.reload.notifications.count).to eq(1) + expect(user2.reload.notifications.count).to eq(1) end it "send_message works with guests are permitted" do From 4d2dfb94b9aec4f078d5ac29a87b120320cd266a Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Tue, 5 Dec 2023 08:55:31 +0100 Subject: [PATCH 5/5] Update admin.scss --- assets/stylesheets/common/admin.scss | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/assets/stylesheets/common/admin.scss b/assets/stylesheets/common/admin.scss index f188ee1d..5e831c41 100644 --- a/assets/stylesheets/common/admin.scss +++ b/assets/stylesheets/common/admin.scss @@ -848,10 +848,9 @@ $error: #ef1700; } } -.wizard-subscription-badge { +.btn.wizard-subscription-badge { display: inline-flex; align-items: center; - max-height: 34px; box-sizing: border-box; position: relative; cursor: pointer; @@ -925,7 +924,6 @@ $error: #ef1700; button.update { width: 40px; - height: 34px; } .wizard-subscription-badge {