0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-24 10:20:28 +01:00

FEATURE: add a sub refresh button

Dieser Commit ist enthalten in:
merefield 2023-10-09 13:39:10 +01:00
Ursprung 1824738bd4
Commit 2b867ce678
4 geänderte Dateien mit 75 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -27,4 +27,18 @@
</g>
</svg>
<span>{{this.label}}</span>
</DButton>
</DButton>
<span class="loading-container">
{{#if this.updating}}
{{loading-spinner size="small"}}
{{else if updateIcon}}
{{d-icon updateIcon}}
{{/if}}
</span>
<DButton
@icon="sync"
@action={{this.update}}
class="btn btn-primary update"
@disabled={{this.updating}}
@title="admin.wizard.subscription.update.title"
/>

Datei anzeigen

@ -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);
});
}
}

Datei anzeigen

@ -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;
}
}
}

Datei anzeigen

@ -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