0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 04:12:53 +01:00
Dieser Commit ist enthalten in:
merefield 2024-02-01 08:30:36 +00:00
Commit fe0ba14dbd
104 geänderte Dateien mit 1531 neuen und 680 gelöschten Zeilen

Datei anzeigen

@ -1,3 +1,4 @@
3.2.0.beta2: 1ee2f7d8babafe32912372fbbfa50c89f5b09ba9
3.1.999: 1f35b80f85e5fd1efb7f4851f0845700432febdc
2.7.99: e07a57e398b6b1676ab42a7e34467556fca5416b
2.5.1: bb85b3a0d2c0ab6b59bcb405731c39089ec6731c

Datei anzeigen

@ -6,3 +6,9 @@ RSpec/ContextWording:
RSpec/DescribeClass:
Enabled: false
Discourse/TimeEqMatcher:
Enabled: false
Discourse/NoAddReferenceOrAliasesActiveRecordMigration:
Enabled: false

Datei anzeigen

@ -4,7 +4,7 @@ The Custom Wizard Plugin lets you make forms for your Discourse forum. Better us
<img src="https://camo.githubusercontent.com/593432f1fc9658ffca104065668cc88fa21dffcd3002cb78ffd50c71f33a2523/68747470733a2f2f706176696c696f6e2d6173736574732e6e7963332e63646e2e6469676974616c6f6365616e7370616365732e636f6d2f706c7567696e732f77697a6172642d7265706f7369746f72792d62616e6e65722e706e67" alt="" data-canonical-src="https://pavilion-assets.nyc3.cdn.digitaloceanspaces.com/plugins/wizard-repository-banner.png" style="max-width: 100%;" width="400">
👋 Looking to report an issue? We're managing issues for this plugin using our [bug report wizard](https://coop.pavilion.tech/w/bug-report).
👋 Looking to report an issue? We're managing issues for this plugin using our [bug report wizard](https://pavilion.tech/products/discourse-custom-wizard-plugin/support/bug-report).
## Install
@ -12,16 +12,20 @@ If you're not sure how to install a plugin in Discourse, please follow the [plug
## Documentation
[Read the full documentation here](https://coop.pavilion.tech/c/82), or go directly to the relevant section
[Read the full documentation here](https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/), or go directly to the relevant section
- [Wizard Administration](https://coop.pavilion.tech/t/1602)
- [Wizard Settings](https://coop.pavilion.tech/t/1614)
- [Step Settings](https://coop.pavilion.tech/t/1735)
- [Field Settings](https://coop.pavilion.tech/t/1580)
- [Conditional Settings](https://coop.pavilion.tech/t/1673)
- [Field Interpolation](https://coop.pavilion.tech/t/1557)
- [Step Settings](https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/step-settings)
- [Field Settings](https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/field-settings)
- [Conditional Settings](https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/conditional-settings)
- [Field Interpolation](https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/field-interpolation)
- [Handling Dates and Times](https://coop.pavilion.tech/t/1708)
## Support
- [Report an issue](https://coop.pavilion.tech/w/bug-report)
- [Report an issue](https://pavilion.tech/products/discourse-custom-wizard-plugin/support/bug-report)
## Statistics
For improved service and development, this plugin collects some generalised quantitative data related to version and usage. No personal or sensitive information is gathered. Please email contact@pavilion.tech if you have any questions or concerns about our data collection.

Datei anzeigen

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

Datei anzeigen

@ -22,7 +22,12 @@ class CustomWizard::AdminSubmissionsController < CustomWizard::AdminController
end
def download
send_data submission_list.submissions.to_json,
content = ActiveModel::ArraySerializer.new(
CustomWizard::Submission.list(@wizard).submissions,
each_serializer: CustomWizard::SubmissionSerializer
)
send_data content.to_json,
filename: "#{Discourse.current_hostname}-wizard-submissions-#{@wizard.name}.json",
content_type: "application/json",
disposition: "attachment"

Datei anzeigen

@ -0,0 +1,18 @@
# frozen_string_literal: true
class CustomWizard::SubscriptionController < ::Admin::AdminController
before_action :ensure_admin
def index
if params[:update_from_remote]
subscription = CustomWizard::Subscription.new(true)
else
subscription = CustomWizard::Subscription.new
end
render_json_dump(
subscribed: subscription.subscribed?,
subscription_type: subscription.type,
subscription_attributes: CustomWizard::Subscription.attributes,
)
end
end

Datei anzeigen

@ -5,7 +5,7 @@ import { makeArray } from "discourse-common/lib/helpers";
export default CategorySelector.extend({
classNames: ["category-selector", "wizard-category-selector"],
content: computed(
"categories.[]",
"categoryIds.[]",
"blacklist.[]",
"whitelist.[]",
function () {

Datei anzeigen

@ -3,6 +3,8 @@ import Category from "discourse/models/category";
import Component from "@ember/component";
export default Component.extend({
categories: [],
didInsertElement() {
const property = this.field.property || "id";
const value = this.field.value;

Datei anzeigen

@ -1,7 +1,7 @@
import Component from "@ember/component";
import { dasherize } from "@ember/string";
import discourseComputed from "discourse-common/utils/decorators";
import { cookAsync } from "discourse/lib/text";
import { cook } from "discourse/lib/text";
export default Component.extend({
classNameBindings: [
@ -14,7 +14,7 @@ export default Component.extend({
didReceiveAttrs() {
this._super(...arguments);
cookAsync(this.field.translatedDescription).then((cookedDescription) => {
cook(this.field.translatedDescription).then((cookedDescription) => {
this.set("cookedDescription", cookedDescription);
});
},

Datei anzeigen

@ -4,7 +4,7 @@ import I18n from "I18n";
import getUrl from "discourse-common/lib/get-url";
import { htmlSafe } from "@ember/template";
import { schedule } from "@ember/runloop";
import { cookAsync } from "discourse/lib/text";
import { cook } from "discourse/lib/text";
import CustomWizard, {
updateCachedWizard,
} from "discourse/plugins/discourse-custom-wizard/discourse/models/custom-wizard";
@ -25,10 +25,10 @@ export default Component.extend({
didReceiveAttrs() {
this._super(...arguments);
cookAsync(this.step.translatedTitle).then((cookedTitle) => {
cook(this.step.translatedTitle).then((cookedTitle) => {
this.set("cookedTitle", cookedTitle);
});
cookAsync(this.step.translatedDescription).then((cookedDescription) => {
cook(this.step.translatedDescription).then((cookedDescription) => {
this.set("cookedDescription", cookedDescription);
});
},

Datei anzeigen

@ -0,0 +1,34 @@
<DModal @closeModal={{@closeModal}} @title={{this.title}}>
{{#if loading}}
<LoadingSpinner size="large" />
{{else}}
<div class="edit-directory-columns-container">
{{#each @model.columns as |column|}}
<div class="edit-directory-column">
<div class="left-content">
<label class="column-name">
<Input @type="checkbox" @checked={{column.enabled}} />
{{directory-table-header-title
field=column.label
translated=true
}}
</label>
</div>
</div>
{{/each}}
</div>
{{/if}}
<div class="modal-footer">
<DButton
class="btn-primary"
@label="directory.edit_columns.save"
@action={{action "save"}}
/>
<DButton
class="btn-secondary reset-to-default"
@label="directory.edit_columns.reset_to_default"
@action={{action "resetToDefault"}}
/>
</div>
</DModal>

Datei anzeigen

@ -0,0 +1,17 @@
import Component from "@glimmer/component";
import { action } from "@ember/object";
import I18n from "I18n";
export default class AdminWizardsColumnComponent extends Component {
title = I18n.t("admin.wizard.edit_columns");
@action
save() {
this.args.closeModal();
}
@action
resetToDefault() {
this.args.model.reset();
}
}

Datei anzeigen

@ -0,0 +1,20 @@
<DModal
@closeModal={{@closeModal}}
class="next-session-time-modal"
@title={{this.title}}
>
<DateTimeInput
@date={{this.bufferedDateTime}}
@onChange={{action "dateTimeChanged"}}
@showTime="true"
@clearable="true"
/>
<div class="modal-footer">
<DButton
@action={{action "submit"}}
class="btn-primary"
@label="admin.wizard.after_time_modal.done"
@disabled={{this.submitDisabled}}
/>
</div>
</DModal>

Datei anzeigen

@ -0,0 +1,32 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import I18n from "I18n";
export default class NextSessionScheduledComponent extends Component {
@tracked bufferedDateTime;
title = I18n.t("admin.wizard.after_time_modal.title");
constructor() {
super(...arguments);
this.bufferedDateTime = this.args.model.dateTime
? moment(this.args.model.dateTime)
: moment(Date.now());
}
get submitDisabled() {
return moment().isAfter(this.bufferedDateTime);
}
@action
submit() {
const dateTime = this.bufferedDateTime;
this.args.model.update(moment(dateTime).utc().toISOString());
this.args.closeModal();
}
@action
dateTimeChanged(dateTime) {
this.bufferedDateTime = dateTime;
}
}

Datei anzeigen

@ -41,7 +41,8 @@ export default Component.extend(UndoChanges, {
};
}),
messageUrl: "https://discourse.pluginmanager.org/t/action-settings",
messageUrl:
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/action-settings",
@discourseComputed("action.type")
messageKey(type) {

Datei anzeigen

@ -27,7 +27,8 @@ export default Component.extend(UndoChanges, {
isTextType: or("isText", "isTextarea", "isComposer"),
isComposerPreview: equal("field.type", "composer_preview"),
categoryPropertyTypes: selectKitContent(["id", "slug"]),
messageUrl: "https://discourse.pluginmanager.org/t/field-settings",
messageUrl:
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/field-settings",
@discourseComputed("field.type")
validations(type) {

Datei anzeigen

@ -4,7 +4,7 @@ import {
default as discourseComputed,
observes,
} from "discourse-common/utils/decorators";
import { getOwner } from "discourse-common/lib/get-owner";
import { getOwner } from "@ember/application";
import { defaultSelectionType, selectionTypes } from "../lib/wizard-mapper";
import {
generateName,
@ -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) {

Datei anzeigen

@ -0,0 +1,19 @@
<DButton
@icon={{this.updateIcon}}
@action={{this.update}}
class="btn update"
@disabled={{this.updating}}
@title="admin.wizard.subscription.update.title"
>
{{#if this.updating}}
{{loading-spinner size="small"}}
{{/if}}
</DButton>
<DButton
@action={{this.click}}
class="wizard-subscription-badge {{this.subscription.subscriptionType}}"
@title={{this.title}}
>
{{d-icon "pavilion-logo"}}
<span>{{this.label}}</span>
</DButton>

Datei anzeigen

@ -0,0 +1,46 @@
import { inject as service } from "@ember/service";
import { action, computed } from "@ember/object";
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import I18n from "I18n";
export default class WizardSubscriptionBadge extends Component {
@service subscription;
@tracked updating = false;
@tracked updateIcon = "sync";
basePath = "/admin/plugins/subscription-client";
@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() {
window.open(this.subscription.subscriptionCtaLink, "_blank").focus();
}
@action
update() {
this.updating = true;
this.updateIcon = null;
this.subscription.updateSubscriptionStatus().finally(() => {
this.updateIcon = "sync";
this.updating = false;
});
}
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -0,0 +1,22 @@
<div class="supplier-authorize">
<WizardSubscriptionBadge />
{{#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}}
</div>

Datei anzeigen

@ -0,0 +1,53 @@
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();
})
.catch(popupAjaxError);
}
}

Datei anzeigen

@ -7,8 +7,11 @@ import { selectKitContent } from "../lib/wizard";
import { underscore } from "@ember/string";
import Controller from "@ember/controller";
import I18n from "I18n";
import { inject as service } from "@ember/service";
export default Controller.extend({
router: service(),
queryParams: ["refresh_list"],
loadingSubscriptions: false,
notAuthorized: not("api.authorized"),
@ -248,7 +251,7 @@ export default Controller.extend({
.catch(popupAjaxError)
.then((result) => {
if (result.success) {
this.transitionToRoute("adminWizardsApis").then(() => {
this.router.transitionTo("adminWizardsApis").then(() => {
this.send("refreshModel");
});
}

Datei anzeigen

@ -1,14 +0,0 @@
import Controller from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
export default Controller.extend(ModalFunctionality, {
actions: {
save() {
this.send("closeModal");
},
resetToDefault() {
this.get("model.reset")();
},
},
});

Datei anzeigen

@ -4,7 +4,8 @@ import CustomWizardCustomField from "../models/custom-wizard-custom-field";
export default Controller.extend({
messageKey: "create",
fieldKeys: ["klass", "type", "name", "serializers"],
documentationUrl: "https://discourse.pluginmanager.org/t/custom-fields",
documentationUrl:
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/custom-fields",
actions: {
addField() {

Datei anzeigen

@ -2,7 +2,8 @@ import Controller from "@ember/controller";
import { default as discourseComputed } from "discourse-common/utils/decorators";
export default Controller.extend({
documentationUrl: "https://thepavilion.io/t/2818",
documentationUrl:
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/",
@discourseComputed("wizardId")
wizardName(wizardId) {

Datei anzeigen

@ -7,7 +7,8 @@ import I18n from "I18n";
import { underscore } from "@ember/string";
export default Controller.extend({
messageUrl: "https://discourse.pluginmanager.org/t/wizard-manager",
messageUrl:
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/wizard-manager",
messageKey: "info",
messageIcon: "info-circle",
messageClass: "info",

Datei anzeigen

@ -2,11 +2,13 @@ import Controller from "@ember/controller";
import { empty } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators";
import { fmt } from "discourse/lib/computed";
import showModal from "discourse/lib/show-modal";
import { inject as service } from "@ember/service";
import AdminWizardsColumnsModal from "../components/modal/admin-wizards-columns";
import CustomWizardAdmin from "../models/custom-wizard-admin";
import { formatModel } from "../lib/wizard-submission";
export default Controller.extend({
modal: service(),
downloadUrl: fmt("wizard.id", "/admin/wizards/submissions/%@/download"),
noResults: empty("submissions"),
page: 0,
@ -57,7 +59,7 @@ export default Controller.extend({
},
showEditColumnsModal() {
return showModal("admin-wizards-columns", {
return this.modal.show(AdminWizardsColumnsModal, {
model: {
columns: this.get("fields"),
reset: () => {

Datei anzeigen

@ -2,7 +2,8 @@ import Controller from "@ember/controller";
import { default as discourseComputed } from "discourse-common/utils/decorators";
export default Controller.extend({
documentationUrl: "https://thepavilion.io/t/2818",
documentationUrl:
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/",
@discourseComputed("wizardId")
wizardName(wizardId) {

Datei anzeigen

@ -3,7 +3,8 @@ import {
observes,
} from "discourse-common/utils/decorators";
import { notEmpty } from "@ember/object/computed";
import showModal from "discourse/lib/show-modal";
import { inject as service } from "@ember/service";
import NextSessionScheduledModal from "../components/modal/next-session-scheduled";
import { generateId, wizardFieldList } from "../lib/wizard";
import { dasherize } from "@ember/string";
import { later, scheduleOnce } from "@ember/runloop";
@ -13,6 +14,7 @@ import I18n from "I18n";
import { filterValues } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
export default Controller.extend({
modal: service(),
hasName: notEmpty("wizard.name"),
@observes("currentStep")
@ -126,15 +128,13 @@ export default Controller.extend({
},
setNextSessionScheduled() {
let controller = showModal("next-session-scheduled", {
this.modal.show(NextSessionScheduledModal, {
model: {
dateTime: this.wizard.after_time_scheduled,
update: (dateTime) =>
this.set("wizard.after_time_scheduled", dateTime),
},
});
controller.setup();
},
copyUrl() {

Datei anzeigen

@ -22,5 +22,5 @@ export default Controller.extend({
},
messageUrl:
"https://discourse.pluginmanager.org/c/discourse-custom-wizard/documentation",
"https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/",
});

Datei anzeigen

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

Datei anzeigen

@ -1,7 +1,9 @@
import Controller from "@ember/controller";
import getUrl from "discourse-common/lib/get-url";
import { inject as service } from "@ember/service";
export default Controller.extend({
router: service(),
wizard: null,
step: null,
@ -15,12 +17,12 @@ export default Controller.extend({
const wizardId = this.get("wizard.id");
window.location.href = getUrl(`/w/${wizardId}/steps/${nextStepId}`);
} else {
this.transitionToRoute("customWizardStep", nextStepId);
this.router.transitionTo("customWizardStep", nextStepId);
}
},
goBack() {
this.transitionToRoute("customWizardStep", this.get("step.previous"));
this.router.transitionTo("customWizardStep", this.get("step.previous"));
},
showMessage(message) {

Datei anzeigen

@ -1,30 +0,0 @@
import { default as discourseComputed } from "discourse-common/utils/decorators";
import Controller from "@ember/controller";
export default Controller.extend({
title: "admin.wizard.after_time_modal.title",
setup() {
this.set(
"bufferedDateTime",
this.model.dateTime ? moment(this.model.dateTime) : moment(Date.now())
);
},
@discourseComputed("bufferedDateTime")
submitDisabled(dateTime) {
return moment().isAfter(dateTime);
},
actions: {
submit() {
const dateTime = this.get("bufferedDateTime");
this.get("model.update")(moment(dateTime).utc().toISOString());
this.send("closeModal");
},
dateTimeChanged(dateTime) {
this.set("bufferedDateTime", dateTime);
},
},
});

Datei anzeigen

@ -0,0 +1,21 @@
import I18n from "I18n";
import Handlebars from "handlebars";
export default function wizardCharCounter(body, maxLength) {
let bodyLength = body ? body.length : 0;
let finalString;
if (maxLength) {
let isOverMax = bodyLength > maxLength ? "true" : "false";
finalString = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t(
"wizard.x_characters",
{ count: parseInt(maxLength, 10) }
)}</div>`;
} else {
finalString = `<div class="body-length">${I18n.t("wizard.x_characters", {
count: parseInt(bodyLength, 10),
})}</div>`;
}
return new Handlebars.SafeString(finalString);
}

Datei anzeigen

@ -1,25 +0,0 @@
import { registerUnbound } from "discourse-common/lib/helpers";
import I18n from "I18n";
import Handlebars from "handlebars";
export default registerUnbound(
"wizard-char-counter",
function (body, maxLength) {
let bodyLength = body ? body.length : 0;
let finalString;
if (maxLength) {
let isOverMax = bodyLength > maxLength ? "true" : "false";
finalString = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t(
"wizard.x_characters",
{ count: parseInt(maxLength, 10) }
)}</div>`;
} else {
finalString = `<div class="body-length">${I18n.t("wizard.x_characters", {
count: parseInt(bodyLength, 10),
})}</div>`;
}
return new Handlebars.SafeString(finalString);
}
);

Datei anzeigen

@ -83,6 +83,21 @@ export default {
}
},
});
api.modifyClass("component:category-chooser", {
pluginId: "custom-wizard",
categoriesByScope(options = {}) {
let categories = this._super(options);
const currentUser = this.currentUser;
if (!currentUser?.staff) {
categories = categories.filter((category) => {
return !category.custom_fields?.create_topic_wizard;
});
}
return categories;
},
});
});
},
};

Datei anzeigen

@ -30,6 +30,7 @@ export default {
.concat(["loading"]);
if (
redirectToWizard &&
!data.url.includes("ignore_redirect") &&
data.currentRouteName !== "customWizardStep" &&
!excludedPaths.find((p) => {
return data.currentRouteName.indexOf(p) > -1;

Datei anzeigen

@ -1,5 +1,5 @@
import { get, set } from "@ember/object";
import { getOwner } from "discourse-common/lib/get-owner";
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
const wizard = {
basic: {
@ -279,7 +279,7 @@ export function filterValues(currentWizard, feature, attribute, values = null) {
return values;
}
const siteSettings = getOwner(this).lookup("service:site-settings");
const siteSettings = getOwnerWithFallback(this).lookup("service:site-settings");
if (siteSettings.wizard_apis_enabled) {
wizardSchema.action.types.send_to_api = {
api: null,

Datei anzeigen

@ -1,5 +1,5 @@
import Mixin from "@ember/object/mixin";
import { getOwner } from "discourse-common/lib/get-owner";
import { getOwner } from "@ember/application";
import { readOnly } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators";
@ -7,7 +7,7 @@ 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";
"https://pavilion.tech/products/discourse-custom-wizard-plugin/support";
export default Mixin.create({
subscriptionLandingUrl: PRODUCT_PAGE,

Datei anzeigen

@ -1,7 +1,10 @@
import CustomWizardApi from "../models/custom-wizard-api";
import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({
router: service(),
model(params) {
if (params.name === "create") {
return CustomWizardApi.create({ isNew: true });
@ -12,7 +15,7 @@ export default DiscourseRoute.extend({
afterModel(model) {
if (model === null) {
return this.transitionTo("adminWizardsApi");
return this.router.transitionTo("adminWizardsApi");
}
},

Datei anzeigen

@ -1,7 +1,10 @@
import DiscourseRoute from "discourse/routes/discourse";
import CustomWizardApi from "../models/custom-wizard-api";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({
router: service(),
model() {
return CustomWizardApi.list();
},
@ -25,11 +28,11 @@ export default DiscourseRoute.extend({
actions: {
changeApi(apiName) {
this.controllerFor("adminWizardsApi").set("apiName", apiName);
this.transitionTo("adminWizardsApiShow", apiName);
this.router.transitionTo("adminWizardsApiShow", apiName);
},
afterDestroy() {
this.transitionTo("adminWizardsApi").then(() => this.refresh());
this.router.transitionTo("adminWizardsApi").then(() => this.refresh());
},
afterSave(apiName) {
@ -38,7 +41,7 @@ export default DiscourseRoute.extend({
createApi() {
this.controllerFor("adminWizardsApi").set("apiName", "create");
this.transitionTo("adminWizardsApiShow", "create");
this.router.transitionTo("adminWizardsApiShow", "create");
},
},
});

Datei anzeigen

@ -1,15 +1,18 @@
import CustomWizardLogs from "../models/custom-wizard-logs";
import DiscourseRoute from "discourse/routes/discourse";
import { A } from "@ember/array";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({
router: service(),
model(params) {
return CustomWizardLogs.list(params.wizardId);
},
afterModel(model) {
if (model === null) {
return this.transitionTo("adminWizardsLogs");
return this.router.transitionTo("adminWizardsLogs");
}
},

Datei anzeigen

@ -1,7 +1,10 @@
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/wizard`);
},
@ -18,7 +21,7 @@ export default DiscourseRoute.extend({
actions: {
changeWizard(wizardId) {
this.controllerFor("adminWizardsLogs").set("wizardId", wizardId);
this.transitionTo("adminWizardsLogsShow", wizardId);
this.router.transitionTo("adminWizardsLogsShow", wizardId);
},
},
});

Datei anzeigen

@ -2,15 +2,18 @@ import { A } from "@ember/array";
import CustomWizardAdmin from "../models/custom-wizard-admin";
import DiscourseRoute from "discourse/routes/discourse";
import { formatModel } from "../lib/wizard-submission";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({
router: service(),
model(params) {
return CustomWizardAdmin.submissions(params.wizardId);
},
afterModel(model) {
if (model === null) {
return this.transitionTo("adminWizardsSubmissions");
return this.router.transitionTo("adminWizardsSubmissions");
}
},

Datei anzeigen

@ -1,7 +1,10 @@
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/wizard`);
},
@ -18,7 +21,7 @@ export default DiscourseRoute.extend({
actions: {
changeWizard(wizardId) {
this.controllerFor("adminWizardsSubmissions").set("wizardId", wizardId);
this.transitionTo("adminWizardsSubmissionsShow", wizardId);
this.router.transitionTo("adminWizardsSubmissionsShow", wizardId);
},
},
});

Datei anzeigen

@ -2,8 +2,11 @@ import CustomWizardAdmin from "../models/custom-wizard-admin";
import { ajax } from "discourse/lib/ajax";
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({
router: service(),
model(params) {
if (params.wizardId === "create") {
return { create: true };
@ -14,7 +17,7 @@ export default DiscourseRoute.extend({
afterModel(model) {
if (model.none) {
return this.transitionTo("adminWizardsWizard");
return this.router.transitionTo("adminWizardsWizard");
}
},

Datei anzeigen

@ -4,8 +4,11 @@ import EmberObject, { set } from "@ember/object";
import { A } from "@ember/array";
import { all } from "rsvp";
import { ajax } from "discourse/lib/ajax";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({
router: service(),
model() {
return ajax("/admin/wizards/wizard");
},
@ -80,14 +83,14 @@ export default DiscourseRoute.extend({
this.controllerFor("adminWizardsWizard").set("wizardId", wizardId);
if (wizardId) {
this.transitionTo("adminWizardsWizardShow", wizardId);
this.router.transitionTo("adminWizardsWizardShow", wizardId);
} else {
this.transitionTo("adminWizardsWizard");
this.router.transitionTo("adminWizardsWizard");
}
},
afterDestroy() {
this.transitionTo("adminWizardsWizard").then(() => this.refresh());
this.router.transitionTo("adminWizardsWizard").then(() => this.refresh());
},
afterSave(wizardId) {
@ -96,7 +99,7 @@ export default DiscourseRoute.extend({
createWizard() {
this.controllerFor("adminWizardsWizard").set("wizardId", "create");
this.transitionTo("adminWizardsWizardShow", "create");
this.router.transitionTo("adminWizardsWizardShow", "create");
},
},
});

Datei anzeigen

@ -1,23 +1,12 @@
import DiscourseRoute from "discourse/routes/discourse";
import { ajax } from "discourse/lib/ajax";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({
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,
});
},
router: service(),
afterModel(model, transition) {
if (transition.targetName === "adminWizards.index") {
this.transitionTo("adminWizardsWizard");
this.router.transitionTo("adminWizardsWizard");
}
},
});

Datei anzeigen

@ -1,11 +1,14 @@
import { getCachedWizard } from "../models/custom-wizard";
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
export default Route.extend({
router: service(),
beforeModel() {
const wizard = getCachedWizard();
if (wizard && wizard.permitted && !wizard.completed && wizard.start) {
this.replaceWith("customWizardStep", wizard.start);
this.router.replaceWith("customWizardStep", wizard.start);
}
},

Datei anzeigen

@ -3,14 +3,17 @@ import { getCachedWizard } from "../models/custom-wizard";
import Route from "@ember/routing/route";
import { scrollTop } from "discourse/mixins/scroll-top";
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
export default Route.extend({
router: service(),
beforeModel() {
const wizard = getCachedWizard();
this.set("wizard", wizard);
if (!wizard || !wizard.permitted || wizard.completed) {
this.replaceWith("customWizard");
this.router.replaceWith("customWizard");
}
},
@ -27,7 +30,7 @@ export default Route.extend({
afterModel(model) {
if (model.completed) {
return this.transitionTo("wizard.index");
return this.router.transitionTo("wizard.index");
}
return model.set("wizardId", this.wizard.id);
},

Datei anzeigen

@ -0,0 +1,65 @@
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://coop.pavilion.tech/c/support/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 = {};
async init() {
super.init(...arguments);
await this.retrieveSubscriptionStatus();
}
async retrieveSubscriptionStatus() {
let result = await ajax("/admin/wizards/subscription").catch(
popupAjaxError
);
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";
}
async updateSubscriptionStatus() {
let result = await ajax(
"/admin/wizards/subscription?update_from_remote=true"
).catch(popupAjaxError);
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";
}
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;
}
}
}

Datei anzeigen

@ -66,9 +66,12 @@
{{#each wizards as |wizard|}}
<tr data-wizard-id={{dasherize wizard.id}}>
<td>
{{#link-to "adminWizardsWizardShow" (dasherize wizard.id)}}
<LinkTo
@route="adminWizardsWizardShow"
@model={{dasherize wizard.id}}
>
{{wizard.name}}
{{/link-to}}
</LinkTo>
</td>
<td class="control-column">
<Input

Datei anzeigen

@ -1,3 +1,5 @@
<PluginOutlet @name="admin-wizards-top" @connectorTagName="div" />
{{#admin-nav}}
{{nav-item route="adminWizardsWizard" label="admin.wizard.nav_label"}}
{{nav-item
@ -18,8 +20,7 @@
}}
<div class="admin-actions">
{{wizard-subscription-badge}}
{{wizard-subscription-cta}}
<WizardSubscriptionStatus />
</div>
{{/admin-nav}}

Datei anzeigen

@ -14,7 +14,7 @@
<div class="setting-value">
{{wizard-subscription-selector
value=action.type
value=this.action.type
feature="action"
attribute="type"
onChange=(action "changeType")
@ -31,9 +31,9 @@
<div class="setting-value">
{{combo-box
value=action.run_after
value=this.action.run_after
content=runAfterContent
onChange=(action (mut action.run_after))
onChange=(action (mut this.action.run_after))
}}
</div>
</div>
@ -48,7 +48,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.title
inputs=this.action.title
property="title"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -67,10 +67,10 @@
<div class="setting-value">
{{combo-box
value=action.post
value=this.action.post
content=wizardFields
nameProperty="label"
onChange=(action (mut action.post))
onChange=(action (mut this.action.post))
options=(hash
none="admin.wizard.selector.placeholder.wizard_field"
isDisabled=showPostBuilder
@ -84,7 +84,7 @@
</div>
</div>
{{#if action.post_builder}}
{{#if this.action.post_builder}}
<div class="setting full">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.post_builder.label"}}</label>
@ -92,7 +92,7 @@
<div class="setting-value editor">
{{wizard-text-editor
value=action.post_template
value=this.action.post_template
wizardFields=wizardFields
}}
</div>
@ -108,7 +108,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.category
inputs=this.action.category
property="category"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -131,7 +131,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.tags
inputs=this.action.tags
property="tags"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -153,7 +153,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.visible
inputs=this.action.visible
property="visible"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -171,7 +171,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.add_event
inputs=this.action.add_event
property="add_event"
onUpdate=(action "mappedFieldUpdated")
options=(hash wizardFieldSelection=true context="action")
@ -188,7 +188,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.add_location
inputs=this.action.add_location
property="add_location"
onUpdate=(action "mappedFieldUpdated")
options=(hash wizardFieldSelection=true context="action")
@ -206,7 +206,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.recipient
inputs=this.action.recipient
property="recipient"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -230,7 +230,7 @@
</div>
{{wizard-mapper
inputs=action.profile_updates
inputs=this.action.profile_updates
property="profile_updates"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -254,11 +254,11 @@
<div class="setting-value">
{{combo-box
value=action.api
value=this.action.api
content=availableApis
onChange=(action (mut action.api))
onChange=(action (mut this.action.api))
options=(hash
isDisabled=action.custom_title_enabled
isDisabled=this.action.custom_title_enabled
none="admin.wizard.action.send_to_api.select_an_api"
)
}}
@ -272,9 +272,9 @@
<div class="setting-value">
{{combo-box
value=action.api_endpoint
value=this.action.api_endpoint
content=availableEndpoints
onChange=(action (mut action.api_endpoint))
onChange=(action (mut this.action.api_endpoint))
options=(hash
isDisabled=apiEmpty
none="admin.wizard.action.send_to_api.select_an_endpoint"
@ -290,7 +290,7 @@
<div class="setting-value">
{{wizard-text-editor
value=action.api_body
value=this.action.api_body
previewEnabled=false
barEnabled=false
wizardFields=wizardFields
@ -308,7 +308,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.group
inputs=this.action.group
property="group"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -333,7 +333,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.url
inputs=this.action.url
property="url"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -357,7 +357,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.categories
inputs=this.action.categories
property="categories"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -381,7 +381,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.mute_remainder
inputs=this.action.mute_remainder
property="mute_remainder"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -402,11 +402,11 @@
<div class="setting-value">
{{combo-box
value=action.notification_level
value=this.action.notification_level
content=availableNotificationLevels
onChange=(action (mut action.notification_level))
onChange=(action (mut this.action.notification_level))
options=(hash
isDisabled=action.custom_title_enabled
isDisabled=this.action.custom_title_enabled
none="admin.wizard.action.watch_x.select_a_notification_level"
)
}}
@ -430,7 +430,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.usernames
inputs=this.action.usernames
property="usernames"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -452,7 +452,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.tags
inputs=this.action.tags
property="tags"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -476,11 +476,11 @@
<div class="setting-value">
{{combo-box
value=action.notification_level
value=this.action.notification_level
content=availableNotificationLevels
onChange=(action (mut action.notification_level))
onChange=(action (mut this.action.notification_level))
options=(hash
isDisabled=action.custom_title_enabled
isDisabled=this.action.custom_title_enabled
none="admin.wizard.action.watch_x.select_a_notification_level"
)
}}
@ -504,7 +504,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.usernames
inputs=this.action.usernames
property="usernames"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -526,7 +526,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.name
inputs=this.action.name
property="name"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -545,7 +545,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.full_name
inputs=this.action.full_name
property="full_name"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -564,7 +564,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.title
inputs=this.action.title
property="title"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -583,7 +583,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.bio_raw
inputs=this.action.bio_raw
property="bio_raw"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -602,7 +602,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.owner_usernames
inputs=this.action.owner_usernames
property="owner_usernames"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -622,7 +622,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.usernames
inputs=this.action.usernames
property="usernames"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -644,7 +644,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.grant_trust_level
inputs=this.action.grant_trust_level
property="grant_trust_level"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -665,7 +665,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.mentionable_level
inputs=this.action.mentionable_level
property="mentionable_level"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -686,7 +686,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.messageable_level
inputs=this.action.messageable_level
property="messageable_level"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -707,7 +707,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.visibility_level
inputs=this.action.visibility_level
property="visibility_level"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -728,7 +728,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.members_visibility_level
inputs=this.action.members_visibility_level
property="members_visibility_level"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -750,7 +750,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.name
inputs=this.action.name
property="name"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -770,7 +770,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.slug
inputs=this.action.slug
property="slug"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -790,7 +790,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.color
inputs=this.action.color
property="color"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -810,7 +810,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.text_color
inputs=this.action.text_color
property="text_color"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -832,7 +832,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.parent_category_id
inputs=this.action.parent_category_id
property="parent_category_id"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -853,7 +853,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.permissions
inputs=this.action.permissions
property="permissions"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -878,7 +878,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.custom_fields
inputs=this.action.custom_fields
property="custom_fields"
onUpdate=(action "mappedFieldUpdated")
options=(hash
@ -903,7 +903,7 @@
<div class="setting-value">
{{wizard-mapper
inputs=action.required
inputs=this.action.required
property="required"
onUpdate=(action "mappedFieldUpdated")
options=(hash

Datei anzeigen

@ -1,23 +1,23 @@
{{wizard-mapper-connector
connector=input.type
connectors=inputTypes
connector=this.input.type
connectors=this.inputTypes
inputTypes=true
inputType=inputType
inputType=this.inputType
connectorType="type"
options=options
onUpdate=onUpdate
options=this.options
onUpdate=this.onUpdate
}}
{{#if hasPairs}}
<div class="mapper-pairs mapper-block">
{{#each input.pairs as |pair|}}
{{#each this.input.pairs as |pair|}}
{{wizard-mapper-pair
pair=pair
last=pair.last
inputType=inputType
options=options
inputType=this.inputType
options=this.options
removePair=(action "removePair")
onUpdate=onUpdate
onUpdate=this.onUpdate
}}
{{/each}}
@ -32,27 +32,27 @@
{{#if hasOutput}}
{{#if hasPairs}}
{{wizard-mapper-connector
connector=input.output_connector
connectors=connectors
connector=this.input.output_connector
connectors=this.connectors
connectorType="output"
inputType=inputType
options=options
onUpdate=onUpdate
inputType=this.inputType
options=this.options
onUpdate=this.onUpdate
}}
{{/if}}
<div class="output mapper-block">
{{wizard-mapper-selector
selectorType="output"
inputType=input.type
value=input.output
activeType=input.output_type
options=options
onUpdate=onUpdate
inputType=this.input.type
value=this.input.output
activeType=this.input.output_type
options=this.options
onUpdate=this.onUpdate
}}
</div>
{{/if}}
<a role="button" class="remove-input" {{action remove input}}>
<a role="button" class="remove-input" {{action remove this.input}}>
{{d-icon "times"}}
</a>

Datei anzeigen

@ -7,7 +7,7 @@
<li>
<span class="setting-title">
<h4>{{i18n (concat "admin.wizard.field.validations." type)}}</h4>
<Input @type="checkbox" @checked={{this.props.status}} />
<Input @type="checkbox" @checked={{props.status}} />
{{i18n "admin.wizard.field.validations.enabled"}}
</span>
<div class="validation-container">
@ -36,7 +36,7 @@
<div class="setting-value">
<Input
@type="number"
@value={{this.props.time_n_value}}
@value={{props.time_n_value}}
class="time-n-value"
/>
{{combo-box

Datei anzeigen

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

Datei anzeigen

@ -1 +0,0 @@
{{d-icon icon}}{{label}}

Datei anzeigen

@ -144,9 +144,9 @@
{{/if}}
{{#if isUser}}
{{#link-to "user" value.username}}
<LinkTo @route="user" @model={{value.username}}>
{{avatar value imageSize="tiny"}}
{{/link-to}}
</LinkTo>
{{/if}}
{{#if showUsername}}

Datei anzeigen

@ -1,35 +0,0 @@
{{#d-modal-body title="admin.wizard.edit_columns"}}
{{#if loading}}
{{loading-spinner size="large"}}
{{else}}
<div class="edit-directory-columns-container">
{{#each model.columns as |column|}}
<div class="edit-directory-column">
<div class="left-content">
<label class="column-name">
{{input type="checkbox" checked=column.enabled}}
{{directory-table-header-title
field=column.label
translated=true
}}
</label>
</div>
</div>
{{/each}}
</div>
{{/if}}
{{/d-modal-body}}
<div class="modal-footer">
{{d-button
class="btn-primary"
label="directory.edit_columns.save"
action=(action "save")
}}
{{d-button
class="btn-secondary reset-to-default"
label="directory.edit_columns.reset_to_default"
action=(action "resetToDefault")
}}
</div>

Datei anzeigen

@ -1,17 +0,0 @@
{{#d-modal-body class="next-session-time-modal" title=title}}
{{date-time-input
date=bufferedDateTime
onChange=(action "dateTimeChanged")
showTime=true
clearable=true
}}
{{/d-modal-body}}
<div class="modal-footer">
{{d-button
action=(action "submit")
class="btn-primary"
label="admin.wizard.after_time_modal.done"
disabled=submitDisabled
}}
</div>

Datei anzeigen

@ -43,14 +43,6 @@ $error: #ef1700;
}
}
.admin-wizards .admin-actions {
display: flex;
.btn-pavilion-support {
margin-left: 10px;
}
}
.wizard-message {
background-color: var(--primary-low);
width: 100%;
@ -831,25 +823,6 @@ $error: #ef1700;
vertical-align: middle;
}
.btn.btn-pavilion-support {
background: var(--pavilion-primary);
color: var(--pavilion-secondary);
.d-icon {
color: var(--pavilion-secondary);
}
&:hover,
&:focus {
background: darken($pavilion_primary, 5%);
&[href],
svg.d-icon {
color: darken($pavilion_secondary, 10%);
}
}
}
.wizard-subscription-container {
width: 100%;
padding: 1em;
@ -875,45 +848,49 @@ $error: #ef1700;
}
}
.wizard-subscription-badge {
.btn.wizard-subscription-badge {
display: inline-flex;
align-items: center;
max-height: 34px;
box-sizing: border-box;
position: relative;
cursor: pointer;
padding: 0.5em 0.65em;
background-color: rgba($primary-medium, 0.05);
border: 1.5px solid rgba($primary-medium, 0.5);
color: $primary-medium;
color: var(--secondary);
&:hover {
color: $primary-medium;
}
svg {
svg.d-icon-pavilion-logo {
width: 15px;
height: 15px;
margin-right: 0.45em;
margin-bottom: 0.15em;
color: var(--secondary);
}
&.none {
background-color: var(--subscription-none);
border: 1.5px solid var(--subscription-none);
}
&.standard {
background-color: rgba($subscription_standard, 0.05);
border: 1.5px solid rgba($subscription_standard, 0.5);
color: $subscription_standard;
background-color: var(--subscription-standard);
border: 1.5px solid var(--subscription-standard);
}
&.business {
background-color: $subscription_business;
border: 1.5px solid $subscription_business;
color: $secondary;
background-color: var(--subscription-business);
border: 1.5px solid var(--subscription-business);
}
&.community {
background-color: $subscription_community;
border: 1.5px solid $pavilion_primary;
color: $pavilion_primary;
background-color: var(--subscription-community);
border: 1.5px solid var(--pavilion-primary);
color: var(--pavilion-primary);
&:hover,
svg {
color: var(--pavilion-primary);
}
}
.d-icon {
@ -940,3 +917,32 @@ $error: #ef1700;
font-size: 0.75em;
}
}
.admin-wizards .admin-actions {
.supplier-authorize {
display: inline-flex;
button.update {
width: 40px;
}
.wizard-subscription-badge {
margin-right: 5px;
svg {
margin-right: 0.45em;
}
}
.btn-primary {
margin-right: 5px;
}
.deauthorize {
background-color: var(--secondary);
&:hover {
color: var(--primary);
}
}
}
}

Datei anzeigen

@ -2,6 +2,7 @@ $pavilion_primary: #3c1c8c;
$pavilion_secondary: #ffffff;
$pavilion_warning: rgb(243, 163, 61);
$subscription_none: $pavilion_primary;
$subscription_standard: $pavilion_primary;
$subscription_business: #333;
$subscription_community: #fff;
@ -10,6 +11,7 @@ $subscription_community: #fff;
--pavilion-primary: #{$pavilion_primary};
--pavilion-secondary: #{$pavilion_secondary};
--pavilion-warning: #{$pavilion_warning};
--subscription-none: #{$subscription_none};
--subscription-standard: #{$subscription_standard};
--subscription-business: #{$subscription_business};
--subscription-community: #{$subscription_community};

Datei anzeigen

@ -3,6 +3,16 @@ body.custom-wizard {
color: var(--primary);
font-size: 1.1em;
.sidebar-wrapper {
display: none;
}
#main-outlet-wrapper {
grid-template-areas: "sidebar content";
grid-template-columns: 0 minmax(0, 1fr);
gap: 0;
}
.wizard-column {
position: relative;
z-index: 11;

Datei anzeigen

@ -167,13 +167,13 @@ en:
destroy_complete: Destruction complete
subscription:
documentation: Check out the subscription documentation
authorize: "Authorize this forum to use your Custom Wizard subscription plan on %{server}."
not_subscribed: "You've authorized, but are not currently subscribed to a Custom Wizard plan on %{server}."
authorize: "Connect this forum to use your Custom Wizard subscription plan on %{server}."
not_subscribed: "You've connected, but are not currently subscribed to a Custom Wizard plan on %{server}."
subscription_expiring: "Your subscription is active, but will expire in the next 48 hours."
subscription_active: "Your subscription is active."
subscription_inactive: "Your subscription is inactive on this forum. Read more in <a href='https://thepavilion.io/t/3652'>the documentation</a>."
unauthorized: "You're unauthorized. If you have a subscription, it will become inactive in the next 48 hours."
unauthorize_failed: Failed to unauthorize.
subscription_inactive: "Your subscription is inactive on this forum. Read more in <a href='https://pavilion.tech/products/discourse-custom-wizard-plugin/documentation/'>the documentation</a>."
unauthorized: "You're not connected. If you have a subscription, it will become inactive in the next 48 hours."
unauthorize_failed: Failed to disconnect.
submissions:
select: "Select a wizard to see its submissions"
viewing: "You're viewing the submissions of the %{wizardName}"
@ -545,6 +545,14 @@ en:
subscription:
title: Subscriber Features
authorize:
label: Connect
title: Connect your subscription to this site
deauthorize:
label: Disconnect
title: Disconnect your subscription from this site
update:
title: "Update subscription status"
subscribed:
label: Subscribed
title: You're subscribed and can use these features
@ -555,25 +563,17 @@ en:
selector: not subscribed
type:
none:
label: Not Subscribed
label: Subscribe
title: There is no Custom Wizard subscription active on this forum.
business:
label: Business
label: Support
title: There is a Custom Wizard Business subscription active on this forum.
standard:
label: Standard
label: Support
title: There is a Custom Wizard Standard subscription active on this forum.
community:
label: Community
title: There is a Custom Wizard Community subscription active on this forum.
cta:
none:
label: Get a Subscription
title: Get a subscription for this forum.
subscribed:
label: Support
title: Get support for your subscription.
title: There is a Custom Wizard Community subscription active on this forum.
wizard_js:
group:

Datei anzeigen

@ -55,6 +55,8 @@ en:
liquid_syntax_error: "Liquid syntax error in %{attribute}: %{message}"
subscription: "%{type} %{property} usage is not supported on your subscription"
not_permitted_for_guests: "%{object_id} is not permitted when guests can access the wizard"
error_messages:
wizard_replacing_composer: "Category not allowed for topic creation."
site_settings:
custom_wizard_enabled: "Enable custom wizards."

Datei anzeigen

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

Datei anzeigen

@ -234,16 +234,16 @@ class ::CustomWizard::CustomField
external = []
CLASSES.keys.each do |klass|
field_types = klass.to_s.classify.constantize.custom_field_types
meta_data = klass.to_s.classify.constantize.send('custom_field_meta_data')
if field_types.present?
field_types.each do |name, type|
if meta_data.present?
meta_data.each do |name, data|
unless list.any? { |field| field.name === name }
field = new(
'external',
name: name,
klass: klass,
type: type
type: data.type
)
external.push(field)
end

Datei anzeigen

@ -131,6 +131,8 @@ class CustomWizard::Submission
params[:key] = list_actor_id if list_actor_id
query = PluginStoreRow.where(params)
query = query.order(order_by) if order_by
result = OpenStruct.new(submissions: [], total: nil)
query.each do |record|

Datei anzeigen

@ -1,4 +1,6 @@
# frozen_string_literal: true
require "discourse_subscription_client"
class CustomWizard::Subscription
PRODUCT_HIERARCHY = %w[
community
@ -104,25 +106,27 @@ class CustomWizard::Subscription
attr_accessor :product_id,
:product_slug
def initialize
if CustomWizard::Subscription.client_installed?
result = DiscourseSubscriptionClient.find_subscriptions("discourse-custom-wizard")
def initialize(update = false)
if update
::DiscourseSubscriptionClient::Subscriptions.update
end
if result&.any?
ids_and_slugs = result.subscriptions.map do |subscription|
{
id: subscription.product_id,
slug: result.products[subscription.product_id]
}
end
result = ::DiscourseSubscriptionClient.find_subscriptions("discourse-custom-wizard")
id_and_slug = ids_and_slugs.sort do |a, b|
PRODUCT_HIERARCHY.index(b[:slug]) - PRODUCT_HIERARCHY.index(a[:slug])
end.first
@product_id = id_and_slug[:id]
@product_slug = id_and_slug[:slug]
if result&.any?
ids_and_slugs = result.subscriptions.map do |subscription|
{
id: subscription.product_id,
slug: result.products[subscription.product_id]
}
end
id_and_slug = ids_and_slugs.sort do |a, b|
PRODUCT_HIERARCHY.index(b[:slug]) - PRODUCT_HIERARCHY.index(a[:slug])
end.first
@product_id = id_and_slug[:id]
@product_slug = id_and_slug[:slug]
end
@product_slug ||= ENV["CUSTOM_WIZARD_PRODUCT_SLUG"]
@ -157,7 +161,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,6 +180,7 @@ class CustomWizard::Subscription
product_slug === "community"
end
# TODO candidate for removal once code that depends on it externally is no longer used.
def self.client_installed?
defined?(DiscourseSubscriptionClient) == 'constant' && DiscourseSubscriptionClient.class == Module
end

Datei anzeigen

@ -128,7 +128,7 @@ class ::CustomWizard::UpdateValidator
return @ctx if @ctx
@ctx = PrettyText.v8
PrettyText.ctx_load(@ctx, "#{Rails.root}/vendor/assets/javascripts/moment.js")
@ctx.load("#{Rails.root}/vendor/assets/javascripts/moment.js")
@ctx
end
end

Datei anzeigen

@ -0,0 +1,98 @@
# frozen_string_literal: true
module DiscoursePluginStatistics
class Plugin
def self.discourse_custom_wizard
subscription_features = {
wizard: {
save_submissions: 0,
after_signup: 0,
prompt_completion: 0,
required: 0,
permitted: 0,
},
step: {
required_data: 0,
permitted_params: 0,
force_final: 0
},
field: {
condition: 0,
type: {
text: 0,
textarea: 0,
text_only: 0,
date: 0,
time: 0,
date_time: 0,
number: 0,
checkbox: 0,
dropdown: 0,
composer: 0,
composer_preview: 0,
url: 0,
upload: 0,
tag: 0,
category: 0,
group: 0,
user_selector: 0,
},
realtime_validations: 0
},
action: {
type: {
create_topic: 0,
send_message: 0,
update_profile: 0,
open_composer: 0,
route_to: 0,
send_to_api: 0,
watch_categories: 0,
watch_tags: 0,
add_to_group: 0,
create_group: 0,
create_category: 0,
}
}
}
increment_feature_count = lambda do |type, key, value|
if key == 'type'
if !subscription_features[type.to_sym][:type][value.to_sym].nil?
subscription_features[type.to_sym][:type][value.to_sym] += 1
end
else
if !subscription_features[type.to_sym][key.to_sym].nil?
subscription_features[type.to_sym][key.to_sym] += 1
end
end
end
CustomWizard::Template.list.each do |template|
template.each do |key, value|
increment_feature_count.call(:wizard, key, value)
end
template['steps'].each do |step|
step.each do |key, value|
increment_feature_count.call(:step, key, value)
end
step['fields'].each do |field|
field.each do |key, value|
increment_feature_count.call(:field, key, value)
end
end
end
template['actions'].each do |action|
action.each do |key, value|
increment_feature_count.call(:action, key, value)
end
end
end
{
total_wizards: CustomWizard::Template.list.size,
subscription_type: CustomWizard::Subscription.type.to_s,
subscription_features: subscription_features
}
end
end
end

Datei anzeigen

@ -1,15 +1,19 @@
# 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.19
# version: 2.6.0
# 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
# meta_topic_id: 73345
gem 'liquid', '5.0.1', require: true
gem "discourse_subscription_client", "0.1.1", require_name: "discourse_subscription_client"
gem 'discourse_plugin_statistics', '0.1.0.pre7', require: true
register_asset 'stylesheets/common/admin.scss'
register_asset 'stylesheets/common/wizard.scss'
register_svg_icon 'pavilion-logo'
enabled_site_setting :custom_wizard_enabled
@ -35,6 +39,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
@ -73,6 +78,7 @@ after_initialize do
../lib/custom_wizard/api/log_entry.rb
../lib/custom_wizard/liquid_extensions/first_non_empty.rb
../lib/custom_wizard/exceptions/exceptions.rb
../lib/discourse_plugin_statistics/plugin.rb
../app/serializers/custom_wizard/api/authorization_serializer.rb
../app/serializers/custom_wizard/api/basic_endpoint_serializer.rb
../app/serializers/custom_wizard/api/endpoint_serializer.rb
@ -236,4 +242,14 @@ after_initialize do
end
DiscourseEvent.trigger(:custom_wizard_ready)
on(:before_create_topic) do |topic_params, user|
category = topic_params.category
wizard_submission_id = topic_params.custom_fields&.[]('wizard_submission_id')
if category&.custom_fields&.[]('create_topic_wizard').present? && wizard_submission_id.blank?
raise Discourse::InvalidParameters.new(
I18n.t('wizard.error_messages.wizard_replacing_composer')
)
end
end
end

Datei anzeigen

@ -158,7 +158,7 @@ describe CustomWizard::Action do
action.perform
expect(action.result.success?).to eq(true)
expect(TopicCustomField.exists?(name: custom_field_name, value: custom_field_value)).to eq(true)
expect(TopicCustomField.exists?(name: custom_field_name)).to eq(true)
end
end
@ -253,11 +253,14 @@ describe CustomWizard::Action do
end
it '#send_message' do
Jobs.run_immediately!
target_user = Fabricate(:user)
send_message['recipient'][0]['output'][0] = target_user.username
wizard_template['actions'] << send_message
update_template(wizard_template)
User.create(username: 'angus1', email: "angus1@email.com")
wizard = CustomWizard::Builder.new(@template[:id], user).build
wizard.create_updater(wizard.steps[0].id, {}).update
wizard.create_updater(wizard.steps[1].id, {}).update
@ -273,18 +276,29 @@ describe CustomWizard::Action do
)
expect(topic.exists?).to eq(true)
expect(topic.first.topic_allowed_users.first.user.username).to eq('angus1')
expect(topic.first.topic_allowed_users.first.user.username).to eq(target_user.username)
expect(post.exists?).to eq(true)
expect(target_user.reload.notifications.count).to eq(1)
end
it '#send_message allows using multiple targets' do
Jobs.run_immediately!
user1 = Fabricate(:user)
user2 = Fabricate(:user)
group1 = Fabricate(:group)
group2 = Fabricate(:group)
send_message_multi['recipient'][0]['output'] = [
user1.username,
user2.username,
group1.name,
group2.name
]
wizard_template['actions'] << send_message_multi
update_template(wizard_template)
update_template(wizard_template)
User.create(username: 'angus1', email: "angus1@email.com")
User.create(username: 'faiz', email: "faiz@email.com")
Group.create(name: "cool_group")
Group.create(name: 'cool_group_1')
wizard = CustomWizard::Builder.new(@template[:id], user).build
wizard.create_updater(wizard.steps[0].id, {}).update
wizard.create_updater(wizard.steps[1].id, {}).update
@ -300,9 +314,11 @@ describe CustomWizard::Action do
)
expect(topic.exists?).to eq(true)
expect(topic.first.all_allowed_users.map(&:username)).to include('angus1', 'faiz')
expect(topic.first.allowed_groups.map(&:name)).to include('cool_group', 'cool_group_1')
expect(topic.first.all_allowed_users.map(&:username)).to include(user1.username, user2.username)
expect(topic.first.allowed_groups.map(&:name)).to include(group1.name, group2.name)
expect(post.exists?).to eq(true)
expect(user1.reload.notifications.count).to eq(1)
expect(user2.reload.notifications.count).to eq(1)
end
it "send_message works with guests are permitted" do
@ -450,4 +466,29 @@ describe CustomWizard::Action do
expect(action.result.success?).to eq(true)
expect(Topic.find(action.result.output).custom_fields["topic_custom_field"]).to eq("t")
end
context 'creating a topic when there are multiple actions' do
it 'works' do
wizard_template['actions'] << create_topic
wizard_template['actions'] << send_message
update_template(wizard_template)
wizard = CustomWizard::Builder.new(@template[:id], user).build
wizard.create_updater(
wizard.steps.first.id,
step_1_field_1: 'Topic Title',
step_1_field_2: 'topic body'
).update
wizard.create_updater(wizard.steps.second.id, {}).update
wizard.create_updater(wizard.steps.last.id, step_3_field_3: category.id)
.update
User.create(username: 'angus1', email: 'angus1@email.com')
wizard.create_updater(wizard.steps[0].id, {}).update
wizard.create_updater(wizard.steps[1].id, {}).update
topic = Topic.where(title: 'Topic Title', category_id: category.id)
expect(topic.exists?).to eq(true)
expect(
Post.where(topic_id: topic.pluck(:id), raw: 'topic body').exists?
).to eq(true)
end
end
end

Datei anzeigen

@ -259,11 +259,11 @@ describe CustomWizard::CustomField do
expect(CustomWizard::CustomField.list_by(:serializers, ['post']).length).to eq(0)
end
it "lists custom field records added by other plugins " do
it "custom field records added by other plugins " do
expect(CustomWizard::CustomField.external_list.length).to be > 2
end
it "lists all custom field records" do
it "all custom field records" do
expect(CustomWizard::CustomField.full_list.length).to be > 2
end
end

Datei anzeigen

@ -13,43 +13,7 @@ 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
before do
define_client_classes
end
it "detects the subscription client" do
expect(described_class.client_installed?).to eq(true)
end
context "with subscription client gem mocked out" do
context "without a subscription" do
before do
DiscourseSubscriptionClient.stubs(:find_subscriptions).returns(nil)
@ -69,11 +33,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.supplier = SubscriptionClientSupplier.new(products: 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: product_id) }
result.products = product_slugs
result
end

Datei anzeigen

@ -0,0 +1,82 @@
# frozen_string_literal: true
describe DiscoursePluginStatistics::Plugin do
let(:template_json) { get_wizard_fixture("wizard") }
describe "#discourse_custom_wizard" do
before do
enable_subscription('standard')
CustomWizard::Template.save(template_json, skip_jobs: true)
template_json_2 = template_json.dup
template_json_2["id"] = 'super_mega_fun_wizard_2'
CustomWizard::Template.save(template_json_2, skip_jobs: true)
@data = DiscoursePluginStatistics::Plugin.discourse_custom_wizard
end
it "includes a total wizard count" do
expect(@data[:total_wizards]).to eq(2)
end
it "includes the subscription type" do
expect(@data[:subscription_type]).to eq('standard')
end
it "includes a count of features being used across all wizards" do
expect(@data[:subscription_features]).to eq(
wizard: {
save_submissions: 2,
after_signup: 2,
prompt_completion: 2,
required: 0,
permitted: 0,
},
step: {
required_data: 0,
permitted_params: 0,
force_final: 0
},
field: {
condition: 0,
type: {
text: 2,
textarea: 2,
text_only: 2,
date: 2,
time: 2,
date_time: 2,
number: 2,
checkbox: 2,
dropdown: 2,
composer: 0,
composer_preview: 0,
url: 0,
upload: 0,
tag: 0,
category: 0,
group: 0,
user_selector: 0,
},
realtime_validations: 0
},
action: {
type: {
create_topic: 2,
send_message: 0,
update_profile: 2,
open_composer: 2,
route_to: 2,
send_to_api: 0,
watch_categories: 0,
watch_tags: 0,
add_to_group: 0,
create_group: 0,
create_category: 0,
}
}
)
end
end
end

Datei anzeigen

@ -20,7 +20,7 @@ describe "custom field extensions" do
context "topic" do
it "registers topic custom fields" do
topic
expect(Topic.get_custom_field_type("topic_field_1")).to eq(:boolean)
expect(Topic.get_custom_field_descriptor("topic_field_1").type).to eq(:boolean)
end
it "adds topic custom fields to the topic_view serializer" do
@ -53,7 +53,7 @@ describe "custom field extensions" do
context "post" do
it "registers post custom fields" do
post
expect(Post.get_custom_field_type("post_field_1")).to eq(:integer)
expect(Post.get_custom_field_descriptor("post_field_1").type).to eq(:integer)
end
it "adds post custom fields to the post serializer" do
@ -83,7 +83,7 @@ describe "custom field extensions" do
context "category" do
it "registers" do
category
expect(Category.get_custom_field_type("category_field_1")).to eq(:json)
expect(Category.get_custom_field_descriptor("category_field_1").type).to eq(:json)
end
it "adds custom fields to the basic category serializer" do
@ -103,7 +103,7 @@ describe "custom field extensions" do
context "group" do
it "registers" do
group
expect(Group.get_custom_field_type("group_field_1")).to eq(:string)
expect(Group.get_custom_field_descriptor("group_field_1").type).to eq(:string)
end
it "adds custom fields to the basic group serializer" do

Datei anzeigen

@ -0,0 +1,45 @@
# frozen_string_literal: true
describe Topic, type: :model do
fab!(:category_with_wizard) do
Fabricate(:category, custom_fields: { create_topic_wizard: 'true' })
end
fab!(:category_without_wizard) { Fabricate(:category) }
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
let(:valid_attrs) { Fabricate.attributes_for(:topic) }
context 'with a create_topic_wizard custom field in the category' do
it 'will not allow creating a topic directly' do
expect do
TopicCreator.create(
user,
Guardian.new(user),
valid_attrs.merge(
title: 'A valid and sufficiently long title for testing',
category: category_with_wizard.id,
raw: 'hello this is a test topic with category with custom fields'
)
)
end.to raise_error(
Discourse::InvalidParameters,
'Category not allowed for topic creation.'
)
end
end
context 'without a create_topic_wizard custom field in the category' do
it 'will allow creating a topic directly' do
expect do
TopicCreator.create(
user,
Guardian.new(user),
valid_attrs.merge(
category: category_without_wizard.id,
title: 'Another valid and sufficiently long title for testing',
raw: 'This is the body of a valid topic'
)
)
end.not_to raise_error
end
end
end

Datei anzeigen

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

Datei anzeigen

@ -23,12 +23,3 @@ def disable_subscriptions
CustomWizard::Subscription.any_instance.stubs("#{type}?".to_sym).returns(false)
end
end
def undefine_client_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
load File.expand_path("#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/subscription_client.rb", __FILE__)
end

Datei anzeigen

@ -9,6 +9,7 @@ describe CustomWizard::AdminApiController do
end
it "does not save if user does not have relevant subscription" do
disable_subscriptions
put "/admin/wizards/api/:name.json", params: api_json.to_h
expect(response.status).to eq(400)
end

Datei anzeigen

@ -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,24 @@ describe CustomWizard::AdminController do
context "without a subscription" do
before do
disable_subscriptions
define_client_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
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

Datei anzeigen

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

Datei anzeigen

@ -24,7 +24,7 @@ describe CustomWizard::SubmissionSerializer do
it 'should return submission attributes' do
wizard = CustomWizard::Wizard.create(template_json["id"])
list = CustomWizard::Submission.list(wizard, page: 0)
list = CustomWizard::Submission.list(wizard, page: 0, order_by: 'id')
json_array = ActiveModel::ArraySerializer.new(
list.submissions,
@ -40,7 +40,7 @@ describe CustomWizard::SubmissionSerializer do
it "should return field values, types and labels" do
wizard = CustomWizard::Wizard.create(template_json["id"])
list = CustomWizard::Submission.list(wizard, page: 0)
list = CustomWizard::Submission.list(wizard, page: 0, order_by: 'id')
json_array = ActiveModel::ArraySerializer.new(
list.submissions,

Datei anzeigen

@ -1,24 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<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
<symbol
id="pavilion-logo"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd"
viewBox="0 0 300 300"
stroke-width="35"
stroke="currentColor"
fill="currentColor"
>
<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>
</symbol>
</svg>

Vorher

Breite:  |  Höhe:  |  Größe: 602 B

Nachher

Breite:  |  Höhe:  |  Größe: 512 B

Datei anzeigen

@ -1,19 +1,21 @@
import {
acceptance,
query,
queryAll,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { click, fillIn, findAll, visit, waitUntil } from "@ember/test-helpers";
import { click, fillIn, visit, waitUntil } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import {
getCustomFields,
getSuppliers,
getUnsubscribedAdminWizards,
getWizard,
} from "../helpers/admin-wizard";
import { Promise } from "rsvp";
acceptance("Admin | Custom Fields Unsuscribed", function (needs) {
acceptance("Admin | Custom Fields Unsubscribed", function (needs) {
needs.user();
needs.settings({
custom_wizard_enabled: true,
@ -24,7 +26,7 @@ acceptance("Admin | Custom Fields Unsuscribed", 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 +38,9 @@ acceptance("Admin | Custom Fields Unsuscribed", 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(
@ -89,9 +94,9 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) {
test("Navigate to custom fields tab", async (assert) => {
await visit("/admin/wizards/custom-fields");
assert.ok(find("table"));
assert.ok(query("table"));
assert.ok(
findAll("table tbody tr").length === 4,
queryAll("table tbody tr").length === 4,
"Display loaded custom fields"
);
assert.ok(
@ -120,10 +125,10 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) {
'.admin-wizard-container details:has(summary[name="Filter by: Select a class"])'
);
await dropdown1.expand();
let enabledOptions1 = findAll(
let enabledOptions1 = queryAll(
'.admin-wizard-container details:has(summary[name="Filter by: Select a class"]) ul li:not(.disabled)'
);
let disabledOptions1 = findAll(
let disabledOptions1 = queryAll(
'.admin-wizard-container details:has(summary[name="Filter by: Select a class"]) ul li.disabled'
);
assert.equal(
@ -140,10 +145,10 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) {
'.admin-wizard-container details:has(summary[name="Filter by: Select a type"])'
);
await dropdown2.expand();
let enabledOptions2 = findAll(
let enabledOptions2 = queryAll(
'.admin-wizard-container details:has(summary[name="Filter by: Select a type"]) ul li:not(.disabled)'
);
let disabledOptions2 = findAll(
let disabledOptions2 = queryAll(
'.admin-wizard-container details:has(summary[name="Filter by: Select a type"]) ul li.disabled'
);
assert.equal(
@ -170,7 +175,7 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) {
".admin-wizard-container details.multi-select"
);
await serializerDropdown.expand();
let enabledOptions1 = findAll(
let enabledOptions1 = queryAll(
".admin-wizard-container details.multi-select ul li"
);
assert.equal(
@ -185,7 +190,7 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) {
await dropdown2.expand();
await click('.select-kit-collection li[data-value="post"]');
await serializerDropdown.expand();
let enabledOptions2 = findAll(
let enabledOptions2 = queryAll(
".admin-wizard-container details.multi-select ul li"
);
assert.equal(
@ -198,7 +203,7 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) {
test("Create Topic and Post custom fields", async (assert) => {
await visit("/admin/wizards/custom-fields");
assert.ok(
findAll("table tbody tr").length === 4,
queryAll("table tbody tr").length === 4,
"Display loaded custom fields"
);
await click(".admin-wizard-controls .btn-icon-text");
@ -263,7 +268,7 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) {
"Post custom field name is displayed"
);
assert.ok(
findAll("table tbody tr").length === 6,
queryAll("table tbody tr").length === 6,
"Display added custom fields"
);
});
@ -326,7 +331,7 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) {
test("Delete Topic custom field", async (assert) => {
await visit("/admin/wizards/custom-fields");
assert.ok(
findAll("table tbody tr").length === 4,
queryAll("table tbody tr").length === 4,
"Display loaded custom fields"
);
await click(".admin-wizard-controls .btn-icon-text");
@ -345,13 +350,13 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) {
await click(".actions .save");
await waitForSaveMessage();
assert.ok(
findAll("table tbody tr").length === 5,
queryAll("table tbody tr").length === 5,
"Display added custom fields"
);
await click(".admin-wizard-container tbody tr:first-child button");
await click(".actions .destroy");
assert.ok(
findAll("table tbody tr").length === 4,
queryAll("table tbody tr").length === 4,
"Display custom fields without deleted fields"
);
});

Datei anzeigen

@ -1,8 +1,13 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import {
acceptance,
query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { click, findAll, visit } from "@ember/test-helpers";
import { click, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import {
getSuppliers,
getUnsubscribedAdminWizards,
getWizard,
getWizardTestingLog,
@ -23,12 +28,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");
@ -51,19 +59,19 @@ acceptance("Admin | Logs", function (needs) {
),
"it displays logs for a selected wizard"
);
assert.ok(find("table"));
assert.ok(findAll("table tbody tr").length === 2, "Displays logs list");
assert.ok(queryAll("table"));
assert.ok(queryAll("table tbody tr").length === 2, "Displays logs list");
await click(".refresh.btn");
assert.ok(find("table"));
assert.ok(queryAll("table"));
assert.ok(
findAll("table tbody tr").length === 2,
queryAll("table tbody tr").length === 2,
"Refresh button works correctly"
);
await wizards.expand();
await click('[data-name="Select a wizard"]');
const wizardContainerDiv = find(".admin-wizard-container");
const wizardContainerDiv = queryAll(".admin-wizard-container");
assert.ok(wizardContainerDiv.children().length === 0, "the div is empty");
});
});

Datei anzeigen

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

Datei anzeigen

@ -1,9 +1,14 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import {
acceptance,
query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { click, findAll, visit } from "@ember/test-helpers";
import { click, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import {
getAnotherWizardSubmission,
getSuppliers,
getUnsubscribedAdminWizards,
getWizard,
getWizardSubmissions,
@ -28,12 +33,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");
@ -57,7 +65,7 @@ acceptance("Admin | Submissions", function (needs) {
"it displays submissions for a selected wizard"
);
const submissions = getWizardSubmissions.submissions; // Get submissions data from your JSON file
const rows = findAll("table tbody tr");
const rows = queryAll("table tbody tr");
for (let i = 0; i < submissions.length; i++) {
const dateCell = rows[i].querySelector("td:nth-child(1)");
@ -84,14 +92,14 @@ acceptance("Admin | Submissions", function (needs) {
);
}
assert.ok(
findAll("table tbody tr").length >= 1,
queryAll("table tbody tr").length >= 1,
"Displays submissions list"
);
await wizards.expand();
await click('[data-name="Select a wizard"]');
const wizardContainerDiv = find(".admin-wizard-container");
assert.ok(wizardContainerDiv.children().length === 0, "the div is empty");
const wizardContainerDiv = query(".admin-wizard-container");
assert.ok(wizardContainerDiv.children.length === 0, "the div is empty");
});
test("View submissions tab for another wizard with more steps", async (assert) => {
await visit("/admin/wizards/submissions");
@ -108,7 +116,7 @@ acceptance("Admin | Submissions", function (needs) {
);
const submissions = getAnotherWizardSubmission.submissions; // Get submissions data from your JSON file
const rows = findAll("table tbody tr");
const rows = queryAll("table tbody tr");
for (let i = 0; i < submissions.length; i++) {
const dateCell = rows[i].querySelector("td:nth-child(1)");
@ -143,7 +151,7 @@ acceptance("Admin | Submissions", function (needs) {
}
assert.ok(
findAll("table tbody tr").length >= 1,
queryAll("table tbody tr").length >= 1,
"Displays submissions list for another wizard"
);
});
@ -154,9 +162,9 @@ acceptance("Admin | Submissions", function (needs) {
await wizards.selectRowByValue("this_is_testing_wizard");
await click(".open-edit-columns-btn");
assert.dom(".modal-inner-container").exists("Modal is displayed");
assert.dom(".d-modal__body").exists("Modal is displayed");
const userCheckbox = find(
const userCheckbox = queryAll(
".edit-directory-columns-container .edit-directory-column:nth-child(2) .left-content .column-name input"
);
assert.ok(userCheckbox, "User checkbox is present");
@ -173,7 +181,7 @@ acceptance("Admin | Submissions", function (needs) {
.doesNotIncludeText("User", "User column is not displayed");
await click(".open-edit-columns-btn");
const submittedAtCheckbox = find(
const submittedAtCheckbox = queryAll(
".edit-directory-columns-container .edit-directory-column:nth-child(1) .left-content .column-name input"
);
assert.ok(submittedAtCheckbox, "Submitted At checkbox is present");
@ -211,7 +219,7 @@ acceptance("Admin | Submissions", function (needs) {
await wizards.expand();
await wizards.selectRowByValue("this_is_testing_wizard");
const downloadLinks = findAll(".download-link");
const downloadLinks = queryAll(".download-link");
assert.ok(downloadLinks.length > 1, "Download links are present");
const downloadLink = downloadLinks[1];

Datei anzeigen

@ -1,4 +1,8 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import {
acceptance,
query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
@ -6,6 +10,7 @@ import {
getBusinessAdminWizard,
getCustomFields,
getNewApi,
getSuppliers,
getWizard,
putNewApi,
} from "../helpers/admin-wizard";
@ -21,7 +26,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,11 +50,14 @@ 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) {
await visit("/admin/wizards/api");
const list = find(".admin-controls li");
const list = queryAll(".admin-controls li");
const count = list.length;
assert.equal(count, 6, "There should be 6 admin tabs");

Datei anzeigen

@ -1,6 +1,8 @@
import {
acceptance,
exists,
query,
queryAll,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
@ -11,6 +13,7 @@ import {
getBusinessAdminWizard,
getCreatedWizard,
getCustomFields,
getSuppliersAuthorized,
getWizard,
} from "../helpers/admin-wizard";
@ -28,7 +31,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,15 +52,30 @@ 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(getSuppliersAuthorized);
});
});
test("Displaying all tabs including API", async (assert) => {
await visit("/admin/wizards");
const list = find(".admin-controls li");
const list = queryAll(".admin-controls li");
const count = list.length;
assert.equal(count, 6, "There should be 6 admin tabs");
});
test("shows authorized and subscribed", async (assert) => {
await visit("/admin/wizards");
assert.notOk(
exists(".supplier-authorize .btn-primary:not(.update)"),
"the authorize button is shown."
);
assert.strictEqual(
query("button.wizard-subscription-badge span").innerText.trim(),
"Support"
);
});
test("creating a new wizard", async (assert) => {
await visit("/admin/wizards/wizard");
await click(".admin-wizard-controls button");
@ -75,10 +93,11 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
wizardTitle,
"The title input is inserted"
);
const wizardLink = find("div.wizard-url a");
const wizardLink = queryAll("div.wizard-url a");
assert.equal(wizardLink.length, 1, "Wizard link was created");
assert.equal(
find(".wizard-subscription-container a:contains('Subscribed')").length,
queryAll(".wizard-subscription-container a:contains('Subscribed')")
.length,
1,
"Wizard subscription features are accesible"
);
@ -86,7 +105,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
'.wizard-subscription-container .subscription-settings .setting-value input[type="checkbox"]'
);
assert.ok(
find(
queryAll(
'.wizard-subscription-container .subscription-settings .setting-value input[type="checkbox"]'
).is(":checked"),
"subscription feature available"
@ -95,7 +114,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
// Step 2: Creating a step section
await click(".step .link-list button");
const stepOneText = "step_1 (step_1)";
const stepOneBtn = find(`.step button:contains(${stepOneText})`);
const stepOneBtn = queryAll(`.step button:contains(${stepOneText})`);
assert.equal(stepOneBtn.length, 1, "Creating a step");
const stepTitle = "step title";
await fillIn(".wizard-custom-step input[name='title']", stepTitle);
@ -107,7 +126,8 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
"The step button changes according to title"
);
assert.equal(
find(".wizard-subscription-container a:contains('Subscribed')").length,
queryAll(".wizard-subscription-container a:contains('Subscribed')")
.length,
2,
"Steps subscription features are accesible"
);
@ -119,7 +139,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
"clear button is not rendered"
);
const fieldOneText = "step_1_field_1 (step_1_field_1)";
const fieldOneBtn = find(`.field button:contains(${fieldOneText})`);
const fieldOneBtn = queryAll(`.field button:contains(${fieldOneText})`);
assert.equal(fieldOneBtn.length, 1, "Creating a field");
const fieldTitle = "field title";
await fillIn(".wizard-custom-field input[name='label']", fieldTitle);
@ -154,7 +174,8 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
"Text tipe for field correctly selected"
);
assert.equal(
find(".wizard-subscription-container a:contains('Subscribed')").length,
queryAll(".wizard-subscription-container a:contains('Subscribed')")
.length,
3,
"Field subscription features are accesible"
);
@ -163,7 +184,7 @@ acceptance("Admin | Custom Wizard Business Subscription", function (needs) {
await click(".action .link-list button");
const actionOneText = "action_1 (action_1)";
const actionOneBtn = find(`.action button:contains(${actionOneText})`);
const actionOneBtn = queryAll(`.action button:contains(${actionOneText})`);
assert.equal(actionOneBtn.length, 1, "Creating an action");
assert.ok(
query(

Datei anzeigen

@ -1,16 +1,19 @@
import {
acceptance,
exists,
query,
queryAll,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { click, currentURL, fillIn, findAll, visit } from "@ember/test-helpers";
import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import {
getAdminTestingWizard,
getCreatedWizard,
getCustomFields,
getStandardAdminWizard,
getSuppliersAuthorized,
getWizard,
} from "../helpers/admin-wizard";
@ -28,7 +31,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,15 +52,30 @@ 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(getSuppliersAuthorized);
});
});
test("Displaying all tabs except API", async (assert) => {
await visit("/admin/wizards");
const list = find(".admin-controls li");
const list = queryAll(".admin-controls li");
const count = list.length;
assert.equal(count, 5, "There should be 5 admin tabs");
});
test("shows authorized and subscribed", async (assert) => {
await visit("/admin/wizards");
assert.notOk(
exists(".supplier-authorize .btn-primary:not(.update)"),
"the authorize button not shown."
);
assert.strictEqual(
query("button.wizard-subscription-badge span").innerText.trim(),
"Support"
);
});
test("creating a new wizard", async (assert) => {
await visit("/admin/wizards/wizard");
await click(".admin-wizard-controls button");
@ -75,14 +93,15 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
wizardTitle,
"The title input is inserted"
);
const wizardLink = find("div.wizard-url a");
const wizardLink = queryAll("div.wizard-url a");
assert.equal(wizardLink.length, 1, "Wizard link was created");
assert.equal(
find(".wizard-subscription-container a:contains('Subscribed')").length,
queryAll(".wizard-subscription-container a:contains('Subscribed')")
.length,
1,
"Wizard subscription features are accesible"
);
const subsFeature = find(
const subsFeature = queryAll(
".wizard-subscription-container .subscription-settings .setting-value input"
);
await click(
@ -92,7 +111,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
// ("Step 2: Creating a step section")
await click(".step .link-list button");
const stepOneText = "step_1 (step_1)";
const stepOneBtn = find(`.step button:contains(${stepOneText})`);
const stepOneBtn = queryAll(`.step button:contains(${stepOneText})`);
assert.equal(stepOneBtn.length, 1, "Creating a step");
const stepTitle = "step title";
await fillIn(".wizard-custom-step input[name='title']", stepTitle);
@ -104,7 +123,8 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
"The step button changes according to title"
);
assert.equal(
find(".wizard-subscription-container a:contains('Subscribed')").length,
queryAll(".wizard-subscription-container a:contains('Subscribed')")
.length,
2,
"Steps subscription features are accesible"
);
@ -115,7 +135,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
"clear button is not rendered"
);
const fieldOneText = "step_1_field_1 (step_1_field_1)";
const fieldOneBtn = find(`.field button:contains(${fieldOneText})`);
const fieldOneBtn = queryAll(`.field button:contains(${fieldOneText})`);
assert.equal(fieldOneBtn.length, 1, "Creating a field");
const fieldTitle = "field title";
await fillIn(".wizard-custom-field input[name='label']", fieldTitle);
@ -150,14 +170,15 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
"Text tipe for field correctly selected"
);
assert.equal(
find(".wizard-subscription-container a:contains('Subscribed')").length,
queryAll(".wizard-subscription-container a:contains('Subscribed')")
.length,
3,
"Field subscription features are accesible"
);
// ("Step 4: Creating a action section")
await click(".action .link-list button");
const actionOneText = "action_1 (action_1)";
const actionOneBtn = find(`.action button:contains(${actionOneText})`);
const actionOneBtn = queryAll(`.action button:contains(${actionOneText})`);
assert.equal(actionOneBtn.length, 1, "Creating an action");
assert.ok(
query(
@ -169,10 +190,10 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
".wizard-custom-action .setting-value .select-kit"
);
await actionTypeDropdown.expand();
const listEnabled = findAll(
const listEnabled = queryAll(
".wizard-custom-action .setting .setting-value ul li:not(.disabled)"
);
const listDisabled = findAll(
const listDisabled = queryAll(
".wizard-custom-action .setting .setting-value ul li.disabled"
);
assert.ok(
@ -190,7 +211,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
),
"Create type action correctly selected"
);
let listTopicSettings = findAll(
let listTopicSettings = queryAll(
".admin-wizard-container .wizard-custom-action .setting"
);
assert.ok(
@ -199,7 +220,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("send_message");
listTopicSettings = findAll(
listTopicSettings = queryAll(
".admin-wizard-container .wizard-custom-action .setting"
);
assert.ok(
@ -208,7 +229,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("watch_categories");
listTopicSettings = findAll(
listTopicSettings = queryAll(
".admin-wizard-container .wizard-custom-action .setting"
);
assert.ok(
@ -217,7 +238,7 @@ acceptance("Admin | Custom Wizard Standard Subscription", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("add_to_group");
listTopicSettings = findAll(
listTopicSettings = queryAll(
".admin-wizard-container .wizard-custom-action .setting"
);
assert.ok(

Datei anzeigen

@ -2,21 +2,23 @@ import {
acceptance,
exists,
query,
queryAll,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { click, currentURL, fillIn, findAll, visit } from "@ember/test-helpers";
import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import {
getAdminTestingWizard,
getCreatedWizard,
getCustomFields,
getSuppliers,
getUniqueWizard,
getUnsubscribedAdminWizards,
getWizard,
} from "../helpers/admin-wizard";
acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
acceptance("Admin | Custom Wizard Unsubscribed", function (needs) {
needs.user();
needs.settings({
custom_wizard_enabled: true,
@ -30,7 +32,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", 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 +56,9 @@ acceptance("Admin | Custom Wizard Unsuscribed", 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) {
@ -67,11 +72,23 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
test("Displaying all tabs except API", async (assert) => {
await visit("/admin/wizards");
const list = find(".admin-controls li");
const list = queryAll(".admin-controls li");
const count = list.length;
assert.equal(count, 5, "There should be 5 admin tabs");
});
test("shows unauthorized and unsubscribed", async (assert) => {
await visit("/admin/wizards");
assert.ok(
exists(".supplier-authorize .btn-primary"),
"the authorize button is shown."
);
assert.strictEqual(
query("button.wizard-subscription-badge span").innerText.trim(),
"Subscribe"
);
});
test("creating a new wizard", async (assert) => {
await visit("/admin/wizards/wizard");
await click(".admin-wizard-controls button");
@ -88,7 +105,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
wizardTitle,
"The title input is inserted"
);
const wizardLink = find("div.wizard-url a");
const wizardLink = queryAll("div.wizard-url a");
assert.equal(wizardLink.length, 1, "Wizard link was created");
await click(".btn-after-time");
assert.ok(
@ -106,13 +123,13 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
"Show messsage and link of user not subscribed"
);
assert.equal(
find(".wizard-subscription-container").length,
queryAll(".wizard-subscription-container").length,
1,
"Wizard subscription features are not accesible"
);
await click(".step .link-list button");
const stepOneText = "step_1 (step_1)";
const stepOneBtn = find(`.step button:contains(${stepOneText})`);
const stepOneBtn = queryAll(`.step button:contains(${stepOneText})`);
assert.equal(stepOneBtn.length, 1, "Creating a step");
const stepTitle = "step title";
await fillIn(".wizard-custom-step input[name='title']", stepTitle);
@ -124,7 +141,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
"The step button changes according to title"
);
assert.equal(
find(".wizard-subscription-container").length,
queryAll(".wizard-subscription-container").length,
2,
"Steps subscription features are not accesible"
);
@ -193,7 +210,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
".wizard-custom-step .wizard-text-editor textarea",
`\n\n* List item\n* List item`
);
let listItems = findAll(
let listItems = queryAll(
".wizard-custom-step .wizard-text-editor .d-editor-preview-wrapper ul li"
);
assert.strictEqual(
@ -215,7 +232,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
".wizard-custom-step .wizard-text-editor textarea",
`\n\n1. List item\n1. List item`
);
let orderedListItems = findAll(
let orderedListItems = queryAll(
".wizard-custom-step .wizard-text-editor .d-editor-preview-wrapper ol li"
);
assert.strictEqual(
@ -240,11 +257,14 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
await click(
".wizard-custom-step .wizard-text-editor .d-editor button.link"
);
assert.ok(exists(".insert-link.modal-body"), "hyperlink modal visible");
assert.ok(
exists(".d-modal.insert-hyperlink-modal"),
"hyperlink modal visible"
);
await fillIn(".modal-body .link-url", "google.com");
await fillIn(".modal-body .link-text", "Google");
await click(".modal-footer button.btn-primary");
await fillIn(".d-modal__body.insert-link .inputs .link-url", "google.com");
await fillIn(".d-modal__body.insert-link .inputs .link-text", "Google");
await click(".d-modal__footer button.btn-primary");
let urlText = await query(
".wizard-custom-step .wizard-text-editor .d-editor-preview-wrapper a"
).innerHTML.trim();
@ -256,24 +276,26 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
await click(
".wizard-custom-step .wizard-text-editor .d-editor button.local-dates"
);
assert.ok(
exists(".discourse-local-dates-create-modal.modal-body"),
exists(".d-modal.discourse-local-dates-create-modal"),
"Insert date-time modal visible"
);
assert.ok(
!exists(
".discourse-local-dates-create-modal.modal-body .advanced-options"
".discourse-local-dates-create-modal .d-modal__body .advanced-options"
),
"Advanced mode not visible"
);
await click(".modal-footer button.advanced-mode-btn");
await click(".d-modal__footer button.advanced-mode-btn");
assert.ok(
exists(
".discourse-local-dates-create-modal.modal-body .advanced-options"
".discourse-local-dates-create-modal .d-modal__body .advanced-options"
),
"Advanced mode is visible"
);
await click(".modal-footer button.btn-primary");
await click(".d-modal__footer button.btn-primary");
assert.ok(
exists(
".wizard-custom-step .wizard-text-editor .d-editor-preview-wrapper span.discourse-local-date"
@ -287,7 +309,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
"clear button is not rendered"
);
const fieldOneText = "step_1_field_1 (step_1_field_1)";
const fieldOneBtn = find(`.field button:contains(${fieldOneText})`);
const fieldOneBtn = queryAll(`.field button:contains(${fieldOneText})`);
assert.equal(fieldOneBtn.length, 1, "Creating a field");
const fieldTitle = "field title";
await fillIn(".wizard-custom-field input[name='label']", fieldTitle);
@ -331,13 +353,13 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
"Text tipe for field correctly selected"
);
assert.equal(
find(".wizard-subscription-container").length,
queryAll(".wizard-subscription-container").length,
3,
"Field subscription features are not accesible"
);
await click(".action .link-list button");
const actionOneText = "action_1 (action_1)";
const actionOneBtn = find(`.action button:contains(${actionOneText})`);
const actionOneBtn = queryAll(`.action button:contains(${actionOneText})`);
assert.equal(actionOneBtn.length, 1, "Creating an action");
assert.ok(
query(
@ -349,10 +371,10 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
".wizard-custom-action .setting-value .select-kit"
);
await actionTypeDropdown.expand();
const listEnabled = findAll(
const listEnabled = queryAll(
".wizard-custom-action .setting .setting-value ul li:not(.disabled)"
);
const listDisabled = findAll(
const listDisabled = queryAll(
".wizard-custom-action .setting .setting-value ul li.disabled"
);
assert.ok(
@ -370,7 +392,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
),
"Create type action correctly selected"
);
let listTopicSettings = findAll(
let listTopicSettings = queryAll(
".admin-wizard-container .wizard-custom-action .setting"
);
assert.ok(
@ -379,7 +401,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("open_composer");
listTopicSettings = findAll(
listTopicSettings = queryAll(
".admin-wizard-container .wizard-custom-action .setting"
);
assert.ok(
@ -388,7 +410,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("update_profile");
listTopicSettings = findAll(
listTopicSettings = queryAll(
".admin-wizard-container .wizard-custom-action .setting"
);
assert.ok(
@ -397,7 +419,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
);
await actionTypeDropdown.expand();
await actionTypeDropdown.selectRowByValue("route_to");
listTopicSettings = findAll(
listTopicSettings = queryAll(
".admin-wizard-container .wizard-custom-action .setting"
);
assert.ok(
@ -406,7 +428,7 @@ acceptance("Admin | Custom Wizard Unsuscribed", function (needs) {
);
await actionTypeDropdown.expand();
await click('[data-name="Select a type"]');
listTopicSettings = findAll(
listTopicSettings = queryAll(
".admin-wizard-container .wizard-custom-action .setting"
);
assert.ok(

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen