diff --git a/app/controllers/discourse_assign/assign_controller.rb b/app/controllers/discourse_assign/assign_controller.rb index 93a6a62..8e141ab 100644 --- a/app/controllers/discourse_assign/assign_controller.rb +++ b/app/controllers/discourse_assign/assign_controller.rb @@ -78,12 +78,6 @@ module DiscourseAssign 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 def translate_failure(reason, user) diff --git a/assets/javascripts/discourse-assign/controllers/user-activity-assigned.js.es6 b/assets/javascripts/discourse-assign/controllers/user-activity-assigned.js.es6 index b87b23d..02ffd8b 100644 --- a/assets/javascripts/discourse-assign/controllers/user-activity-assigned.js.es6 +++ b/assets/javascripts/discourse-assign/controllers/user-activity-assigned.js.es6 @@ -6,28 +6,7 @@ export default UserTopicsList.extend({ user: Ember.inject.controller(), taskActions: Ember.inject.service(), - @computed("model.topics") - canUnassignAll(topics) { - return topics && topics.length && this.currentUser.get("staff"); - }, - 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) { this.get("taskActions") .unassign(topic.get("id")) diff --git a/assets/javascripts/discourse/templates/user-activity-assigned.hbs b/assets/javascripts/discourse/templates/user-activity-assigned.hbs index 8728c39..c24cd68 100644 --- a/assets/javascripts/discourse/templates/user-activity-assigned.hbs +++ b/assets/javascripts/discourse/templates/user-activity-assigned.hbs @@ -1,11 +1 @@ -
{{username}} {{description}}
" - unassign_all: - title: "Unassign All" - confirm: "Are you sure you want to unassign all topics from {{username}}?" unassign: title: "Unassign" help: "Unassign Topic" diff --git a/config/routes.rb b/config/routes.rb index f67c1b0..766057d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,5 @@ DiscourseAssign::Engine.routes.draw do put "/claim/:topic_id" => "assign#claim" put "/assign" => "assign#assign" put "/unassign" => "assign#unassign" - put "/unassign-all" => "assign#unassign_all" get "/suggestions" => "assign#suggestions" end diff --git a/jobs/unassign_bulk.rb b/jobs/unassign_bulk.rb deleted file mode 100644 index 1a98531..0000000 --- a/jobs/unassign_bulk.rb +++ /dev/null @@ -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 diff --git a/lib/topic_assigner.rb b/lib/topic_assigner.rb index 181212a..9eee36f 100644 --- a/lib/topic_assigner.rb +++ b/lib/topic_assigner.rb @@ -7,24 +7,6 @@ class ::TopicAssigner ASSIGNED_TO_ID = 'assigned_to_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 staff_mention = User.where('moderator OR admin') .pluck('username') diff --git a/plugin.rb b/plugin.rb index a224f73..6ad4bb8 100644 --- a/plugin.rb +++ b/plugin.rb @@ -24,7 +24,6 @@ Discourse::Application.routes.append do end 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/regular/remind_user.rb', __FILE__) require 'topic_assigner' diff --git a/spec/lib/topic_assigner_spec.rb b/spec/lib/topic_assigner_spec.rb index b2b7da9..30ce5b2 100644 --- a/spec/lib/topic_assigner_spec.rb +++ b/spec/lib/topic_assigner_spec.rb @@ -85,12 +85,6 @@ RSpec.describe TopicAssigner do .to eq(TopicUser.notification_levels[:muted]) 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 let(:system_user) { Discourse.system_user } let(:moderator) { Fabricate(:admin, username: "modi") }