1
0
Fork 0

Commits vergleichen

...

16 Commits

Autor SHA1 Nachricht Datum
Faizaan Gagan
9e76acbd66 FIX: checkout correct branches of plugin and discourse (#182)
* FIX: checkout correct branches of plugin and discourse

* add condition to check correct discourse branch

* FIX: use updated redis version

* bump patch version
2022-02-16 19:52:58 +05:30
Faizaan Gagan
c6ec744b13 bump version, cleanup 2022-02-09 12:03:17 +05:30
Angus McLeod
ec78229ba0 FIX: use request_store properly 2022-02-09 11:59:00 +05:30
Angus McLeod
5360cef214 Update plugin.rb 2022-02-09 11:58:23 +05:30
Faizaan Gagan
86ff55c33a FEATURE: allow tags from tag field to be confined to a tag group (#175)
* FEATURE: allow tag field to be confined to a tag group

* fixed linting

* bump minor version

* moved monkeypatch to a separate module

* use snake case for variable names

* added specs
2022-02-07 16:00:25 +05:30
angusmcleod
52fe6e2baa Merge branch 'main' into stable 2022-01-31 21:50:12 +08:00
Angus McLeod
ecd1fdc5c7 FEATURE: Wizard Composer Mentionables Integration 2021-10-14 18:27:38 +05:30
Faizaan Gagan
d696ccd982 Bump version according to policy 2021-10-06 15:36:15 +05:30
angusmcleod
8770266d3e DEV: add stable to github workflows
(cherry picked from commit d4c25d406b)
2021-10-06 17:49:53 +08:00
angusmcleod
f537d8504b COMPATIBILITY: require all mixins for forwards compatibility 2021-10-05 11:55:20 +08:00
angusmcleod
72778884fa DEV: Update stable coverage percent 2021-10-05 10:51:10 +08:00
angusmcleod
f13b017b83 COMPATIBILITY: backwards compatibility for wizard spec 2021-10-05 10:38:41 +08:00
angusmcleod
76c2fd511c DEV: remove group log settings change from create_group action
(cherry picked from commit 1edfcca78b)
2021-10-05 10:25:23 +08:00
angusmcleod
95b0758647 COMPATIBILITY: Add backwards compatibility for category serialization 2021-10-05 10:07:21 +08:00
Faizaan Gagan
21cf81b7a5 FEATURE: add resume wizard popup (#146)
* FEATURE: add resume wizard popup

* code cleanup, copy edits

* FIX: address functionality, setting and copy issues

@fzngagan a few issues fixed

1. The resume button wasn't working (old reference to ``resumeDialog`` remained in callback.
2. This needs a wizard setting
3. It's not necessary to serialize the first step separately. We have all the steps in ``steps`` and steps have indexes.
4. Button copy

* Fix linting

* Ensure aa submission exists

* Apply prettier

Co-authored-by: angusmcleod <angus@mcleod.org.au>
(cherry picked from commit 2678ee153d)
2021-10-05 09:18:18 +08:00
angusmcleod
de2faf893f FIX: Minor bugfixes in manager and create_group action
(cherry picked from commit 208cb1229a)
2021-10-05 09:17:13 +08:00
16 geänderte Dateien mit 153 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -31,7 +31,7 @@ jobs:
build_type: ["backend", "frontend"]
ruby: ["2.7"]
postgres: ["12"]
redis: ["4.x"]
redis: ["6.x"]
services:
postgres:
@ -49,10 +49,17 @@ jobs:
--health-retries 5
steps:
- uses: haya14busa/action-cond@v1
id: discourse_branch
with:
cond: ${{ github.base_ref == 'stable' }}
if_true: "stable"
if_false: "tests-passed"
- uses: actions/checkout@v2
with:
repository: discourse/discourse
ref: "${{ (github.base_ref || github.ref) }}"
ref: ${{ steps.discourse_branch.outputs.value }}
fetch-depth: 1
- name: Fetch Repo Name
@ -63,6 +70,7 @@ jobs:
uses: actions/checkout@v2
with:
path: plugins/${{ steps.repo-name.outputs.value }}
ref: "${{ github.base_ref }}"
fetch-depth: 1
- name: Check spec existence

Datei anzeigen

@ -208,6 +208,20 @@
</div>
{{/if}}
{{#if isTag}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.field.tag_groups"}}</label>
</div>
<div class="setting-value">
{{tag-group-chooser
tagGroups=field.tag_groups
}}
</div>
</div>
{{/if}}
{{#if showAdvanced}}
{{wizard-advanced-toggle showAdvanced=field.showAdvanced}}

Datei anzeigen

@ -0,0 +1,12 @@
import TagChooser from "select-kit/components/tag-chooser";
export default TagChooser.extend({
searchTags(url, data, callback) {
if (this.tagGroups) {
let tagGroupsString = this.tagGroups.join(",");
data.tag_groups = tagGroupsString;
}
return this._super(url, data, callback);
},
});

Datei anzeigen

@ -40,6 +40,12 @@ CustomWizard.reopenClass({
.catch(popupAjaxError);
},
restart(wizardId) {
ajax({ url: `/w/${wizardId}/skip`, type: "PUT" }).then(() => {
window.location.href = `/w/${wizardId}`;
});
},
finished(result) {
let url = "/";
if (result.redirect_on_complete) {

Datei anzeigen

@ -1 +1,7 @@
{{tag-chooser tags=field.value maximum=field.limit tabindex=field.tabindex everyTag=true}}
{{wizard-tag-chooser
tags=field.value
maximum=field.limit
tabindex=field.tabindex
tagGroups=field.tag_groups
everyTag=true
}}

Datei anzeigen

@ -188,6 +188,7 @@ en:
property: "Property"
prefill: "Prefill"
content: "Content"
tag_groups: "Tag Groups"
date_time_format:
label: "Format"
instructions: "<a href='https://momentjs.com/docs/#/displaying/format/' target='_blank'>Moment.js format</a>"

Datei anzeigen

@ -117,6 +117,7 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
condition: mapped_params,
index: mapped_params,
validations: {},
tag_groups: [],
]
],
actions: [

Datei anzeigen

@ -0,0 +1,18 @@
# frozen_string_literal: true
require 'request_store'
module CustomWizardDiscourseTagging
def filter_allowed_tags(guardian, opts = {})
if tag_groups = ::RequestStore.store[:tag_groups]
tag_group_array = tag_groups.split(",")
filtered_tags = TagGroup.includes(:tags).where(name: tag_group_array).map do |tag_group|
tag_group.tags.pluck(:name)
end.flatten
opts[:only_tag_names] ||= []
opts[:only_tag_names].push(*filtered_tags)
end
super
end
end

Datei anzeigen

@ -0,0 +1,9 @@
# frozen_string_literal: true
require 'request_store'
module CustomWizardTagsController
def search
::RequestStore.store[:tag_groups] = params[:tag_groups] if params[:tag_groups].present?
super
end
end

Datei anzeigen

@ -86,7 +86,7 @@ class CustomWizard::Builder
required: field_template['required']
}
%w(label description image key validations min_length max_length char_counter).each do |key|
%w(label description image key validations min_length max_length char_counter tag_groups).each do |key|
params[key.to_sym] = field_template[key] if field_template[key]
end

Datei anzeigen

@ -21,6 +21,7 @@ class CustomWizard::Field
:limit,
:property,
:content,
:tag_groups,
:preview_template,
:placeholder
@ -46,6 +47,7 @@ class CustomWizard::Field
@limit = attrs[:limit]
@property = attrs[:property]
@content = attrs[:content]
@tag_groups = attrs[:tag_groups]
@preview_template = attrs[:preview_template]
@placeholder = attrs[:placeholder]
end
@ -111,7 +113,8 @@ class CustomWizard::Field
tag: {
limit: nil,
prefill: nil,
content: nil
content: nil,
tag_groups: nil
},
category: {
limit: 1,

Datei anzeigen

@ -1,12 +1,13 @@
# frozen_string_literal: true
# name: discourse-custom-wizard
# about: Create custom wizards
# version: 1.17.2
# version: 1.18.2.stable
# authors: Angus McLeod
# url: https://github.com/paviliondev/discourse-custom-wizard
# contact emails: angus@thepavilion.io
gem 'liquid', '5.0.1', require: true
register_asset 'stylesheets/common/wizard-admin.scss'
register_asset 'stylesheets/common/wizard-mapper.scss'
@ -110,9 +111,11 @@ after_initialize do
../extensions/invites_controller.rb
../extensions/guardian.rb
../extensions/users_controller.rb
../extensions/tags_controller.rb
../extensions/custom_field/preloader.rb
../extensions/custom_field/serializer.rb
../extensions/custom_field/extension.rb
../extensions/discourse_tagging.rb
].each do |path|
load File.expand_path(path, __FILE__)
end
@ -249,5 +252,10 @@ after_initialize do
"#{serializer_klass}_serializer".classify.constantize.prepend CustomWizardCustomFieldSerializer
end
reloadable_patch do |plugin|
::TagsController.prepend CustomWizardTagsController
::DiscourseTagging.singleton_class.prepend CustomWizardDiscourseTagging
end
DiscourseEvent.trigger(:custom_wizard_ready)
end

Datei anzeigen

@ -16,6 +16,7 @@ class CustomWizard::FieldSerializer < ::ApplicationSerializer
:limit,
:property,
:content,
:tag_groups,
:validations,
:max_length,
:char_counter,
@ -100,6 +101,10 @@ class CustomWizard::FieldSerializer < ::ApplicationSerializer
object.content
end
def content
object.tag_groups
end
def validations
validations = {}
object.validations&.each do |type, props|

Datei anzeigen

@ -64,6 +64,12 @@ class CustomWizard::WizardSerializer < CustomWizard::BasicWizardSerializer
end
def categories
object.categories.map { |c| c.to_h }
object.categories.map do |category|
if category.respond_to?(:to_h)
category.to_h
else
::BasicCategorySerializer.new(category).as_json
end
end
end
end

Datei anzeigen

@ -199,7 +199,7 @@ describe CustomWizard::Wizard do
end
it "lists the site categories" do
Site.clear_cache
Site.clear_cache if Site.respond_to?(:clear_cache)
expect(@wizard.categories.length).to eq(1)
end

Datei anzeigen

@ -0,0 +1,48 @@
# frozen_string_literal: true
require_relative '../plugin_helper'
describe ::TagsController, type: :request do
fab!(:tag_1) { Fabricate(:tag, name: "Angus") }
fab!(:tag_2) { Fabricate(:tag, name: "Faizaan") }
fab!(:tag_3) { Fabricate(:tag, name: "Robert") }
fab!(:tag_4) { Fabricate(:tag, name: "Eli") }
fab!(:tag_5) { Fabricate(:tag, name: "Jeff") }
fab!(:tag_group_1) { Fabricate(:tag_group, tags: [tag_1, tag_2]) }
fab!(:tag_group_2) { Fabricate(:tag_group, tags: [tag_3, tag_4]) }
before do
::RequestStore.store[:tag_groups] = nil
end
describe "#search" do
context "tag group param present" do
it "returns tags only in the tag group" do
get "/tags/filter/search.json", params: { q: '', tag_groups: [tag_group_1.name, tag_group_2.name] }
expect(response.status).to eq(200)
results = response.parsed_body['results']
names = results.map { |result| result['name'] }
expected_tag_names = TagGroup
.includes(:tags)
.where(id: [tag_group_1.id, tag_group_2.id])
.map { |tag_group| tag_group.tags.pluck(:name) }.flatten
expect(names).to contain_exactly(*expected_tag_names)
end
end
context "tag group param not present" do
it "returns all tags" do
get "/tags/filter/search.json", params: { q: '' }
expect(response.status).to eq(200)
results = response.parsed_body['results']
names = results.map { |result| result['name'] }
all_tag_names = Tag.all.pluck(:name)
expect(names).to contain_exactly(*all_tag_names)
end
end
end
end