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
Jérome Perrin
gitlab-ce
Commits
b26637c5
Commit
b26637c5
authored
Jul 14, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IssueNotesRefactor: Move inline fn to utils file.
parent
db0b7fb3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
app/assets/javascripts/notes/stores/issue_notes_store.js
app/assets/javascripts/notes/stores/issue_notes_store.js
+8
-10
app/assets/javascripts/notes/stores/issue_notes_utils.js
app/assets/javascripts/notes/stores/issue_notes_utils.js
+3
-0
No files found.
app/assets/javascripts/notes/stores/issue_notes_store.js
View file @
b26637c5
...
...
@@ -3,8 +3,6 @@
import
service
from
'
../services/issue_notes_service
'
;
import
utils
from
'
./issue_notes_utils
'
;
const
findNoteObjectById
=
(
notes
,
id
)
=>
notes
.
filter
(
n
=>
n
.
id
===
id
)[
0
];
const
state
=
{
notes
:
[],
targetNoteHash
:
null
,
...
...
@@ -39,17 +37,17 @@ const mutations = {
storeState
.
targetNoteHash
=
hash
;
},
toggleDiscussion
(
storeState
,
{
discussionId
})
{
const
discussion
=
findNoteObjectById
(
storeState
.
notes
,
discussionId
);
const
discussion
=
utils
.
findNoteObjectById
(
storeState
.
notes
,
discussionId
);
discussion
.
expanded
=
!
discussion
.
expanded
;
},
deleteNote
(
storeState
,
note
)
{
const
noteObj
=
findNoteObjectById
(
storeState
.
notes
,
note
.
discussion_id
);
const
noteObj
=
utils
.
findNoteObjectById
(
storeState
.
notes
,
note
.
discussion_id
);
if
(
noteObj
.
individual_note
)
{
storeState
.
notes
.
splice
(
storeState
.
notes
.
indexOf
(
noteObj
),
1
);
}
else
{
const
comment
=
findNoteObjectById
(
noteObj
.
notes
,
note
.
id
);
const
comment
=
utils
.
findNoteObjectById
(
noteObj
.
notes
,
note
.
id
);
noteObj
.
notes
.
splice
(
noteObj
.
notes
.
indexOf
(
comment
),
1
);
if
(
!
noteObj
.
notes
.
length
)
{
...
...
@@ -58,19 +56,19 @@ const mutations = {
}
},
addNewReplyToDiscussion
(
storeState
,
note
)
{
const
noteObj
=
findNoteObjectById
(
storeState
.
notes
,
note
.
discussion_id
);
const
noteObj
=
utils
.
findNoteObjectById
(
storeState
.
notes
,
note
.
discussion_id
);
if
(
noteObj
)
{
noteObj
.
notes
.
push
(
note
);
}
},
updateNote
(
storeState
,
note
)
{
const
noteObj
=
findNoteObjectById
(
storeState
.
notes
,
note
.
discussion_id
);
const
noteObj
=
utils
.
findNoteObjectById
(
storeState
.
notes
,
note
.
discussion_id
);
if
(
noteObj
.
individual_note
)
{
noteObj
.
notes
.
splice
(
0
,
1
,
note
);
}
else
{
const
comment
=
findNoteObjectById
(
noteObj
.
notes
,
note
.
id
);
const
comment
=
utils
.
findNoteObjectById
(
noteObj
.
notes
,
note
.
id
);
noteObj
.
notes
.
splice
(
noteObj
.
notes
.
indexOf
(
comment
),
1
,
note
);
}
},
...
...
@@ -112,7 +110,7 @@ const mutations = {
showPlaceholderNote
(
storeState
,
data
)
{
let
notesArr
=
storeState
.
notes
;
if
(
data
.
replyId
)
{
notesArr
=
findNoteObjectById
(
notesArr
,
data
.
replyId
).
notes
;
notesArr
=
utils
.
findNoteObjectById
(
notesArr
,
data
.
replyId
).
notes
;
}
notesArr
.
push
({
...
...
@@ -255,7 +253,7 @@ const actions = {
if
(
notesById
[
note
.
id
])
{
context
.
commit
(
'
updateNote
'
,
note
);
}
else
if
(
note
.
type
===
'
DiscussionNote
'
)
{
const
discussion
=
findNoteObjectById
(
context
.
state
.
notes
,
note
.
discussion_id
);
const
discussion
=
utils
.
findNoteObjectById
(
context
.
state
.
notes
,
note
.
discussion_id
);
if
(
discussion
)
{
context
.
commit
(
'
addNewReplyToDiscussion
'
,
note
);
...
...
app/assets/javascripts/notes/stores/issue_notes_utils.js
View file @
b26637c5
...
...
@@ -3,6 +3,9 @@ import AjaxCache from '~/lib/utils/ajax_cache';
const
REGEX_QUICK_ACTIONS
=
/^
\/\w
+.*$/gm
;
export
default
{
findNoteObjectById
(
notes
,
id
)
{
return
notes
.
filter
(
n
=>
n
.
id
===
id
)[
0
];
},
getQuickActionText
(
note
)
{
let
text
=
'
Applying command
'
;
const
quickActions
=
AjaxCache
.
get
(
gl
.
GfmAutoComplete
.
dataSources
.
commands
);
...
...
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