From c888e73bc6bf7c89c551a45e579a3b319d435d21 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 23 Feb 2018 16:52:18 +0100 Subject: refactor methods inline --- app/helpers/blob_helper.rb | 12 ++++++------ app/views/projects/tree/_tree_header.html.haml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 551af3301db..0e806d16bc5 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -16,6 +16,10 @@ module BlobHelper options[:link_opts]) end + def ide_edit_path(project = @project, ref = @ref, path = @path, options = {}) + "#{ide_path}/project#{edit_blob_path(project, ref, path, options)}" + end + def edit_blob_button(project = @project, ref = @ref, path = @path, options = {}) return unless blob = readable_blob(options, path, project, ref) @@ -29,10 +33,6 @@ module BlobHelper ref) end - def display_modify_blob?(blob, project, ref) - !current_user || (current_user && can_modify_blob?(blob, project, ref)) - end - def ide_edit_button(project = @project, ref = @ref, path = @path, options = {}) return unless show_new_ide? return unless blob = readable_blob(options, path, project, ref) @@ -42,7 +42,7 @@ module BlobHelper edit_button_tag(blob, common_classes, _('Web IDE'), - "#{ide_path}/project#{edit_blob_path(project, ref, path, options)}", + ide_edit_path(project, ref, path, options), project, ref) end @@ -335,7 +335,7 @@ module BlobHelper edit_disabled_button_tag(text, common_classes) # This condition only applies to users who are logged in # Web IDE (Beta) requires the user to have this feature enabled - elsif display_modify_blob?(blob, project, ref) + elsif !current_user || (current_user && can_modify_blob?(blob, project, ref)) edit_link_tag(text, edit_path, common_classes) elsif current_user && can?(current_user, :fork_project, project) edit_fork_button_tag(common_classes, project, text, edit_blob_fork_params(edit_path)) diff --git a/app/views/projects/tree/_tree_header.html.haml b/app/views/projects/tree/_tree_header.html.haml index ff3928552af..39511435508 100644 --- a/app/views/projects/tree/_tree_header.html.haml +++ b/app/views/projects/tree/_tree_header.html.haml @@ -74,7 +74,7 @@ .tree-controls - if show_new_ide? = succeed " " do - = link_to "#{ide_path}/project#{edit_blob_path(@project, @id, @path, {})}", class: 'btn btn-default' do + = link_to ide_edit_path(@project, @id), class: 'btn btn-default' do = _('Web IDE') = link_to s_('Commits|History'), project_commits_path(@project, @id), class: 'btn' -- cgit v1.2.1