BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9d2ca3f5
Commit
9d2ca3f5
authored
Apr 25, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '31276-fix-diffs-with-edit-forking-needs' into 'master'
Fix diffs with edit-forking needs Closes #31276 See merge request !10868
parents
04811cbb
a27b59f6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
21 deletions
+64
-21
merge_request_tabs.js
app/assets/javascripts/merge_request_tabs.js
+11
-0
blob_helper.rb
app/helpers/blob_helper.rb
+1
-1
_fork_suggestion.html.haml
app/views/projects/_fork_suggestion.html.haml
+11
-0
_header.html.haml
app/views/projects/blob/_header.html.haml
+1
-11
_file.html.haml
app/views/projects/diffs/_file.html.haml
+2
-0
diffs_spec.rb
spec/features/merge_requests/diffs_spec.rb
+38
-9
No files found.
app/assets/javascripts/merge_request_tabs.js
View file @
9d2ca3f5
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
import
Cookies
from
'js-cookie'
;
import
Cookies
from
'js-cookie'
;
import
'./breakpoints'
;
import
'./breakpoints'
;
import
'./flash'
;
import
'./flash'
;
import
BlobForkSuggestion
from
'./blob/blob_fork_suggestion'
;
/* eslint-disable max-len */
/* eslint-disable max-len */
// MergeRequestTabs
// MergeRequestTabs
...
@@ -266,6 +267,16 @@ import './flash';
...
@@ -266,6 +267,16 @@ import './flash';
new
gl
.
Diff
();
new
gl
.
Diff
();
this
.
scrollToElement
(
'#diffs'
);
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 @
9d2ca3f5
...
@@ -29,7 +29,7 @@ module BlobHelper
...
@@ -29,7 +29,7 @@ module BlobHelper
link_to
'Edit'
,
edit_path
(
project
,
ref
,
path
,
options
),
class:
"
#{
common_classes
}
btn-sm"
link_to
'Edit'
,
edit_path
(
project
,
ref
,
path
,
options
),
class:
"
#{
common_classes
}
btn-sm"
elsif
current_user
&&
can?
(
current_user
,
:fork_project
,
project
)
elsif
current_user
&&
can?
(
current_user
,
:fork_project
,
project
)
continue_params
=
{
continue_params
=
{
to:
edit_path
,
to:
edit_path
(
project
,
ref
,
path
,
options
)
,
notice:
edit_in_new_fork_notice
,
notice:
edit_in_new_fork_notice
,
notice_now:
edit_in_new_fork_notice_now
notice_now:
edit_in_new_fork_notice_now
}
}
...
...
app/views/projects/_fork_suggestion.html.haml
0 → 100644
View file @
9d2ca3f5
-
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 @
9d2ca3f5
...
@@ -39,14 +39,4 @@
...
@@ -39,14 +39,4 @@
=
replace_blob_link
=
replace_blob_link
=
delete_blob_link
=
delete_blob_link
-
if
current_user
=
render
'projects/fork_suggestion'
.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/diffs/_file.html.haml
View file @
9d2ca3f5
...
@@ -18,4 +18,6 @@
...
@@ -18,4 +18,6 @@
=
view_file_button
(
diff_commit
.
id
,
diff_file
.
new_path
,
project
)
=
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
=
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
=
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 @
9d2ca3f5
require
'spec_helper'
require
'spec_helper'
feature
'Diffs URL'
,
js:
true
,
feature:
true
do
feature
'Diffs URL'
,
js:
true
,
feature:
true
do
before
do
include
ApplicationHelper
login_as
:admin
@merge_request
=
create
(
:merge_request
)
let
(
:author_user
)
{
create
(
:user
)
}
@project
=
@merge_request
.
source_project
let
(
:user
)
{
create
(
:user
)
}
end
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
context
'when visit with */* as accept header'
do
before
(
:each
)
do
before
(
:each
)
do
...
@@ -13,9 +15,9 @@ feature 'Diffs URL', js: true, feature: true do
...
@@ -13,9 +15,9 @@ feature 'Diffs URL', js: true, feature: true do
end
end
it
'renders the notes'
do
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
# Load notes and diff through AJAX
expect
(
page
).
to
have_css
(
'.note-text'
,
visible:
false
,
text:
'Rebasing with master'
)
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
...
@@ -28,11 +30,38 @@ feature 'Diffs URL', js: true, feature: true do
allow_any_instance_of
(
MergeRequestDiff
).
to
receive
(
:overflow?
).
and_return
(
true
)
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
)
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
page
.
within
(
'.alert'
)
do
expect
(
page
).
to
have_text
(
"Too many changes to show. Plain diff Email patch To preserve
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
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