Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ffda1701
Commit
ffda1701
authored
Oct 23, 2020
by
Himanshu Kapoor
Committed by
Robert Speicher
Oct 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Merge Request "Edit in Web IDE" dropdown link on MR diffs page
parent
3dcc22a2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
14 deletions
+74
-14
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+19
-0
app/helpers/gitlab_routing_helper.rb
app/helpers/gitlab_routing_helper.rb
+0
-12
app/serializers/diff_file_base_entity.rb
app/serializers/diff_file_base_entity.rb
+1
-1
changelogs/unreleased/268301-mr-ide-button.yml
changelogs/unreleased/268301-mr-ide-button.yml
+5
-0
config/routes.rb
config/routes.rb
+0
-1
spec/helpers/blob_helper_spec.rb
spec/helpers/blob_helper_spec.rb
+49
-0
No files found.
app/helpers/blob_helper.rb
View file @
ffda1701
...
...
@@ -26,6 +26,25 @@ module BlobHelper
File
.
join
(
segments
)
end
def
ide_merge_request_path
(
merge_request
,
path
=
''
)
target_project
=
merge_request
.
target_project
source_project
=
merge_request
.
source_project
if
merge_request
.
merged?
branch
=
merge_request
.
target_branch_exists?
?
merge_request
.
target_branch
:
target_project
.
default_branch
return
ide_edit_path
(
target_project
,
branch
,
path
)
end
if
target_project
!=
source_project
params
=
{
target_project:
target_project
.
full_path
}
end
result
=
File
.
join
(
ide_path
,
'project'
,
source_project
.
full_path
,
'merge_requests'
,
merge_request
.
to_param
)
result
+=
"?
#{
params
.
to_query
}
"
unless
params
.
nil?
result
end
def
ide_fork_and_edit_path
(
project
=
@project
,
ref
=
@ref
,
path
=
@path
,
options
=
{})
fork_path_for_current_user
(
project
,
ide_edit_path
(
project
,
ref
,
path
))
end
...
...
app/helpers/gitlab_routing_helper.rb
View file @
ffda1701
...
...
@@ -343,18 +343,6 @@ module GitlabRoutingHelper
Gitlab
::
UrlBuilder
.
wiki_page_url
(
wiki
,
page
,
only_path:
true
,
**
options
)
end
def
gitlab_ide_merge_request_path
(
merge_request
)
target_project
=
merge_request
.
target_project
source_project
=
merge_request
.
source_project
params
=
{}
if
target_project
!=
source_project
params
=
{
target_project:
target_project
.
full_path
}
end
ide_merge_request_path
(
source_project
.
namespace
,
source_project
,
merge_request
,
params
)
end
private
def
snippet_query_params
(
snippet
,
*
args
)
...
...
app/serializers/diff_file_base_entity.rb
View file @
ffda1701
...
...
@@ -48,7 +48,7 @@ class DiffFileBaseEntity < Grape::Entity
next
unless
has_edit_path?
(
merge_request
)
gitlab_ide_merge_request_path
(
merge_request
)
ide_merge_request_path
(
merge_request
,
diff_file
.
new_path
)
end
expose
:old_path_html
do
|
diff_file
|
...
...
changelogs/unreleased/268301-mr-ide-button.yml
0 → 100644
View file @
ffda1701
---
title
:
Fix Merge Request "Edit in Web IDE" dropdown link on MR diffs page
merge_request
:
45653
author
:
type
:
fixed
config/routes.rb
View file @
ffda1701
...
...
@@ -122,7 +122,6 @@ Rails.application.routes.draw do
get
'ide'
=>
'ide#index'
get
'ide/*vueroute'
=>
'ide#index'
,
format:
false
get
'ide/project/:namespace/:project/merge_requests/:id'
=>
'ide#index'
,
format:
false
,
as: :ide_merge_request
draw
:operations
draw
:jira_connect
...
...
spec/helpers/blob_helper_spec.rb
View file @
ffda1701
...
...
@@ -444,6 +444,55 @@ RSpec.describe BlobHelper do
end
end
describe
'#ide_merge_request_path'
do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)}
it
'returns IDE path for the given MR if MR is not merged'
do
expect
(
helper
.
ide_merge_request_path
(
merge_request
)).
to
eq
(
"/-/ide/project/
#{
project
.
full_path
}
/merge_requests/
#{
merge_request
.
iid
}
"
)
end
context
'when the MR comes from a fork'
do
include
ProjectForksHelper
let
(
:forked_project
)
{
fork_project
(
project
,
nil
,
repository:
true
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
forked_project
,
target_project:
project
)
}
it
'returns IDE path for MR in the forked repo with target project included as param'
do
expect
(
helper
.
ide_merge_request_path
(
merge_request
)).
to
eq
(
"/-/ide/project/
#{
forked_project
.
full_path
}
/merge_requests/
#{
merge_request
.
iid
}
?target_project=
#{
CGI
.
escape
(
project
.
full_path
)
}
"
)
end
end
context
'when the MR is merged'
do
let
(
:current_user
)
{
build
(
:user
)
}
let_it_be
(
:merge_request
)
{
create
(
:merge_request
,
:merged
,
source_project:
project
,
source_branch:
'testing-1'
,
target_branch:
'feature-1'
)
}
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
current_user
)
allow
(
helper
).
to
receive
(
:can?
).
and_return
(
true
)
end
it
'returns default IDE url with master branch'
do
expect
(
helper
.
ide_merge_request_path
(
merge_request
)).
to
eq
(
"/-/ide/project/
#{
project
.
full_path
}
/edit/master"
)
end
it
'includes file path passed'
do
expect
(
helper
.
ide_merge_request_path
(
merge_request
,
'README.md'
)).
to
eq
(
"/-/ide/project/
#{
project
.
full_path
}
/edit/master/-/README.md"
)
end
context
'when target branch exists'
do
before
do
allow
(
merge_request
).
to
receive
(
:target_branch_exists?
).
and_return
(
true
)
end
it
'returns IDE edit url with the target branch'
do
expect
(
helper
.
ide_merge_request_path
(
merge_request
)).
to
eq
(
"/-/ide/project/
#{
project
.
full_path
}
/edit/feature-1"
)
end
end
end
end
describe
'#ide_fork_and_edit_path'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment