diff --git a/assets/javascripts/discourse/components/wizard-subscription-badge.hbs b/assets/javascripts/discourse/components/wizard-subscription-badge.hbs
index 31048eab..fb5becfa 100644
--- a/assets/javascripts/discourse/components/wizard-subscription-badge.hbs
+++ b/assets/javascripts/discourse/components/wizard-subscription-badge.hbs
@@ -27,4 +27,18 @@
{{this.label}}
-
\ No newline at end of file
+
+
+ {{#if this.updating}}
+ {{loading-spinner size="small"}}
+ {{else if updateIcon}}
+ {{d-icon updateIcon}}
+ {{/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 fdee6e64..910e9cb3 100644
--- a/assets/javascripts/discourse/components/wizard-subscription-badge.js
+++ b/assets/javascripts/discourse/components/wizard-subscription-badge.js
@@ -1,11 +1,17 @@
import { inject as service } from "@ember/service";
import { action, computed } from "@ember/object";
+import { ajax } from "discourse/lib/ajax";
+import { popupAjaxError } from "discourse/lib/ajax-error";
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 {
@service subscription;
+ @tracked updating = false;
+ @tracked updateIcon = null;
+ basePath = "/admin/plugins/subscription-client";
@computed("subscription.subscriptionType")
get i18nKey() {
@@ -30,4 +36,26 @@ export default class WizardSubscriptionBadge extends Component {
click() {
DiscourseURL.routeTo(this.subscription.subscriptionLink);
}
+
+ @action
+ update() {
+ this.updating = true;
+ return ajax(`${this.basePath}/subscriptions`, {
+ type: "POST",
+ })
+ .then(() => {
+ if (this.subscription.subscribed) {
+ this.updateIcon = "check";
+ } else {
+ this.updateIcon = "times";
+ }
+ })
+ .catch(popupAjaxError)
+ .finally(() => {
+ this.updating = false;
+ // setTimeout(() => {
+ // this.updateIcon = null;
+ // }, 7000);
+ });
+ }
}
diff --git a/assets/stylesheets/common/admin.scss b/assets/stylesheets/common/admin.scss
index 8862592b..66ab59e1 100644
--- a/assets/stylesheets/common/admin.scss
+++ b/assets/stylesheets/common/admin.scss
@@ -43,23 +43,6 @@ $error: #ef1700;
}
}
-.admin-wizards .admin-actions {
- .supplier-authorize {
- display: inline-flex;
-
- .btn-pavilion-support {
- margin-left: 10px;
- &:hover {
- color: var(--pavilion-secondary);
- }
- }
-
- .btn-primary {
- margin-right: 10px;
- }
- }
-}
-
.wizard-message {
background-color: var(--primary-low);
width: 100%;
@@ -949,3 +932,33 @@ $error: #ef1700;
font-size: 0.75em;
}
}
+
+.admin-wizards .admin-actions {
+ .supplier-authorize {
+ display: inline-flex;
+
+ .btn-pavilion-support {
+ margin-left: 10px;
+ &:hover {
+ color: var(--pavilion-secondary);
+ }
+ }
+
+ .wizard-subscription-badge {
+ margin-right: 5px;
+ }
+
+ .loading-container {
+ svg,
+ div {
+ vertical-align: -moz-middle-with-baseline;
+ vertical-align: -webkit-baseline-middle;
+ margin-right: 3px;
+ }
+ }
+
+ .btn-primary {
+ margin-right: 5px;
+ }
+ }
+}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 26450b48..9f468ed3 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -551,6 +551,8 @@ en:
deauthorize:
label: deauthorize
title: Deauthorize your subscription on this site
+ update:
+ title: "Update subscription status"
subscribed:
label: Subscribed
title: You're subscribed and can use these features