diff --git a/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 b/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 index 7be180cc777..69cdc749832 100644 --- a/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 @@ -26,6 +26,19 @@ export default Ember.Controller.extend(ModalFunctionality, { categoryId: Ember.computed.alias('model.category.id'), onShow() { + let showRelistButton = false; + const topics = this.get('model.topics'); + for (let t = 0; t < topics.length; t++) { + if (!topics[t].visible) { + showRelistButton = true; + break; + } + } + if (showRelistButton && !_buttons[9]) { + addBulkButton('relistTopics', 'relist_topics'); + } else if (!showRelistButton && _buttons[9]) { + _buttons.splice(9, 1); + } this.set('modal.modalClass', 'topic-bulk-actions-modal small'); const buttonRows = []; @@ -126,6 +139,10 @@ export default Ember.Controller.extend(ModalFunctionality, { this.forEachPerformed({type: 'unlist'}, t => t.set('visible', false)); }, + relistTopics() { + this.forEachPerformed({type: 'relist'}, t => t.set('visible', true)); + }, + changeCategory() { const categoryId = parseInt(this.get('newCategoryId'), 10) || 0; const category = Discourse.Category.findById(categoryId); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 09875846ba3..2dcb8b2d9e4 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1364,6 +1364,7 @@ en: select_all: "Select All" clear_all: "Clear All" unlist_topics: "Unlist Topics" + relist_topics: "Relist Topics" reset_read: "Reset Read" delete: "Delete Topics" dismiss: "Dismiss" diff --git a/lib/topics_bulk_action.rb b/lib/topics_bulk_action.rb index aa7d3acffb0..5e4d8d9f75d 100644 --- a/lib/topics_bulk_action.rb +++ b/lib/topics_bulk_action.rb @@ -11,7 +11,7 @@ class TopicsBulkAction def self.operations @operations ||= %w(change_category close archive change_notification_level reset_read dismiss_posts delete unlist archive_messages - move_messages_to_inbox change_tags append_tags) + move_messages_to_inbox change_tags append_tags relist) end def self.register_operation(name, &block) @@ -115,6 +115,15 @@ class TopicsBulkAction end end + def relist + topics.each do |t| + if guardian.can_moderate?(t) + t.update_status('visible', true, @user) + @changed_ids << t.id + end + end + end + def archive topics.each do |t| if guardian.can_moderate?(t)