diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6 index bdbe52b9c89..6f1ec69eb9e 100644 --- a/app/assets/javascripts/discourse/controllers/composer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/composer.js.es6 @@ -228,7 +228,7 @@ export default DiscourseController.extend({ }).then(function(result) { if (result.responseJson.action === "enqueued") { - self.send('postWasEnqueued', {pending_count: result.responseJson.pending_count }); + self.send('postWasEnqueued', result.responseJson); self.destroyDraft(); self.close(); return result; diff --git a/app/assets/javascripts/discourse/controllers/post-enqueued.js.es6 b/app/assets/javascripts/discourse/controllers/post-enqueued.js.es6 index 77c79b724a7..5cb644f22e3 100644 --- a/app/assets/javascripts/discourse/controllers/post-enqueued.js.es6 +++ b/app/assets/javascripts/discourse/controllers/post-enqueued.js.es6 @@ -1 +1,6 @@ -export default Ember.Controller.extend(); +export default Ember.Controller.extend({ + description: Ember.computed('model.reason', function() { + const reason = this.get('model.reason'); + return reason ? I18n.t('queue_reason.' + reason + '.description') : I18n.t('queue.approval.description'); + }) +}); diff --git a/app/assets/javascripts/discourse/routes/application.js.es6 b/app/assets/javascripts/discourse/routes/application.js.es6 index 55967c0dbd9..03e1c453c35 100644 --- a/app/assets/javascripts/discourse/routes/application.js.es6 +++ b/app/assets/javascripts/discourse/routes/application.js.es6 @@ -38,7 +38,8 @@ const ApplicationRoute = Discourse.Route.extend({ }, postWasEnqueued(details) { - showModal('post-enqueued', {model: details, title: 'queue.approval.title' }); + const title = details.reason ? 'queue_reason.' + details.reason + '.title' : 'queue.approval.title'; + showModal('post-enqueued', {model: details, title }); }, composePrivateMessage(user, post) { diff --git a/app/assets/javascripts/discourse/templates/modal/post-enqueued.hbs b/app/assets/javascripts/discourse/templates/modal/post-enqueued.hbs index ad547994a39..1ebdd0c4c40 100644 --- a/app/assets/javascripts/discourse/templates/modal/post-enqueued.hbs +++ b/app/assets/javascripts/discourse/templates/modal/post-enqueued.hbs @@ -1,5 +1,5 @@ diff --git a/app/serializers/new_post_result_serializer.rb b/app/serializers/new_post_result_serializer.rb index da3b7285e2e..068f3a9c9d7 100644 --- a/app/serializers/new_post_result_serializer.rb +++ b/app/serializers/new_post_result_serializer.rb @@ -5,7 +5,8 @@ class NewPostResultSerializer < ApplicationSerializer :post, :errors, :success, - :pending_count + :pending_count, + :reason def post post_serializer = PostSerializer.new(object.post, scope: scope, root: false) @@ -33,6 +34,14 @@ class NewPostResultSerializer < ApplicationSerializer !object.errors.empty? end + def reason + object.reason + end + + def include_reason? + reason.present? + end + def action object.action end diff --git a/lib/new_post_manager.rb b/lib/new_post_manager.rb index 9ada9820ad5..03fc09e9b5c 100644 --- a/lib/new_post_manager.rb +++ b/lib/new_post_manager.rb @@ -60,7 +60,7 @@ class NewPostManager end # Enqueue this post in a queue - def enqueue(queue) + def enqueue(queue, reason=nil) result = NewPostResult.new(:enqueued) enqueuer = PostEnqueuer.new(@user, queue) @@ -73,6 +73,7 @@ class NewPostManager QueuedPost.broadcast_new! if post && post.errors.empty? result.queued_post = post + result.reason = reason if reason result.check_errors_from(enqueuer) result.pending_count = QueuedPost.new_posts.where(user_id: @user.id).count result diff --git a/lib/new_post_result.rb b/lib/new_post_result.rb index 938513078d3..63acab0b002 100644 --- a/lib/new_post_result.rb +++ b/lib/new_post_result.rb @@ -4,6 +4,8 @@ class NewPostResult include HasErrors attr_reader :action + + attr_accessor :reason attr_accessor :post attr_accessor :queued_post attr_accessor :pending_count