From 5ab95ba69a46ad23c41f395aea16d8a7a425eb41 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Wed, 6 Jul 2016 20:33:28 +0100 Subject: [PATCH] review changes --- .../javascripts/files_comment_button.js.coffee | 12 +++++++----- app/views/projects/diffs/_diffs.html.haml | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/files_comment_button.js.coffee b/app/assets/javascripts/files_comment_button.js.coffee index 2cc051b9e12..3941e181875 100644 --- a/app/assets/javascripts/files_comment_button.js.coffee +++ b/app/assets/javascripts/files_comment_button.js.coffee @@ -1,10 +1,10 @@ class @FilesCommentButton constructor: (@filesContainerElement) -> - return if not @filesContainerElement - return if not @filesContainerElement.data 'can-create-note' + return unless @filesContainerElement + return if _.isUndefined @filesContainerElement.data 'can-create-note' @COMMENT_BUTTON_CLASS = '.add-diff-note' - @COMMENT_BUTTON_TEMPLATE = _.template("") + @COMMENT_BUTTON_TEMPLATE = _.template '' @LINE_HOLDER_CLASS = '.line_holder' @LINE_NUMBER_CLASS = 'diff-line-num' @@ -37,7 +37,7 @@ class @FilesCommentButton lineContentElement = @getLineContent(currentTarget) buttonParentElement = @getButtonParent(currentTarget) - return if not @shouldRender e, buttonParentElement + return unless @shouldRender e, buttonParentElement buttonParentElement.append @buildButton id: @@ -58,7 +58,9 @@ class @FilesCommentButton return buildButton: (buttonAttributes) -> - $(@COMMENT_BUTTON_TEMPLATE COMMENT_BUTTON_CLASS: @COMMENT_BUTTON_CLASS.substr 1).attr + initializedButtonTemplate = @COMMENT_BUTTON_TEMPLATE + COMMENT_BUTTON_CLASS: @COMMENT_BUTTON_CLASS.substr 1 + $(initializedButtonTemplate).attr 'data-noteable-id': buttonAttributes.id.noteable 'data-commit-id': buttonAttributes.id.commit 'data-discussion-id': buttonAttributes.id.discussion diff --git a/app/views/projects/diffs/_diffs.html.haml b/app/views/projects/diffs/_diffs.html.haml index fea294628fe..94f765a097c 100644 --- a/app/views/projects/diffs/_diffs.html.haml +++ b/app/views/projects/diffs/_diffs.html.haml @@ -21,7 +21,7 @@ - if diff_files.overflow? = render 'projects/diffs/warning', diff_files: diff_files -.files{data: {can_create_note: (!@diff_notes_disabled && can?(current_user, :create_note, @project)).to_s}} +.files{data: {can_create_note: (!@diff_notes_disabled && can?(current_user, :create_note, @project))}} - diff_files.each_with_index do |diff_file, index| - diff_commit = commit_for_diff(diff_file) - blob = project.repository.blob_for_diff(diff_commit, diff_file)