Commits vergleichen
66 Commits
main
...
use_subscr
Autor | SHA1 | Datum | |
---|---|---|---|
|
e120a1a426 | ||
|
fdfccf51e2 | ||
|
e17f90c5fd | ||
|
df9a3c6e6e | ||
|
4007fd9c65 | ||
|
c8263ed6aa | ||
|
13fb5dc1ea | ||
|
da2a56adc6 | ||
|
4422badf6a | ||
|
c0082b82b9 | ||
|
6aa68ebd5f | ||
|
1a32862fd1 | ||
|
c5d8003761 | ||
|
ea02e53882 | ||
|
80fcddc45f | ||
|
45db2270ec | ||
|
43ad5785e1 | ||
|
8407227f53 | ||
|
2c109c54f5 | ||
|
0ad8616239 | ||
|
6755c70d31 | ||
|
648b976ee0 | ||
|
1fdd78bc7e | ||
|
c89dbbb7a8 | ||
|
74a96af622 | ||
|
0399cff6a5 | ||
|
885fdd1215 | ||
|
18001bebc1 | ||
|
56181f65f4 | ||
|
15f596e8ec | ||
|
db7d9c14bc | ||
|
d5bd3c3c47 | ||
|
73e8b0a7fc | ||
|
5192e08893 | ||
|
9cc65d24b5 | ||
|
dd7f2a7e52 | ||
|
f97d15ac42 | ||
|
a8af37b334 | ||
|
7f245d6a59 | ||
|
e43fbd0b50 | ||
|
0b2e66ba0e | ||
|
390f53a8a2 | ||
|
ca11dacf8e | ||
|
f012dc2407 | ||
|
26e4267d23 | ||
|
6a1ead0322 | ||
|
eefbe0a1fc | ||
|
b1fddc33a7 | ||
|
a558e19a54 | ||
|
d6ca154668 | ||
|
b454340263 | ||
|
4f8ab0b249 | ||
|
4f887a858e | ||
|
2f206f60c7 | ||
|
051d1dbcfd | ||
|
437709446e | ||
|
baf533a8f4 | ||
|
76288932c8 | ||
|
b78914e4fd | ||
|
28f17045c5 | ||
|
07bed7ec86 | ||
|
bcd6f86fc8 | ||
|
f1e3db48a3 | ||
|
3a0ba4589d | ||
|
c2ffa7699b | ||
|
27cde861b6 |
71 geänderte Dateien mit 463 neuen und 307 gelöschten Zeilen
|
@ -2,16 +2,6 @@
|
|||
class CustomWizard::AdminController < ::Admin::AdminController
|
||||
before_action :ensure_admin
|
||||
|
||||
def index
|
||||
subcription = CustomWizard::Subscription.new
|
||||
render_json_dump(
|
||||
subscribed: subcription.subscribed?,
|
||||
subscription_type: subcription.type,
|
||||
subscription_attributes: CustomWizard::Subscription.attributes,
|
||||
subscription_client_installed: CustomWizard::Subscription.client_installed?
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_wizard
|
||||
|
|
13
app/controllers/custom_wizard/admin/subscription.rb
Normale Datei
13
app/controllers/custom_wizard/admin/subscription.rb
Normale Datei
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::SubscriptionController < ::Admin::AdminController
|
||||
before_action :ensure_admin
|
||||
|
||||
def index
|
||||
subscription = CustomWizard::Subscription.new
|
||||
render_json_dump(
|
||||
subscribed: subscription.subscribed?,
|
||||
subscription_type: subscription.type,
|
||||
subscription_attributes: CustomWizard::Subscription.attributes,
|
||||
)
|
||||
end
|
||||
end
|
|
@ -5,11 +5,13 @@ import I18n from "I18n";
|
|||
export default class AdminWizardsColumnComponent extends Component {
|
||||
title = I18n.t("admin.wizard.edit_columns");
|
||||
|
||||
@action save() {
|
||||
@action
|
||||
save() {
|
||||
this.args.closeModal();
|
||||
}
|
||||
|
||||
@action resetToDefault() {
|
||||
@action
|
||||
resetToDefault() {
|
||||
this.args.model.reset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,13 +18,15 @@ export default class NextSessionScheduledComponent extends Component {
|
|||
return moment().isAfter(this.bufferedDateTime);
|
||||
}
|
||||
|
||||
@action submit() {
|
||||
@action
|
||||
submit() {
|
||||
const dateTime = this.bufferedDateTime;
|
||||
this.args.model.update(moment(dateTime).utc().toISOString());
|
||||
this.args.closeModal();
|
||||
}
|
||||
|
||||
@action dateTimeChanged(dateTime) {
|
||||
@action
|
||||
dateTimeChanged(dateTime) {
|
||||
this.bufferedDateTime = dateTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
import Component from "@ember/component";
|
||||
import { bind, later } from "@ember/runloop";
|
||||
import I18n from "I18n";
|
||||
import Subscription from "../mixins/subscription";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
const customFieldActionMap = {
|
||||
topic: ["create_topic", "send_message"],
|
||||
|
@ -27,8 +27,9 @@ const customFieldActionMap = {
|
|||
|
||||
const values = ["present", "true", "false"];
|
||||
|
||||
export default Component.extend(Subscription, {
|
||||
export default Component.extend({
|
||||
classNameBindings: [":mapper-selector", "activeType"],
|
||||
subscription: service(),
|
||||
|
||||
showText: computed("activeType", function () {
|
||||
return this.showInput("text");
|
||||
|
@ -130,7 +131,11 @@ export default Component.extend(Subscription, {
|
|||
return this.connector === "is";
|
||||
}),
|
||||
|
||||
@discourseComputed("site.groups", "guestGroup", "subscriptionType")
|
||||
@discourseComputed(
|
||||
"site.groups",
|
||||
"guestGroup",
|
||||
"subscription.subscriptionType"
|
||||
)
|
||||
groups(groups, guestGroup, subscriptionType) {
|
||||
let result = groups;
|
||||
if (!guestGroup) {
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<DButton
|
||||
@action={{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>{{this.label}}</span>
|
||||
</DButton>
|
33
assets/javascripts/discourse/components/wizard-subscription-badge.js
Normale Datei
33
assets/javascripts/discourse/components/wizard-subscription-badge.js
Normale Datei
|
@ -0,0 +1,33 @@
|
|||
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 `${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);
|
||||
},
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
<div
|
||||
class="wizard-subscription-container
|
||||
{{if this.subscription.subscribed 'subscribed'}}"
|
||||
>
|
||||
<div class="subscription-header">
|
||||
<h4>{{i18n "admin.wizard.subscription.title"}}</h4>
|
||||
|
||||
<a href={{subscriptionLink}} title={{i18n subscribedTitle}}>
|
||||
{{d-icon subscribedIcon}}
|
||||
{{i18n subscribedLabel}}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="subscription-settings">
|
||||
{{yield}}
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,26 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { computed } from "@ember/object";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
export default class WizardSubscriptionContainer extends Component {
|
||||
@service subscription;
|
||||
|
||||
@computed("subscription.subscribed")
|
||||
get subscribedIcon() {
|
||||
return this.subscription.subscribed ? "check" : "times";
|
||||
}
|
||||
|
||||
@computed("subscription.subscribed")
|
||||
get subscribedLabel() {
|
||||
return `admin.wizard.subscription.${
|
||||
this.subscription.subscribed ? "subscribed" : "not_subscribed"
|
||||
}.label`;
|
||||
}
|
||||
|
||||
@computed("subscription.subscribed")
|
||||
get subscribedTitle() {
|
||||
return `admin.wizard.subscription.${
|
||||
this.subscription.subscribed ? "subscribed" : "not_subscribed"
|
||||
}.title`;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import Component from "@ember/component";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import Subscription from "../mixins/subscription";
|
||||
|
||||
export default Component.extend(Subscription, {
|
||||
classNameBindings: [":wizard-subscription-container", "subscribed"],
|
||||
|
||||
@discourseComputed("subscribed")
|
||||
subscribedIcon(subscribed) {
|
||||
return subscribed ? "check" : "times";
|
||||
},
|
||||
|
||||
@discourseComputed("subscribed")
|
||||
subscribedLabel(subscribed) {
|
||||
return `admin.wizard.subscription.${
|
||||
subscribed ? "subscribed" : "not_subscribed"
|
||||
}.label`;
|
||||
},
|
||||
|
||||
@discourseComputed("subscribed")
|
||||
subscribedTitle(subscribed) {
|
||||
return `admin.wizard.subscription.${
|
||||
subscribed ? "subscribed" : "not_subscribed"
|
||||
}.title`;
|
||||
},
|
||||
});
|
|
@ -0,0 +1,7 @@
|
|||
<DButton
|
||||
@action={{this.click}}
|
||||
class="btn btn-pavilion-support {{this.subscription.subscriptionType}}"
|
||||
@title={{this.title}}
|
||||
@label={{this.label}}
|
||||
@icon={{this.icon}}
|
||||
/>
|
34
assets/javascripts/discourse/components/wizard-subscription-cta.js
Normale Datei
34
assets/javascripts/discourse/components/wizard-subscription-cta.js
Normale Datei
|
@ -0,0 +1,34 @@
|
|||
import { inject as service } from "@ember/service";
|
||||
import { action, computed } from "@ember/object";
|
||||
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 `${this.i18nKey}.title`;
|
||||
}
|
||||
|
||||
@computed("i18nKey")
|
||||
get label() {
|
||||
return `${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 Subscription from "../mixins/subscription";
|
||||
import { inject as service } from "@ember/service";
|
||||
import { filterValues } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
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"],
|
||||
subscription: service(),
|
||||
|
||||
selectKitOptions: {
|
||||
autoFilterable: false,
|
||||
|
@ -26,7 +27,7 @@ export default SingleSelectComponent.extend(Subscription, {
|
|||
},
|
||||
|
||||
allowedSubscriptionTypes(feature, attribute, value) {
|
||||
let attributes = this.subscriptionAttributes[feature];
|
||||
let attributes = this.subscription.subscriptionAttributes[feature];
|
||||
if (!attributes || !attributes[attribute]) {
|
||||
return ["none"];
|
||||
}
|
||||
|
@ -59,10 +60,9 @@ export default SingleSelectComponent.extend(Subscription, {
|
|||
name: I18n.t(nameKey(feature, attribute, value)),
|
||||
subscriptionRequired,
|
||||
};
|
||||
|
||||
if (subscriptionRequired) {
|
||||
let subscribed = allowedSubscriptionTypes.includes(
|
||||
this.subscriptionType
|
||||
this.subscription.subscriptionType
|
||||
);
|
||||
let selectorKey = subscribed ? "subscribed" : "not_subscribed";
|
||||
let selectorLabel = `admin.wizard.subscription.${selectorKey}.selector`;
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<div class="supplier-authorize">
|
||||
{{#if authorized}}
|
||||
{{conditional-loading-spinner size="small" condition=unauthorizing}}
|
||||
<DButton
|
||||
class="deauthorize"
|
||||
@title=admin.wizard.subscription.deauthorize.title
|
||||
@disabled={{unauthorizing}}
|
||||
@action={{this.deauthorize}}
|
||||
>
|
||||
{{i18n "admin.wizard.subscription.deauthorize.label"}}
|
||||
</DButton>
|
||||
{{else}}
|
||||
<DButton
|
||||
@icon="id-card"
|
||||
class="btn-primary"
|
||||
@label=admin.wizard.subscription.authorize.label
|
||||
@title=admin.wizard.subscription.authorize.title
|
||||
@action={{this.authorize}}
|
||||
/>
|
||||
{{/if}}
|
||||
<WizardSubscriptionBadge />
|
||||
<WizardSubscriptionCta />
|
||||
</div>
|
|
@ -0,0 +1,54 @@
|
|||
import { action } from "@ember/object";
|
||||
import { inject as service } from "@ember/service";
|
||||
import Component from "@glimmer/component";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
|
||||
export default class WizardSubscriptionStatus extends Component {
|
||||
@service siteSettings;
|
||||
@service subscription;
|
||||
@tracked supplierId = null;
|
||||
@tracked authorized = false;
|
||||
@tracked unauthorizing = false;
|
||||
basePath = "/admin/plugins/subscription-client/suppliers";
|
||||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
ajax(`${this.basePath}`)
|
||||
.then((result) => {
|
||||
this.supplierId = result.suppliers[0].id;
|
||||
this.authorized = result.suppliers[0].authorized;
|
||||
})
|
||||
.finally(() => {
|
||||
this.subscription.retrieveSubscriptionStatus();
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
authorize() {
|
||||
window.location.href = `${this.basePath}/authorize?supplier_id=${this.supplierId}&final_landing_path=/admin/wizards/wizard`;
|
||||
}
|
||||
|
||||
@action
|
||||
deauthorize() {
|
||||
this.unauthorizing = true;
|
||||
|
||||
ajax(`${this.basePath}/authorize`, {
|
||||
type: "DELETE",
|
||||
data: {
|
||||
supplier_id: this.supplierId,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
this.supplierId = result.supplier.id;
|
||||
this.authorized = !(result.supplier.authorized_at === null);
|
||||
})
|
||||
.finally(() => {
|
||||
this.unauthorizing = false;
|
||||
this.subscription.retrieveSubscriptionStatus();
|
||||
//window.location.reload();
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
import Controller from "@ember/controller";
|
||||
import { equal, or } from "@ember/object/computed";
|
||||
import { or } from "@ember/object/computed";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
export default Controller.extend({
|
||||
businessSubscription: equal("subscriptionType", "business"),
|
||||
communitySubscription: equal("subscriptionType", "community"),
|
||||
standardSubscription: equal("subscriptionType", "standard"),
|
||||
showApi: or("businessSubscription", "communitySubscription"),
|
||||
subscription: service(),
|
||||
|
||||
showApi: or(
|
||||
"subscription.businessSubscription",
|
||||
"subscription.communitySubscription"
|
||||
),
|
||||
});
|
||||
|
|
|
@ -1,53 +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"),
|
||||
subscriptionClientInstalled: readOnly(
|
||||
"adminWizards.subscriptionClientInstalled"
|
||||
),
|
||||
|
||||
@discourseComputed("subscriptionClientInstalled")
|
||||
subscriptionLink(subscriptionClientInstalled) {
|
||||
return subscriptionClientInstalled
|
||||
? this.subscriptionClientUrl
|
||||
: 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;
|
||||
}
|
||||
},
|
||||
});
|
|
@ -1,23 +1,9 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
router: service(),
|
||||
|
||||
model() {
|
||||
return ajax("/admin/wizards");
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.setProperties({
|
||||
subscribed: model.subscribed,
|
||||
subscriptionType: model.subscription_type,
|
||||
subscriptionAttributes: model.subscription_attributes,
|
||||
subscriptionClientInstalled: model.subscription_client_installed,
|
||||
});
|
||||
},
|
||||
|
||||
afterModel(model, transition) {
|
||||
if (transition.targetName === "adminWizards.index") {
|
||||
this.router.transitionTo("adminWizardsWizard");
|
||||
|
|
57
assets/javascripts/discourse/services/subscription.js
Normale Datei
57
assets/javascripts/discourse/services/subscription.js
Normale Datei
|
@ -0,0 +1,57 @@
|
|||
import Service from "@ember/service";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
|
||||
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 SubscriptionService extends Service {
|
||||
@tracked subscribed = false;
|
||||
@tracked subscriptionType = "";
|
||||
@tracked businessSubscription = false;
|
||||
@tracked communitySubscription = false;
|
||||
@tracked standardSubscription = false;
|
||||
@tracked subscriptionAttributes = {};
|
||||
subscriptionLandingUrl = PRODUCT_PAGE;
|
||||
|
||||
init() {
|
||||
super.init(...arguments);
|
||||
this.retrieveSubscriptionStatus();
|
||||
}
|
||||
|
||||
retrieveSubscriptionStatus() {
|
||||
ajax("/admin/wizards/subscription")
|
||||
.then((result) => {
|
||||
this.subscribed = result.subscribed;
|
||||
this.subscriptionType = result.subscription_type;
|
||||
this.subscriptionAttributes = result.subscription_attributes;
|
||||
this.businessSubscription = this.subscriptionType === "business";
|
||||
this.communitySubscription = this.subscriptionType === "community";
|
||||
this.standardSubscription = this.subscriptionType === "standard";
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,8 +18,7 @@
|
|||
}}
|
||||
|
||||
<div class="admin-actions">
|
||||
{{wizard-subscription-badge}}
|
||||
{{wizard-subscription-cta}}
|
||||
<WizardSubscriptionStatus />
|
||||
</div>
|
||||
{{/admin-nav}}
|
||||
|
||||
|
|
|
@ -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,12 +0,0 @@
|
|||
<div class="subscription-header">
|
||||
<h4>{{i18n "admin.wizard.subscription.title"}}</h4>
|
||||
|
||||
<a href={{subscriptionLink}} title={{i18n subscribedTitle}}>
|
||||
{{d-icon subscribedIcon}}
|
||||
{{i18n subscribedLabel}}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="subscription-settings">
|
||||
{{yield}}
|
||||
</div>
|
|
@ -1 +0,0 @@
|
|||
{{d-icon icon}}{{label}}
|
|
@ -49,6 +49,10 @@ $error: #ef1700;
|
|||
.btn-pavilion-support {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.supplier-authorize .btn-primary {
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.wizard-message {
|
||||
|
|
|
@ -545,6 +545,12 @@ en:
|
|||
|
||||
subscription:
|
||||
title: Subscriber Features
|
||||
authorize:
|
||||
label: Authorize
|
||||
title: Authorize your subscription on this site
|
||||
deauthorize:
|
||||
label: deauthorize
|
||||
title: Deauthorize your subscription on this site
|
||||
subscribed:
|
||||
label: Subscribed
|
||||
title: You're subscribed and can use these features
|
||||
|
|
|
@ -14,6 +14,7 @@ Discourse::Application.routes.append do
|
|||
|
||||
scope module: 'custom_wizard', constraints: AdminConstraint.new do
|
||||
get 'admin/wizards' => 'admin#index'
|
||||
get 'admin/wizards/subscription' => 'subscription#index'
|
||||
|
||||
get 'admin/wizards/wizard' => 'admin_wizard#index'
|
||||
get 'admin/wizards/wizard/create' => 'admin#index'
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
require "discourse_subscription_client"
|
||||
|
||||
class CustomWizard::Subscription
|
||||
PRODUCT_HIERARCHY = %w[
|
||||
community
|
||||
|
@ -105,8 +107,7 @@ class CustomWizard::Subscription
|
|||
:product_slug
|
||||
|
||||
def initialize
|
||||
if CustomWizard::Subscription.client_installed?
|
||||
result = DiscourseSubscriptionClient.find_subscriptions("discourse-custom-wizard")
|
||||
result = ::DiscourseSubscriptionClient.find_subscriptions("discourse-custom-wizard")
|
||||
|
||||
if result&.any?
|
||||
ids_and_slugs = result.subscriptions.map do |subscription|
|
||||
|
@ -123,7 +124,6 @@ class CustomWizard::Subscription
|
|||
@product_id = id_and_slug[:id]
|
||||
@product_slug = id_and_slug[:slug]
|
||||
end
|
||||
end
|
||||
|
||||
@product_slug ||= ENV["CUSTOM_WIZARD_PRODUCT_SLUG"]
|
||||
end
|
||||
|
@ -157,7 +157,7 @@ class CustomWizard::Subscription
|
|||
return :none unless subscribed?
|
||||
return :business if business?
|
||||
return :standard if standard?
|
||||
return :community if community?
|
||||
:community if community?
|
||||
end
|
||||
|
||||
def subscribed?
|
||||
|
@ -176,10 +176,6 @@ class CustomWizard::Subscription
|
|||
product_slug === "community"
|
||||
end
|
||||
|
||||
def self.client_installed?
|
||||
defined?(DiscourseSubscriptionClient) == 'constant' && DiscourseSubscriptionClient.class == Module
|
||||
end
|
||||
|
||||
def self.subscribed?
|
||||
new.subscribed?
|
||||
end
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
# name: discourse-custom-wizard
|
||||
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
|
||||
# version: 2.4.23
|
||||
# version: 2.4.24
|
||||
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos
|
||||
# url: https://github.com/paviliondev/discourse-custom-wizard
|
||||
# contact_emails: development@pavilion.tech
|
||||
# subscription_url: https://coop.pavilion.tech
|
||||
|
||||
gem 'liquid', '5.0.1', require: true
|
||||
gem "discourse_subscription_client", "0.1.0.pre15", require_name: "discourse_subscription_client"
|
||||
|
||||
register_asset 'stylesheets/common/admin.scss'
|
||||
register_asset 'stylesheets/common/wizard.scss'
|
||||
|
||||
|
@ -35,6 +37,7 @@ after_initialize do
|
|||
../lib/custom_wizard/engine.rb
|
||||
../config/routes.rb
|
||||
../app/controllers/custom_wizard/admin/admin.rb
|
||||
../app/controllers/custom_wizard/admin/subscription.rb
|
||||
../app/controllers/custom_wizard/admin/wizard.rb
|
||||
../app/controllers/custom_wizard/admin/submissions.rb
|
||||
../app/controllers/custom_wizard/admin/api.rb
|
||||
|
|
|
@ -42,6 +42,7 @@ describe CustomWizard::Action do
|
|||
}
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
Group.refresh_automatic_group!(:trust_level_2)
|
||||
update_template(wizard_template)
|
||||
end
|
||||
|
|
|
@ -29,6 +29,7 @@ describe CustomWizard::Builder do
|
|||
}
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
Group.refresh_automatic_group!(:trust_level_3)
|
||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
||||
|
|
|
@ -5,6 +5,7 @@ describe CustomWizard::CustomField do
|
|||
let(:custom_field_subscription_json) { get_wizard_fixture("custom_field/subscription_custom_fields") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::CustomField.invalidate_cache
|
||||
end
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ describe CustomWizard::Submission do
|
|||
let(:guest_id) { CustomWizard::Wizard.generate_guest_id }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Template.save(template_json, skip_jobs: true)
|
||||
@wizard = CustomWizard::Wizard.create(template_json["id"], user)
|
||||
described_class.new(@wizard, step_1_field_1: "I am user submission").save
|
||||
|
|
|
@ -13,41 +13,9 @@ describe CustomWizard::Subscription do
|
|||
}
|
||||
}
|
||||
|
||||
after do
|
||||
undefine_client_classes
|
||||
end
|
||||
|
||||
it "detects the subscription client" do
|
||||
undefine_client_classes
|
||||
expect(described_class.client_installed?).to eq(false)
|
||||
end
|
||||
|
||||
context "without a subscription client" do
|
||||
it "is not subscribed" do
|
||||
expect(described_class.subscribed?).to eq(false)
|
||||
end
|
||||
|
||||
it "has none type" do
|
||||
subscription = described_class.new
|
||||
expect(subscription.type).to eq(:none)
|
||||
end
|
||||
|
||||
it "non subscriber features are included" do
|
||||
expect(described_class.includes?(:wizard, :after_signup, true)).to eq(true)
|
||||
end
|
||||
|
||||
it "subscriber features are not included" do
|
||||
expect(described_class.includes?(:wizard, :permitted, {})).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "with subscription client" do
|
||||
context "with subscription client gem mocked out" do
|
||||
before do
|
||||
define_client_classes
|
||||
end
|
||||
|
||||
it "detects the subscription client" do
|
||||
expect(described_class.client_installed?).to eq(true)
|
||||
stub_out_subscription_classes
|
||||
end
|
||||
|
||||
context "without a subscription" do
|
||||
|
@ -69,11 +37,12 @@ describe CustomWizard::Subscription do
|
|||
end
|
||||
|
||||
context "with subscriptions" do
|
||||
|
||||
def get_subscription_result(product_ids)
|
||||
result = DiscourseSubscriptionClient::Subscriptions::Result.new
|
||||
result.supplier = SubscriptionClientSupplier.new(product_slugs)
|
||||
result.resource = SubscriptionClientResource.new
|
||||
result.subscriptions = product_ids.map { |product_id| SubscriptionClientSubscription.new(product_id) }
|
||||
result.subscriptions = product_ids.map { |product_id| ::SubscriptionClientSubscription.new(product_id) }
|
||||
result.products = product_slugs
|
||||
result
|
||||
end
|
||||
|
|
|
@ -7,6 +7,7 @@ describe CustomWizard::Template do
|
|||
fab!(:upload) { Fabricate(:upload) }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Template.save(template_json, skip_jobs: true)
|
||||
end
|
||||
|
||||
|
|
|
@ -39,6 +39,10 @@ describe CustomWizard::TemplateValidator do
|
|||
expect(validator.errors.first.message).to eq("Liquid syntax error in #{object_id}: #{message}")
|
||||
end
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
end
|
||||
|
||||
it "validates valid templates" do
|
||||
expect(
|
||||
CustomWizard::TemplateValidator.new(template).perform
|
||||
|
|
|
@ -6,6 +6,7 @@ describe CustomWizard::UpdateValidator do
|
|||
let(:url_field) { get_wizard_fixture("field/url") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Template.save(template, skip_jobs: true)
|
||||
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
||||
end
|
||||
|
|
|
@ -10,6 +10,7 @@ describe CustomWizard::Wizard do
|
|||
let(:step_json) { get_wizard_fixture("step/step") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
Group.refresh_automatic_group!(:trust_level_3)
|
||||
@permitted_template = template_json.dup
|
||||
@permitted_template["permitted"] = permitted_json["permitted"]
|
||||
|
|
|
@ -11,6 +11,7 @@ describe "custom field extensions" do
|
|||
let(:subscription_custom_field_json) { get_wizard_fixture("custom_field/subscription_custom_fields") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
custom_field_json['custom_fields'].each do |field_json|
|
||||
custom_field = CustomWizard::CustomField.new(nil, field_json)
|
||||
custom_field.save
|
||||
|
|
|
@ -7,6 +7,7 @@ describe ExtraLocalesControllerCustomWizard, type: :request do
|
|||
let(:permitted) { get_wizard_fixture("wizard/permitted") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Template.save(template, skip_jobs: true)
|
||||
end
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ describe ::Guardian do
|
|||
end
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@ describe InvitesControllerCustomWizard, type: :request do
|
|||
let(:template) { get_wizard_fixture("wizard") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
@controller = InvitesController.new
|
||||
end
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ describe CustomWizardUsersController, type: :request do
|
|||
let(:template) { get_wizard_fixture("wizard") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
@controller = UsersController.new
|
||||
end
|
||||
|
||||
|
|
6
spec/fixtures/subscription_client.rb
gevendort
6
spec/fixtures/subscription_client.rb
gevendort
|
@ -5,7 +5,7 @@ module DiscourseSubscriptionClient
|
|||
end
|
||||
end
|
||||
|
||||
class SubscriptionClientSupplier
|
||||
SubscriptionClientSupplier = Class.new Object do
|
||||
attr_reader :product_slugs
|
||||
|
||||
def initialize(product_slugs)
|
||||
|
@ -13,10 +13,10 @@ class SubscriptionClientSupplier
|
|||
end
|
||||
end
|
||||
|
||||
class SubscriptionClientResource
|
||||
SubscriptionClientResource = Class.new Object do
|
||||
end
|
||||
|
||||
class SubscriptionClientSubscription
|
||||
SubscriptionClientSubscription = Class.new Object do
|
||||
attr_reader :product_id
|
||||
|
||||
def initialize(product_id)
|
||||
|
|
|
@ -9,11 +9,13 @@ def get_wizard_fixture(path)
|
|||
end
|
||||
|
||||
def enable_subscription(type)
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Subscription.stubs("#{type}?".to_sym).returns(true)
|
||||
CustomWizard::Subscription.any_instance.stubs("#{type}?".to_sym).returns(true)
|
||||
end
|
||||
|
||||
def disable_subscriptions
|
||||
stub_out_subscription_classes
|
||||
%w[
|
||||
standard
|
||||
business
|
||||
|
@ -24,11 +26,11 @@ def disable_subscriptions
|
|||
end
|
||||
end
|
||||
|
||||
def undefine_client_classes
|
||||
def unstub_out_subscription_classes
|
||||
Object.send(:remove_const, :DiscourseSubscriptionClient) if Object.constants.include?(:DiscourseSubscriptionClient)
|
||||
Object.send(:remove_const, :SubscriptionClientSubscription) if Object.constants.include?(:SubscriptionClientSubscription)
|
||||
end
|
||||
|
||||
def define_client_classes
|
||||
def stub_out_subscription_classes
|
||||
load File.expand_path("#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/subscription_client.rb", __FILE__)
|
||||
end
|
||||
|
|
|
@ -5,6 +5,7 @@ describe CustomWizard::AdminApiController do
|
|||
let(:api_json) { get_wizard_fixture("api/api") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
sign_in(admin_user)
|
||||
end
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ describe CustomWizard::AdminCustomFieldsController do
|
|||
let(:custom_field_json) { get_wizard_fixture("custom_field/custom_fields") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
custom_field_json['custom_fields'].each do |field_json|
|
||||
CustomWizard::CustomField.new(nil, field_json).save
|
||||
end
|
||||
|
|
|
@ -5,6 +5,7 @@ describe CustomWizard::AdminLogsController do
|
|||
let(:template) { get_wizard_fixture("wizard") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
["first", "second", "third"].each_with_index do |key, index|
|
||||
temp = template.dup
|
||||
temp["id"] = "#{key}_test_wizard"
|
||||
|
|
|
@ -5,6 +5,7 @@ describe CustomWizard::AdminManagerController do
|
|||
let(:template) { get_wizard_fixture("wizard") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
sign_in(admin_user)
|
||||
|
||||
template_2 = template.dup
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
describe CustomWizard::AdminController do
|
||||
describe CustomWizard::SubscriptionController do
|
||||
fab!(:admin_user) { Fabricate(:user, admin: true) }
|
||||
|
||||
it "requires an admin" do
|
||||
|
@ -16,28 +16,26 @@ describe CustomWizard::AdminController do
|
|||
context "without a subscription" do
|
||||
before do
|
||||
disable_subscriptions
|
||||
define_client_classes
|
||||
stub_out_subscription_classes
|
||||
end
|
||||
|
||||
it "returns the right subscription details" do
|
||||
get "/admin/wizards.json"
|
||||
get "/admin/wizards/subscription.json"
|
||||
expect(response.parsed_body["subscribed"]).to eq(false)
|
||||
expect(response.parsed_body["subscription_attributes"]).to eq(CustomWizard::Subscription.attributes.as_json)
|
||||
expect(response.parsed_body["subscription_client_installed"]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context "with a subscription" do
|
||||
before do
|
||||
enable_subscription("standard")
|
||||
define_client_classes
|
||||
stub_out_subscription_classes
|
||||
end
|
||||
|
||||
it "returns the right subscription details" do
|
||||
get "/admin/wizards.json"
|
||||
get "/admin/wizards/subscription.json"
|
||||
expect(response.parsed_body["subscribed"]).to eq(true)
|
||||
expect(response.parsed_body["subscription_type"]).to eq("standard")
|
||||
expect(response.parsed_body["subscription_client_installed"]).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,9 +8,8 @@ describe CustomWizard::AdminWizardController do
|
|||
let(:category) { Fabricate(:category, custom_fields: { create_topic_wizard: template['name'].parameterize(separator: "_") }) }
|
||||
|
||||
before do
|
||||
CustomWizard::Template.save(template, skip_jobs: true)
|
||||
enable_subscription("standard")
|
||||
|
||||
CustomWizard::Template.save(template, skip_jobs: true)
|
||||
template_2 = template.dup
|
||||
template_2["id"] = 'super_mega_fun_wizard_2'
|
||||
template_2["permitted"] = template_2['permitted']
|
||||
|
|
|
@ -5,6 +5,7 @@ describe ApplicationController do
|
|||
let(:wizard_template) { get_wizard_fixture("wizard") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
||||
end
|
||||
|
|
|
@ -10,6 +10,7 @@ describe "custom field extensions" do
|
|||
let(:subscription_custom_field_json) { get_wizard_fixture("custom_field/subscription_custom_fields") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
custom_field_json['custom_fields'].each do |field_json|
|
||||
custom_field = CustomWizard::CustomField.new(nil, field_json)
|
||||
custom_field.save
|
||||
|
|
|
@ -11,6 +11,7 @@ describe CustomWizard::StepsController do
|
|||
let(:guests_permitted) { get_wizard_fixture("wizard/guests_permitted") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ describe CustomWizard::WizardController do
|
|||
let(:permitted_json) { get_wizard_fixture("wizard/permitted") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||
@template = CustomWizard::Template.find("super_mega_fun_wizard")
|
||||
end
|
||||
|
|
|
@ -4,6 +4,10 @@ describe CustomWizard::BasicWizardSerializer do
|
|||
fab!(:user) { Fabricate(:user) }
|
||||
let(:template) { get_wizard_fixture("wizard") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
end
|
||||
|
||||
it 'should return basic wizard attributes' do
|
||||
CustomWizard::Template.save(template, skip_jobs: true)
|
||||
json = CustomWizard::BasicWizardSerializer.new(
|
||||
|
|
|
@ -4,6 +4,10 @@ describe CustomWizard::CustomFieldSerializer do
|
|||
fab!(:user) { Fabricate(:user) }
|
||||
let(:custom_field_json) { get_wizard_fixture("custom_field/custom_fields") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
end
|
||||
|
||||
it 'should return custom field attributes' do
|
||||
custom_field_json['custom_fields'].each do |field_json|
|
||||
CustomWizard::CustomField.new(nil, field_json).save
|
||||
|
|
|
@ -13,6 +13,7 @@ describe CustomWizard::SubmissionSerializer do
|
|||
}
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Template.save(template_json, skip_jobs: true)
|
||||
|
||||
wizard = CustomWizard::Wizard.create(template_json["id"], user1)
|
||||
|
|
|
@ -5,6 +5,7 @@ describe CustomWizard::FieldSerializer do
|
|||
let(:template) { get_wizard_fixture("wizard") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Template.save(template, skip_jobs: true)
|
||||
@wizard = CustomWizard::Builder.new("super_mega_fun_wizard", user).build
|
||||
end
|
||||
|
|
|
@ -8,6 +8,7 @@ describe CustomWizard::WizardSerializer do
|
|||
let(:advanced_fields) { get_wizard_fixture("field/advanced_types") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Template.save(template, skip_jobs: true)
|
||||
@template = CustomWizard::Template.find('super_mega_fun_wizard')
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@ describe CustomWizard::StepSerializer do
|
|||
let(:required_data_json) { get_wizard_fixture("step/required_data") }
|
||||
|
||||
before do
|
||||
stub_out_subscription_classes
|
||||
CustomWizard::Template.save(wizard_template, skip_jobs: true)
|
||||
@wizard = CustomWizard::Builder.new("super_mega_fun_wizard", user).build
|
||||
end
|
||||
|
|
|
@ -8,6 +8,7 @@ import { click, fillIn, findAll, visit, waitUntil } from "@ember/test-helpers";
|
|||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import {
|
||||
getCustomFields,
|
||||
getSuppliers,
|
||||
getUnsubscribedAdminWizards,
|
||||
getWizard,
|
||||
} from "../helpers/admin-wizard";
|
||||
|
@ -24,7 +25,7 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) {
|
|||
server.get("/admin/wizards/wizard", () => {
|
||||
return helper.response(getWizard);
|
||||
});
|
||||
server.get("/admin/wizards", () => {
|
||||
server.get("/admin/wizards/subscription", () => {
|
||||
return helper.response(getUnsubscribedAdminWizards);
|
||||
});
|
||||
server.get("/admin/wizards/custom-fields", () => {
|
||||
|
@ -36,6 +37,9 @@ acceptance("Admin | Custom Fields Unsubscribed", function (needs) {
|
|||
server.delete("/admin/wizards/custom-fields/topic_custom_field", () => {
|
||||
return helper.response({ success: "OK" });
|
||||
});
|
||||
server.get("/admin/plugins/subscription-client/suppliers", () => {
|
||||
return helper.response(getSuppliers);
|
||||
});
|
||||
});
|
||||
|
||||
async function selectTypeAndSerializerAndFillInName(
|
||||
|
|
|
@ -3,6 +3,7 @@ import { test } from "qunit";
|
|||
import { click, findAll, visit } from "@ember/test-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import {
|
||||
getSuppliers,
|
||||
getUnsubscribedAdminWizards,
|
||||
getWizard,
|
||||
getWizardTestingLog,
|
||||
|
@ -23,12 +24,15 @@ acceptance("Admin | Logs", function (needs) {
|
|||
server.get("/admin/wizards/logs/this_is_testing_wizard", () => {
|
||||
return helper.response(getWizardTestingLog);
|
||||
});
|
||||
server.get("/admin/wizards", () => {
|
||||
server.get("/admin/wizards/subscription", () => {
|
||||
return helper.response(getUnsubscribedAdminWizards);
|
||||
});
|
||||
server.get("/admin/wizards/wizard", () => {
|
||||
return helper.response(getWizard);
|
||||
});
|
||||
server.get("/admin/plugins/subscription-client/suppliers", () => {
|
||||
return helper.response(getSuppliers);
|
||||
});
|
||||
});
|
||||
test("viewing logs fields tab", async (assert) => {
|
||||
await visit("/admin/wizards/logs");
|
||||
|
|
|
@ -2,6 +2,7 @@ import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
|||
import { test } from "qunit";
|
||||
import { click, find, findAll, visit, waitUntil } from "@ember/test-helpers";
|
||||
import {
|
||||
getSuppliers,
|
||||
getUnsubscribedAdminWizards,
|
||||
getWizard,
|
||||
getWizardTestingLog,
|
||||
|
@ -18,7 +19,7 @@ acceptance("Admin | Manager", function (needs) {
|
|||
server.get("/admin/wizards/manager/this_is_testing_wizard", () => {
|
||||
return helper.response(getWizardTestingLog);
|
||||
});
|
||||
server.get("/admin/wizards", () => {
|
||||
server.get("/admin/wizards/subscription", () => {
|
||||
return helper.response(getUnsubscribedAdminWizards);
|
||||
});
|
||||
server.get("/admin/wizards/wizard", () => {
|
||||
|
@ -33,6 +34,9 @@ acceptance("Admin | Manager", function (needs) {
|
|||
failures: [],
|
||||
});
|
||||
});
|
||||
server.get("/admin/plugins/subscription-client/suppliers", () => {
|
||||
return helper.response(getSuppliers);
|
||||
});
|
||||
});
|
||||
async function waitForDestructionAndResetMessage() {
|
||||
await waitUntil(
|
||||
|
|
|
@ -4,6 +4,7 @@ import { click, findAll, visit } from "@ember/test-helpers";
|
|||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import {
|
||||
getAnotherWizardSubmission,
|
||||
getSuppliers,
|
||||
getUnsubscribedAdminWizards,
|
||||
getWizard,
|
||||
getWizardSubmissions,
|
||||
|
@ -28,12 +29,15 @@ acceptance("Admin | Submissions", function (needs) {
|
|||
server.get("/admin/wizards/submissions/another_wizard", () => {
|
||||
return helper.response(getAnotherWizardSubmission);
|
||||
});
|
||||
server.get("/admin/wizards", () => {
|
||||
server.get("/admin/wizards/subscription", () => {
|
||||
return helper.response(getUnsubscribedAdminWizards);
|
||||
});
|
||||
server.get("/admin/wizards/wizard", () => {
|
||||
return helper.response(getWizard);
|
||||
});
|
||||
server.get("/admin/plugins/subscription-client/suppliers", () => {
|
||||
return helper.response(getSuppliers);
|
||||
});
|
||||
});
|
||||
test("View submissions fields tab and content", async (assert) => {
|
||||
await visit("/admin/wizards/submissions");
|
||||
|
|
|
@ -6,6 +6,7 @@ import {
|
|||
getBusinessAdminWizard,
|
||||
getCustomFields,
|
||||
getNewApi,
|
||||
getSuppliers,
|
||||
getWizard,
|
||||
putNewApi,
|
||||
} from "../helpers/admin-wizard";
|
||||
|
@ -21,7 +22,7 @@ acceptance("Admin | API tab", function (needs) {
|
|||
server.get("/admin/wizards/wizard", () => {
|
||||
return helper.response(getWizard);
|
||||
});
|
||||
server.get("/admin/wizards", () => {
|
||||
server.get("/admin/wizards/subscription", () => {
|
||||
return helper.response(getBusinessAdminWizard);
|
||||
});
|
||||
server.get("/admin/wizards/custom-fields", () => {
|
||||
|
@ -45,6 +46,9 @@ acceptance("Admin | API tab", function (needs) {
|
|||
server.get("/admin/wizards/api/new_api", () => {
|
||||
return helper.response(getNewApi);
|
||||
});
|
||||
server.get("/admin/plugins/subscription-client/suppliers", () => {
|
||||
return helper.response(getSuppliers);
|
||||
});
|
||||
});
|
||||
|
||||
test("Visit API tab and fill data", async function (assert) {
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
getBusinessAdminWizard,
|
||||
getCreatedWizard,
|
||||
getCustomFields,
|
||||
getSuppliers,
|
||||
getWizard,
|
||||
} from "../helpers/admin-wizard";
|
||||
|
||||
|
@ -28,7 +29,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
|
|||
server.get("/admin/wizards/custom-fields", () => {
|
||||
return helper.response(getCustomFields);
|
||||
});
|
||||
server.get("/admin/wizards", () => {
|
||||
server.get("/admin/wizards/subscription", () => {
|
||||
return helper.response(getBusinessAdminWizard);
|
||||
});
|
||||
server.get("/admin/wizards/api", () => {
|
||||
|
@ -49,6 +50,9 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
|
|||
server.get("/admin/wizards/wizard/new_wizard_for_testing", () => {
|
||||
return helper.response(getCreatedWizard);
|
||||
});
|
||||
server.get("/admin/plugins/subscription-client/suppliers", () => {
|
||||
return helper.response(getSuppliers);
|
||||
});
|
||||
});
|
||||
|
||||
test("Displaying all tabs including API", async (assert) => {
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
getCreatedWizard,
|
||||
getCustomFields,
|
||||
getStandardAdminWizard,
|
||||
getSuppliers,
|
||||
getWizard,
|
||||
} from "../helpers/admin-wizard";
|
||||
|
||||
|
@ -28,7 +29,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
|
|||
server.get("/admin/wizards/custom-fields", () => {
|
||||
return helper.response(getCustomFields);
|
||||
});
|
||||
server.get("/admin/wizards", () => {
|
||||
server.get("/admin/wizards/subscription", () => {
|
||||
return helper.response(getStandardAdminWizard);
|
||||
});
|
||||
server.get("/admin/wizards/api", () => {
|
||||
|
@ -49,6 +50,9 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
|
|||
server.get("/admin/wizards/wizard/new_wizard_for_testing", () => {
|
||||
return helper.response(getCreatedWizard);
|
||||
});
|
||||
server.get("/admin/plugins/subscription-client/suppliers", () => {
|
||||
return helper.response(getSuppliers);
|
||||
});
|
||||
});
|
||||
|
||||
test("Displaying all tabs except API", async (assert) => {
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
getAdminTestingWizard,
|
||||
getCreatedWizard,
|
||||
getCustomFields,
|
||||
getSuppliers,
|
||||
getUniqueWizard,
|
||||
getUnsubscribedAdminWizards,
|
||||
getWizard,
|
||||
|
@ -30,7 +31,7 @@ acceptance("Admin | Custom Wizard Unsubscribed", function (needs) {
|
|||
server.get("/admin/wizards/custom-fields", () => {
|
||||
return helper.response(getCustomFields);
|
||||
});
|
||||
server.get("/admin/wizards", () => {
|
||||
server.get("/admin/wizards/subscription", () => {
|
||||
return helper.response(getUnsubscribedAdminWizards);
|
||||
});
|
||||
server.get("/admin/wizards/api", () => {
|
||||
|
@ -54,6 +55,9 @@ acceptance("Admin | Custom Wizard Unsubscribed", function (needs) {
|
|||
server.get("/admin/wizards/wizard/unique_wizard", () => {
|
||||
return helper.response(getUniqueWizard);
|
||||
});
|
||||
server.get("/admin/plugins/subscription-client/suppliers", () => {
|
||||
return helper.response(getSuppliers);
|
||||
});
|
||||
});
|
||||
|
||||
async function appendText(selector, text) {
|
|
@ -224,7 +224,6 @@ const getUnsubscribedAdminWizards = {
|
|||
all: { none: [], standard: [], business: ["*"], community: ["*"] },
|
||||
},
|
||||
},
|
||||
subscription_client_installed: false,
|
||||
};
|
||||
const getCustomFields = {
|
||||
custom_fields: [
|
||||
|
@ -478,7 +477,6 @@ const getBusinessAdminWizard = {
|
|||
all: { none: [], standard: [], business: ["*"], community: ["*"] },
|
||||
},
|
||||
},
|
||||
subscription_client_installed: false,
|
||||
};
|
||||
const getStandardAdminWizard = {
|
||||
subscribed: true,
|
||||
|
@ -589,7 +587,6 @@ const getStandardAdminWizard = {
|
|||
all: { none: [], standard: [], business: ["*"], community: ["*"] },
|
||||
},
|
||||
},
|
||||
subscription_client_installed: false,
|
||||
};
|
||||
const getAdminTestingWizard = {
|
||||
id: "this_is_testing_wizard",
|
||||
|
@ -917,6 +914,19 @@ const putNewApi = {
|
|||
log: [],
|
||||
},
|
||||
};
|
||||
|
||||
const getSuppliers = {
|
||||
suppliers: [
|
||||
{
|
||||
id: 1,
|
||||
name: "Pavilion",
|
||||
authorized: false,
|
||||
authorized_at: null,
|
||||
user: null,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export {
|
||||
getWizard,
|
||||
getUnsubscribedAdminWizards,
|
||||
|
@ -931,4 +941,5 @@ export {
|
|||
putNewApi,
|
||||
getAnotherWizardSubmission,
|
||||
getUniqueWizard,
|
||||
getSuppliers,
|
||||
};
|
||||
|
|
Laden …
In neuem Issue referenzieren