Merge pull request #3039 from okriuchykhin/ok_SCI_5339

Disable comment adding for archived objects [SCI-5339]
This commit is contained in:
Alex Kriuchykhin 2021-01-04 10:53:13 +01:00 committed by GitHub
commit 15a8524a99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

View file

@ -13,6 +13,11 @@ var CommentsSidebar = (function() {
$(SIDEBAR).removeClass('loading'); $(SIDEBAR).removeClass('loading');
$(SIDEBAR).find('.comments-subject-title').text(result.object_name); $(SIDEBAR).find('.comments-subject-title').text(result.object_name);
$(SIDEBAR).find('.comments-list').html(result.comments); $(SIDEBAR).find('.comments-list').html(result.comments);
if (result.comment_addable) {
$(SIDEBAR).find('.comment-input-container').removeClass('hidden');
} else {
$(SIDEBAR).find('.comment-input-container').addClass('hidden');
}
}); });
} }

View file

@ -17,6 +17,7 @@ class CommentsController < ApplicationController
render json: { render json: {
object_name: @commentable.name, object_name: @commentable.name,
comment_addable: comment_addable?(@commentable),
comments: render_to_string(partial: 'shared/comments/comments_list.html.erb', comments: render_to_string(partial: 'shared/comments/comments_list.html.erb',
locals: { comments: comments }) locals: { comments: comments })
} }

View file

@ -57,6 +57,19 @@ module CommentHelper
end end
end end
def comment_addable?(object)
case object.class.name
when 'MyModule'
can_create_comments_in_module?(object)
when 'Step', 'Result'
can_create_comments_in_module?(object.my_module)
when 'Project'
can_create_comments_in_project?(object)
else
false
end
end
def comment_editable?(comment) def comment_editable?(comment)
case comment.type case comment.type
when 'TaskComment', 'StepComment', 'ResultComment' when 'TaskComment', 'StepComment', 'ResultComment'