summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2018-02-09 10:32:28 +0100
committerJames Lopez <james@jameslopez.es>2018-02-23 14:02:39 +0100
commitf13609663912e940e860b8f7b5e8aa98c99800e9 (patch)
tree0c023e0af474ae20ab0d172cf53e3e5e677a1b1b
parent4c8f8f4fe9248567e4b1a5ef5a6bc049513751a4 (diff)
downloadgitlab-ce-f13609663912e940e860b8f7b5e8aa98c99800e9.tar.gz
refactor modify_file_link
-rw-r--r--app/helpers/blob_helper.rb23
1 files changed, 18 insertions, 5 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index b54dd93cc08..848a59d3756 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -27,7 +27,7 @@ module BlobHelper
elsif !current_user || (current_user && can_modify_blob?(blob, project, ref))
edit_link_tag(edit_text, edit_blob_path(project, ref, path, options), common_classes)
elsif current_user && can?(current_user, :fork_project, project)
- edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project, edit_in_new_fork_notice)
+ edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project)
end
end
@@ -56,7 +56,7 @@ module BlobHelper
elsif current_user && can_modify_blob?(blob, project, ref)
edit_link_tag(ide_edit_text, ide_edit_path(project, ref, path, options), common_classes)
elsif current_user && can?(current_user, :fork_project, project)
- edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project, edit_in_new_fork_notice)
+ edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project)
end
end
@@ -76,7 +76,7 @@ module BlobHelper
elsif can_modify_blob?(blob, project, ref)
button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal'
elsif can?(current_user, :fork_project, project)
- edit_blob_fork(common_classes, request.fullpath, project, edit_in_new_fork_notice_action(action), action)
+ edit_modify_file_fork(action, common_classes, label, project)
end
end
@@ -311,16 +311,29 @@ module BlobHelper
blob if blob&.readable_text?
end
- def edit_blob_fork(common_classes, path, project, notice, action = 'edit')
+ def edit_blob_fork(common_classes, path, project)
continue_params = {
to: path,
- notice: notice,
+ notice: edit_in_new_fork_notice,
notice_now: edit_in_new_fork_notice_now
}
fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params)
button_tag edit_text,
class: "#{common_classes} js-edit-blob-link-fork-toggler",
+ data: { action: 'edit', fork_path: fork_path }
+ end
+
+ def edit_modify_file_fork(action, common_classes, label, project)
+ continue_params = {
+ to: request.fullpath,
+ notice: edit_in_new_fork_notice + " Try to #{action} this file again.",
+ notice_now: edit_in_new_fork_notice_now
+ }
+ fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params)
+
+ button_tag label,
+ class: "#{common_classes} js-edit-blob-link-fork-toggler",
data: { action: action, fork_path: fork_path }
end