Commit 73c4c995 authored by James Lopez's avatar James Lopez

inline methods

parent b8028c6c
...@@ -23,32 +23,16 @@ module BlobHelper ...@@ -23,32 +23,16 @@ module BlobHelper
edit_button_tag(blob, edit_button_tag(blob,
common_classes, common_classes,
edit_text, _('Edit'),
edit_blob_path(project, ref, path, options), edit_blob_path(project, ref, path, options),
project, project,
ref) ref)
end end
def user_can_fork_project?(project)
current_user && can?(current_user, :fork_project, project)
end
def display_modify_blob?(blob, project, ref) def display_modify_blob?(blob, project, ref)
!current_user || (current_user && can_modify_blob?(blob, project, ref)) !current_user || (current_user && can_modify_blob?(blob, project, ref))
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_text
_('Edit')
end
def ide_edit_text
_('Web IDE')
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)
...@@ -57,13 +41,13 @@ module BlobHelper ...@@ -57,13 +41,13 @@ module BlobHelper
edit_button_tag(blob, edit_button_tag(blob,
common_classes, common_classes,
ide_edit_text, _('Web IDE'),
ide_edit_path(project, ref, path, options), "#{ide_path}/project#{edit_blob_path(project, ref, path, options)}",
project, project,
ref) ref)
end end
def modify_file_element(project = @project, ref = @ref, path = @path, label:, action:, btn_class:, modal_type:) def modify_file_button(project = @project, ref = @ref, path = @path, label:, action:, btn_class:, modal_type:)
return unless current_user return unless current_user
blob = project.repository.blob_at(ref, path) rescue nil blob = project.repository.blob_at(ref, path) rescue nil
...@@ -84,7 +68,7 @@ module BlobHelper ...@@ -84,7 +68,7 @@ module BlobHelper
end end
def replace_blob_link(project = @project, ref = @ref, path = @path) def replace_blob_link(project = @project, ref = @ref, path = @path)
modify_file_element( modify_file_button(
project, project,
ref, ref,
path, path,
...@@ -96,7 +80,7 @@ module BlobHelper ...@@ -96,7 +80,7 @@ module BlobHelper
end end
def delete_blob_link(project = @project, ref = @ref, path = @path) def delete_blob_link(project = @project, ref = @ref, path = @path)
modify_file_element( modify_file_button(
project, project,
ref, ref,
path, path,
...@@ -353,7 +337,7 @@ module BlobHelper ...@@ -353,7 +337,7 @@ module BlobHelper
# 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 display_modify_blob?(blob, project, ref)
edit_link_tag(text, edit_path, common_classes) edit_link_tag(text, edit_path, common_classes)
elsif user_can_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))
end end
end end
......
...@@ -74,8 +74,8 @@ ...@@ -74,8 +74,8 @@
.tree-controls .tree-controls
- if show_new_ide? - if show_new_ide?
= succeed " " do = succeed " " do
= link_to ide_edit_path(@project, @id), class: 'btn btn-default' do = link_to "#{ide_path}/project#{edit_blob_path(@project, @id, @path, {})}", class: 'btn btn-default' do
= ide_edit_text = _('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'
......
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