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
dc668d68
Commit
dc668d68
authored
Jul 27, 2020
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auto expand collapsed diffs when in single diff file mode
Closes
https://gitlab.com/gitlab-org/gitlab/-/issues/230511
parent
e4741ce5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
1 deletion
+74
-1
app/assets/javascripts/diffs/components/diff_file.vue
app/assets/javascripts/diffs/components/diff_file.vue
+18
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-0
spec/features/merge_request/user_views_auto_expanding_diff_spec.rb
...ures/merge_request/user_views_auto_expanding_diff_spec.rb
+35
-0
spec/frontend/diffs/components/diff_file_spec.js
spec/frontend/diffs/components/diff_file_spec.js
+20
-0
No files found.
app/assets/javascripts/diffs/components/diff_file.vue
View file @
dc668d68
...
...
@@ -89,8 +89,25 @@ export default {
this
.
setFileCollapsed
({
filePath
:
this
.
file
.
file_path
,
collapsed
:
newVal
});
},
'
file.file_hash
'
:
{
handler
:
function
watchFileHash
()
{
if
(
window
.
gon
?.
features
?.
autoExpandCollapsedDiffs
&&
this
.
viewDiffsFileByFile
&&
this
.
file
.
viewer
.
collapsed
)
{
this
.
isCollapsed
=
false
;
this
.
handleLoadCollapsedDiff
();
}
else
{
this
.
isCollapsed
=
this
.
file
.
viewer
.
collapsed
||
false
;
}
},
immediate
:
true
,
},
'
file.viewer.collapsed
'
:
function
setIsCollapsed
(
newVal
)
{
this
.
isCollapsed
=
newVal
;
if
(
!
this
.
viewDiffsFileByFile
&&
!
window
.
gon
?.
features
?.
autoExpandCollapsedDiffs
)
{
this
.
isCollapsed
=
newVal
;
}
},
},
created
()
{
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
dc668d68
...
...
@@ -36,6 +36,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
push_frontend_feature_flag
(
:multiline_comments
,
@project
)
push_frontend_feature_flag
(
:file_identifier_hash
)
push_frontend_feature_flag
(
:batch_suggestions
,
@project
,
default_enabled:
true
)
push_frontend_feature_flag
(
:auto_expand_collapsed_diffs
,
@project
)
end
before_action
do
...
...
spec/features/merge_request/user_views_auto_expanding_diff_spec.rb
0 → 100644
View file @
dc668d68
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'User views diffs file-by-file'
,
:js
do
let
(
:merge_request
)
do
create
(
:merge_request
,
source_branch:
'squash-large-files'
,
source_project:
project
,
target_project:
project
)
end
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
,
view_diffs_file_by_file:
true
)
}
before
do
allow
(
Gitlab
::
Git
::
Diff
).
to
receive
(
:size_limit
).
and_return
(
100
.
kilobytes
)
allow
(
Gitlab
::
Git
::
Diff
).
to
receive
(
:collapse_limit
).
and_return
(
10
.
kilobytes
)
project
.
add_developer
(
user
)
sign_in
(
user
)
visit
(
diffs_project_merge_request_path
(
project
,
merge_request
,
anchor:
'5091f7b9dd6202e37eaedd73d7b75d82f25fdb61'
))
wait_for_requests
end
it
'shows diffs file-by-file'
do
page
.
within
(
'#diffs'
)
do
expect
(
page
).
not_to
have_content
(
'This diff is collapsed'
)
click_button
'Next'
expect
(
page
).
not_to
have_content
(
'This diff is collapsed'
)
end
end
end
spec/frontend/diffs/components/diff_file_spec.js
View file @
dc668d68
...
...
@@ -128,6 +128,26 @@ describe('DiffFile', () => {
});
});
it
(
'
should auto-expand collapsed files when viewDiffsFileByFile is true
'
,
done
=>
{
vm
.
$destroy
();
window
.
gon
=
{
features
:
{
autoExpandCollapsedDiffs
:
true
},
};
vm
=
createComponentWithStore
(
Vue
.
extend
(
DiffFileComponent
),
createStore
(),
{
file
:
JSON
.
parse
(
JSON
.
stringify
(
diffFileMockDataUnreadable
)),
canCurrentUserFork
:
false
,
viewDiffsFileByFile
:
true
,
}).
$mount
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
innerText
).
not
.
toContain
(
'
This diff is collapsed
'
);
window
.
gon
=
{};
done
();
});
});
it
(
'
should be collapsed for renamed files
'
,
done
=>
{
vm
.
renderIt
=
true
;
vm
.
isCollapsed
=
false
;
...
...
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