1
0
Fork 0

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")
subscribedIcon(subscribed) {
return subscribed ? "check" : "dash";
return subscribed ? "check" : "times";
},
@discourseComputed("subscribed")

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -40,7 +40,12 @@
</div>
{{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>
{{/if}}
</div>

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -3,9 +3,10 @@
<label>{{i18n "admin.wizard.step.title"}}</label>
</div>
<div class="setting-value">
{{input
<Input
name="title"
value=step.title}}
@value={{this.step.title}}
/>
</div>
</div>
@ -51,7 +52,10 @@
<div class="setting-label"></div>
<div class="setting-value force-final">
<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>
</div>
</div>
@ -77,7 +81,9 @@
<div class="label">
{{i18n "admin.wizard.step.required_data.not_permitted_message"}}
</div>
{{input value=step.required_data_message}}
<Input
@value={{this.step.required_data_message}}
/>
</div>
{{/if}}
</div>

Datei anzeigen

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

Datei anzeigen

@ -7,7 +7,10 @@
<li>
<span class="setting-title">
<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"}}
</span>
<div class="validation-container">
@ -27,7 +30,11 @@
<label>{{i18n "admin.wizard.field.validations.max_topic_age"}}</label>
</div>
<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
value=(readonly props.time_unit)
content=timeUnits

Datei anzeigen

@ -456,11 +456,16 @@ class CustomWizard::Action
if new_group_params[:usernames].present?
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.each { |user_id| group.group_users.build(user_id: user_id) }
end
if group.save
log_success("Group created", group.name)
end
result.output = group.name
else

Datei anzeigen

@ -1,15 +1,15 @@
# frozen_string_literal: true
# name: discourse-custom-wizard
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
# version: 2.2.20
# version: 2.3.2
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever
# url: https://github.com/paviliondev/discourse-custom-wizard
# contact_emails: development@pavilion.tech
# subscription_url: https://coop.pavilion.tech
gem 'liquid', '5.0.1', require: true
register_asset 'stylesheets/common/admin.scss'
register_asset 'stylesheets/common/wizard.scss'
gem "liquid", "5.0.1", require: true
register_asset "stylesheets/common/admin.scss"
register_asset "stylesheets/common/wizard.scss"
enabled_site_setting :custom_wizard_enabled
@ -111,7 +111,7 @@ after_initialize do
Liquid::Template.register_filter(::CustomWizard::LiquidFilter::FirstNonEmpty)
add_to_class(:topic, :wizard_submission_id) do
custom_fields['wizard_submission_id']
custom_fields["wizard_submission_id"]
end
add_class_method(:wizard, :user_requires_completion?) do |user|
@ -123,7 +123,6 @@ after_initialize do
if user &&
user.first_seen_at.blank? &&
wizard = CustomWizard::Wizard.after_signup(user)
if !wizard.completed?
custom_redirect = true
CustomWizard::Wizard.set_user_redirect(wizard.id, user)
@ -134,8 +133,8 @@ after_initialize do
end
add_to_class(:user, :redirect_to_wizard) do
if custom_fields['redirect_to_wizard'].present?
custom_fields['redirect_to_wizard']
if custom_fields["redirect_to_wizard"].present?
custom_fields["redirect_to_wizard"]
else
nil
end
@ -160,10 +159,10 @@ after_initialize do
end
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
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
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"
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
# legacy method, Discourse 2.7.0.beta5 and below
DiscoursePluginRegistry.register_asset(full_path, {}, "wizard_custom")

Datei anzeigen

@ -2,6 +2,7 @@
describe CustomWizard::Action do
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!(:tag) { Fabricate(:tag, name: 'tag1') }
fab!(:group) { Fabricate(:group) }
@ -12,6 +13,7 @@ describe CustomWizard::Action do
let(:watch_categories) { get_wizard_fixture("actions/watch_categories") }
let(:watch_tags) { get_wizard_fixture("actions/watch_tags") }
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(:send_message) { get_wizard_fixture("actions/send_message") }
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.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(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
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"
}
]
}