From 27cde861b63ace5ed7351964c36ab944a3f1be9a Mon Sep 17 00:00:00 2001 From: merefield Date: Mon, 4 Sep 2023 14:55:51 +0100 Subject: [PATCH] wip --- .../wizard-subscription-authorize.js | 24 +++++++++++++++++++ .../discourse/templates/admin-wizards.hbs | 1 + .../wizard-subscription-authorize.hbs | 15 ++++++++++++ assets/stylesheets/common/admin.scss | 4 ++++ config/locales/client.en.yml | 2 ++ plugin.rb | 2 ++ 6 files changed, 48 insertions(+) create mode 100644 assets/javascripts/discourse/components/wizard-subscription-authorize.js create mode 100644 assets/javascripts/discourse/templates/components/wizard-subscription-authorize.hbs diff --git a/assets/javascripts/discourse/components/wizard-subscription-authorize.js b/assets/javascripts/discourse/components/wizard-subscription-authorize.js new file mode 100644 index 00000000..4422288c --- /dev/null +++ b/assets/javascripts/discourse/components/wizard-subscription-authorize.js @@ -0,0 +1,24 @@ +// import { geoLocationSearch, providerDetails } from "../lib/location-utilities"; +//import { ajax } from "discourse/lib/ajax"; +import { action, set } from "@ember/object"; +// import { equal } from "@ember/object/computed"; +// import { A } from "@ember/array"; +import { inject as service } from "@ember/service"; +import Component from "@glimmer/component"; +import { tracked } from "@glimmer/tracking"; +// import I18n from "I18n"; + +export default class WizardSubscriptionAuthorize extends Component { + @service siteSettings; + @tracked supplierId = 1; + + constructor() { + super(...arguments); + + } + + @action + authorize() { + window.location.href = `${basePath}/authorize?supplier_id=${this.supplierId}`; + } +} diff --git a/assets/javascripts/discourse/templates/admin-wizards.hbs b/assets/javascripts/discourse/templates/admin-wizards.hbs index 452193b1..6d6bad5b 100644 --- a/assets/javascripts/discourse/templates/admin-wizards.hbs +++ b/assets/javascripts/discourse/templates/admin-wizards.hbs @@ -18,6 +18,7 @@ }}
+ {{wizard-subscription-authorize}} {{wizard-subscription-badge}} {{wizard-subscription-cta}}
diff --git a/assets/javascripts/discourse/templates/components/wizard-subscription-authorize.hbs b/assets/javascripts/discourse/templates/components/wizard-subscription-authorize.hbs new file mode 100644 index 00000000..996f8865 --- /dev/null +++ b/assets/javascripts/discourse/templates/components/wizard-subscription-authorize.hbs @@ -0,0 +1,15 @@ +
+ {{#if authorized}} + {{conditional-loading-spinner size="small" condition=unauthorizing}} + + {{i18n "admin.wizard.subscription.deauthorize"}} + + {{else}} + {{d-button + icon="id-card" + class="btn-primary" + label="admin.wizard.subscription.authorize" + title="admin.wizard.subscription.authorize" + action=(action "authorize")}} + {{/if}} +
\ No newline at end of file diff --git a/assets/stylesheets/common/admin.scss b/assets/stylesheets/common/admin.scss index 6a1601d9..6b91a173 100644 --- a/assets/stylesheets/common/admin.scss +++ b/assets/stylesheets/common/admin.scss @@ -49,6 +49,10 @@ $error: #ef1700; .btn-pavilion-support { margin-left: 10px; } + + .supplier-authorize .btn-primary { + margin-right: 10px; + } } .wizard-message { diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 98519335..996951a8 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -545,6 +545,8 @@ en: subscription: title: Subscriber Features + authorize: "Authorize Subscription" + deauthorize: "De-authorize Subscription" subscribed: label: Subscribed title: You're subscribed and can use these features diff --git a/plugin.rb b/plugin.rb index 756154bb..cf6bc714 100644 --- a/plugin.rb +++ b/plugin.rb @@ -8,6 +8,8 @@ # subscription_url: https://coop.pavilion.tech gem 'liquid', '5.0.1', require: true +gem "discourse_subscription_client", "0.1.0.pre14", require_name: "discourse_subscription_client" + register_asset 'stylesheets/common/admin.scss' register_asset 'stylesheets/common/wizard.scss'