diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6 index 75695d8055d..8ad012dd282 100644 --- a/app/assets/javascripts/discourse/controllers/composer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/composer.js.es6 @@ -168,15 +168,15 @@ export default Ember.ObjectController.extend(Presence, { }.property('model.loading'), save(force) { - const composer = this.get('model'), - self = this; + const composer = this.get('model'); + const self = this; // Clear the warning state if we're not showing the checkbox anymore if (!this.get('showWarning')) { this.set('model.isWarning', false); } - if(composer.get('cantSubmitPost')) { + if (composer.get('cantSubmitPost')) { const now = Date.now(); this.setProperties({ 'view.showTitleTip': now, diff --git a/app/assets/javascripts/discourse/models/composer.js.es6 b/app/assets/javascripts/discourse/models/composer.js.es6 index 6148efa04ce..49838fdf72c 100644 --- a/app/assets/javascripts/discourse/models/composer.js.es6 +++ b/app/assets/javascripts/discourse/models/composer.js.es6 @@ -114,6 +114,7 @@ const Composer = RestModel.extend({ // whether to disable the post button cantSubmitPost: function() { + // can't submit while loading if (this.get('loading')) return true; @@ -199,12 +200,9 @@ const Composer = RestModel.extend({ } }.property('privateMessage'), - /** - Number of missing characters in the reply until valid. - - @property missingReplyCharacters - **/ missingReplyCharacters: function() { + const postType = this.get('post.post_type'); + if (postType === this.site.get('post_types.small_action')) { return 0; } return this.get('minimumPostLength') - this.get('replyLength'); }.property('minimumPostLength', 'replyLength'), diff --git a/app/assets/javascripts/discourse/views/composer.js.es6 b/app/assets/javascripts/discourse/views/composer.js.es6 index 354ed503dc1..36a47779338 100644 --- a/app/assets/javascripts/discourse/views/composer.js.es6 +++ b/app/assets/javascripts/discourse/views/composer.js.es6 @@ -584,15 +584,18 @@ const ComposerView = Discourse.View.extend(Ember.Evented, { }.property('model.categoryId'), replyValidation: function() { + const postType = this.get('model.post.post_type'); + if (postType === this.site.get('post_types.small_action')) { return; } + const replyLength = this.get('model.replyLength'), - missingChars = this.get('model.missingReplyCharacters'); + missingChars = this.get('model.missingReplyCharacters'); let reason; if (replyLength < 1) { reason = I18n.t('composer.error.post_missing'); } else if (missingChars > 0) { reason = I18n.t('composer.error.post_length', {min: this.get('model.minimumPostLength')}); - let tl = Discourse.User.currentProp("trust_level"); + const tl = Discourse.User.currentProp("trust_level"); if (tl === 0 || tl === 1) { reason += "
" + I18n.t('composer.error.try_like'); } diff --git a/app/assets/javascripts/discourse/views/post.js.es6 b/app/assets/javascripts/discourse/views/post.js.es6 index a5c24925d24..12891e215cc 100644 --- a/app/assets/javascripts/discourse/views/post.js.es6 +++ b/app/assets/javascripts/discourse/views/post.js.es6 @@ -13,7 +13,7 @@ const PostView = Discourse.GroupedView.extend(Ember.Evented, { post: Ember.computed.alias('content'), templateName: function() { - return (this.get('post.post_type') === 3) ? 'post-small-action' : 'post'; + return (this.get('post.post_type') === this.site.get('post_types.small_action')) ? 'post-small-action' : 'post'; }.property('post.post_type'), historyHeat: function() { diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index ad0e8cb5409..0d301b1bbb3 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -131,8 +131,14 @@ class PostsController < ApplicationController changes[:category_id] = params[:post][:category_id] if params[:post][:category_id] end + # We don't need to validate edits to small action posts by staff + opts = {} + if post.post_type == Post.types[:small_action] && current_user.staff? + opts[:skip_validations] = true + end + revisor = PostRevisor.new(post) - if revisor.revise!(current_user, changes) + if revisor.revise!(current_user, changes, opts) TopicLink.extract_from(post) QuotedPost.extract_from(post) end diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index dc6bcf096eb..ce2948fd955 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -306,7 +306,7 @@ describe PostsController do end it "calls revise with valid parameters" do - PostRevisor.any_instance.expects(:revise!).with(post.user, { raw: 'edited body' , edit_reason: 'typo' }) + PostRevisor.any_instance.expects(:revise!).with(post.user, { raw: 'edited body' , edit_reason: 'typo' }, anything) xhr :put, :update, update_params end