DEV: Assign allowed groups are sent alongside suggestions. After the migration happens, we'll need to still have access to the allowed group names so we can search users.
This commit is contained in:
parent
64324ce9db
commit
8792cf51bd
|
|
@ -23,8 +23,10 @@ module DiscourseAssign
|
||||||
.order('X.last_assigned DESC')
|
.order('X.last_assigned DESC')
|
||||||
.limit(6)
|
.limit(6)
|
||||||
|
|
||||||
render json: ActiveModel::ArraySerializer.new(users,
|
render json: {
|
||||||
scope: guardian, each_serializer: BasicUserSerializer)
|
assign_allowed_on_groups: Group.assign_allowed_groups.pluck(:name),
|
||||||
|
suggestions: ActiveModel::ArraySerializer.new(users, scope: guardian, each_serializer: BasicUserSerializer)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def claim
|
def claim
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,16 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
assignSuggestions: null,
|
assignSuggestions: null,
|
||||||
|
allowedGroups: [],
|
||||||
taskActions: Ember.inject.service(),
|
taskActions: Ember.inject.service(),
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
ajax("/assign/suggestions").then(users =>
|
ajax("/assign/suggestions").then(data => {
|
||||||
this.set("assignSuggestions", users)
|
this.set("assignSuggestions", data.suggestions);
|
||||||
);
|
this.set("allowedGroups", data.assign_allowed_on_groups);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onClose() {
|
onClose() {
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,6 @@ import showModal from "discourse/lib/show-modal";
|
||||||
import { getOwner } from "discourse-common/lib/get-owner";
|
import { getOwner } from "discourse-common/lib/get-owner";
|
||||||
|
|
||||||
export default Ember.Service.extend({
|
export default Ember.Service.extend({
|
||||||
init() {
|
|
||||||
this._super(...arguments);
|
|
||||||
|
|
||||||
this.allowedGroups = getOwner(this)
|
|
||||||
.lookup("site-settings:main")
|
|
||||||
.assign_allowed_on_groups.split("|");
|
|
||||||
},
|
|
||||||
|
|
||||||
unassign(topicId) {
|
unassign(topicId) {
|
||||||
return ajax("/assign/unassign", {
|
return ajax("/assign/unassign", {
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
|
|
@ -22,8 +14,7 @@ export default Ember.Service.extend({
|
||||||
return showModal("assign-user", {
|
return showModal("assign-user", {
|
||||||
model: {
|
model: {
|
||||||
topic,
|
topic,
|
||||||
username: topic.get("assigned_to_user.username"),
|
username: topic.get("assigned_to_user.username")
|
||||||
allowedGroups: this.allowedGroups
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
single=true
|
single=true
|
||||||
allowAny=false
|
allowAny=false
|
||||||
group="staff"
|
group="staff"
|
||||||
groupMembersOf=model.allowedGroups
|
groupMembersOf=allowedGroups
|
||||||
excludeCurrentUser=false
|
excludeCurrentUser=false
|
||||||
includeMentionableGroups=false
|
includeMentionableGroups=false
|
||||||
hasGroups=false
|
hasGroups=false
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ RSpec.describe DiscourseAssign::AssignController do
|
||||||
TopicAssigner.new(post.topic, user).assign(user2)
|
TopicAssigner.new(post.topic, user).assign(user2)
|
||||||
|
|
||||||
get '/assign/suggestions.json'
|
get '/assign/suggestions.json'
|
||||||
suggestions = JSON.parse(response.body).map { |u| u['username'] }
|
suggestions = JSON.parse(response.body)['suggestions'].map { |u| u['username'] }
|
||||||
|
|
||||||
expect(suggestions).to contain_exactly(user2.username, user.username)
|
expect(suggestions).to contain_exactly(user2.username, user.username)
|
||||||
end
|
end
|
||||||
|
|
@ -60,7 +60,7 @@ RSpec.describe DiscourseAssign::AssignController do
|
||||||
TopicAssigner.new(post.topic, user).assign(user2)
|
TopicAssigner.new(post.topic, user).assign(user2)
|
||||||
|
|
||||||
get '/assign/suggestions.json'
|
get '/assign/suggestions.json'
|
||||||
suggestions = JSON.parse(response.body).map { |u| u['username'] }
|
suggestions = JSON.parse(response.body)['suggestions'].map { |u| u['username'] }
|
||||||
|
|
||||||
expect(suggestions).to contain_exactly(user.username)
|
expect(suggestions).to contain_exactly(user.username)
|
||||||
end
|
end
|
||||||
|
|
@ -78,7 +78,7 @@ RSpec.describe DiscourseAssign::AssignController do
|
||||||
TopicAssigner.new(post.topic, user).assign(another_admin)
|
TopicAssigner.new(post.topic, user).assign(another_admin)
|
||||||
|
|
||||||
get '/assign/suggestions.json'
|
get '/assign/suggestions.json'
|
||||||
suggestions = JSON.parse(response.body).map { |u| u['username'] }
|
suggestions = JSON.parse(response.body)['suggestions'].map { |u| u['username'] }
|
||||||
|
|
||||||
expect(suggestions).to contain_exactly(user.username)
|
expect(suggestions).to contain_exactly(user.username)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue