diff options
author | Markus Koller <mkoller@gitlab.com> | 2019-07-11 19:27:21 +0200 |
---|---|---|
committer | Markus Koller <mkoller@gitlab.com> | 2019-07-12 16:23:00 +0200 |
commit | 60a6074dc977a72e00043596623094e006c84704 (patch) | |
tree | 5a9606f23ad802e073e6974960da19220d64110a /app | |
parent | 21c372827eb0b536d667dd2ae16e5a4930db6300 (diff) | |
download | gitlab-ce-60a6074dc977a72e00043596623094e006c84704.tar.gz |
Open WebIDE in fork when user doesn't have access51952-redirect-to-webide-in-fork
When opening the IDE on a project where the user doesn't have push
access, we create a fork and then redirect back to the IDE. To make
sure the user can actually commit, we need to open the IDE in the forked
project rather than the upstream project.
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/blob_helper.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 0d6a6496993..4b0713001a1 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -18,7 +18,16 @@ module BlobHelper end def ide_edit_path(project = @project, ref = @ref, path = @path, options = {}) - segments = [ide_path, 'project', project.full_path, 'edit', ref] + project_path = + if !current_user || can?(current_user, :push_code, project) + project.full_path + else + # We currently always fork to the user's namespace + # in edit_fork_button_tag + "#{current_user.namespace.full_path}/#{project.path}" + end + + segments = [ide_path, 'project', project_path, 'edit', ref] segments.concat(['-', encode_ide_path(path)]) if path.present? File.join(segments) end |