0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 09:20:29 +01:00
Dieser Commit ist enthalten in:
merefield 2023-09-24 11:58:20 +01:00
Ursprung 73e8b0a7fc
Commit d5bd3c3c47
10 geänderte Dateien mit 88 neuen und 68 gelöschten Zeilen

Datei anzeigen

@ -131,7 +131,11 @@ export default Component.extend({
return this.connector === "is"; return this.connector === "is";
}), }),
@discourseComputed("site.groups", "guestGroup", "subscription.subscriptionType") @discourseComputed(
"site.groups",
"guestGroup",
"subscription.subscriptionType"
)
groups(groups, guestGroup, subscriptionType) { groups(groups, guestGroup, subscriptionType) {
let result = groups; let result = groups;
if (!guestGroup) { if (!guestGroup) {

Datei anzeigen

@ -1,4 +1,8 @@
<a onclick={{this.click}} class="wizard-subscription-badge {{this.subscription.subscriptionType}}" title="{{this.title}}"> <a
onclick={{this.click}}
class="wizard-subscription-badge {{this.subscription.subscriptionType}}"
title="{{this.title}}"
>
<svg <svg
width="300px" width="300px"
height="300px" height="300px"

Datei anzeigen

@ -1,6 +1,6 @@
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { action, computed } from "@ember/object"; import { action, computed } from "@ember/object";
import Component from '@glimmer/component'; import Component from "@glimmer/component";
import DiscourseURL from "discourse/lib/url"; import DiscourseURL from "discourse/lib/url";
import I18n from "I18n"; import I18n from "I18n";
@ -9,21 +9,25 @@ export default class WizardSubscriptionBadge extends Component {
@computed("subscription.subscriptionType") @computed("subscription.subscriptionType")
get i18nKey() { get i18nKey() {
return `admin.wizard.subscription.type.${this.subscription.subscriptionType ? this.subscription.subscriptionType : "none"}`; return `admin.wizard.subscription.type.${
}; this.subscription.subscriptionType
? this.subscription.subscriptionType
: "none"
}`;
}
@computed("i18nKey") @computed("i18nKey")
get title() { get title() {
return I18n.t(`${this.i18nKey}.title`); return I18n.t(`${this.i18nKey}.title`);
}; }
@computed("i18nKey") @computed("i18nKey")
get label() { get label() {
return I18n.t(`${this.i18nKey}.label`); return I18n.t(`${this.i18nKey}.label`);
}; }
@action @action
click() { click() {
DiscourseURL.routeTo(this.subscription.subscriptionLink); DiscourseURL.routeTo(this.subscription.subscriptionLink);
}; }
}; }

Datei anzeigen

@ -1,4 +1,7 @@
<div class="wizard-subscription-container {{if this.subscription.subscribed "subscribed"}}"> <div
class="wizard-subscription-container
{{if this.subscription.subscribed 'subscribed'}}"
>
<div class="subscription-header"> <div class="subscription-header">
<h4>{{i18n "admin.wizard.subscription.title"}}</h4> <h4>{{i18n "admin.wizard.subscription.title"}}</h4>

Datei anzeigen

@ -1,4 +1,4 @@
import Component from '@glimmer/component'; import Component from "@glimmer/component";
import { computed } from "@ember/object"; import { computed } from "@ember/object";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
@ -8,19 +8,19 @@ export default class WizardSubscriptionContainer extends Component {
@computed("subscription.subscribed") @computed("subscription.subscribed")
get subscribedIcon() { get subscribedIcon() {
return this.subscription.subscribed ? "check" : "times"; return this.subscription.subscribed ? "check" : "times";
}; }
@computed("subscription.subscribed") @computed("subscription.subscribed")
get subscribedLabel() { get subscribedLabel() {
return `admin.wizard.subscription.${ return `admin.wizard.subscription.${
this.subscription.subscribed ? "subscribed" : "not_subscribed" this.subscription.subscribed ? "subscribed" : "not_subscribed"
}.label`; }.label`;
}; }
@computed("subscription.subscribed") @computed("subscription.subscribed")
get subscribedTitle() { get subscribedTitle() {
return `admin.wizard.subscription.${ return `admin.wizard.subscription.${
this.subscription.subscribed ? "subscribed" : "not_subscribed" this.subscription.subscribed ? "subscribed" : "not_subscribed"
}.title`; }.title`;
}; }
}; }

Datei anzeigen

@ -1,3 +1,7 @@
<a onclick={{this.click}} class="btn btn-pavilion-support {{this.subscription.subscriptionType}}" title="{{this.title}}"> <a
onclick={{this.click}}
class="btn btn-pavilion-support {{this.subscription.subscriptionType}}"
title="{{this.title}}"
>
{{d-icon icon}}{{label}} {{d-icon icon}}{{label}}
</a> </a>

Datei anzeigen

@ -1,8 +1,7 @@
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { action, computed } from "@ember/object"; import { action, computed } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
import Component from '@glimmer/component'; import Component from "@glimmer/component";
export default class WizardSubscriptionCta extends Component { export default class WizardSubscriptionCta extends Component {
@service subscription; @service subscription;
@ -12,25 +11,25 @@ export default class WizardSubscriptionCta extends Component {
return `admin.wizard.subscription.cta.${ return `admin.wizard.subscription.cta.${
this.subscription.subscribed ? "subscribed" : "none" this.subscription.subscribed ? "subscribed" : "none"
}`; }`;
}; }
@computed("subscription.subscribed") @computed("subscription.subscribed")
get icon() { get icon() {
return this.subscription.subscribed ? "far-life-ring" : "external-link-alt"; return this.subscription.subscribed ? "far-life-ring" : "external-link-alt";
}; }
@computed("i18nKey") @computed("i18nKey")
get title() { get title() {
return I18n.t(`${this.i18nKey}.title`); return I18n.t(`${this.i18nKey}.title`);
}; }
@computed("i18nKey") @computed("i18nKey")
get label() { get label() {
return I18n.t(`${this.i18nKey}.label`); return I18n.t(`${this.i18nKey}.label`);
}; }
@action @action
click() { click() {
window.open(this.subscription.subscriptionCtaLink, "_blank").focus(); window.open(this.subscription.subscriptionCtaLink, "_blank").focus();
}; }
}; }

Datei anzeigen

@ -15,13 +15,14 @@ export default class WizardSubscriptionStatus extends Component {
constructor() { constructor() {
super(...arguments); super(...arguments);
ajax(`${this.basePath}`).then((result) => { ajax(`${this.basePath}`)
this.supplierId = result.suppliers[0].id; .then((result) => {
this.authorized = result.suppliers[0].authorized; this.supplierId = result.suppliers[0].id;
}) this.authorized = result.suppliers[0].authorized;
.finally(() => { })
this.subscription.retrieveSubscriptionStatus(); .finally(() => {
}); this.subscription.retrieveSubscriptionStatus();
});
} }
@action @action

Datei anzeigen

@ -10,7 +10,7 @@ export default DiscourseRoute.extend({
controller.setProperties({ controller.setProperties({
subscribed: model.subscribed, subscribed: model.subscribed,
subscriptionType: model.subscription_type, subscriptionType: model.subscription_type,
subscriptionAttributes: model.subscription_attributes subscriptionAttributes: model.subscription_attributes,
}); });
}, },

Datei anzeigen

@ -1,4 +1,4 @@
import Service from '@ember/service'; import Service from "@ember/service";
import { getOwner } from "discourse-common/lib/get-owner"; import { getOwner } from "discourse-common/lib/get-owner";
import { tracked } from "@glimmer/tracking"; import { tracked } from "@glimmer/tracking";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
@ -12,21 +12,22 @@ const MANAGER_CATEGORY =
"https://discourse.pluginmanager.org/c/discourse-custom-wizard"; "https://discourse.pluginmanager.org/c/discourse-custom-wizard";
export default class SubscriptionService extends Service { export default class SubscriptionService extends Service {
@tracked subscribed = false; @tracked subscribed = false;
@tracked subscriptionType = ""; @tracked subscriptionType = "";
@tracked businessSubscription = false; @tracked businessSubscription = false;
@tracked communitySubscription = false; @tracked communitySubscription = false;
@tracked standardSubscription = false; @tracked standardSubscription = false;
@tracked subscriptionAttributes = {}; @tracked subscriptionAttributes = {};
subscriptionLandingUrl = PRODUCT_PAGE; subscriptionLandingUrl = PRODUCT_PAGE;
init() { init() {
super.init(...arguments); super.init(...arguments);
this.retrieveSubscriptionStatus(); this.retrieveSubscriptionStatus();
} }
retrieveSubscriptionStatus() { retrieveSubscriptionStatus() {
ajax("/admin/wizards/subscription").then(result => { ajax("/admin/wizards/subscription")
.then((result) => {
this.subscribed = result.subscribed; this.subscribed = result.subscribed;
this.subscriptionType = result.subscription_type; this.subscriptionType = result.subscription_type;
this.subscriptionAttributes = result.subscription_attributes; this.subscriptionAttributes = result.subscription_attributes;
@ -35,28 +36,28 @@ export default class SubscriptionService extends Service {
this.standardSubscription = equal(this.subscriptionType, "standard"); this.standardSubscription = equal(this.subscriptionType, "standard");
}) })
.catch(popupAjaxError); .catch(popupAjaxError);
}; }
get adminWizards() { get adminWizards() {
return getOwner(this).lookup("controller:admin-wizards"); return getOwner(this).lookup("controller:admin-wizards");
}; }
get subscriptionLink() { get subscriptionLink() {
return this.subscriptionLandingUrl; return this.subscriptionLandingUrl;
}; }
get subscriptionCtaLink() { get subscriptionCtaLink() {
switch (this.subscriptionType) { switch (this.subscriptionType) {
case "none": case "none":
return PRODUCT_PAGE; return PRODUCT_PAGE;
case "standard": case "standard":
return SUPPORT_MESSAGE; return SUPPORT_MESSAGE;
case "business": case "business":
return SUPPORT_MESSAGE; return SUPPORT_MESSAGE;
case "community": case "community":
return MANAGER_CATEGORY; return MANAGER_CATEGORY;
default: default:
return PRODUCT_PAGE; return PRODUCT_PAGE;
} }
}; }
} }