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
a2f5e739
Commit
a2f5e739
authored
Dec 23, 2020
by
Lukas Eipert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run prettier on 31 files - 21 of 73
Part of our prettier migration; changing the arrow-parens style.
parent
80f1ea7e
Changes
32
Show whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
132 additions
and
165 deletions
+132
-165
.prettierignore
.prettierignore
+0
-33
app/assets/javascripts/mr_popover/components/mr_popover.vue
app/assets/javascripts/mr_popover/components/mr_popover.vue
+1
-1
app/assets/javascripts/mr_popover/index.js
app/assets/javascripts/mr_popover/index.js
+2
-2
app/assets/javascripts/namespace_select.js
app/assets/javascripts/namespace_select.js
+1
-1
app/assets/javascripts/network/branch_graph.js
app/assets/javascripts/network/branch_graph.js
+2
-2
app/assets/javascripts/new_branch_form.js
app/assets/javascripts/new_branch_form.js
+1
-1
app/assets/javascripts/notebook/cells/markdown.vue
app/assets/javascripts/notebook/cells/markdown.vue
+2
-2
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+3
-3
app/assets/javascripts/notes/components/diff_with_note.vue
app/assets/javascripts/notes/components/diff_with_note.vue
+1
-1
app/assets/javascripts/notes/components/discussion_actions.vue
...ssets/javascripts/notes/components/discussion_actions.vue
+2
-2
app/assets/javascripts/notes/components/discussion_counter.vue
...ssets/javascripts/notes/components/discussion_counter.vue
+3
-3
app/assets/javascripts/notes/components/discussion_filter.vue
...assets/javascripts/notes/components/discussion_filter.vue
+1
-1
app/assets/javascripts/notes/components/multiline_comment_utils.js
...s/javascripts/notes/components/multiline_comment_utils.js
+5
-5
app/assets/javascripts/notes/components/note_actions.vue
app/assets/javascripts/notes/components/note_actions.vue
+2
-2
app/assets/javascripts/notes/components/note_body.vue
app/assets/javascripts/notes/components/note_body.vue
+1
-1
app/assets/javascripts/notes/components/note_form.vue
app/assets/javascripts/notes/components/note_form.vue
+3
-3
app/assets/javascripts/notes/components/noteable_discussion.vue
...sets/javascripts/notes/components/noteable_discussion.vue
+2
-2
app/assets/javascripts/notes/components/noteable_note.vue
app/assets/javascripts/notes/components/noteable_note.vue
+1
-1
app/assets/javascripts/notes/components/notes_app.vue
app/assets/javascripts/notes/components/notes_app.vue
+2
-2
app/assets/javascripts/notes/components/toggle_replies_widget.vue
...ts/javascripts/notes/components/toggle_replies_widget.vue
+2
-2
app/assets/javascripts/notes/discussion_filters.js
app/assets/javascripts/notes/discussion_filters.js
+2
-2
app/assets/javascripts/notes/mixins/diff_line_note_form.js
app/assets/javascripts/notes/mixins/diff_line_note_form.js
+3
-3
app/assets/javascripts/notes/mixins/discussion_navigation.js
app/assets/javascripts/notes/mixins/discussion_navigation.js
+1
-1
app/assets/javascripts/notes/mixins/resolvable.js
app/assets/javascripts/notes/mixins/resolvable.js
+1
-1
app/assets/javascripts/notes/sort_discussions.js
app/assets/javascripts/notes/sort_discussions.js
+1
-1
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/actions.js
+16
-16
app/assets/javascripts/notes/stores/collapse_utils.js
app/assets/javascripts/notes/stores/collapse_utils.js
+2
-2
app/assets/javascripts/notes/stores/getters.js
app/assets/javascripts/notes/stores/getters.js
+48
-48
app/assets/javascripts/notes/stores/mutations.js
app/assets/javascripts/notes/stores/mutations.js
+12
-12
app/assets/javascripts/notes/stores/utils.js
app/assets/javascripts/notes/stores/utils.js
+7
-7
app/assets/javascripts/notes/utils.js
app/assets/javascripts/notes/utils.js
+1
-1
app/assets/javascripts/notifications_dropdown.js
app/assets/javascripts/notifications_dropdown.js
+1
-1
No files found.
.prettierignore
View file @
a2f5e739
...
...
@@ -517,39 +517,6 @@ app/assets/javascripts/lib/utils/text_markdown.js
app/assets/javascripts/lib/utils/text_utility.js
app/assets/javascripts/lib/utils/type_utility.js
## cool-dirac
app/assets/javascripts/mr_popover/components/mr_popover.vue
app/assets/javascripts/mr_popover/index.js
app/assets/javascripts/namespace_select.js
app/assets/javascripts/network/branch_graph.js
app/assets/javascripts/new_branch_form.js
app/assets/javascripts/notebook/cells/markdown.vue
app/assets/javascripts/notes.js
app/assets/javascripts/notes/components/diff_with_note.vue
app/assets/javascripts/notes/components/discussion_actions.vue
app/assets/javascripts/notes/components/discussion_counter.vue
app/assets/javascripts/notes/components/discussion_filter.vue
app/assets/javascripts/notes/components/multiline_comment_utils.js
app/assets/javascripts/notes/components/note_actions.vue
app/assets/javascripts/notes/components/note_body.vue
app/assets/javascripts/notes/components/note_form.vue
app/assets/javascripts/notes/components/noteable_discussion.vue
app/assets/javascripts/notes/components/noteable_note.vue
app/assets/javascripts/notes/components/notes_app.vue
app/assets/javascripts/notes/components/toggle_replies_widget.vue
app/assets/javascripts/notes/discussion_filters.js
app/assets/javascripts/notes/mixins/diff_line_note_form.js
app/assets/javascripts/notes/mixins/discussion_navigation.js
app/assets/javascripts/notes/mixins/resolvable.js
app/assets/javascripts/notes/sort_discussions.js
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/collapse_utils.js
app/assets/javascripts/notes/stores/getters.js
app/assets/javascripts/notes/stores/mutations.js
app/assets/javascripts/notes/stores/utils.js
app/assets/javascripts/notes/utils.js
app/assets/javascripts/notifications_dropdown.js
## practical-cohen
app/assets/javascripts/onboarding_issues/index.js
app/assets/javascripts/operation_settings/store/actions.js
...
...
app/assets/javascripts/mr_popover/components/mr_popover.vue
View file @
a2f5e739
...
...
@@ -72,7 +72,7 @@ export default {
apollo
:
{
mergeRequest
:
{
query
,
update
:
data
=>
data
.
project
.
mergeRequest
,
update
:
(
data
)
=>
data
.
project
.
mergeRequest
,
variables
()
{
const
{
projectPath
,
mergeRequestIID
}
=
this
;
...
...
app/assets/javascripts/mr_popover/index.js
View file @
a2f5e739
...
...
@@ -42,7 +42,7 @@ const handleMRPopoverMount = ({ apolloProvider, projectPath, mrTitle, iid }) =>
},
200
);
// 200ms delay so not every mouseover triggers Popover + API Call
};
export
default
elements
=>
{
export
default
(
elements
)
=>
{
const
mrLinks
=
elements
||
[...
document
.
querySelectorAll
(
'
.gfm-merge_request
'
)];
if
(
mrLinks
.
length
>
0
)
{
Vue
.
use
(
VueApollo
);
...
...
@@ -52,7 +52,7 @@ export default elements => {
});
const
listenerAddedAttr
=
'
data-mr-listener-added
'
;
mrLinks
.
forEach
(
el
=>
{
mrLinks
.
forEach
(
(
el
)
=>
{
const
{
projectPath
,
mrTitle
,
iid
}
=
el
.
dataset
;
if
(
!
el
.
getAttribute
(
listenerAddedAttr
)
&&
projectPath
&&
mrTitle
&&
iid
)
{
...
...
app/assets/javascripts/namespace_select.js
View file @
a2f5e739
...
...
@@ -25,7 +25,7 @@ export default class NamespaceSelect {
return
`
${
selected
.
kind
}
:
${
selected
.
full_path
}
`
;
},
data
(
term
,
dataCallback
)
{
return
Api
.
namespaces
(
term
,
namespaces
=>
{
return
Api
.
namespaces
(
term
,
(
namespaces
)
=>
{
if
(
isFilter
)
{
const
anyNamespace
=
{
text
:
__
(
'
Any namespace
'
),
...
...
app/assets/javascripts/network/branch_graph.js
View file @
a2f5e739
...
...
@@ -66,12 +66,12 @@ export default class BranchGraph {
collectParents
()
{
const
ref
=
this
.
commits
;
const
results
=
[];
ref
.
forEach
(
c
=>
{
ref
.
forEach
(
(
c
)
=>
{
this
.
mtime
=
Math
.
max
(
this
.
mtime
,
c
.
time
);
this
.
mspace
=
Math
.
max
(
this
.
mspace
,
c
.
space
);
const
ref1
=
c
.
parents
;
const
results1
=
[];
ref1
.
forEach
(
p
=>
{
ref1
.
forEach
(
(
p
)
=>
{
this
.
parents
[
p
[
0
]]
=
true
;
results1
.
push
((
this
.
mspace
=
Math
.
max
(
this
.
mspace
,
p
[
1
])));
});
...
...
app/assets/javascripts/new_branch_form.js
View file @
a2f5e739
...
...
@@ -60,7 +60,7 @@ export default class NewBranchForm {
return
values
;
};
const
formatter
=
function
(
values
,
restriction
)
{
const
formatted
=
values
.
map
(
value
=>
{
const
formatted
=
values
.
map
(
(
value
)
=>
{
switch
(
false
)
{
case
!
/
\s
/
.
test
(
value
):
return
'
spaces
'
;
...
...
app/assets/javascripts/notebook/cells/markdown.vue
View file @
a2f5e739
...
...
@@ -77,11 +77,11 @@ function renderKatex(t) {
}
return
[
text
,
numInline
>
0
];
}
renderer
.
paragraph
=
t
=>
{
renderer
.
paragraph
=
(
t
)
=>
{
const
[
text
,
inline
]
=
renderKatex
(
t
);
return
`<p class="
${
inline
?
'
inline-katex
'
:
''
}
">
${
text
}
</p>`
;
};
renderer
.
listitem
=
t
=>
{
renderer
.
listitem
=
(
t
)
=>
{
const
[
text
,
inline
]
=
renderKatex
(
t
);
return
`<li class="
${
inline
?
'
inline-katex
'
:
''
}
">
${
text
}
</li>`
;
};
...
...
app/assets/javascripts/notes.js
View file @
a2f5e739
...
...
@@ -345,7 +345,7 @@ export default class Notes {
votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
loadAwardsHandler
()
.
then
(
awardsHandler
=>
{
.
then
(
(
awardsHandler
)
=>
{
awardsHandler
.
addAwardToEmojiBar
(
votesBlock
,
noteEntity
.
commands_changes
.
emoji_award
);
awardsHandler
.
scrollToAwards
();
})
...
...
@@ -1396,7 +1396,7 @@ export default class Notes {
let
tempFormContent
;
// Identify executed quick actions from `formContent`
const
executedCommands
=
availableQuickActions
.
filter
(
command
=>
{
const
executedCommands
=
availableQuickActions
.
filter
(
(
command
)
=>
{
const
commandRegex
=
new
RegExp
(
`/
${
command
.
name
}
`
);
return
commandRegex
.
test
(
formContent
);
});
...
...
@@ -1583,7 +1583,7 @@ export default class Notes {
// Make request to submit comment on server
return
axios
.
post
(
`
${
formAction
}
?html=true`
,
formData
)
.
then
(
res
=>
{
.
then
(
(
res
)
=>
{
const
note
=
res
.
data
;
$submitBtn
.
prop
(
'
disabled
'
,
false
);
...
...
app/assets/javascripts/notes/components/diff_with_note.vue
View file @
a2f5e739
...
...
@@ -31,7 +31,7 @@ export default {
},
computed
:
{
...
mapState
({
projectPath
:
state
=>
state
.
diffs
.
projectPath
,
projectPath
:
(
state
)
=>
state
.
diffs
.
projectPath
,
}),
diffMode
()
{
return
getDiffMode
(
this
.
discussion
.
diff_file
);
...
...
app/assets/javascripts/notes/components/discussion_actions.vue
View file @
a2f5e739
...
...
@@ -42,10 +42,10 @@ export default {
return
this
.
glFeatures
.
hideJumpToNextUnresolvedInThreads
;
},
resolvableNotes
()
{
return
this
.
discussion
.
notes
.
filter
(
x
=>
x
.
resolvable
);
return
this
.
discussion
.
notes
.
filter
(
(
x
)
=>
x
.
resolvable
);
},
userCanResolveDiscussion
()
{
return
this
.
resolvableNotes
.
every
(
note
=>
note
.
current_user
?.
can_resolve_discussion
);
return
this
.
resolvableNotes
.
every
(
(
note
)
=>
note
.
current_user
?.
can_resolve_discussion
);
},
},
};
...
...
app/assets/javascripts/notes/components/discussion_counter.vue
View file @
a2f5e739
...
...
@@ -32,10 +32,10 @@ export default {
return
this
.
getNoteableData
.
create_issue_to_resolve_discussions_path
;
},
toggeableDiscussions
()
{
return
this
.
discussions
.
filter
(
discussion
=>
!
discussion
.
individual_note
);
return
this
.
discussions
.
filter
(
(
discussion
)
=>
!
discussion
.
individual_note
);
},
allExpanded
()
{
return
this
.
toggeableDiscussions
.
every
(
discussion
=>
discussion
.
expanded
);
return
this
.
toggeableDiscussions
.
every
(
(
discussion
)
=>
discussion
.
expanded
);
},
lineResolveClass
()
{
return
this
.
allResolved
?
'
line-resolve-btn is-active
'
:
'
line-resolve-text
'
;
...
...
@@ -48,7 +48,7 @@ export default {
...
mapActions
([
'
setExpandDiscussions
'
]),
handleExpandDiscussions
()
{
this
.
setExpandDiscussions
({
discussionIds
:
this
.
toggeableDiscussions
.
map
(
discussion
=>
discussion
.
id
),
discussionIds
:
this
.
toggeableDiscussions
.
map
(
(
discussion
)
=>
discussion
.
id
),
expanded
:
!
this
.
allExpanded
,
});
},
...
...
app/assets/javascripts/notes/components/discussion_filter.vue
View file @
a2f5e739
...
...
@@ -42,7 +42,7 @@ export default {
...
mapGetters
([
'
getNotesDataByProp
'
,
'
timelineEnabled
'
]),
currentFilter
()
{
if
(
!
this
.
currentValue
)
return
this
.
filters
[
0
];
return
this
.
filters
.
find
(
filter
=>
filter
.
value
===
this
.
currentValue
);
return
this
.
filters
.
find
(
(
filter
)
=>
filter
.
value
===
this
.
currentValue
);
},
},
created
()
{
...
...
app/assets/javascripts/notes/components/multiline_comment_utils.js
View file @
a2f5e739
...
...
@@ -48,11 +48,11 @@ export function getLineClasses(line) {
export
function
commentLineOptions
(
diffLines
,
startingLine
,
lineCode
,
side
=
'
left
'
)
{
const
preferredSide
=
side
===
'
left
'
?
'
old_line
'
:
'
new_line
'
;
const
fallbackSide
=
preferredSide
===
'
new_line
'
?
'
old_line
'
:
'
new_line
'
;
const
notMatchType
=
l
=>
l
.
type
!==
'
match
'
;
const
notMatchType
=
(
l
)
=>
l
.
type
!==
'
match
'
;
const
linesCopy
=
[...
diffLines
];
// don't mutate the argument
const
startingLineCode
=
startingLine
.
line_code
;
const
currentIndex
=
linesCopy
.
findIndex
(
line
=>
line
.
line_code
===
lineCode
);
const
currentIndex
=
linesCopy
.
findIndex
(
(
line
)
=>
line
.
line_code
===
lineCode
);
// We're limiting adding comments to only lines above the current line
// to make rendering simpler. Future interations will use a more
...
...
@@ -66,10 +66,10 @@ export function commentLineOptions(diffLines, startingLine, lineCode, side = 'le
// If the selected line is "hidden" in an unchanged line block
// or "above" the current group of lines add it to the array so
// that the drop down is not defaulted to empty
const
selectedIndex
=
lines
.
findIndex
(
line
=>
line
.
line_code
===
startingLineCode
);
const
selectedIndex
=
lines
.
findIndex
(
(
line
)
=>
line
.
line_code
===
startingLineCode
);
if
(
selectedIndex
<
0
)
lines
.
unshift
(
startingLine
);
return
lines
.
map
(
l
=>
{
return
lines
.
map
(
(
l
)
=>
{
const
{
line_code
,
type
,
old_line
,
new_line
}
=
l
;
return
{
value
:
{
line_code
,
type
,
old_line
,
new_line
},
...
...
@@ -103,7 +103,7 @@ export function getCommentedLines(selectedCommentPosition, diffLines) {
};
}
const
findLineCodeIndex
=
line
=>
position
=>
{
const
findLineCodeIndex
=
(
line
)
=>
(
position
)
=>
{
return
[
position
.
line_code
,
position
.
left
?.
line_code
,
position
.
right
?.
line_code
].
includes
(
line
.
line_code
,
);
...
...
app/assets/javascripts/notes/components/note_actions.vue
View file @
a2f5e739
...
...
@@ -206,14 +206,14 @@ export default {
const
{
project_id
,
iid
}
=
this
.
getNoteableData
;
if
(
this
.
isUserAssigned
)
{
assignees
=
assignees
.
filter
(
assignee
=>
assignee
.
id
!==
this
.
author
.
id
);
assignees
=
assignees
.
filter
(
(
assignee
)
=>
assignee
.
id
!==
this
.
author
.
id
);
}
else
{
assignees
.
push
({
id
:
this
.
author
.
id
});
}
if
(
this
.
targetType
===
'
issue
'
)
{
Api
.
updateIssue
(
project_id
,
iid
,
{
assignee_ids
:
assignees
.
map
(
assignee
=>
assignee
.
id
),
assignee_ids
:
assignees
.
map
(
(
assignee
)
=>
assignee
.
id
),
})
.
then
(()
=>
this
.
handleAssigneeUpdate
(
assignees
))
.
catch
(()
=>
flash
(
__
(
'
Something went wrong while updating assignees
'
)));
...
...
app/assets/javascripts/notes/components/note_body.vue
View file @
a2f5e739
...
...
@@ -52,7 +52,7 @@ export default {
return
this
.
getDiscussion
(
this
.
note
.
discussion_id
);
},
...
mapState
({
batchSuggestionsInfo
:
state
=>
state
.
notes
.
batchSuggestionsInfo
,
batchSuggestionsInfo
:
(
state
)
=>
state
.
notes
.
batchSuggestionsInfo
,
}),
noteBody
()
{
return
this
.
note
.
note
;
...
...
app/assets/javascripts/notes/components/note_form.vue
View file @
a2f5e739
...
...
@@ -115,7 +115,7 @@ export default {
'
getUserDataByProp
'
,
]),
...
mapState
({
withBatchComments
:
state
=>
state
.
batchComments
?.
withBatchComments
,
withBatchComments
:
(
state
)
=>
state
.
batchComments
?.
withBatchComments
,
}),
...
mapGetters
(
'
batchComments
'
,
[
'
hasDrafts
'
]),
showBatchCommentsActions
()
{
...
...
@@ -126,8 +126,8 @@ export default {
return
(
this
.
discussion
?.
notes
.
filter
(
n
=>
n
.
resolvable
)
.
some
(
n
=>
n
.
current_user
?.
can_resolve_discussion
)
||
this
.
isDraft
.
filter
(
(
n
)
=>
n
.
resolvable
)
.
some
(
(
n
)
=>
n
.
current_user
?.
can_resolve_discussion
)
||
this
.
isDraft
);
},
noteHash
()
{
...
...
app/assets/javascripts/notes/components/noteable_discussion.vue
View file @
a2f5e739
...
...
@@ -201,14 +201,14 @@ export default {
};
this
.
saveNote
(
replyData
)
.
then
(
res
=>
{
.
then
(
(
res
)
=>
{
if
(
res
.
hasFlash
!==
true
)
{
this
.
isReplying
=
false
;
clearDraft
(
this
.
autosaveKey
);
}
callback
();
})
.
catch
(
err
=>
{
.
catch
(
(
err
)
=>
{
this
.
removePlaceholderNotes
();
const
msg
=
__
(
'
Your comment could not be submitted! Please check your network connection and try again.
'
,
...
...
app/assets/javascripts/notes/components/noteable_note.vue
View file @
a2f5e739
...
...
@@ -296,7 +296,7 @@ export default {
this
.
updateSuccess
();
callback
();
})
.
catch
(
response
=>
{
.
catch
(
(
response
)
=>
{
if
(
response
.
status
===
httpStatusCodes
.
GONE
)
{
this
.
removeNote
(
this
.
note
);
this
.
updateSuccess
();
...
...
app/assets/javascripts/notes/components/notes_app.vue
View file @
a2f5e739
...
...
@@ -130,7 +130,7 @@ export default {
const
{
parentElement
}
=
this
.
$el
;
if
(
parentElement
&&
parentElement
.
classList
.
contains
(
'
js-vue-notes-event
'
))
{
parentElement
.
addEventListener
(
'
toggleAward
'
,
event
=>
{
parentElement
.
addEventListener
(
'
toggleAward
'
,
(
event
)
=>
{
const
{
awardName
,
noteId
}
=
event
.
detail
;
this
.
toggleAward
({
awardName
,
noteId
});
});
...
...
@@ -217,7 +217,7 @@ export default {
const
noteId
=
hash
&&
hash
.
replace
(
/^note_/
,
''
);
if
(
noteId
)
{
const
discussion
=
this
.
discussions
.
find
(
d
=>
d
.
notes
.
some
(({
id
})
=>
id
===
noteId
));
const
discussion
=
this
.
discussions
.
find
(
(
d
)
=>
d
.
notes
.
some
(({
id
})
=>
id
===
noteId
));
if
(
discussion
)
{
this
.
expandDiscussion
({
discussionId
:
discussion
.
id
});
...
...
app/assets/javascripts/notes/components/toggle_replies_widget.vue
View file @
a2f5e739
...
...
@@ -26,9 +26,9 @@ export default {
return
this
.
replies
[
this
.
replies
.
length
-
1
];
},
uniqueAuthors
()
{
const
authors
=
this
.
replies
.
map
(
reply
=>
reply
.
author
||
{});
const
authors
=
this
.
replies
.
map
(
(
reply
)
=>
reply
.
author
||
{});
return
uniqBy
(
authors
,
author
=>
author
.
username
);
return
uniqBy
(
authors
,
(
author
)
=>
author
.
username
);
},
className
()
{
return
this
.
collapsed
?
'
collapsed
'
:
'
expanded
'
;
...
...
app/assets/javascripts/notes/discussion_filters.js
View file @
a2f5e739
import
Vue
from
'
vue
'
;
import
DiscussionFilter
from
'
./components/discussion_filter.vue
'
;
export
default
store
=>
{
export
default
(
store
)
=>
{
const
discussionFilterEl
=
document
.
getElementById
(
'
js-vue-discussion-filter
'
);
if
(
discussionFilterEl
)
{
const
{
defaultFilter
,
notesFilters
}
=
discussionFilterEl
.
dataset
;
const
filterValues
=
notesFilters
?
JSON
.
parse
(
notesFilters
)
:
{};
const
filters
=
Object
.
keys
(
filterValues
).
map
(
entry
=>
({
const
filters
=
Object
.
keys
(
filterValues
).
map
(
(
entry
)
=>
({
title
:
entry
,
value
:
filterValues
[
entry
],
}));
...
...
app/assets/javascripts/notes/mixins/diff_line_note_form.js
View file @
a2f5e739
...
...
@@ -9,9 +9,9 @@ import { formatLineRange } from '~/notes/components/multiline_comment_utils';
export
default
{
computed
:
{
...
mapState
({
noteableData
:
state
=>
state
.
notes
.
noteableData
,
notesData
:
state
=>
state
.
notes
.
notesData
,
withBatchComments
:
state
=>
state
.
batchComments
?.
withBatchComments
,
noteableData
:
(
state
)
=>
state
.
notes
.
noteableData
,
notesData
:
(
state
)
=>
state
.
notes
.
notesData
,
withBatchComments
:
(
state
)
=>
state
.
batchComments
?.
withBatchComments
,
}),
...
mapGetters
(
'
diffs
'
,
[
'
getDiffFileByHash
'
]),
...
mapGetters
(
'
batchComments
'
,
[
'
shouldRenderDraftRowInDiscussion
'
,
'
draftForDiscussion
'
]),
...
...
app/assets/javascripts/notes/mixins/discussion_navigation.js
View file @
a2f5e739
...
...
@@ -99,7 +99,7 @@ export default {
'
getDiscussion
'
,
]),
...
mapState
({
currentDiscussionId
:
state
=>
state
.
notes
.
currentDiscussionId
,
currentDiscussionId
:
(
state
)
=>
state
.
notes
.
currentDiscussionId
,
}),
},
methods
:
{
...
...
app/assets/javascripts/notes/mixins/resolvable.js
View file @
a2f5e739
...
...
@@ -15,7 +15,7 @@ export default {
if
(
notes
)
{
// Decide resolved state using store. Only valid for discussions.
return
notes
.
filter
(
note
=>
!
note
.
system
).
every
(
note
=>
note
.
resolved
);
return
notes
.
filter
(
(
note
)
=>
!
note
.
system
).
every
((
note
)
=>
note
.
resolved
);
}
return
resolved
;
...
...
app/assets/javascripts/notes/sort_discussions.js
View file @
a2f5e739
import
Vue
from
'
vue
'
;
import
SortDiscussion
from
'
./components/sort_discussion.vue
'
;
export
default
store
=>
{
export
default
(
store
)
=>
{
const
el
=
document
.
getElementById
(
'
js-vue-sort-issue-discussions
'
);
if
(
!
el
)
return
null
;
...
...
app/assets/javascripts/notes/stores/actions.js
View file @
a2f5e739
...
...
@@ -141,7 +141,7 @@ export const updateNote = ({ commit, dispatch }, { endpoint, note }) =>
export
const
updateOrCreateNotes
=
({
commit
,
state
,
getters
,
dispatch
},
notes
)
=>
{
const
{
notesById
}
=
getters
;
const
debouncedFetchDiscussions
=
isFetching
=>
{
const
debouncedFetchDiscussions
=
(
isFetching
)
=>
{
if
(
!
isFetching
)
{
commit
(
types
.
SET_FETCHING_DISCUSSIONS
,
true
);
dispatch
(
'
fetchDiscussions
'
,
{
path
:
state
.
notesData
.
discussionsPath
});
...
...
@@ -159,7 +159,7 @@ export const updateOrCreateNotes = ({ commit, state, getters, dispatch }, notes)
}
};
notes
.
forEach
(
note
=>
{
notes
.
forEach
(
(
note
)
=>
{
if
(
notesById
[
note
.
id
])
{
commit
(
types
.
UPDATE_NOTE
,
note
);
}
else
if
(
note
.
type
===
constants
.
DISCUSSION_NOTE
||
note
.
type
===
constants
.
DIFF_NOTE
)
{
...
...
@@ -329,7 +329,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
}
}
const
processQuickActions
=
res
=>
{
const
processQuickActions
=
(
res
)
=>
{
const
{
errors
:
{
commands_only
:
message
}
=
{
commands_only
:
null
}
}
=
res
;
/*
The following reply means that quick actions have been successfully applied:
...
...
@@ -347,7 +347,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
return
res
;
};
const
processEmojiAward
=
res
=>
{
const
processEmojiAward
=
(
res
)
=>
{
const
{
commands_changes
:
commandsChanges
}
=
res
;
const
{
emoji_award
:
emojiAward
}
=
commandsChanges
||
{};
if
(
!
emojiAward
)
{
...
...
@@ -357,7 +357,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
const
votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
return
loadAwardsHandler
()
.
then
(
awardsHandler
=>
{
.
then
(
(
awardsHandler
)
=>
{
awardsHandler
.
addAwardToEmojiBar
(
votesBlock
,
emojiAward
);
awardsHandler
.
scrollToAwards
();
})
...
...
@@ -371,7 +371,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
.
then
(()
=>
res
);
};
const
processTimeTracking
=
res
=>
{
const
processTimeTracking
=
(
res
)
=>
{
const
{
commands_changes
:
commandsChanges
}
=
res
;
const
{
spend_time
:
spendTime
,
time_estimate
:
timeEstimate
}
=
commandsChanges
||
{};
if
(
spendTime
!=
null
||
timeEstimate
!=
null
)
{
...
...
@@ -383,7 +383,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
return
res
;
};
const
removePlaceholder
=
res
=>
{
const
removePlaceholder
=
(
res
)
=>
{
if
(
replyId
)
{
commit
(
types
.
REMOVE_PLACEHOLDER_NOTES
);
}
...
...
@@ -391,7 +391,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
return
res
;
};
const
processErrors
=
error
=>
{
const
processErrors
=
(
error
)
=>
{
if
(
error
.
response
)
{
const
{
response
:
{
data
=
{}
},
...
...
@@ -435,7 +435,7 @@ const pollSuccessCallBack = (resp, commit, state, getters, dispatch) => {
return
resp
;
};
const
getFetchDataParams
=
state
=>
{
const
getFetchDataParams
=
(
state
)
=>
{
const
endpoint
=
state
.
notesData
.
notesPath
;
const
options
=
{
headers
:
{
...
...
@@ -570,7 +570,7 @@ export const submitSuggestion = (
return
Api
.
applySuggestion
(
suggestionId
)
.
then
(()
=>
commit
(
types
.
APPLY_SUGGESTION
,
{
discussionId
,
noteId
,
suggestionId
}))
.
then
(
dispatchResolveDiscussion
)
.
catch
(
err
=>
{
.
catch
(
(
err
)
=>
{
const
defaultMessage
=
__
(
'
Something went wrong while applying the suggestion. Please try again.
'
,
);
...
...
@@ -591,12 +591,12 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai
const
suggestionIds
=
state
.
batchSuggestionsInfo
.
map
(({
suggestionId
})
=>
suggestionId
);
const
applyAllSuggestions
=
()
=>
state
.
batchSuggestionsInfo
.
map
(
suggestionInfo
=>
state
.
batchSuggestionsInfo
.
map
(
(
suggestionInfo
)
=>
commit
(
types
.
APPLY_SUGGESTION
,
suggestionInfo
),
);
const
resolveAllDiscussions
=
()
=>
state
.
batchSuggestionsInfo
.
map
(
suggestionInfo
=>
{
state
.
batchSuggestionsInfo
.
map
(
(
suggestionInfo
)
=>
{
const
{
discussionId
}
=
suggestionInfo
;
return
dispatch
(
'
resolveDiscussion
'
,
{
discussionId
}).
catch
(()
=>
{});
});
...
...
@@ -609,7 +609,7 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai
.
then
(()
=>
Promise
.
all
(
applyAllSuggestions
()))
.
then
(()
=>
Promise
.
all
(
resolveAllDiscussions
()))
.
then
(()
=>
commit
(
types
.
CLEAR_SUGGESTION_BATCH
))
.
catch
(
err
=>
{
.
catch
(
(
err
)
=>
{
const
defaultMessage
=
__
(
'
Something went wrong while applying the batch of suggestions. Please try again.
'
,
);
...
...
@@ -652,10 +652,10 @@ export const fetchDescriptionVersion = ({ dispatch }, { endpoint, startingVersio
return
axios
.
get
(
requestUrl
)
.
then
(
res
=>
{
.
then
(
(
res
)
=>
{
dispatch
(
'
receiveDescriptionVersion
'
,
{
descriptionVersion
:
res
.
data
,
versionId
});
})
.
catch
(
error
=>
{
.
catch
(
(
error
)
=>
{
dispatch
(
'
receiveDescriptionVersionError
'
,
error
);
Flash
(
__
(
'
Something went wrong while fetching description changes. Please try again.
'
));
});
...
...
@@ -687,7 +687,7 @@ export const softDeleteDescriptionVersion = (
.
then
(()
=>
{
dispatch
(
'
receiveDeleteDescriptionVersion
'
,
versionId
);
})
.
catch
(
error
=>
{
.
catch
(
(
error
)
=>
{
dispatch
(
'
receiveDeleteDescriptionVersionError
'
,
error
);
Flash
(
__
(
'
Something went wrong while deleting description changes. Please try again.
'
));
...
...
app/assets/javascripts/notes/stores/collapse_utils.js
View file @
a2f5e739
...
...
@@ -18,7 +18,7 @@ export const getTimeDifferenceMinutes = (noteBeggining, noteEnd) => {
* @param {Object} note
* @returns {Boolean}
*/
export
const
isDescriptionSystemNote
=
note
=>
note
.
system
&&
note
.
note
===
DESCRIPTION_TYPE
;
export
const
isDescriptionSystemNote
=
(
note
)
=>
note
.
system
&&
note
.
note
===
DESCRIPTION_TYPE
;
/**
* Collapses the system notes of a description type, e.g. Changed the description, n minutes ago
...
...
@@ -29,7 +29,7 @@ export const isDescriptionSystemNote = note => note.system && note.note === DESC
* @param {Array} notes
* @returns {Array}
*/
export
const
collapseSystemNotes
=
notes
=>
{
export
const
collapseSystemNotes
=
(
notes
)
=>
{
let
lastDescriptionSystemNote
=
null
;
let
lastDescriptionSystemNoteIndex
=
-
1
;
...
...
app/assets/javascripts/notes/stores/getters.js
View file @
a2f5e739
...
...
@@ -2,14 +2,14 @@ import { flattenDeep, clone } from 'lodash';
import
*
as
constants
from
'
../constants
'
;
import
{
collapseSystemNotes
}
from
'
./collapse_utils
'
;
export
const
discussions
=
state
=>
{
export
const
discussions
=
(
state
)
=>
{
let
discussionsInState
=
clone
(
state
.
discussions
);
// NOTE: not testing bc will be removed when backend is finished.
if
(
state
.
isTimelineEnabled
)
{
discussionsInState
=
discussionsInState
.
reduce
((
acc
,
discussion
)
=>
{
const
transformedToIndividualNotes
=
discussion
.
notes
.
map
(
note
=>
({
const
transformedToIndividualNotes
=
discussion
.
notes
.
map
(
(
note
)
=>
({
...
discussion
,
id
:
note
.
id
,
created_at
:
note
.
created_at
,
...
...
@@ -29,52 +29,52 @@ export const discussions = state => {
return
collapseSystemNotes
(
discussionsInState
);
};
export
const
convertedDisscussionIds
=
state
=>
state
.
convertedDisscussionIds
;
export
const
convertedDisscussionIds
=
(
state
)
=>
state
.
convertedDisscussionIds
;
export
const
targetNoteHash
=
state
=>
state
.
targetNoteHash
;
export
const
targetNoteHash
=
(
state
)
=>
state
.
targetNoteHash
;
export
const
getNotesData
=
state
=>
state
.
notesData
;
export
const
getNotesData
=
(
state
)
=>
state
.
notesData
;
export
const
isNotesFetched
=
state
=>
state
.
isNotesFetched
;
export
const
isNotesFetched
=
(
state
)
=>
state
.
isNotesFetched
;
/*
* WARNING: This is an example of an "unnecessary" getter
* more info found here: https://gitlab.com/groups/gitlab-org/-/epics/2913.
*/
export
const
sortDirection
=
state
=>
state
.
discussionSortOrder
;
export
const
sortDirection
=
(
state
)
=>
state
.
discussionSortOrder
;
export
const
persistSortOrder
=
state
=>
state
.
persistSortOrder
;
export
const
persistSortOrder
=
(
state
)
=>
state
.
persistSortOrder
;
export
const
timelineEnabled
=
state
=>
state
.
isTimelineEnabled
;
export
const
timelineEnabled
=
(
state
)
=>
state
.
isTimelineEnabled
;
export
const
isLoading
=
state
=>
state
.
isLoading
;
export
const
isLoading
=
(
state
)
=>
state
.
isLoading
;
export
const
getNotesDataByProp
=
state
=>
prop
=>
state
.
notesData
[
prop
];
export
const
getNotesDataByProp
=
(
state
)
=>
(
prop
)
=>
state
.
notesData
[
prop
];
export
const
getNoteableData
=
state
=>
state
.
noteableData
;
export
const
getNoteableData
=
(
state
)
=>
state
.
noteableData
;
export
const
getNoteableDataByProp
=
state
=>
prop
=>
state
.
noteableData
[
prop
];
export
const
getNoteableDataByProp
=
(
state
)
=>
(
prop
)
=>
state
.
noteableData
[
prop
];
export
const
getBlockedByIssues
=
state
=>
state
.
noteableData
.
blocked_by_issues
;
export
const
getBlockedByIssues
=
(
state
)
=>
state
.
noteableData
.
blocked_by_issues
;
export
const
userCanReply
=
state
=>
Boolean
(
state
.
noteableData
.
current_user
.
can_create_note
);
export
const
userCanReply
=
(
state
)
=>
Boolean
(
state
.
noteableData
.
current_user
.
can_create_note
);
export
const
openState
=
state
=>
state
.
noteableData
.
state
;
export
const
openState
=
(
state
)
=>
state
.
noteableData
.
state
;
export
const
getUserData
=
state
=>
state
.
userData
||
{};
export
const
getUserData
=
(
state
)
=>
state
.
userData
||
{};
export
const
getUserDataByProp
=
state
=>
prop
=>
state
.
userData
&&
state
.
userData
[
prop
];
export
const
getUserDataByProp
=
(
state
)
=>
(
prop
)
=>
state
.
userData
&&
state
.
userData
[
prop
];
export
const
descriptionVersions
=
state
=>
state
.
descriptionVersions
;
export
const
descriptionVersions
=
(
state
)
=>
state
.
descriptionVersions
;
export
const
notesById
=
state
=>
export
const
notesById
=
(
state
)
=>
state
.
discussions
.
reduce
((
acc
,
note
)
=>
{
note
.
notes
.
every
(
n
=>
Object
.
assign
(
acc
,
{
[
n
.
id
]:
n
}));
note
.
notes
.
every
(
(
n
)
=>
Object
.
assign
(
acc
,
{
[
n
.
id
]:
n
}));
return
acc
;
},
{});
export
const
noteableType
=
state
=>
{
export
const
noteableType
=
(
state
)
=>
{
const
{
ISSUE_NOTEABLE_TYPE
,
MERGE_REQUEST_NOTEABLE_TYPE
,
EPIC_NOTEABLE_TYPE
}
=
constants
;
if
(
state
.
noteableData
.
noteableType
===
EPIC_NOTEABLE_TYPE
)
{
...
...
@@ -84,21 +84,21 @@ export const noteableType = state => {
return
state
.
noteableData
.
merge_params
?
MERGE_REQUEST_NOTEABLE_TYPE
:
ISSUE_NOTEABLE_TYPE
;
};
const
reverseNotes
=
array
=>
array
.
slice
(
0
).
reverse
();
const
reverseNotes
=
(
array
)
=>
array
.
slice
(
0
).
reverse
();
const
isLastNote
=
(
note
,
state
)
=>
!
note
.
system
&&
state
.
userData
&&
note
.
author
&&
note
.
author
.
id
===
state
.
userData
.
id
;
export
const
getCurrentUserLastNote
=
state
=>
flattenDeep
(
reverseNotes
(
state
.
discussions
).
map
(
note
=>
reverseNotes
(
note
.
notes
))).
find
(
el
=>
export
const
getCurrentUserLastNote
=
(
state
)
=>
flattenDeep
(
reverseNotes
(
state
.
discussions
).
map
(
(
note
)
=>
reverseNotes
(
note
.
notes
))).
find
((
el
)
=>
isLastNote
(
el
,
state
),
);
export
const
getDiscussionLastNote
=
state
=>
discussion
=>
reverseNotes
(
discussion
.
notes
).
find
(
el
=>
isLastNote
(
el
,
state
));
export
const
getDiscussionLastNote
=
(
state
)
=>
(
discussion
)
=>
reverseNotes
(
discussion
.
notes
).
find
(
(
el
)
=>
isLastNote
(
el
,
state
));
export
const
unresolvedDiscussionsCount
=
state
=>
state
.
unresolvedDiscussionsCount
;
export
const
resolvableDiscussionsCount
=
state
=>
state
.
resolvableDiscussionsCount
;
export
const
unresolvedDiscussionsCount
=
(
state
)
=>
state
.
unresolvedDiscussionsCount
;
export
const
resolvableDiscussionsCount
=
(
state
)
=>
state
.
resolvableDiscussionsCount
;
export
const
showJumpToNextDiscussion
=
(
state
,
getters
)
=>
(
mode
=
'
discussion
'
)
=>
{
const
orderedDiffs
=
...
...
@@ -109,20 +109,20 @@ export const showJumpToNextDiscussion = (state, getters) => (mode = 'discussion'
return
orderedDiffs
.
length
>
1
;
};
export
const
isDiscussionResolved
=
(
state
,
getters
)
=>
discussionId
=>
export
const
isDiscussionResolved
=
(
state
,
getters
)
=>
(
discussionId
)
=>
getters
.
resolvedDiscussionsById
[
discussionId
]
!==
undefined
;
export
const
allResolvableDiscussions
=
state
=>
state
.
discussions
.
filter
(
d
=>
!
d
.
individual_note
&&
d
.
resolvable
);
export
const
allResolvableDiscussions
=
(
state
)
=>
state
.
discussions
.
filter
(
(
d
)
=>
!
d
.
individual_note
&&
d
.
resolvable
);
export
const
resolvedDiscussionsById
=
state
=>
{
export
const
resolvedDiscussionsById
=
(
state
)
=>
{
const
map
=
{};
state
.
discussions
.
filter
(
d
=>
d
.
resolvable
)
.
forEach
(
n
=>
{
.
filter
(
(
d
)
=>
d
.
resolvable
)
.
forEach
(
(
n
)
=>
{
if
(
n
.
notes
)
{
const
resolved
=
n
.
notes
.
filter
(
note
=>
note
.
resolvable
).
every
(
note
=>
note
.
resolved
);
const
resolved
=
n
.
notes
.
filter
(
(
note
)
=>
note
.
resolvable
).
every
((
note
)
=>
note
.
resolved
);
if
(
resolved
)
{
map
[
n
.
id
]
=
n
;
...
...
@@ -136,7 +136,7 @@ export const resolvedDiscussionsById = state => {
// Gets Discussions IDs ordered by the date of their initial note
export
const
unresolvedDiscussionsIdsByDate
=
(
state
,
getters
)
=>
getters
.
allResolvableDiscussions
.
filter
(
d
=>
!
d
.
resolved
)
.
filter
(
(
d
)
=>
!
d
.
resolved
)
.
sort
((
a
,
b
)
=>
{
const
aDate
=
new
Date
(
a
.
notes
[
0
].
created_at
);
const
bDate
=
new
Date
(
b
.
notes
[
0
].
created_at
);
...
...
@@ -147,7 +147,7 @@ export const unresolvedDiscussionsIdsByDate = (state, getters) =>
return
aDate
===
bDate
?
0
:
1
;
})
.
map
(
d
=>
d
.
id
);
.
map
(
(
d
)
=>
d
.
id
);
// Gets Discussions IDs ordered by their position in the diff
//
...
...
@@ -156,7 +156,7 @@ export const unresolvedDiscussionsIdsByDate = (state, getters) =>
// line numbers.
export
const
unresolvedDiscussionsIdsByDiff
=
(
state
,
getters
)
=>
getters
.
allResolvableDiscussions
.
filter
(
d
=>
!
d
.
resolved
&&
d
.
active
)
.
filter
(
(
d
)
=>
!
d
.
resolved
&&
d
.
active
)
.
sort
((
a
,
b
)
=>
{
if
(
!
a
.
diff_file
||
!
b
.
diff_file
)
{
return
0
;
...
...
@@ -176,7 +176,7 @@ export const unresolvedDiscussionsIdsByDiff = (state, getters) =>
?
-
1
:
1
;
})
.
map
(
d
=>
d
.
id
);
.
map
(
(
d
)
=>
d
.
id
);
export
const
resolvedDiscussionCount
=
(
state
,
getters
)
=>
{
const
resolvedMap
=
getters
.
resolvedDiscussionsById
;
...
...
@@ -184,16 +184,16 @@ export const resolvedDiscussionCount = (state, getters) => {
return
Object
.
keys
(
resolvedMap
).
length
;
};
export
const
discussionTabCounter
=
state
=>
export
const
discussionTabCounter
=
(
state
)
=>
state
.
discussions
.
reduce
(
(
acc
,
discussion
)
=>
acc
+
discussion
.
notes
.
filter
(
note
=>
!
note
.
system
&&
!
note
.
placeholder
).
length
,
acc
+
discussion
.
notes
.
filter
(
(
note
)
=>
!
note
.
system
&&
!
note
.
placeholder
).
length
,
0
,
);
// Returns the list of discussion IDs ordered according to given parameter
// @param {Boolean} diffOrder - is ordered by diff?
export
const
unresolvedDiscussionsIdsOrdered
=
(
state
,
getters
)
=>
diffOrder
=>
{
export
const
unresolvedDiscussionsIdsOrdered
=
(
state
,
getters
)
=>
(
diffOrder
)
=>
{
if
(
diffOrder
)
{
return
getters
.
unresolvedDiscussionsIdsByDiff
;
}
...
...
@@ -241,17 +241,17 @@ export const previousUnresolvedDiscussionId = (state, getters) => (discussionId,
getters
.
findUnresolvedDiscussionIdNeighbor
({
discussionId
,
diffOrder
,
step
:
-
1
});
// @param {Boolean} diffOrder - is ordered by diff?
export
const
firstUnresolvedDiscussionId
=
(
state
,
getters
)
=>
diffOrder
=>
{
export
const
firstUnresolvedDiscussionId
=
(
state
,
getters
)
=>
(
diffOrder
)
=>
{
if
(
diffOrder
)
{
return
getters
.
unresolvedDiscussionsIdsByDiff
[
0
];
}
return
getters
.
unresolvedDiscussionsIdsByDate
[
0
];
};
export
const
getDiscussion
=
state
=>
discussionId
=>
state
.
discussions
.
find
(
discussion
=>
discussion
.
id
===
discussionId
);
export
const
getDiscussion
=
(
state
)
=>
(
discussionId
)
=>
state
.
discussions
.
find
(
(
discussion
)
=>
discussion
.
id
===
discussionId
);
export
const
commentsDisabled
=
state
=>
state
.
commentsDisabled
;
export
const
commentsDisabled
=
(
state
)
=>
state
.
commentsDisabled
;
export
const
suggestionsCount
=
(
state
,
getters
)
=>
Object
.
values
(
getters
.
notesById
).
filter
(
n
=>
n
.
suggestions
.
length
).
length
;
Object
.
values
(
getters
.
notesById
).
filter
(
(
n
)
=>
n
.
suggestions
.
length
).
length
;
app/assets/javascripts/notes/stores/mutations.js
View file @
a2f5e739
...
...
@@ -7,7 +7,7 @@ export default {
[
types
.
ADD_NEW_NOTE
](
state
,
data
)
{
const
note
=
data
.
discussion
?
data
.
discussion
.
notes
[
0
]
:
data
;
const
{
discussion_id
,
type
}
=
note
;
const
[
exists
]
=
state
.
discussions
.
filter
(
n
=>
n
.
id
===
note
.
discussion_id
);
const
[
exists
]
=
state
.
discussions
.
filter
(
(
n
)
=>
n
.
id
===
note
.
discussion_id
);
const
isDiscussion
=
type
===
constants
.
DISCUSSION_NOTE
||
type
===
constants
.
DIFF_NOTE
;
if
(
!
exists
)
{
...
...
@@ -128,7 +128,7 @@ export default {
// To support legacy notes, should be very rare case.
if
(
discussion
.
individual_note
&&
discussion
.
notes
.
length
>
1
)
{
discussion
.
notes
.
forEach
(
n
=>
{
discussion
.
notes
.
forEach
(
(
n
)
=>
{
acc
.
push
({
...
discussion
,
...
diffData
,
...
...
@@ -183,7 +183,7 @@ export default {
const
{
id
,
name
,
username
}
=
state
.
userData
;
const
hasEmojiAwardedByCurrentUser
=
note
.
award_emoji
.
filter
(
emoji
=>
`
${
emoji
.
name
}
`
===
`
${
data
.
awardName
}
`
&&
emoji
.
user
.
id
===
id
,
(
emoji
)
=>
`
${
emoji
.
name
}
`
===
`
${
data
.
awardName
}
`
&&
emoji
.
user
.
id
===
id
,
);
if
(
hasEmojiAwardedByCurrentUser
.
length
)
{
...
...
@@ -206,7 +206,7 @@ export default {
[
types
.
SET_EXPAND_DISCUSSIONS
](
state
,
{
discussionIds
,
expanded
})
{
if
(
discussionIds
?.
length
)
{
discussionIds
.
forEach
(
discussionId
=>
{
discussionIds
.
forEach
(
(
discussionId
)
=>
{
const
discussion
=
utils
.
findNoteObjectById
(
state
.
discussions
,
discussionId
);
Object
.
assign
(
discussion
,
{
expanded
});
});
...
...
@@ -236,7 +236,7 @@ export default {
const
noteObj
=
utils
.
findNoteObjectById
(
state
.
discussions
,
discussionId
);
const
comment
=
utils
.
findNoteObjectById
(
noteObj
.
notes
,
noteId
);
comment
.
suggestions
=
comment
.
suggestions
.
map
(
suggestion
=>
({
comment
.
suggestions
=
comment
.
suggestions
.
map
(
(
suggestion
)
=>
({
...
suggestion
,
applied
:
suggestion
.
applied
||
suggestion
.
id
===
suggestionId
,
appliable
:
false
,
...
...
@@ -244,13 +244,13 @@ export default {
},
[
types
.
SET_APPLYING_BATCH_STATE
](
state
,
isApplyingBatch
)
{
state
.
batchSuggestionsInfo
.
forEach
(
suggestionInfo
=>
{
state
.
batchSuggestionsInfo
.
forEach
(
(
suggestionInfo
)
=>
{
const
{
discussionId
,
noteId
,
suggestionId
}
=
suggestionInfo
;
const
noteObj
=
utils
.
findNoteObjectById
(
state
.
discussions
,
discussionId
);
const
comment
=
utils
.
findNoteObjectById
(
noteObj
.
notes
,
noteId
);
comment
.
suggestions
=
comment
.
suggestions
.
map
(
suggestion
=>
({
comment
.
suggestions
=
comment
.
suggestions
.
map
(
(
suggestion
)
=>
({
...
suggestion
,
is_applying_batch
:
suggestion
.
id
===
suggestionId
&&
isApplyingBatch
,
}));
...
...
@@ -278,7 +278,7 @@ export default {
[
types
.
UPDATE_DISCUSSION
](
state
,
noteData
)
{
const
note
=
noteData
;
const
selectedDiscussion
=
state
.
discussions
.
find
(
disc
=>
disc
.
id
===
note
.
id
);
const
selectedDiscussion
=
state
.
discussions
.
find
(
(
disc
)
=>
disc
.
id
===
note
.
id
);
note
.
expanded
=
true
;
// override expand flag to prevent collapse
if
(
note
.
diff_file
)
{
Object
.
assign
(
note
,
{
...
...
@@ -289,7 +289,7 @@ export default {
},
[
types
.
UPDATE_DISCUSSION_POSITION
](
state
,
{
discussionId
,
position
})
{
const
selectedDiscussion
=
state
.
discussions
.
find
(
disc
=>
disc
.
id
===
discussionId
);
const
selectedDiscussion
=
state
.
discussions
.
find
(
(
disc
)
=>
disc
.
id
===
discussionId
);
if
(
selectedDiscussion
)
Object
.
assign
(
selectedDiscussion
.
position
,
{
...
position
});
},
...
...
@@ -341,13 +341,13 @@ export default {
},
[
types
.
UPDATE_RESOLVABLE_DISCUSSIONS_COUNTS
](
state
)
{
state
.
resolvableDiscussionsCount
=
state
.
discussions
.
filter
(
discussion
=>
!
discussion
.
individual_note
&&
discussion
.
resolvable
,
(
discussion
)
=>
!
discussion
.
individual_note
&&
discussion
.
resolvable
,
).
length
;
state
.
unresolvedDiscussionsCount
=
state
.
discussions
.
filter
(
discussion
=>
(
discussion
)
=>
!
discussion
.
individual_note
&&
discussion
.
resolvable
&&
discussion
.
notes
.
some
(
note
=>
note
.
resolvable
&&
!
note
.
resolved
),
discussion
.
notes
.
some
(
(
note
)
=>
note
.
resolvable
&&
!
note
.
resolved
),
).
length
;
},
...
...
app/assets/javascripts/notes/stores/utils.js
View file @
a2f5e739
...
...
@@ -6,13 +6,13 @@ import createGqClient, { fetchPolicies } from '~/lib/graphql';
// factory function because global flag makes RegExp stateful
const
createQuickActionsRegex
=
()
=>
/^
\/\w
+.*$/gm
;
export
const
findNoteObjectById
=
(
notes
,
id
)
=>
notes
.
filter
(
n
=>
n
.
id
===
id
)[
0
];
export
const
findNoteObjectById
=
(
notes
,
id
)
=>
notes
.
filter
(
(
n
)
=>
n
.
id
===
id
)[
0
];
export
const
getQuickActionText
=
note
=>
{
export
const
getQuickActionText
=
(
note
)
=>
{
let
text
=
__
(
'
Applying command
'
);
const
quickActions
=
AjaxCache
.
get
(
gl
.
GfmAutoComplete
.
dataSources
.
commands
)
||
[];
const
executedCommands
=
quickActions
.
filter
(
command
=>
{
const
executedCommands
=
quickActions
.
filter
(
(
command
)
=>
{
const
commandRegex
=
new
RegExp
(
`/
${
command
.
name
}
`
);
return
commandRegex
.
test
(
note
);
});
...
...
@@ -29,12 +29,12 @@ export const getQuickActionText = note => {
return
text
;
};
export
const
hasQuickActions
=
note
=>
createQuickActionsRegex
().
test
(
note
);
export
const
hasQuickActions
=
(
note
)
=>
createQuickActionsRegex
().
test
(
note
);
export
const
stripQuickActions
=
note
=>
note
.
replace
(
createQuickActionsRegex
(),
''
).
trim
();
export
const
stripQuickActions
=
(
note
)
=>
note
.
replace
(
createQuickActionsRegex
(),
''
).
trim
();
export
const
prepareDiffLines
=
diffLines
=>
diffLines
.
map
(
line
=>
({
...
trimFirstCharOfLineContent
(
line
)
}));
export
const
prepareDiffLines
=
(
diffLines
)
=>
diffLines
.
map
(
(
line
)
=>
({
...
trimFirstCharOfLineContent
(
line
)
}));
export
const
gqClient
=
createGqClient
(
{},
...
...
app/assets/javascripts/notes/utils.js
View file @
a2f5e739
...
...
@@ -4,7 +4,7 @@
* Tracks snowplow event when User toggles timeline view
* @param {Boolean} enabled that will be send as a property for the event
*/
export
const
trackToggleTimelineView
=
enabled
=>
({
export
const
trackToggleTimelineView
=
(
enabled
)
=>
({
category
:
'
Incident Management
'
,
action
:
'
toggle_incident_comments_into_timeline_view
'
,
label
:
'
Status
'
,
...
...
app/assets/javascripts/notifications_dropdown.js
View file @
a2f5e739
...
...
@@ -23,7 +23,7 @@ export default function notificationsDropdown() {
Rails
.
fire
(
form
[
0
],
'
submit
'
);
});
$
(
document
).
on
(
'
ajax:success
'
,
'
.notification-form
'
,
e
=>
{
$
(
document
).
on
(
'
ajax:success
'
,
'
.notification-form
'
,
(
e
)
=>
{
const
data
=
e
.
detail
[
0
];
if
(
data
.
saved
)
{
...
...
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