0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 17:30:29 +01:00

Merge branch 'main' into admin-acceptance-tests

Dieser Commit ist enthalten in:
jumagura 2023-04-17 11:56:31 -04:00
Commit 54ad75bafd
17 geänderte Dateien mit 349 neuen und 96 gelöschten Zeilen

Datei anzeigen

@ -7,7 +7,7 @@ export default Component.extend(Subscription, {
@discourseComputed("subscribed") @discourseComputed("subscribed")
subscribedIcon(subscribed) { subscribedIcon(subscribed) {
return subscribed ? "check" : "dash"; return subscribed ? "check" : "times";
}, },
@discourseComputed("subscribed") @discourseComputed("subscribed")

Datei anzeigen

@ -1,6 +1,8 @@
import I18n from "I18n"; import I18n from "I18n";
import { getCachedWizard } from "../models/custom-wizard"; import { getCachedWizard } from "../models/custom-wizard";
import Route from "@ember/routing/route"; import Route from "@ember/routing/route";
import { scrollTop } from "discourse/mixins/scroll-top";
import { action } from "@ember/object";
export default Route.extend({ export default Route.extend({
beforeModel() { beforeModel() {
@ -48,4 +50,10 @@ export default Route.extend({
controller.setProperties(props); controller.setProperties(props);
}, },
@action
didTransition() {
scrollTop();
return true;
},
}); });

Datei anzeigen

@ -32,13 +32,19 @@
<div class="metadata"> <div class="metadata">
<div class="title"> <div class="title">
<label>{{i18n "admin.wizard.api.title"}}</label> <label>{{i18n "admin.wizard.api.title"}}</label>
{{input value=api.title placeholder=(i18n "admin.wizard.api.title_placeholder")}} <Input
@value={{this.api.title}}
placeholder={{i18n "admin.wizard.api.title_placeholder"}}
/>
</div> </div>
<div class="name {{nameClass}}"> <div class="name {{nameClass}}">
<label>{{i18n "admin.wizard.api.name"}}</label> <label>{{i18n "admin.wizard.api.name"}}</label>
{{#if api.isNew}} {{#if api.isNew}}
{{input value=api.name placeholder=(i18n "admin.wizard.api.name_placeholder")}} <Input
@value={{this.api.name}}
placeholder={{i18n "admin.wizard.api.name_placeholder"}}
/>
{{else}} {{else}}
<span>{{api.name}}</span> <span>{{api.name}}</span>
{{/if}} {{/if}}
@ -104,7 +110,9 @@
<div class="control-group"> <div class="control-group">
<label>{{i18n "admin.wizard.api.auth.url"}}</label> <label>{{i18n "admin.wizard.api.auth.url"}}</label>
<div class="controls"> <div class="controls">
{{input value=api.authUrl}} <Input
@value={{this.api.authUrl}}
/>
</div> </div>
</div> </div>
{{/if}} {{/if}}
@ -112,21 +120,27 @@
<div class="control-group"> <div class="control-group">
<label>{{i18n "admin.wizard.api.auth.token_url"}}</label> <label>{{i18n "admin.wizard.api.auth.token_url"}}</label>
<div class="controls"> <div class="controls">
{{input value=api.tokenUrl}} <Input
@value={{this.api.tokenUrl}}
/>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label>{{i18n "admin.wizard.api.auth.client_id"}}</label> <label>{{i18n "admin.wizard.api.auth.client_id"}}</label>
<div class="controls"> <div class="controls">
{{input value=api.clientId}} <Input
@value={{this.api.clientId}}
/>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label>{{i18n "admin.wizard.api.auth.client_secret"}}</label> <label>{{i18n "admin.wizard.api.auth.client_secret"}}</label>
<div class="controls"> <div class="controls">
{{input value=api.clientSecret}} <Input
@value={{this.api.clientSecret}}
/>
</div> </div>
</div> </div>
@ -135,8 +149,14 @@
<div class="controls"> <div class="controls">
{{#each api.authParams as |param|}} {{#each api.authParams as |param|}}
<div class="param"> <div class="param">
{{input value=param.key placeholder=(i18n "admin.wizard.key")}} <Input
{{input value=param.value placeholder=(i18n "admin.wizard.value")}} @value={{this.param.key}}
placeholder={{i18n "admin.wizard.key"}}
/>
<Input
@value={{this.param.value}}
placeholder={{i18n "admin.wizard.value"}}
/>
{{d-button action=(action "removeParam") actionParam=param icon="times"}} {{d-button action=(action "removeParam") actionParam=param icon="times"}}
</div> </div>
{{/each}} {{/each}}
@ -149,14 +169,18 @@
<div class="control-group"> <div class="control-group">
<label>{{i18n "admin.wizard.api.auth.username"}}</label> <label>{{i18n "admin.wizard.api.auth.username"}}</label>
<div class="controls"> <div class="controls">
{{input value=api.username}} <Input
@value={{this.api.username}}
/>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label>{{i18n "admin.wizard.api.auth.password"}}</label> <label>{{i18n "admin.wizard.api.auth.password"}}</label>
<div class="controls"> <div class="controls">
{{input value=api.password}} <Input
@value={{this.api.password}}
/>
</div> </div>
</div> </div>
{{/if}} {{/if}}
@ -235,11 +259,15 @@
<div class="endpoint"> <div class="endpoint">
<div class="endpoint-"> <div class="endpoint-">
<div class="top"> <div class="top">
{{input value=endpoint.name <Input
placeholder=(i18n "admin.wizard.api.endpoint.name")}} @value={{this.endpoint.name}}
{{input value=endpoint.url placeholder={{i18n "admin.wizard.api.endpoint.name"}}
placeholder=(i18n "admin.wizard.api.endpoint.url") />
class="endpoint-url"}} <Input
@value={{this.endpoint.url}}
placeholder={{i18n "admin.wizard.api.endpoint.url"}}
class="endpoint-url"
/>
{{d-button action=(action "removeEndpoint") {{d-button action=(action "removeEndpoint")
actionParam=endpoint actionParam=endpoint
icon="times" icon="times"

Datei anzeigen

@ -11,11 +11,12 @@
</div> </div>
{{/if}} {{/if}}
{{input <Input
id="custom-wizard-file-upload" id="custom-wizard-file-upload"
type="file" @type="file"
accept="application/json" accept="application/json"
input=(action "setFile")}} {{on "input" (action "setFile")}}
/>
{{d-button {{d-button
id="upload-button" id="upload-button"
label="admin.wizard.manager.upload" label="admin.wizard.manager.upload"
@ -65,16 +66,18 @@
{{/link-to}} {{/link-to}}
</td> </td>
<td class="control-column"> <td class="control-column">
{{input <Input
type="checkbox" @type="checkbox"
class="export" class="export"
change=(action "selectWizard")}} {{on "change" (action "selectWizard")}}
/>
</td> </td>
<td class="control-column"> <td class="control-column">
{{input <Input
type="checkbox" @type="checkbox"
class="destroy" class="destroy"
change=(action "selectWizard")}} {{on "change" (action "selectWizard")}}
/>
</td> </td>
</tr> </tr>
{{/each}} {{/each}}

Datei anzeigen

@ -1,9 +1,10 @@
{{#if wizard}} {{#if wizard}}
<div class="wizard-header large"> <div class="wizard-header large">
{{input <Input
@value={{this.wizard.name}}
name="name" name="name"
value=wizard.name placeholder={{i18n "admin.wizard.name_placeholder"}}
placeholderKey="admin.wizard.name_placeholder"}} />
<div class="wizard-url"> <div class="wizard-url">
{{#if wizard.name}} {{#if wizard.name}}
@ -23,11 +24,12 @@
<label>{{i18n "admin.wizard.background"}}</label> <label>{{i18n "admin.wizard.background"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input <Input
@value={{this.wizard.background}}
name="background" name="background"
value=wizard.background placeholder={{i18n "admin.wizard.background_placeholder"}}
placeholderKey="admin.wizard.background_placeholder" class="small"
class="small"}} />
</div> </div>
</div> </div>
@ -58,7 +60,10 @@
<label>{{i18n "admin.wizard.save_submissions"}}</label> <label>{{i18n "admin.wizard.save_submissions"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="checkbox" checked=wizard.save_submissions}} <Input
@type="checkbox"
@checked={{this.wizard.save_submissions}}
/>
<span>{{i18n "admin.wizard.save_submissions_label"}}</span> <span>{{i18n "admin.wizard.save_submissions_label"}}</span>
</div> </div>
</div> </div>
@ -68,7 +73,10 @@
<label>{{i18n "admin.wizard.multiple_submissions"}}</label> <label>{{i18n "admin.wizard.multiple_submissions"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="checkbox" checked=wizard.multiple_submissions}} <Input
@type="checkbox"
@checked={{this.wizard.multiple_submissions}}
/>
<span>{{i18n "admin.wizard.multiple_submissions_label"}}</span> <span>{{i18n "admin.wizard.multiple_submissions_label"}}</span>
</div> </div>
</div> </div>
@ -78,7 +86,10 @@
<label>{{i18n "admin.wizard.after_signup"}}</label> <label>{{i18n "admin.wizard.after_signup"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="checkbox" checked=wizard.after_signup}} <Input
@type="checkbox"
@checked={{this.wizard.after_signup}}
/>
<span>{{i18n "admin.wizard.after_signup_label"}}</span> <span>{{i18n "admin.wizard.after_signup_label"}}</span>
</div> </div>
</div> </div>
@ -88,7 +99,10 @@
<label>{{i18n "admin.wizard.prompt_completion"}}</label> <label>{{i18n "admin.wizard.prompt_completion"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="checkbox" checked=wizard.prompt_completion}} <Input
@type="checkbox"
@checked={{this.wizard.prompt_completion}}
/>
<span>{{i18n "admin.wizard.prompt_completion_label"}}</span> <span>{{i18n "admin.wizard.prompt_completion_label"}}</span>
</div> </div>
</div> </div>
@ -98,7 +112,10 @@
<label>{{i18n "admin.wizard.after_time"}}</label> <label>{{i18n "admin.wizard.after_time"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="checkbox" checked=wizard.after_time}} <Input
@type="checkbox"
@checked={{this.wizard.after_time}}
/>
<span>{{i18n "admin.wizard.after_time_label"}}</span> <span>{{i18n "admin.wizard.after_time_label"}}</span>
{{d-button {{d-button
action=(action "setNextSessionScheduled") action=(action "setNextSessionScheduled")
@ -114,7 +131,10 @@
<label>{{i18n "admin.wizard.required"}}</label> <label>{{i18n "admin.wizard.required"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="checkbox" checked=wizard.required}} <Input
@type="checkbox"
@checked={{this.wizard.required}}
/>
<span>{{i18n "admin.wizard.required_label"}}</span> <span>{{i18n "admin.wizard.required_label"}}</span>
</div> </div>
</div> </div>
@ -124,7 +144,10 @@
<label>{{i18n "admin.wizard.restart_on_revisit"}}</label> <label>{{i18n "admin.wizard.restart_on_revisit"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="checkbox" checked=wizard.restart_on_revisit}} <Input
@type="checkbox"
@checked={{this.wizard.restart_on_revisit}}
/>
<span>{{i18n "admin.wizard.restart_on_revisit_label"}}</span> <span>{{i18n "admin.wizard.restart_on_revisit_label"}}</span>
</div> </div>
</div> </div>

Datei anzeigen

@ -20,9 +20,10 @@
)}} )}}
</td> </td>
<td class="input"> <td class="input">
{{input <Input
value=field.name @value={{this.field.name}}
placeholder=(i18n "admin.wizard.custom_field.name.select")}} placeholder={{i18n "admin.wizard.custom_field.name.select"}}
/>
</td> </td>
<td class="multi-select"> <td class="multi-select">
{{multi-select {{multi-select

Datei anzeigen

@ -40,7 +40,12 @@
</div> </div>
{{conditional-loading-spinner condition=loading}} {{conditional-loading-spinner condition=loading}}
{{textarea tabindex=tabindex value=value class="d-editor-input" placeholder=placeholder}} <Textarea
tabindex={{this.tabindex}}
@value={{this.value}}
class="d-editor-input"
placeholder={{this.placeholder}}
/>
</div> </div>
{{/if}} {{/if}}
</div> </div>

Datei anzeigen

@ -15,6 +15,6 @@
</button> </button>
{{#if field.char_counter}} {{#if field.char_counter}}
{{char-counter field.value field.max_length}} {{wizard-char-counter field.value field.max_length}}
{{/if}} {{/if}}
</div> </div>

Datei anzeigen

@ -79,7 +79,10 @@
)}} )}}
<div class="setting-gutter"> <div class="setting-gutter">
{{input type="checkbox" checked=action.post_builder}} <Input
@type="checkbox"
@checked={{this.action.post_builder}}
/>
<span>{{i18n "admin.wizard.action.post_builder.checkbox"}}</span> <span>{{i18n "admin.wizard.action.post_builder.checkbox"}}</span>
</div> </div>
</div> </div>
@ -408,7 +411,10 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="checkbox" checked=action.wizard_user}} <Input
@type="checkbox"
@checked={{this.action.wizard_user}}
/>
</div> </div>
</div> </div>
@ -477,7 +483,10 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="checkbox" checked=action.wizard_user}} <Input
@type="checkbox"
@checked={{this.action.wizard_user}}
/>
</div> </div>
</div> </div>
@ -877,7 +886,10 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="checkbox" checked=action.skip_redirect}} <Input
@type="checkbox"
@checked={{this.action.skip_redirect}}
/>
<span> <span>
{{i18n "admin.wizard.action.skip_redirect.description" type="topic"}} {{i18n "admin.wizard.action.skip_redirect.description" type="topic"}}
@ -891,7 +903,10 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="checkbox" checked=action.suppress_notifications}} <Input
@type="checkbox"
@checked={{this.action.suppress_notifications}}
/>
<span> <span>
{{i18n "admin.wizard.action.suppress_notifications.description" type="topic"}} {{i18n "admin.wizard.action.suppress_notifications.description" type="topic"}}
@ -907,7 +922,7 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input value=action.code}} <Input @value={{this.action.code}} />
</div> </div>
</div> </div>
{{/if}} {{/if}}

Datei anzeigen

@ -11,7 +11,10 @@
<label>{{i18n "admin.wizard.field.label"}}</label> <label>{{i18n "admin.wizard.field.label"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input name="label" value=field.label}} <Input
name="label"
@value={{this.field.label}}
/>
</div> </div>
</div> </div>
@ -22,7 +25,10 @@
<div class="setting-value"> <div class="setting-value">
<span>{{i18n "admin.wizard.field.required_label"}}</span> <span>{{i18n "admin.wizard.field.required_label"}}</span>
{{input type="checkbox" checked=field.required}} <Input
@type="checkbox"
@checked={{this.field.required}}
/>
</div> </div>
</div> </div>
@ -31,7 +37,10 @@
<label>{{i18n "admin.wizard.field.description"}}</label> <label>{{i18n "admin.wizard.field.description"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{textarea name="description" value=field.description}} <Textarea
name="description"
@value={{this.field.description}}
/>
</div> </div>
</div> </div>
@ -78,11 +87,12 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input <Input
type="number" @type="number"
name="min_length" name="min_length"
value=field.min_length @value={{this.field.min_length}}
class="small"}} class="small"
/>
</div> </div>
</div> </div>
@ -92,11 +102,12 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input <Input
type="number" @type="number"
name="max_length" name="max_length"
value=field.max_length @value={{this.field.max_length}}
class="small"}} class="small"
/>
</div> </div>
</div> </div>
@ -107,9 +118,10 @@
<div class="setting-value"> <div class="setting-value">
<span>{{i18n "admin.wizard.field.char_counter_placeholder"}}</span> <span>{{i18n "admin.wizard.field.char_counter_placeholder"}}</span>
{{input <Input
type="checkbox" @type="checkbox"
checked=field.char_counter}} @checked={{this.field.char_counter}}
/>
</div> </div>
</div> </div>
@ -119,10 +131,11 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{textarea <Textarea
name="field_placeholder" name="field_placeholder"
class="medium" class="medium"
value=field.placeholder}} @value={{this.field.placeholder}}
/>
</div> </div>
</div> </div>
{{/if}} {{/if}}
@ -134,7 +147,11 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{textarea name="preview-template" value=field.preview_template class="preview-template"}} <Textarea
name="preview-template"
class="preview-template"
@value={{this.field.preview_template}}
/>
</div> </div>
</div> </div>
{{/if}} {{/if}}
@ -146,7 +163,10 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input value=field.file_types class="medium"}} <Input
@value={{this.field.file_types}}
class="medium"
/>
</div> </div>
</div> </div>
{{/if}} {{/if}}
@ -158,7 +178,11 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="number" value=field.limit class="small"}} <Input
@type="number"
@value={{this.field.limit}}
class="small"
/>
</div> </div>
</div> </div>
{{/if}} {{/if}}
@ -170,7 +194,10 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input value=field.format class="medium"}} <Input
@value={{this.field.format}}
class="medium"
/>
<label>{{html-safe (i18n "admin.wizard.field.date_time_format.instructions")}}</label> <label>{{html-safe (i18n "admin.wizard.field.date_time_format.instructions")}}</label>
</div> </div>
</div> </div>
@ -229,9 +256,10 @@
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input <Input
type="checkbox" @type="checkbox"
checked=field.can_create_tag}} @checked={{this.field.can_create_tag}}
/>
</div> </div>
</div> </div>
{{/if}} {{/if}}

Datei anzeigen

@ -3,9 +3,10 @@
<label>{{i18n "admin.wizard.step.title"}}</label> <label>{{i18n "admin.wizard.step.title"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input <Input
name="title" name="title"
value=step.title}} @value={{this.step.title}}
/>
</div> </div>
</div> </div>
@ -51,7 +52,10 @@
<div class="setting-label"></div> <div class="setting-label"></div>
<div class="setting-value force-final"> <div class="setting-value force-final">
<h4>{{i18n "admin.wizard.step.force_final.label"}}</h4> <h4>{{i18n "admin.wizard.step.force_final.label"}}</h4>
{{input type="checkbox" checked=step.force_final}} <Input
@type="checkbox"
@checked={{this.step.force_final}}
/>
<span>{{i18n "admin.wizard.step.force_final.description"}}</span> <span>{{i18n "admin.wizard.step.force_final.description"}}</span>
</div> </div>
</div> </div>
@ -77,7 +81,9 @@
<div class="label"> <div class="label">
{{i18n "admin.wizard.step.required_data.not_permitted_message"}} {{i18n "admin.wizard.step.required_data.not_permitted_message"}}
</div> </div>
{{input value=step.required_data_message}} <Input
@value={{this.step.required_data_message}}
/>
</div> </div>
{{/if}} {{/if}}
</div> </div>

Datei anzeigen

@ -21,11 +21,12 @@
<div class="input"> <div class="input">
{{#if showText}} {{#if showText}}
{{input <Input
type="text" @type="text"
value=value @value={{this.value}}
placeholder=(i18n placeholderKey) placeholder={{i18n placeholderKey}}
change=(action "changeInputValue")}} {{on "change" (action "changeInputValue")}}
/>
{{/if}} {{/if}}
{{#if showComboBox}} {{#if showComboBox}}

Datei anzeigen

@ -7,7 +7,10 @@
<li> <li>
<span class="setting-title"> <span class="setting-title">
<h4>{{i18n (concat "admin.wizard.field.validations." type)}}</h4> <h4>{{i18n (concat "admin.wizard.field.validations." type)}}</h4>
{{input type="checkbox" checked=props.status}} <Input
@type="checkbox"
@checked={{this.props.status}}
/>
{{i18n "admin.wizard.field.validations.enabled"}} {{i18n "admin.wizard.field.validations.enabled"}}
</span> </span>
<div class="validation-container"> <div class="validation-container">
@ -27,7 +30,11 @@
<label>{{i18n "admin.wizard.field.validations.max_topic_age"}}</label> <label>{{i18n "admin.wizard.field.validations.max_topic_age"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{input type="number" class="time-n-value" value=props.time_n_value}} <Input
@type="number"
@value={{this.props.time_n_value}}
class="time-n-value"
/>
{{combo-box {{combo-box
value=(readonly props.time_unit) value=(readonly props.time_unit)
content=timeUnits content=timeUnits

Datei anzeigen

@ -456,11 +456,16 @@ class CustomWizard::Action
if new_group_params[:usernames].present? if new_group_params[:usernames].present?
user_ids = get_user_ids(new_group_params[:usernames]) user_ids = get_user_ids(new_group_params[:usernames])
if user_ids.count < new_group_params[:usernames].count
log_error("Warning, group creation: some users were not found!")
end
user_ids -= owner_ids if owner_ids user_ids -= owner_ids if owner_ids
user_ids.each { |user_id| group.group_users.build(user_id: user_id) } user_ids.each { |user_id| group.group_users.build(user_id: user_id) }
end end
log_success("Group created", group.name) if group.save
log_success("Group created", group.name)
end
result.output = group.name result.output = group.name
else else

Datei anzeigen

@ -1,15 +1,15 @@
# frozen_string_literal: true # frozen_string_literal: true
# name: discourse-custom-wizard # name: discourse-custom-wizard
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more. # about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
# version: 2.2.20 # version: 2.3.2
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever
# url: https://github.com/paviliondev/discourse-custom-wizard # url: https://github.com/paviliondev/discourse-custom-wizard
# contact_emails: development@pavilion.tech # contact_emails: development@pavilion.tech
# subscription_url: https://coop.pavilion.tech # subscription_url: https://coop.pavilion.tech
gem 'liquid', '5.0.1', require: true gem "liquid", "5.0.1", require: true
register_asset 'stylesheets/common/admin.scss' register_asset "stylesheets/common/admin.scss"
register_asset 'stylesheets/common/wizard.scss' register_asset "stylesheets/common/wizard.scss"
enabled_site_setting :custom_wizard_enabled enabled_site_setting :custom_wizard_enabled
@ -111,7 +111,7 @@ after_initialize do
Liquid::Template.register_filter(::CustomWizard::LiquidFilter::FirstNonEmpty) Liquid::Template.register_filter(::CustomWizard::LiquidFilter::FirstNonEmpty)
add_to_class(:topic, :wizard_submission_id) do add_to_class(:topic, :wizard_submission_id) do
custom_fields['wizard_submission_id'] custom_fields["wizard_submission_id"]
end end
add_class_method(:wizard, :user_requires_completion?) do |user| add_class_method(:wizard, :user_requires_completion?) do |user|
@ -123,7 +123,6 @@ after_initialize do
if user && if user &&
user.first_seen_at.blank? && user.first_seen_at.blank? &&
wizard = CustomWizard::Wizard.after_signup(user) wizard = CustomWizard::Wizard.after_signup(user)
if !wizard.completed? if !wizard.completed?
custom_redirect = true custom_redirect = true
CustomWizard::Wizard.set_user_redirect(wizard.id, user) CustomWizard::Wizard.set_user_redirect(wizard.id, user)
@ -134,8 +133,8 @@ after_initialize do
end end
add_to_class(:user, :redirect_to_wizard) do add_to_class(:user, :redirect_to_wizard) do
if custom_fields['redirect_to_wizard'].present? if custom_fields["redirect_to_wizard"].present?
custom_fields['redirect_to_wizard'] custom_fields["redirect_to_wizard"]
else else
nil nil
end end
@ -160,10 +159,10 @@ after_initialize do
end end
add_to_class(:application_controller, :redirect_to_wizard_if_required) do add_to_class(:application_controller, :redirect_to_wizard_if_required) do
@excluded_routes ||= SiteSetting.wizard_redirect_exclude_paths.split('|') + ['/w/'] @excluded_routes ||= SiteSetting.wizard_redirect_exclude_paths.split("|") + ["/w/"]
url = request.referer || request.original_url url = request.referer || request.original_url
excluded_route = @excluded_routes.any? { |str| /#{str}/ =~ url } excluded_route = @excluded_routes.any? { |str| /#{str}/ =~ url }
not_api = request.format === 'text/html' not_api = request.format === "text/html"
if not_api && !excluded_route if not_api && !excluded_route
wizard_id = current_user.redirect_to_wizard wizard_id = current_user.redirect_to_wizard
@ -203,7 +202,7 @@ after_initialize do
full_path = "#{Rails.root}/plugins/discourse-custom-wizard/assets/stylesheets/wizard/wizard_custom.scss" full_path = "#{Rails.root}/plugins/discourse-custom-wizard/assets/stylesheets/wizard/wizard_custom.scss"
if Stylesheet::Importer.respond_to?(:plugin_assets) if Stylesheet::Importer.respond_to?(:plugin_assets)
Stylesheet::Importer.plugin_assets['wizard_custom'] = Set[full_path] Stylesheet::Importer.plugin_assets["wizard_custom"] = Set[full_path]
else else
# legacy method, Discourse 2.7.0.beta5 and below # legacy method, Discourse 2.7.0.beta5 and below
DiscoursePluginRegistry.register_asset(full_path, {}, "wizard_custom") DiscoursePluginRegistry.register_asset(full_path, {}, "wizard_custom")

Datei anzeigen

@ -2,6 +2,7 @@
describe CustomWizard::Action do describe CustomWizard::Action do
fab!(:user) { Fabricate(:user, name: "Angus", username: 'angus', email: "angus@email.com", trust_level: TrustLevel[2]) } fab!(:user) { Fabricate(:user, name: "Angus", username: 'angus', email: "angus@email.com", trust_level: TrustLevel[2]) }
fab!(:user1) { Fabricate(:user, name: "Angus One", username: 'angus1', email: "angus_one@email.com", trust_level: TrustLevel[2]) }
fab!(:category) { Fabricate(:category, name: 'cat1', slug: 'cat-slug') } fab!(:category) { Fabricate(:category, name: 'cat1', slug: 'cat-slug') }
fab!(:tag) { Fabricate(:tag, name: 'tag1') } fab!(:tag) { Fabricate(:tag, name: 'tag1') }
fab!(:group) { Fabricate(:group) } fab!(:group) { Fabricate(:group) }
@ -12,6 +13,7 @@ describe CustomWizard::Action do
let(:watch_categories) { get_wizard_fixture("actions/watch_categories") } let(:watch_categories) { get_wizard_fixture("actions/watch_categories") }
let(:watch_tags) { get_wizard_fixture("actions/watch_tags") } let(:watch_tags) { get_wizard_fixture("actions/watch_tags") }
let(:create_group) { get_wizard_fixture("actions/create_group") } let(:create_group) { get_wizard_fixture("actions/create_group") }
let(:create_group_with_nonexistent_user) { get_wizard_fixture("actions/create_group_bad_user") }
let(:add_to_group) { get_wizard_fixture("actions/add_to_group") } let(:add_to_group) { get_wizard_fixture("actions/add_to_group") }
let(:send_message) { get_wizard_fixture("actions/send_message") } let(:send_message) { get_wizard_fixture("actions/send_message") }
let(:send_message_multi) { get_wizard_fixture("actions/send_message_multi") } let(:send_message_multi) { get_wizard_fixture("actions/send_message_multi") }
@ -350,7 +352,25 @@ describe CustomWizard::Action do
wizard = CustomWizard::Builder.new(@template[:id], user).build wizard = CustomWizard::Builder.new(@template[:id], user).build
wizard.create_updater(wizard.steps[0].id, step_1_field_1: "Text input").update wizard.create_updater(wizard.steps[0].id, step_1_field_1: "Text input").update
group_id = Group.where(name: wizard.current_submission.fields['action_9']).first.id
user_id = User.find_by(username: wizard_template['actions'][4]['usernames'][0]["output"][0]).id
expect(Group.where(name: wizard.current_submission.fields['action_9']).exists?).to eq(true) expect(Group.where(name: wizard.current_submission.fields['action_9']).exists?).to eq(true)
expect(GroupUser.where(group_id: group_id, user_id: user_id).exists?).to eq(true)
end
it '#create_group completes successfully when user included in usernames does not exist but excludes users who do not exist and includes warning in log' do
wizard_template['actions'] << create_group_with_nonexistent_user
update_template(wizard_template)
wizard = CustomWizard::Builder.new(@template[:id], user).build
wizard.create_updater(wizard.steps[0].id, step_1_field_1: "Text input").update
group_id = Group.where(name: wizard.current_submission.fields['action_9']).first.id
expect(CustomWizard::Log.list_query.all.last.value.include? "some users were not found").to eq(true)
expect(Group.where(name: wizard.current_submission.fields['action_9']).exists?).to eq(true)
expect(GroupUser.where(group_id: group_id).count).to eq(1)
end end
it '#add_to_group' do it '#add_to_group' do

Datei anzeigen

@ -0,0 +1,104 @@
{
"id": "action_9",
"run_after": "step_1",
"type": "create_group",
"title": [
{
"type": "assignment",
"output": "New Group Member",
"output_type": "text",
"output_connector": "set"
}
],
"custom_fields": [
{
"type": "association",
"pairs": [
{
"index": 0,
"key": "group_custom_field",
"key_type": "text",
"value": "step_3_field_1",
"value_type": "wizard_field",
"connector": "association"
}
]
}
],
"name": [
{
"type": "assignment",
"output": "step_1_field_1",
"output_type": "wizard_field",
"output_connector": "set"
}
],
"full_name": [
{
"type": "assignment",
"output": "step_1_field_1",
"output_type": "wizard_field",
"output_connector": "set"
}
],
"usernames": [
{
"type": "assignment",
"output_type": "user",
"output_connector": "set",
"output": [
"angus3"
]
}
],
"owner_usernames": [
{
"type": "assignment",
"output_type": "user",
"output_connector": "set",
"output": [
"angus"
]
}
],
"grant_trust_level": [
{
"type": "assignment",
"output": "3",
"output_type": "text",
"output_connector": "set"
}
],
"mentionable_level": [
{
"type": "assignment",
"output": "1",
"output_type": "text",
"output_connector": "set"
}
],
"messageable_level": [
{
"type": "assignment",
"output": "2",
"output_type": "text",
"output_connector": "set"
}
],
"visibility_level": [
{
"type": "assignment",
"output": "3",
"output_type": "text",
"output_connector": "set"
}
],
"members_visibility_level": [
{
"type": "assignment",
"output": "99",
"output_type": "text",
"output_connector": "set"
}
]
}