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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
a27b59f6
Commit
a27b59f6
authored
Apr 22, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix diffs with edit-forking needs
Fix
https://gitlab.com/gitlab-org/gitlab-ce/issues/31276
parent
9c35162f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
21 deletions
+64
-21
app/assets/javascripts/merge_request_tabs.js
app/assets/javascripts/merge_request_tabs.js
+11
-0
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+1
-1
app/views/projects/_fork_suggestion.html.haml
app/views/projects/_fork_suggestion.html.haml
+11
-0
app/views/projects/blob/_header.html.haml
app/views/projects/blob/_header.html.haml
+1
-11
app/views/projects/diffs/_file.html.haml
app/views/projects/diffs/_file.html.haml
+2
-0
spec/features/merge_requests/diffs_spec.rb
spec/features/merge_requests/diffs_spec.rb
+38
-9
No files found.
app/assets/javascripts/merge_request_tabs.js
View file @
a27b59f6
...
...
@@ -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
'
),
});
});
},
});
}
...
...
app/helpers/blob_helper.rb
View file @
a27b59f6
...
...
@@ -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
}
...
...
app/views/projects/_fork_suggestion.html.haml
0 → 100644
View file @
a27b59f6
-
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
app/views/projects/blob/_header.html.haml
View file @
a27b59f6
...
...
@@ -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'
app/views/projects/diffs/_file.html.haml
View file @
a27b59f6
...
...
@@ -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
spec/features/merge_requests/diffs_spec.rb
View file @
a27b59f6
require
'spec_helper'
feature
'Diffs URL'
,
js:
true
,
feature:
true
do
before
do
login_as
:admin
@merge_request
=
create
(
:merge_request
)
@project
=
@merge_request
.
source_project
end
include
ApplicationHelper
let
(
:author_user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:forked_project
)
{
Projects
::
ForkService
.
new
(
project
,
author_user
).
execute
}
let
(
:merge_request
)
{
create
(
:merge_request_with_diffs
,
source_project:
forked_project
,
target_project:
project
,
author:
author_user
)
}
context
'when visit with */* as accept header'
do
before
(
:each
)
do
...
...
@@ -13,9 +15,9 @@ feature 'Diffs URL', js: true, feature: true do
end
it
'renders the notes'
do
create
:note_on_merge_request
,
project:
@project
,
noteable:
@
merge_request
,
note:
'Rebasing with master'
create
:note_on_merge_request
,
project:
project
,
noteable:
merge_request
,
note:
'Rebasing with master'
visit
diffs_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@
merge_request
)
visit
diffs_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
# Load notes and diff through AJAX
expect
(
page
).
to
have_css
(
'.note-text'
,
visible:
false
,
text:
'Rebasing with master'
)
...
...
@@ -28,11 +30,38 @@ feature 'Diffs URL', js: true, feature: true do
allow_any_instance_of
(
MergeRequestDiff
).
to
receive
(
:overflow?
).
and_return
(
true
)
allow
(
Commit
).
to
receive
(
:max_diff_options
).
and_return
(
max_files:
20
,
max_lines:
20
)
visit
diffs_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@
merge_request
)
visit
diffs_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
page
.
within
(
'.alert'
)
do
expect
(
page
).
to
have_text
(
"Too many changes to show. Plain diff Email patch To preserve
performance only 3 of 3+ files are displayed."
)
performance only 3 of 3 files are displayed."
)
end
end
end
describe
'when editing file'
do
let
(
:changelog_id
)
{
hexdigest
(
"CHANGELOG"
)
}
context
'as author'
do
it
'shows direct edit link'
do
login_as
(
author_user
)
visit
diffs_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
# Throws `Capybara::Poltergeist::InvalidSelector` if we try to use `#hash` syntax
expect
(
page
).
to
have_selector
(
"[id=
\"
#{
changelog_id
}
\"
] a.js-edit-blob"
)
end
end
context
'as user who needs to fork'
do
it
'shows fork/cancel confirmation'
do
login_as
(
user
)
visit
diffs_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
# Throws `Capybara::Poltergeist::InvalidSelector` if we try to use `#hash` syntax
find
(
"[id=
\"
#{
changelog_id
}
\"
] .js-edit-blob"
).
click
expect
(
page
).
to
have_selector
(
'.js-fork-suggestion-button'
,
count:
1
)
expect
(
page
).
to
have_selector
(
'.js-cancel-fork-suggestion-button'
,
count:
1
)
end
end
end
...
...
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