summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2017-04-22 00:54:03 -0500
committerEric Eastwood <contact@ericeastwood.com>2017-04-24 10:22:26 -0500
commita27b59f620ff26c9b358c5a34e175a6a513c9d15 (patch)
tree0996ce8fda9dd5d64be82688464c3d612a6f1828 /app
parent9c35162f83fb62349b922baaf192038522b09793 (diff)
downloadgitlab-ce-a27b59f620ff26c9b358c5a34e175a6a513c9d15.tar.gz
Fix diffs with edit-forking needs31276-fix-diffs-with-edit-forking-needs
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/31276
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/merge_request_tabs.js11
-rw-r--r--app/helpers/blob_helper.rb2
-rw-r--r--app/views/projects/_fork_suggestion.html.haml11
-rw-r--r--app/views/projects/blob/_header.html.haml12
-rw-r--r--app/views/projects/diffs/_file.html.haml2
5 files changed, 26 insertions, 12 deletions
diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js
index f7f6a773036..6075157ec31 100644
--- a/app/assets/javascripts/merge_request_tabs.js
+++ b/app/assets/javascripts/merge_request_tabs.js
@@ -5,6 +5,7 @@
import Cookies from 'js-cookie';
import './breakpoints';
import './flash';
+import BlobForkSuggestion from './blob/blob_fork_suggestion';
/* eslint-disable max-len */
// MergeRequestTabs
@@ -266,6 +267,16 @@ import './flash';
new gl.Diff();
this.scrollToElement('#diffs');
+
+ $('.diff-file').each((i, el) => {
+ new BlobForkSuggestion({
+ openButtons: $(el).find('.js-edit-blob-link-fork-toggler'),
+ forkButtons: $(el).find('.js-fork-suggestion-button'),
+ cancelButtons: $(el).find('.js-cancel-fork-suggestion-button'),
+ suggestionSections: $(el).find('.js-file-fork-suggestion-section'),
+ actionTextPieces: $(el).find('.js-file-fork-suggestion-section-action'),
+ });
+ });
},
});
}
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 3736e1ffcbb..36b16421e8f 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -29,7 +29,7 @@ module BlobHelper
link_to 'Edit', edit_path(project, ref, path, options), class: "#{common_classes} btn-sm"
elsif current_user && can?(current_user, :fork_project, project)
continue_params = {
- to: edit_path,
+ to: edit_path(project, ref, path, options),
notice: edit_in_new_fork_notice,
notice_now: edit_in_new_fork_notice_now
}
diff --git a/app/views/projects/_fork_suggestion.html.haml b/app/views/projects/_fork_suggestion.html.haml
new file mode 100644
index 00000000000..c855bfaf067
--- /dev/null
+++ b/app/views/projects/_fork_suggestion.html.haml
@@ -0,0 +1,11 @@
+- if current_user
+ .js-file-fork-suggestion-section.file-fork-suggestion.hidden
+ %span.file-fork-suggestion-note
+ You're not allowed to
+ %span.js-file-fork-suggestion-section-action
+ edit
+ files in this project directly. Please fork this project,
+ make your changes there, and submit a merge request.
+ = link_to 'Fork', nil, method: :post, class: 'js-fork-suggestion-button btn btn-grouped btn-inverted btn-new'
+ %button.js-cancel-fork-suggestion-button.btn.btn-grouped{ type: 'button' }
+ Cancel
diff --git a/app/views/projects/blob/_header.html.haml b/app/views/projects/blob/_header.html.haml
index d46e4534497..c553db84ee0 100644
--- a/app/views/projects/blob/_header.html.haml
+++ b/app/views/projects/blob/_header.html.haml
@@ -39,14 +39,4 @@
= replace_blob_link
= delete_blob_link
-- if current_user
- .js-file-fork-suggestion-section.file-fork-suggestion.hidden
- %span.file-fork-suggestion-note
- You're not allowed to
- %span.js-file-fork-suggestion-section-action
- edit
- files in this project directly. Please fork this project,
- make your changes there, and submit a merge request.
- = link_to 'Fork', nil, method: :post, class: 'js-fork-suggestion-button btn btn-grouped btn-inverted btn-new'
- %button.js-cancel-fork-suggestion-button.btn.btn-grouped{ type: 'button' }
- Cancel
+= render 'projects/fork_suggestion'
diff --git a/app/views/projects/diffs/_file.html.haml b/app/views/projects/diffs/_file.html.haml
index 0232a09b4a8..4622b980754 100644
--- a/app/views/projects/diffs/_file.html.haml
+++ b/app/views/projects/diffs/_file.html.haml
@@ -18,4 +18,6 @@
= view_file_button(diff_commit.id, diff_file.new_path, project)
= view_on_environment_button(diff_commit.id, diff_file.new_path, environment) if environment
+ = render 'projects/fork_suggestion'
+
= render 'projects/diffs/content', diff_file: diff_file, diff_commit: diff_commit, blob: blob, project: project