mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 13:06:56 +08:00
DEV: add an option in user-chooser to list staged users (#13201)
* DEV: add an option in user-chooser to list staged users * included rspec tests * force boolean
This commit is contained in:
@ -21,6 +21,7 @@ function performSearch(
|
|||||||
includeMessageableGroups,
|
includeMessageableGroups,
|
||||||
allowedUsers,
|
allowedUsers,
|
||||||
groupMembersOf,
|
groupMembersOf,
|
||||||
|
includeStagedUsers,
|
||||||
resultsFn
|
resultsFn
|
||||||
) {
|
) {
|
||||||
let cached = cache[term];
|
let cached = cache[term];
|
||||||
@ -49,6 +50,7 @@ function performSearch(
|
|||||||
include_messageable_groups: includeMessageableGroups,
|
include_messageable_groups: includeMessageableGroups,
|
||||||
groups: groupMembersOf,
|
groups: groupMembersOf,
|
||||||
topic_allowed_users: allowedUsers,
|
topic_allowed_users: allowedUsers,
|
||||||
|
include_staged_users: includeStagedUsers,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -90,6 +92,7 @@ let debouncedSearch = function (
|
|||||||
includeMessageableGroups,
|
includeMessageableGroups,
|
||||||
allowedUsers,
|
allowedUsers,
|
||||||
groupMembersOf,
|
groupMembersOf,
|
||||||
|
includeStagedUsers,
|
||||||
resultsFn
|
resultsFn
|
||||||
) {
|
) {
|
||||||
discourseDebounce(
|
discourseDebounce(
|
||||||
@ -103,6 +106,7 @@ let debouncedSearch = function (
|
|||||||
includeMessageableGroups,
|
includeMessageableGroups,
|
||||||
allowedUsers,
|
allowedUsers,
|
||||||
groupMembersOf,
|
groupMembersOf,
|
||||||
|
includeStagedUsers,
|
||||||
resultsFn,
|
resultsFn,
|
||||||
300
|
300
|
||||||
);
|
);
|
||||||
@ -189,7 +193,8 @@ export default function userSearch(options) {
|
|||||||
allowedUsers = options.allowedUsers,
|
allowedUsers = options.allowedUsers,
|
||||||
topicId = options.topicId,
|
topicId = options.topicId,
|
||||||
categoryId = options.categoryId,
|
categoryId = options.categoryId,
|
||||||
groupMembersOf = options.groupMembersOf;
|
groupMembersOf = options.groupMembersOf,
|
||||||
|
includeStagedUsers = options.includeStagedUsers;
|
||||||
|
|
||||||
if (oldSearch) {
|
if (oldSearch) {
|
||||||
oldSearch.abort();
|
oldSearch.abort();
|
||||||
@ -226,6 +231,7 @@ export default function userSearch(options) {
|
|||||||
includeMessageableGroups,
|
includeMessageableGroups,
|
||||||
allowedUsers,
|
allowedUsers,
|
||||||
groupMembersOf,
|
groupMembersOf,
|
||||||
|
includeStagedUsers,
|
||||||
function (r) {
|
function (r) {
|
||||||
cancel(clearPromise);
|
cancel(clearPromise);
|
||||||
resolve(organizeResults(r, options));
|
resolve(organizeResults(r, options));
|
||||||
|
@ -75,6 +75,7 @@ export default MultiSelectComponent.extend({
|
|||||||
includeMessageableGroups: options.includeMessageableGroups,
|
includeMessageableGroups: options.includeMessageableGroups,
|
||||||
groupMembersOf: options.groupMembersOf,
|
groupMembersOf: options.groupMembersOf,
|
||||||
allowEmails: options.allowEmails,
|
allowEmails: options.allowEmails,
|
||||||
|
includeStagedUsers: this.includeStagedUsers,
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
if (typeof result === "string") {
|
if (typeof result === "string") {
|
||||||
// do nothing promise probably got cancelled
|
// do nothing promise probably got cancelled
|
||||||
|
@ -1074,6 +1074,7 @@ class UsersController < ApplicationController
|
|||||||
groups: @groups
|
groups: @groups
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options[:include_staged_users] = !!ActiveModel::Type::Boolean.new.cast(params[:include_staged_users])
|
||||||
options[:topic_id] = topic_id if topic_id
|
options[:topic_id] = topic_id if topic_id
|
||||||
options[:category_id] = category_id if category_id
|
options[:category_id] = category_id if category_id
|
||||||
|
|
||||||
|
@ -3731,6 +3731,7 @@ describe UsersController do
|
|||||||
fab!(:topic) { Fabricate :topic }
|
fab!(:topic) { Fabricate :topic }
|
||||||
let(:user) { Fabricate :user, username: "joecabot", name: "Lawrence Tierney" }
|
let(:user) { Fabricate :user, username: "joecabot", name: "Lawrence Tierney" }
|
||||||
let(:post1) { Fabricate(:post, user: user, topic: topic) }
|
let(:post1) { Fabricate(:post, user: user, topic: topic) }
|
||||||
|
let(:staged_user) { Fabricate(:user, staged: true) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
SearchIndexer.enable
|
SearchIndexer.enable
|
||||||
@ -4000,6 +4001,26 @@ describe UsersController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context '`include_staged_users`' do
|
||||||
|
it "includes staged users when the param is true" do
|
||||||
|
get "/u/search/users.json", params: { term: staged_user.name, include_staged_users: true }
|
||||||
|
json = response.parsed_body
|
||||||
|
expect(json["users"].map { |u| u["name"] }).to include(staged_user.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't include staged users when the param is not passed" do
|
||||||
|
get "/u/search/users.json", params: { term: staged_user.name }
|
||||||
|
json = response.parsed_body
|
||||||
|
expect(json["users"].map { |u| u["name"] }).not_to include(staged_user.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't include staged users when the param explicitly set to false" do
|
||||||
|
get "/u/search/users.json", params: { term: staged_user.name, include_staged_users: false }
|
||||||
|
json = response.parsed_body
|
||||||
|
expect(json["users"].map { |u| u["name"] }).not_to include(staged_user.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#email_login' do
|
describe '#email_login' do
|
||||||
|
Reference in New Issue
Block a user