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
Boxiang Sun
gitlab-ce
Commits
2845dad2
Commit
2845dad2
authored
Jul 28, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Find last note created by current user through vue instead of querying the DOM
parent
7a251207
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
22 deletions
+48
-22
app/assets/javascripts/notes/components/issue_comment_form.vue
...ssets/javascripts/notes/components/issue_comment_form.vue
+10
-7
app/assets/javascripts/notes/components/issue_discussion.vue
app/assets/javascripts/notes/components/issue_discussion.vue
+3
-2
app/assets/javascripts/notes/components/issue_note.vue
app/assets/javascripts/notes/components/issue_note.vue
+2
-1
app/assets/javascripts/notes/components/issue_note_body.vue
app/assets/javascripts/notes/components/issue_note_body.vue
+1
-9
app/assets/javascripts/notes/components/issue_note_form.vue
app/assets/javascripts/notes/components/issue_note_form.vue
+10
-1
app/assets/javascripts/notes/components/issue_notes_app.vue
app/assets/javascripts/notes/components/issue_notes_app.vue
+9
-2
app/assets/javascripts/notes/stores/getters.js
app/assets/javascripts/notes/stores/getters.js
+13
-0
No files found.
app/assets/javascripts/notes/components/issue_comment_form.vue
View file @
2845dad2
<
script
>
/* global Flash */
import
{
mapActions
}
from
'
vuex
'
;
import
{
mapActions
,
mapGetters
}
from
'
vuex
'
;
import
userAvatarLink
from
'
../../vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
markdownField
from
'
../../vue_shared/components/markdown/field.vue
'
;
import
issueNoteSignedOutWidget
from
'
./issue_note_signed_out_widget.vue
'
;
...
...
@@ -30,6 +30,9 @@
issueNoteSignedOutWidget
,
},
computed
:
{
...
mapGetters
([
'
getCurrentUserLastNote
'
,
]),
isLoggedIn
()
{
return
window
.
gon
.
current_user_id
;
},
...
...
@@ -126,13 +129,13 @@
setNoteType
(
type
)
{
this
.
noteType
=
type
;
},
edit
My
LastNote
()
{
edit
CurrentUser
LastNote
()
{
if
(
this
.
note
===
''
)
{
const
myLastNoteId
=
$
(
'
.js-my-note
'
).
last
().
attr
(
'
id
'
);
debugger
;
if
(
myLastNoteId
)
{
const
lastNote
=
this
.
getCurrentUserLastNote
(
window
.
gon
.
current_user_id
);
console
.
log
(
lastNote
)
if
(
lastNote
)
{
eventHub
.
$emit
(
'
enterEditMode
'
,
{
noteId
:
parseInt
(
myLastNoteId
.
replace
(
'
note_
'
,
''
),
10
)
,
noteId
:
lastNote
.
id
,
});
}
}
...
...
@@ -185,7 +188,7 @@
ref=
"textarea"
slot=
"textarea"
placeholder=
"Write a comment or drag your files here..."
@
keydown.up=
"edit
MyLastNote
"
@
keydown.up=
"edit
CurrentUserLastNote()
"
@
keydown.meta.enter=
"handleSave()"
>
</textarea>
</markdown-field>
...
...
app/assets/javascripts/notes/components/issue_discussion.vue
View file @
2845dad2
...
...
@@ -164,8 +164,9 @@
<issue-note-form
v-if=
"isReplying"
saveButtonTitle=
"Comment"
:update-handler=
"saveReply"
:cancel-handler=
"cancelReplyForm"
:discussion=
"note"
@
handleFormUpdate=
"saveReply"
@
cancelFormEdition=
"cancelReplyForm"
ref=
"noteForm"
/>
<issue-note-signed-out-widget
v-if=
"!canReply"
/>
...
...
app/assets/javascripts/notes/components/issue_note.vue
View file @
2845dad2
...
...
@@ -118,7 +118,8 @@
<li
class=
"note timeline-entry"
:id=
"noteAnchorId"
:class=
"classNameBindings"
>
:class=
"classNameBindings"
:note-id=
"note.id"
>
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-icon"
>
<user-avatar-link
...
...
app/assets/javascripts/notes/components/issue_note_body.vue
View file @
2845dad2
...
...
@@ -19,14 +19,6 @@
required
:
false
,
default
:
false
,
},
formUpdateHandler
:
{
type
:
Function
,
required
:
true
,
},
formCancelHandler
:
{
type
:
Function
,
required
:
true
,
},
},
components
:
{
issueNoteEditedText
,
...
...
@@ -93,7 +85,7 @@
v-if=
"note.last_edited_by"
:edited-at=
"note.last_edited_at"
:edited-by=
"note.last_edited_by"
action
T
ext=
"Edited"
action
-t
ext=
"Edited"
/>
<issue-note-awards-list
v-if=
"note.award_emoji.length"
...
...
app/assets/javascripts/notes/components/issue_note_form.vue
View file @
2845dad2
...
...
@@ -18,6 +18,10 @@
required
:
false
,
default
:
'
Save comment
'
,
},
discussion
:
{
type
:
Array
,
required
:
false
,
}
},
data
()
{
const
{
getIssueData
,
getNotesData
}
=
this
.
$store
.
getters
;
...
...
@@ -44,9 +48,14 @@
},
editMyLastNote
()
{
if
(
this
.
note
===
''
)
{
// TODO: HANDLE THIS WITHOUTH JQUERY OR QUERYING THE DOM
// FIND the discussion we are in and the last comment on that discussion
const
discussion
=
$
(
this
.
$el
).
closest
(
'
.discussion-notes
'
);
const
myLastNoteId
=
discussion
.
find
(
'
.js-my-note
'
).
last
().
attr
(
'
id
'
);
debugger
;
const
lastNoteInDiscussion
=
this
.
$store
.
getters
.
getDiscussionLastNote
(
this
.
discussion
);
if
(
myLastNoteId
)
{
eventHub
.
$emit
(
'
enterEditMode
'
,
{
noteId
:
parseInt
(
myLastNoteId
.
replace
(
'
note_
'
,
''
),
10
),
...
...
@@ -116,7 +125,7 @@
{{
saveButtonTitle
}}
</button>
<button
@
click=
"cancelHandler"
@
click=
"cancelHandler
()
"
class=
"btn btn-nr btn-cancel note-edit-cancel"
type=
"button"
>
Cancel
...
...
app/assets/javascripts/notes/components/issue_notes_app.vue
View file @
2845dad2
...
...
@@ -60,6 +60,7 @@
setNotesData
:
'
setNotesData
'
,
setIssueData
:
'
setIssueData
'
,
setUserData
:
'
setUserData
'
,
setLastFetchedAt
:
'
setLastFetchedAt
'
}),
getComponentName
(
note
)
{
if
(
note
.
isPlaceholderNote
)
{
...
...
@@ -86,7 +87,10 @@
this
.
checkLocationHash
();
});
})
.
catch
(()
=>
Flash
(
'
Something went wrong while fetching issue comments. Please try again.
'
));
.
catch
((
error
)
=>
{
console
.
log
(
error
)
Flash
(
'
Something went wrong while fetching issue comments. Please try again.
'
)
});
},
initPolling
()
{
this
.
setLastFetchedAt
(
this
.
getNotesDataByProp
(
'
lastFetchedAt
'
));
...
...
@@ -98,7 +102,10 @@
.
then
((
res
)
=>
{
this
.
setLastFetchedAt
(
res
.
lastFetchedAt
);
})
.
catch
(()
=>
Flash
(
'
Something went wrong while fetching latest comments.
'
));
.
catch
((
error
)
=>
{
console
.
log
(
error
)
Flash
(
'
Something went wrong while fetching latest comments.
'
)
}
);
},
15000
);
},
bindEventHubListeners
()
{
...
...
app/assets/javascripts/notes/stores/getters.js
View file @
2845dad2
...
...
@@ -21,3 +21,16 @@ export const notesById = (state) => {
return
notesByIdObject
;
};
const
reverseNotes
=
array
=>
array
.
slice
(
0
).
reverse
();
const
isLastNote
=
(
note
,
userId
)
=>
!
note
.
system
&&
note
.
author
.
id
===
userId
;
export
const
getCurrentUserLastNote
=
state
=>
userId
=>
reverseNotes
(
state
.
notes
)
.
reduce
((
acc
,
note
)
=>
{
acc
.
push
(
reverseNotes
(
note
.
notes
).
find
(
el
=>
isLastNote
(
el
,
userId
)));
return
acc
;
},
[]).
filter
(
el
=>
el
!==
undefined
)[
0
];
export
const
getDiscussionLastNote
=
state
=>
(
discussion
,
userId
)
=>
reverseNotes
(
discussion
[
0
].
notes
)
.
find
(
el
=>
isLastNote
(
el
,
userId
));
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