Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
convert subscription mixin to service, colocate glimmer files
Dieser Commit ist enthalten in:
Ursprung
4f8ab0b249
Commit
b454340263
14 geänderte Dateien mit 151 neuen und 152 gelöschten Zeilen
|
@ -15,7 +15,7 @@ import {
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { bind, later } from "@ember/runloop";
|
import { bind, later } from "@ember/runloop";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import Subscription from "../mixins/subscription";
|
import { inject as service } from "@ember/service";
|
||||||
|
|
||||||
const customFieldActionMap = {
|
const customFieldActionMap = {
|
||||||
topic: ["create_topic", "send_message"],
|
topic: ["create_topic", "send_message"],
|
||||||
|
@ -27,8 +27,9 @@ const customFieldActionMap = {
|
||||||
|
|
||||||
const values = ["present", "true", "false"];
|
const values = ["present", "true", "false"];
|
||||||
|
|
||||||
export default Component.extend(Subscription, {
|
export default Component.extend({
|
||||||
classNameBindings: [":mapper-selector", "activeType"],
|
classNameBindings: [":mapper-selector", "activeType"],
|
||||||
|
subscription: service(),
|
||||||
|
|
||||||
showText: computed("activeType", function () {
|
showText: computed("activeType", function () {
|
||||||
return this.showInput("text");
|
return this.showInput("text");
|
||||||
|
@ -130,7 +131,7 @@ export default Component.extend(Subscription, {
|
||||||
return this.connector === "is";
|
return this.connector === "is";
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@discourseComputed("site.groups", "guestGroup", "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) {
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
<a onclick={{this.click}} class="wizard-subscription-badge {{this.subscription.subscriptionType}}" title="{{this.title}}">
|
||||||
|
<svg
|
||||||
|
width="300px"
|
||||||
|
height="300px"
|
||||||
|
viewBox="0 0 300 300"
|
||||||
|
version="1.1"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
>
|
||||||
|
<g
|
||||||
|
id="pavilion-logo"
|
||||||
|
stroke="none"
|
||||||
|
stroke-width="1"
|
||||||
|
fill="none"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
id="Combined-Shape"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="35"
|
||||||
|
d="M41.1381822,291.00006 L40.5778853,130.009744 M258.850727,291.638415 L259.290397,130.37133 M36.0002279,140.721678 L139.995368,36.2122772 M263.350577,141.009083 L138.927245,16.2478517"
|
||||||
|
></path>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
<span>{{label}}</span>
|
||||||
|
</a>
|
29
assets/javascripts/discourse/components/wizard-subscription-badge.js
Normale Datei
29
assets/javascripts/discourse/components/wizard-subscription-badge.js
Normale Datei
|
@ -0,0 +1,29 @@
|
||||||
|
import { inject as service } from "@ember/service";
|
||||||
|
import { action, computed } from "@ember/object";
|
||||||
|
import Component from '@glimmer/component';
|
||||||
|
import DiscourseURL from "discourse/lib/url";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
|
export default class WizardSubscriptionBadge extends Component {
|
||||||
|
@service subscription;
|
||||||
|
|
||||||
|
@computed("subscription.subscriptionType")
|
||||||
|
get i18nKey() {
|
||||||
|
return `admin.wizard.subscription.type.${this.subscription.subscriptionType ? this.subscription.subscriptionType : "none"}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
@computed("i18nKey")
|
||||||
|
get title() {
|
||||||
|
return I18n.t(`${this.i18nKey}.title`);
|
||||||
|
};
|
||||||
|
|
||||||
|
@computed("i18nKey")
|
||||||
|
get label() {
|
||||||
|
return I18n.t(`${this.i18nKey}.label`);
|
||||||
|
};
|
||||||
|
|
||||||
|
@action
|
||||||
|
click() {
|
||||||
|
DiscourseURL.routeTo(this.subscription.subscriptionLink);
|
||||||
|
};
|
||||||
|
};
|
|
@ -1,30 +0,0 @@
|
||||||
import Component from "@ember/component";
|
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
|
||||||
import Subscription from "../mixins/subscription";
|
|
||||||
import DiscourseURL from "discourse/lib/url";
|
|
||||||
import I18n from "I18n";
|
|
||||||
|
|
||||||
export default Component.extend(Subscription, {
|
|
||||||
tagName: "a",
|
|
||||||
classNameBindings: [":wizard-subscription-badge", "subscriptionType"],
|
|
||||||
attributeBindings: ["title"],
|
|
||||||
|
|
||||||
@discourseComputed("subscriptionType")
|
|
||||||
i18nKey(type) {
|
|
||||||
return `admin.wizard.subscription.type.${type ? type : "none"}`;
|
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed("i18nKey")
|
|
||||||
title(i18nKey) {
|
|
||||||
return I18n.t(`${i18nKey}.title`);
|
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed("i18nKey")
|
|
||||||
label(i18nKey) {
|
|
||||||
return I18n.t(`${i18nKey}.label`);
|
|
||||||
},
|
|
||||||
|
|
||||||
click() {
|
|
||||||
DiscourseURL.routeTo(this.subscriptionLink);
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -1,23 +1,24 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import Subscription from "../mixins/subscription";
|
import { inject as service } from "@ember/service";
|
||||||
|
|
||||||
export default Component.extend(Subscription, {
|
export default Component.extend({
|
||||||
classNameBindings: [":wizard-subscription-container", "subscribed"],
|
classNameBindings: [":wizard-subscription-container", "subscribed"],
|
||||||
|
subscription: service(),
|
||||||
|
|
||||||
@discourseComputed("subscribed")
|
@discourseComputed("subscription.subscribed")
|
||||||
subscribedIcon(subscribed) {
|
subscribedIcon(subscribed) {
|
||||||
return subscribed ? "check" : "times";
|
return subscribed ? "check" : "times";
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("subscribed")
|
@discourseComputed("subscription.subscribed")
|
||||||
subscribedLabel(subscribed) {
|
subscribedLabel(subscribed) {
|
||||||
return `admin.wizard.subscription.${
|
return `admin.wizard.subscription.${
|
||||||
subscribed ? "subscribed" : "not_subscribed"
|
subscribed ? "subscribed" : "not_subscribed"
|
||||||
}.label`;
|
}.label`;
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("subscribed")
|
@discourseComputed("subscription.subscribed")
|
||||||
subscribedTitle(subscribed) {
|
subscribedTitle(subscribed) {
|
||||||
return `admin.wizard.subscription.${
|
return `admin.wizard.subscription.${
|
||||||
subscribed ? "subscribed" : "not_subscribed"
|
subscribed ? "subscribed" : "not_subscribed"
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<a onclick={{this.click}} class="btn btn-pavilion-support {{this.subscription.subscriptionType}}" title="{{this.title}}">
|
||||||
|
{{d-icon icon}}{{label}}
|
||||||
|
</a>
|
36
assets/javascripts/discourse/components/wizard-subscription-cta.js
Normale Datei
36
assets/javascripts/discourse/components/wizard-subscription-cta.js
Normale Datei
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
import { inject as service } from "@ember/service";
|
||||||
|
import { action, computed } from "@ember/object";
|
||||||
|
import I18n from "I18n";
|
||||||
|
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 I18n.t(`${this.i18nKey}.title`);
|
||||||
|
};
|
||||||
|
|
||||||
|
@computed("i18nKey")
|
||||||
|
get label() {
|
||||||
|
return I18n.t(`${this.i18nKey}.label`);
|
||||||
|
};
|
||||||
|
|
||||||
|
@action
|
||||||
|
click() {
|
||||||
|
window.open(this.subscription.subscriptionCtaLink, "_blank").focus();
|
||||||
|
};
|
||||||
|
};
|
|
@ -1,36 +0,0 @@
|
||||||
import Component from "@ember/component";
|
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
|
||||||
import Subscription from "../mixins/subscription";
|
|
||||||
import I18n from "I18n";
|
|
||||||
|
|
||||||
export default Component.extend(Subscription, {
|
|
||||||
tagName: "a",
|
|
||||||
classNameBindings: [":btn", ":btn-pavilion-support", "subscriptionType"],
|
|
||||||
attributeBindings: ["title"],
|
|
||||||
|
|
||||||
@discourseComputed("subscribed")
|
|
||||||
i18nKey(subscribed) {
|
|
||||||
return `admin.wizard.subscription.cta.${
|
|
||||||
subscribed ? "subscribed" : "none"
|
|
||||||
}`;
|
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed("subscribed")
|
|
||||||
icon(subscribed) {
|
|
||||||
return subscribed ? "far-life-ring" : "external-link-alt";
|
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed("i18nKey")
|
|
||||||
title(i18nKey) {
|
|
||||||
return I18n.t(`${i18nKey}.title`);
|
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed("i18nKey")
|
|
||||||
label(i18nKey) {
|
|
||||||
return I18n.t(`${i18nKey}.label`);
|
|
||||||
},
|
|
||||||
|
|
||||||
click() {
|
|
||||||
window.open(this.subscriptionCtaLink, "_blank").focus();
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -1,5 +1,5 @@
|
||||||
import SingleSelectComponent from "select-kit/components/single-select";
|
import SingleSelectComponent from "select-kit/components/single-select";
|
||||||
import Subscription from "../mixins/subscription";
|
import { inject as service } from "@ember/service";
|
||||||
import { filterValues } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
import { filterValues } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
@ -12,8 +12,9 @@ const nameKey = function (feature, attribute, value) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SingleSelectComponent.extend(Subscription, {
|
export default SingleSelectComponent.extend({
|
||||||
classNames: ["combo-box", "wizard-subscription-selector"],
|
classNames: ["combo-box", "wizard-subscription-selector"],
|
||||||
|
subscription: service(),
|
||||||
|
|
||||||
selectKitOptions: {
|
selectKitOptions: {
|
||||||
autoFilterable: false,
|
autoFilterable: false,
|
||||||
|
@ -26,13 +27,13 @@ export default SingleSelectComponent.extend(Subscription, {
|
||||||
},
|
},
|
||||||
|
|
||||||
allowedSubscriptionTypes(feature, attribute, value) {
|
allowedSubscriptionTypes(feature, attribute, value) {
|
||||||
let attributes = this.subscriptionAttributes[feature];
|
let attributes = this.subscription.subscriptionAttributes[feature];
|
||||||
if (!attributes || !attributes[attribute]) {
|
if (!attributes || !attributes[attribute]) {
|
||||||
return ["none"];
|
return ["none"];
|
||||||
}
|
}
|
||||||
let allowedTypes = [];
|
let allowedTypes = [];
|
||||||
Object.keys(attributes[attribute]).forEach((subscriptionType) => {
|
Object.keys(attributes[attribute]).forEach((subscriptionType) => {
|
||||||
let values = attributes[attribute][subscriptionType];
|
let values = attributes[attribute][subscription.subscriptionType];
|
||||||
if (values[0] === "*" || values.includes(value)) {
|
if (values[0] === "*" || values.includes(value)) {
|
||||||
allowedTypes.push(subscriptionType);
|
allowedTypes.push(subscriptionType);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +45,7 @@ export default SingleSelectComponent.extend(Subscription, {
|
||||||
content(feature, attribute) {
|
content(feature, attribute) {
|
||||||
return filterValues(this.wizard, feature, attribute)
|
return filterValues(this.wizard, feature, attribute)
|
||||||
.map((value) => {
|
.map((value) => {
|
||||||
let allowedSubscriptionTypes = this.allowedSubscriptionTypes(
|
let allowedSubscriptionTypes = this.subscription.allowedSubscriptionTypes(
|
||||||
feature,
|
feature,
|
||||||
attribute,
|
attribute,
|
||||||
value
|
value
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
import Mixin from "@ember/object/mixin";
|
|
||||||
import { getOwner } from "discourse-common/lib/get-owner";
|
|
||||||
import { readOnly } from "@ember/object/computed";
|
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
|
||||||
|
|
||||||
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";
|
|
||||||
|
|
||||||
export default Mixin.create({
|
|
||||||
subscriptionLandingUrl: PRODUCT_PAGE,
|
|
||||||
subscriptionClientUrl: "/admin/plugins/subscription-client",
|
|
||||||
|
|
||||||
@discourseComputed
|
|
||||||
adminWizards() {
|
|
||||||
return getOwner(this).lookup("controller:admin-wizards");
|
|
||||||
},
|
|
||||||
|
|
||||||
subscribed: readOnly("adminWizards.subscribed"),
|
|
||||||
subscriptionType: readOnly("adminWizards.subscriptionType"),
|
|
||||||
businessSubscription: readOnly("adminWizards.businessSubscription"),
|
|
||||||
communitySubscription: readOnly("adminWizards.communitySubscription"),
|
|
||||||
standardSubscription: readOnly("adminWizards.standardSubscription"),
|
|
||||||
subscriptionAttributes: readOnly("adminWizards.subscriptionAttributes"),
|
|
||||||
|
|
||||||
@discourseComputed
|
|
||||||
subscriptionLink() {
|
|
||||||
return this.subscriptionLandingUrl;
|
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed("subscriptionType")
|
|
||||||
subscriptionCtaLink(subscriptionType) {
|
|
||||||
switch (subscriptionType) {
|
|
||||||
case "none":
|
|
||||||
return PRODUCT_PAGE;
|
|
||||||
case "standard":
|
|
||||||
return SUPPORT_MESSAGE;
|
|
||||||
case "business":
|
|
||||||
return SUPPORT_MESSAGE;
|
|
||||||
case "community":
|
|
||||||
return MANAGER_CATEGORY;
|
|
||||||
default:
|
|
||||||
return PRODUCT_PAGE;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
41
assets/javascripts/discourse/services/subscription.js
Normale Datei
41
assets/javascripts/discourse/services/subscription.js
Normale Datei
|
@ -0,0 +1,41 @@
|
||||||
|
import Service from '@ember/service';
|
||||||
|
import { getOwner } from "discourse-common/lib/get-owner";
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
|
export default class Subscription extends Service {
|
||||||
|
subscriptionLandingUrl = PRODUCT_PAGE;
|
||||||
|
subscribed = this.adminWizards.subscribed;
|
||||||
|
subscriptionType = this.adminWizards.subscriptionType;
|
||||||
|
businessSubscription = this.adminWizards.businessSubscription;
|
||||||
|
communitySubscription = this.adminWizards.communitySubscription;
|
||||||
|
standardSubscription = this.adminWizards.standardSubscription;
|
||||||
|
subscriptionAttributes = this.adminWizards.subscriptionAttributes;
|
||||||
|
|
||||||
|
get adminWizards() {
|
||||||
|
return getOwner(this).lookup("controller:admin-wizards");
|
||||||
|
};
|
||||||
|
|
||||||
|
get subscriptionLink() {
|
||||||
|
return this.subscriptionLandingUrl;
|
||||||
|
};
|
||||||
|
|
||||||
|
get subscriptionCtaLink() {
|
||||||
|
switch (this.subscriptionType) {
|
||||||
|
case "none":
|
||||||
|
return PRODUCT_PAGE;
|
||||||
|
case "standard":
|
||||||
|
return SUPPORT_MESSAGE;
|
||||||
|
case "business":
|
||||||
|
return SUPPORT_MESSAGE;
|
||||||
|
case "community":
|
||||||
|
return MANAGER_CATEGORY;
|
||||||
|
default:
|
||||||
|
return PRODUCT_PAGE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,24 +0,0 @@
|
||||||
<svg
|
|
||||||
width="300px"
|
|
||||||
height="300px"
|
|
||||||
viewBox="0 0 300 300"
|
|
||||||
version="1.1"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
||||||
>
|
|
||||||
<g
|
|
||||||
id="pavilion-logo"
|
|
||||||
stroke="none"
|
|
||||||
stroke-width="1"
|
|
||||||
fill="none"
|
|
||||||
fill-rule="evenodd"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
id="Combined-Shape"
|
|
||||||
stroke="currentColor"
|
|
||||||
stroke-width="35"
|
|
||||||
d="M41.1381822,291.00006 L40.5778853,130.009744 M258.850727,291.638415 L259.290397,130.37133 M36.0002279,140.721678 L139.995368,36.2122772 M263.350577,141.009083 L138.927245,16.2478517"
|
|
||||||
></path>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
<span>{{label}}</span>
|
|
Vorher Breite: | Höhe: | Größe: 602 B |
|
@ -1 +0,0 @@
|
||||||
{{d-icon icon}}{{label}}
|
|
Laden …
In neuem Issue referenzieren