Skip to content

Commit

Permalink
Remove 'Unassign All' feature
Browse files Browse the repository at this point in the history
  • Loading branch information
romanrizzi committed May 15, 2019
1 parent 615ad7c commit c882b09
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 78 deletions.
6 changes: 0 additions & 6 deletions app/controllers/discourse_assign/assign_controller.rb
Expand Up @@ -78,12 +78,6 @@ def assign
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)
Expand Down
Expand Up @@ -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"))
Expand Down
10 changes: 0 additions & 10 deletions assets/javascripts/discourse/templates/user-activity-assigned.hbs
@@ -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}}
3 changes: 0 additions & 3 deletions config/locales/client.en.yml
Expand Up @@ -9,9 +9,6 @@ en:
assigned: "Assigned"
assigned_to: "Assigned to"
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:
title: "Unassign"
help: "Unassign Topic"
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Expand Up @@ -4,6 +4,5 @@
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
12 changes: 0 additions & 12 deletions jobs/unassign_bulk.rb

This file was deleted.

18 changes: 0 additions & 18 deletions lib/topic_assigner.rb
Expand Up @@ -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')
Expand Down
1 change: 0 additions & 1 deletion plugin.rb
Expand Up @@ -24,7 +24,6 @@
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'
Expand Down
6 changes: 0 additions & 6 deletions spec/lib/topic_assigner_spec.rb
Expand Up @@ -85,12 +85,6 @@ def assert_publish_topic_state(topic, user)
.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") }
Expand Down

0 comments on commit c882b09

Please sign in to comment.