Remove 'Unassign All' feature
This commit is contained in:
parent
615ad7c5c3
commit
c882b097f8
|
@ -78,12 +78,6 @@ module DiscourseAssign
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unassign_all
|
|
||||||
user = User.find_by(id: params[:user_id])
|
|
||||||
TopicAssigner.unassign_all(user, current_user)
|
|
||||||
render json: success_json
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def translate_failure(reason, user)
|
def translate_failure(reason, user)
|
||||||
|
|
|
@ -6,28 +6,7 @@ export default UserTopicsList.extend({
|
||||||
user: Ember.inject.controller(),
|
user: Ember.inject.controller(),
|
||||||
taskActions: Ember.inject.service(),
|
taskActions: Ember.inject.service(),
|
||||||
|
|
||||||
@computed("model.topics")
|
|
||||||
canUnassignAll(topics) {
|
|
||||||
return topics && topics.length && this.currentUser.get("staff");
|
|
||||||
},
|
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
unassignAll() {
|
|
||||||
let user = this.get("user.model");
|
|
||||||
bootbox.confirm(
|
|
||||||
I18n.t("discourse_assign.unassign_all.confirm", {
|
|
||||||
username: user.get("username")
|
|
||||||
}),
|
|
||||||
value => {
|
|
||||||
if (value) {
|
|
||||||
ajax("/assign/unassign-all", {
|
|
||||||
type: "PUT",
|
|
||||||
data: { user_id: user.get("id") }
|
|
||||||
}).then(() => this.send("changeAssigned"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
unassign(topic) {
|
unassign(topic) {
|
||||||
this.get("taskActions")
|
this.get("taskActions")
|
||||||
.unassign(topic.get("id"))
|
.unassign(topic.get("id"))
|
||||||
|
|
|
@ -1,11 +1 @@
|
||||||
<div class='assign-controls'>
|
|
||||||
{{#if canUnassignAll}}
|
|
||||||
{{d-button
|
|
||||||
action=(action "unassignAll")
|
|
||||||
class="btn-default"
|
|
||||||
icon="times"
|
|
||||||
label="discourse_assign.unassign_all.title"}}
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{outlet}}
|
{{outlet}}
|
||||||
|
|
|
@ -9,9 +9,6 @@ en:
|
||||||
assigned: "Assigned"
|
assigned: "Assigned"
|
||||||
assigned_to: "Assigned to"
|
assigned_to: "Assigned to"
|
||||||
assign_notification: "<p><span>{{username}}</span> {{description}}</p>"
|
assign_notification: "<p><span>{{username}}</span> {{description}}</p>"
|
||||||
unassign_all:
|
|
||||||
title: "Unassign All"
|
|
||||||
confirm: "Are you sure you want to unassign all topics from {{username}}?"
|
|
||||||
unassign:
|
unassign:
|
||||||
title: "Unassign"
|
title: "Unassign"
|
||||||
help: "Unassign Topic"
|
help: "Unassign Topic"
|
||||||
|
|
|
@ -4,6 +4,5 @@ DiscourseAssign::Engine.routes.draw do
|
||||||
put "/claim/:topic_id" => "assign#claim"
|
put "/claim/:topic_id" => "assign#claim"
|
||||||
put "/assign" => "assign#assign"
|
put "/assign" => "assign#assign"
|
||||||
put "/unassign" => "assign#unassign"
|
put "/unassign" => "assign#unassign"
|
||||||
put "/unassign-all" => "assign#unassign_all"
|
|
||||||
get "/suggestions" => "assign#suggestions"
|
get "/suggestions" => "assign#suggestions"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Jobs
|
|
||||||
class UnassignBulk < Jobs::Base
|
|
||||||
def execute(args)
|
|
||||||
assigned_by = User.find(args[:assigned_by_id])
|
|
||||||
Topic.where(id: args[:topic_ids]).each do |t|
|
|
||||||
TopicAssigner.new(t, assigned_by).unassign
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -7,24 +7,6 @@ class ::TopicAssigner
|
||||||
ASSIGNED_TO_ID = 'assigned_to_id'
|
ASSIGNED_TO_ID = 'assigned_to_id'
|
||||||
ASSIGNED_BY_ID = 'assigned_by_id'
|
ASSIGNED_BY_ID = 'assigned_by_id'
|
||||||
|
|
||||||
def self.unassign_all(user, assigned_by)
|
|
||||||
topic_ids = TopicCustomField.where(name: ASSIGNED_TO_ID, value: user.id).pluck(:topic_id)
|
|
||||||
|
|
||||||
# Fast path: by doing this we can instantly refresh for the user showing no assigned topics
|
|
||||||
# while doing the "full" removal asynchronously.
|
|
||||||
TopicCustomField.where(
|
|
||||||
name: [ASSIGNED_TO_ID, ASSIGNED_BY_ID],
|
|
||||||
topic_id: topic_ids
|
|
||||||
).delete_all
|
|
||||||
|
|
||||||
Jobs.enqueue(
|
|
||||||
:unassign_bulk,
|
|
||||||
user_id: user.id,
|
|
||||||
assigned_by_id: assigned_by.id,
|
|
||||||
topic_ids: topic_ids
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.backfill_auto_assign
|
def self.backfill_auto_assign
|
||||||
staff_mention = User.where('moderator OR admin')
|
staff_mention = User.where('moderator OR admin')
|
||||||
.pluck('username')
|
.pluck('username')
|
||||||
|
|
|
@ -24,7 +24,6 @@ Discourse::Application.routes.append do
|
||||||
end
|
end
|
||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
require File.expand_path('../jobs/unassign_bulk.rb', __FILE__)
|
|
||||||
require File.expand_path('../jobs/scheduled/enqueue_reminders.rb', __FILE__)
|
require File.expand_path('../jobs/scheduled/enqueue_reminders.rb', __FILE__)
|
||||||
require File.expand_path('../jobs/regular/remind_user.rb', __FILE__)
|
require File.expand_path('../jobs/regular/remind_user.rb', __FILE__)
|
||||||
require 'topic_assigner'
|
require 'topic_assigner'
|
||||||
|
|
|
@ -85,12 +85,6 @@ RSpec.describe TopicAssigner do
|
||||||
.to eq(TopicUser.notification_levels[:muted])
|
.to eq(TopicUser.notification_levels[:muted])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can unassign all a user's topics at once" do
|
|
||||||
assigner.assign(moderator)
|
|
||||||
TopicAssigner.unassign_all(moderator, moderator)
|
|
||||||
expect(TopicQuery.new(moderator, assigned: moderator.username).list_latest.topics).to be_blank
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when assigns_by_staff_mention is set to true" do
|
context "when assigns_by_staff_mention is set to true" do
|
||||||
let(:system_user) { Discourse.system_user }
|
let(:system_user) { Discourse.system_user }
|
||||||
let(:moderator) { Fabricate(:admin, username: "modi") }
|
let(:moderator) { Fabricate(:admin, username: "modi") }
|
||||||
|
|
Loading…
Reference in New Issue