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
Léo-Paul Géneau
gitlab-ce
Commits
8563499b
Commit
8563499b
authored
Sep 02, 2018
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for Getter + Linting
parent
a424e814
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
78 deletions
+8
-78
app/assets/javascripts/diffs/store/getters.js
app/assets/javascripts/diffs/store/getters.js
+1
-39
app/assets/javascripts/diffs/store/utils.js
app/assets/javascripts/diffs/store/utils.js
+2
-0
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/actions.js
+2
-3
spec/javascripts/diffs/store/getters_spec.js
spec/javascripts/diffs/store/getters_spec.js
+3
-36
No files found.
app/assets/javascripts/diffs/store/getters.js
View file @
8563499b
...
@@ -72,44 +72,6 @@ export const getDiffFileDiscussions = (state, getters, rootState, rootGetters) =
...
@@ -72,44 +72,6 @@ export const getDiffFileDiscussions = (state, getters, rootState, rootGetters) =
discussion
.
diff_discussion
&&
_
.
isEqual
(
discussion
.
diff_file
.
file_hash
,
diff
.
fileHash
),
discussion
.
diff_discussion
&&
_
.
isEqual
(
discussion
.
diff_file
.
file_hash
,
diff
.
fileHash
),
)
||
[];
)
||
[];
/**
* Returns an Object with discussions by their diff line code
* To avoid rendering outdated discussions on the Changes tab we should do a bunch of SHA
* comparisions. `note.position.formatter` have the current version diff refs but
* `note.original_position.formatter` will have the first version's diff refs.
* If line diff refs matches with one of them, we should render it as a discussion on Changes tab.
*
* @param {Object} diff
* @returns {Array}
*/
export
const
discussionsByLineCode
=
(
state
,
getters
,
rootState
,
rootGetters
)
=>
{
const
diffRefsByLineCode
=
getDiffRefsByLineCode
(
state
.
diffFiles
);
return
rootGetters
.
discussions
.
reduce
((
acc
,
note
)
=>
{
const
isDiffDiscussion
=
note
.
diff_discussion
;
const
hasLineCode
=
note
.
line_code
;
const
isResolvable
=
note
.
resolvable
;
const
diffRefs
=
diffRefsByLineCode
[
note
.
line_code
];
if
(
isDiffDiscussion
&&
hasLineCode
&&
isResolvable
&&
diffRefs
)
{
const
refs
=
convertObjectPropsToCamelCase
(
note
.
position
.
formatter
);
const
originalRefs
=
convertObjectPropsToCamelCase
(
note
.
original_position
.
formatter
);
if
(
_
.
isEqual
(
refs
,
diffRefs
)
||
_
.
isEqual
(
originalRefs
,
diffRefs
))
{
const
lineCode
=
note
.
line_code
;
if
(
acc
[
lineCode
])
{
acc
[
lineCode
].
push
(
note
);
}
else
{
acc
[
lineCode
]
=
[
note
];
}
}
}
return
acc
;
},
{});
};
export
const
shouldRenderParallelCommentRow
=
state
=>
line
=>
{
export
const
shouldRenderParallelCommentRow
=
state
=>
line
=>
{
const
hasDiscussion
=
const
hasDiscussion
=
(
line
.
left
&&
line
.
left
.
discussions
&&
line
.
left
.
discussions
.
length
)
||
(
line
.
left
&&
line
.
left
.
discussions
&&
line
.
left
.
discussions
.
length
)
||
...
@@ -137,7 +99,7 @@ export const shouldRenderParallelCommentRow = state => line => {
...
@@ -137,7 +99,7 @@ export const shouldRenderParallelCommentRow = state => line => {
export
const
shouldRenderInlineCommentRow
=
state
=>
line
=>
{
export
const
shouldRenderInlineCommentRow
=
state
=>
line
=>
{
if
(
state
.
diffLineCommentForms
[
line
.
lineCode
])
return
true
;
if
(
state
.
diffLineCommentForms
[
line
.
lineCode
])
return
true
;
if
(
!
line
.
discussions
&&
line
.
discussions
.
length
===
0
)
{
if
(
!
line
.
discussions
||
line
.
discussions
.
length
===
0
)
{
return
false
;
return
false
;
}
}
...
...
app/assets/javascripts/diffs/store/utils.js
View file @
8563499b
...
@@ -161,7 +161,9 @@ export function addContextLines(options) {
...
@@ -161,7 +161,9 @@ export function addContextLines(options) {
* @returns {Object}
* @returns {Object}
*/
*/
export
function
trimFirstCharOfLineContent
(
line
=
{})
{
export
function
trimFirstCharOfLineContent
(
line
=
{})
{
// eslint-disable-next-line no-param-reassign
delete
line
.
text
;
delete
line
.
text
;
// eslint-disable-next-line no-param-reassign
line
.
discussions
=
[];
line
.
discussions
=
[];
const
parsedLine
=
Object
.
assign
({},
line
);
const
parsedLine
=
Object
.
assign
({},
line
);
...
...
app/assets/javascripts/notes/stores/actions.js
View file @
8563499b
...
@@ -43,8 +43,8 @@ export const fetchDiscussions = ({ commit }, path) =>
...
@@ -43,8 +43,8 @@ export const fetchDiscussions = ({ commit }, path) =>
commit
(
types
.
SET_INITIAL_DISCUSSIONS
,
discussions
);
commit
(
types
.
SET_INITIAL_DISCUSSIONS
,
discussions
);
});
});
export
const
refetchDiscussionById
=
({
commit
},
{
path
,
discussionId
})
=>
{
export
const
refetchDiscussionById
=
({
commit
},
{
path
,
discussionId
})
=>
return
new
Promise
(
resolve
=>
{
new
Promise
(
resolve
=>
{
service
service
.
fetchDiscussions
(
path
)
.
fetchDiscussions
(
path
)
.
then
(
res
=>
res
.
json
())
.
then
(
res
=>
res
.
json
())
...
@@ -57,7 +57,6 @@ export const refetchDiscussionById = ({ commit }, { path, discussionId }) => {
...
@@ -57,7 +57,6 @@ export const refetchDiscussionById = ({ commit }, { path, discussionId }) => {
})
})
.
catch
(()
=>
{});
.
catch
(()
=>
{});
});
});
};
export
const
deleteNote
=
({
commit
},
note
)
=>
export
const
deleteNote
=
({
commit
},
note
)
=>
service
.
deleteNote
(
note
.
path
).
then
(()
=>
{
service
.
deleteNote
(
note
.
path
).
then
(()
=>
{
...
...
spec/javascripts/diffs/store/getters_spec.js
View file @
8563499b
...
@@ -184,27 +184,6 @@ describe('Diffs Module Getters', () => {
...
@@ -184,27 +184,6 @@ describe('Diffs Module Getters', () => {
});
});
});
});
describe
(
'
singleDiscussionByLineCode
'
,
()
=>
{
it
(
'
returns found discussion per line Code
'
,
()
=>
{
const
discussionsMock
=
{};
discussionsMock
.
ABC
=
discussionMock
;
expect
(
getters
.
singleDiscussionByLineCode
(
localState
,
{},
null
,
{
discussionsByLineCode
:
()
=>
discussionsMock
,
})(
'
DEF
'
),
).
toEqual
([]);
});
it
(
'
returns empty array when no discussions match
'
,
()
=>
{
expect
(
getters
.
singleDiscussionByLineCode
(
localState
,
{},
null
,
{
discussionsByLineCode
:
()
=>
{},
})(
'
DEF
'
),
).
toEqual
([]);
});
});
describe
(
'
shouldRenderParallelCommentRow
'
,
()
=>
{
describe
(
'
shouldRenderParallelCommentRow
'
,
()
=>
{
let
line
;
let
line
;
...
@@ -223,32 +202,20 @@ describe('Diffs Module Getters', () => {
...
@@ -223,32 +202,20 @@ describe('Diffs Module Getters', () => {
it
(
'
returns true when discussion is expanded
'
,
()
=>
{
it
(
'
returns true when discussion is expanded
'
,
()
=>
{
discussionMock
.
expanded
=
true
;
discussionMock
.
expanded
=
true
;
expect
(
expect
(
getters
.
shouldRenderParallelCommentRow
(
localState
)(
line
)).
toEqual
(
true
);
getters
.
shouldRenderParallelCommentRow
(
localState
,
{
singleDiscussionByLineCode
:
()
=>
[
discussionMock
],
})(
line
),
).
toEqual
(
true
);
});
});
it
(
'
returns false when no discussion was found
'
,
()
=>
{
it
(
'
returns false when no discussion was found
'
,
()
=>
{
localState
.
diffLineCommentForms
.
ABC
=
false
;
localState
.
diffLineCommentForms
.
ABC
=
false
;
localState
.
diffLineCommentForms
.
DEF
=
false
;
localState
.
diffLineCommentForms
.
DEF
=
false
;
expect
(
expect
(
getters
.
shouldRenderParallelCommentRow
(
localState
)(
line
)).
toEqual
(
false
);
getters
.
shouldRenderParallelCommentRow
(
localState
,
{
singleDiscussionByLineCode
:
()
=>
[],
})(
line
),
).
toEqual
(
false
);
});
});
it
(
'
returns true when discussionForm was found
'
,
()
=>
{
it
(
'
returns true when discussionForm was found
'
,
()
=>
{
localState
.
diffLineCommentForms
.
ABC
=
{};
localState
.
diffLineCommentForms
.
ABC
=
{};
expect
(
expect
(
getters
.
shouldRenderParallelCommentRow
(
localState
)(
line
)).
toEqual
(
true
);
getters
.
shouldRenderParallelCommentRow
(
localState
,
{
singleDiscussionByLineCode
:
()
=>
[
discussionMock
],
})(
line
),
).
toEqual
(
true
);
});
});
});
});
...
...
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