Commit c888e73b authored by James Lopez's avatar James Lopez

refactor methods inline

parent 73c4c995
...@@ -16,6 +16,10 @@ module BlobHelper ...@@ -16,6 +16,10 @@ module BlobHelper
options[:link_opts]) options[:link_opts])
end 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 = {}) def edit_blob_button(project = @project, ref = @ref, path = @path, options = {})
return unless blob = readable_blob(options, path, project, ref) return unless blob = readable_blob(options, path, project, ref)
...@@ -29,10 +33,6 @@ module BlobHelper ...@@ -29,10 +33,6 @@ module BlobHelper
ref) ref)
end 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 = {}) def ide_edit_button(project = @project, ref = @ref, path = @path, options = {})
return unless show_new_ide? return unless show_new_ide?
return unless blob = readable_blob(options, path, project, ref) return unless blob = readable_blob(options, path, project, ref)
...@@ -42,7 +42,7 @@ module BlobHelper ...@@ -42,7 +42,7 @@ module BlobHelper
edit_button_tag(blob, edit_button_tag(blob,
common_classes, common_classes,
_('Web IDE'), _('Web IDE'),
"#{ide_path}/project#{edit_blob_path(project, ref, path, options)}", ide_edit_path(project, ref, path, options),
project, project,
ref) ref)
end end
...@@ -335,7 +335,7 @@ module BlobHelper ...@@ -335,7 +335,7 @@ module BlobHelper
edit_disabled_button_tag(text, common_classes) edit_disabled_button_tag(text, common_classes)
# This condition only applies to users who are logged in # This condition only applies to users who are logged in
# Web IDE (Beta) requires the user to have this feature enabled # 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) edit_link_tag(text, edit_path, common_classes)
elsif current_user && can?(current_user, :fork_project, project) elsif current_user && can?(current_user, :fork_project, project)
edit_fork_button_tag(common_classes, project, text, edit_blob_fork_params(edit_path)) edit_fork_button_tag(common_classes, project, text, edit_blob_fork_params(edit_path))
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
.tree-controls .tree-controls
- if show_new_ide? - if show_new_ide?
= succeed " " do = 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') = _('Web IDE')
= link_to s_('Commits|History'), project_commits_path(@project, @id), class: 'btn' = link_to s_('Commits|History'), project_commits_path(@project, @id), class: 'btn'
......
...@@ -74,7 +74,7 @@ describe BlobHelper do ...@@ -74,7 +74,7 @@ describe BlobHelper do
end end
end end
describe "#edit_blob_element" do describe "#edit_blob_link" do
let(:namespace) { create(:namespace, name: 'gitlab' )} let(:namespace) { create(:namespace, name: 'gitlab' )}
let(:project) { create(:project, :repository, namespace: namespace) } let(:project) { create(:project, :repository, namespace: namespace) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment