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
32de3753
Commit
32de3753
authored
Jul 17, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disables toggle comments button for diff with no discussions
parent
ff060ad4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
8 deletions
+74
-8
app/assets/javascripts/diffs/components/diff_file_header.vue
app/assets/javascripts/diffs/components/diff_file_header.vue
+2
-1
app/assets/javascripts/diffs/store/getters.js
app/assets/javascripts/diffs/store/getters.js
+8
-0
changelogs/unreleased/49161-disable-toggle-comments.yml
changelogs/unreleased/49161-disable-toggle-comments.yml
+5
-0
spec/javascripts/diffs/components/diff_file_header_spec.js
spec/javascripts/diffs/components/diff_file_header_spec.js
+41
-7
spec/javascripts/diffs/store/getters_spec.js
spec/javascripts/diffs/store/getters_spec.js
+18
-0
No files found.
app/assets/javascripts/diffs/components/diff_file_header.vue
View file @
32de3753
...
...
@@ -50,7 +50,7 @@ export default {
};
},
computed
:
{
...
mapGetters
(
'
diffs
'
,
[
'
diffHasExpandedDiscussions
'
]),
...
mapGetters
(
'
diffs
'
,
[
'
diffHasExpandedDiscussions
'
,
'
diffHasDiscussions
'
]),
hasExpandedDiscussions
()
{
return
this
.
diffHasExpandedDiscussions
(
this
.
diffFile
);
},
...
...
@@ -221,6 +221,7 @@ export default {
v-if=
"diffFile.blob && diffFile.blob.readableText"
>
<button
:disabled=
"!diffHasDiscussions(diffFile)"
:class=
"
{ active: hasExpandedDiscussions }"
:title="s__('MergeRequests|Toggle comments for this file')"
class="js-btn-vue-toggle-comments btn"
...
...
app/assets/javascripts/diffs/store/getters.js
View file @
32de3753
...
...
@@ -47,6 +47,14 @@ export const diffHasExpandedDiscussions = (state, getters) => diff => {
);
};
/**
* Checks if the diff has any discussion
* @param {Boolean} diff
* @returns {Boolean}
*/
export
const
diffHasDiscussions
=
(
state
,
getters
)
=>
diff
=>
getters
.
getDiffFileDiscussions
(
diff
).
length
>
0
;
/**
* Returns an array with the discussions of the given diff
* @param {Object} diff
...
...
changelogs/unreleased/49161-disable-toggle-comments.yml
0 → 100644
View file @
32de3753
---
title
:
Disables toggle comments button if diff has no discussions
merge_request
:
author
:
type
:
other
spec/javascripts/diffs/components/diff_file_header_spec.js
View file @
32de3753
...
...
@@ -11,7 +11,9 @@ const discussionFixture = 'merge_requests/diff_discussion.json';
describe
(
'
diff_file_header
'
,
()
=>
{
let
vm
;
let
props
;
const
diffDiscussionMock
=
getJSONFixture
(
discussionFixture
)[
0
];
const
Component
=
Vue
.
extend
(
DiffFileHeader
);
const
store
=
new
Vuex
.
Store
({
modules
:
{
diffs
:
diffsModule
,
...
...
@@ -20,7 +22,6 @@ describe('diff_file_header', () => {
});
beforeEach
(()
=>
{
const
diffDiscussionMock
=
getJSONFixture
(
discussionFixture
)[
0
];
const
diffFile
=
convertObjectPropsToCamelCase
(
diffDiscussionMock
.
diff_file
,
{
deep
:
true
});
props
=
{
diffFile
,
...
...
@@ -409,7 +410,7 @@ describe('diff_file_header', () => {
});
describe
(
'
handles toggle discussions
'
,
()
=>
{
it
(
'
dispatches toggleFileDiscussions when user clicks on toggle discussions button
'
,
()
=>
{
it
(
'
renders a disabled button when diff has no discussions
'
,
()
=>
{
const
propsCopy
=
Object
.
assign
({},
props
);
propsCopy
.
diffFile
.
submodule
=
false
;
propsCopy
.
diffFile
.
blob
=
{
...
...
@@ -428,6 +429,38 @@ describe('diff_file_header', () => {
store
,
});
expect
(
vm
.
$el
.
querySelector
(
'
.js-btn-vue-toggle-comments
'
).
getAttribute
(
'
disabled
'
),
).
toEqual
(
'
disabled
'
);
});
describe
(
'
with discussions
'
,
()
=>
{
it
(
'
dispatches toggleFileDiscussions when user clicks on toggle discussions button
'
,
()
=>
{
const
propsCopy
=
Object
.
assign
({},
props
);
propsCopy
.
diffFile
.
submodule
=
false
;
propsCopy
.
diffFile
.
blob
=
{
id
:
'
848ed9407c6730ff16edb3dd24485a0eea24292a
'
,
path
:
'
lib/base.js
'
,
name
:
'
base.js
'
,
mode
:
'
100644
'
,
readableText
:
true
,
icon
:
'
file-text-o
'
,
};
propsCopy
.
addMergeRequestButtons
=
true
;
propsCopy
.
diffFile
.
deletedFile
=
true
;
const
discussionGetter
=
()
=>
[
diffDiscussionMock
];
notesModule
.
getters
.
discussions
=
discussionGetter
;
vm
=
mountComponentWithStore
(
Component
,
{
props
:
propsCopy
,
store
:
new
Vuex
.
Store
({
modules
:
{
diffs
:
diffsModule
,
notes
:
notesModule
,
},
}),
});
spyOn
(
vm
,
'
toggleFileDiscussions
'
);
vm
.
$el
.
querySelector
(
'
.js-btn-vue-toggle-comments
'
).
click
();
...
...
@@ -436,4 +469,5 @@ describe('diff_file_header', () => {
});
});
});
});
});
spec/javascripts/diffs/store/getters_spec.js
View file @
32de3753
...
...
@@ -167,6 +167,24 @@ describe('Diffs Module Getters', () => {
});
});
describe
(
'
diffHasDiscussions
'
,
()
=>
{
it
(
'
returns true when getDiffFileDiscussions returns discussions
'
,
()
=>
{
expect
(
getters
.
diffHasDiscussions
(
localState
,
{
getDiffFileDiscussions
:
()
=>
[
discussionMock
],
})(
diffFileMock
),
).
toEqual
(
true
);
});
it
(
'
returns false when getDiffFileDiscussions returns no discussions
'
,
()
=>
{
expect
(
getters
.
diffHasDiscussions
(
localState
,
{
getDiffFileDiscussions
:
()
=>
[],
})(
diffFileMock
),
).
toEqual
(
false
);
});
});
describe
(
'
getDiffFileDiscussions
'
,
()
=>
{
it
(
'
returns an array with discussions when fileHash matches and the discussion belongs to a diff
'
,
()
=>
{
discussionMock
.
diff_file
.
file_hash
=
diffFileMock
.
fileHash
;
...
...
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