BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
22 deletions
+48
-22
issue_comment_form.vue
...ssets/javascripts/notes/components/issue_comment_form.vue
+10
-7
issue_discussion.vue
app/assets/javascripts/notes/components/issue_discussion.vue
+3
-2
issue_note.vue
app/assets/javascripts/notes/components/issue_note.vue
+2
-1
issue_note_body.vue
app/assets/javascripts/notes/components/issue_note_body.vue
+1
-9
issue_note_form.vue
app/assets/javascripts/notes/components/issue_note_form.vue
+10
-1
issue_notes_app.vue
app/assets/javascripts/notes/components/issue_notes_app.vue
+9
-2
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
>
<
script
>
/* global Flash */
/* global Flash */
import
{
mapActions
}
from
'vuex'
;
import
{
mapActions
,
mapGetters
}
from
'vuex'
;
import
userAvatarLink
from
'../../vue_shared/components/user_avatar/user_avatar_link.vue'
;
import
userAvatarLink
from
'../../vue_shared/components/user_avatar/user_avatar_link.vue'
;
import
markdownField
from
'../../vue_shared/components/markdown/field.vue'
;
import
markdownField
from
'../../vue_shared/components/markdown/field.vue'
;
import
issueNoteSignedOutWidget
from
'./issue_note_signed_out_widget.vue'
;
import
issueNoteSignedOutWidget
from
'./issue_note_signed_out_widget.vue'
;
...
@@ -30,6 +30,9 @@
...
@@ -30,6 +30,9 @@
issueNoteSignedOutWidget
,
issueNoteSignedOutWidget
,
},
},
computed
:
{
computed
:
{
...
mapGetters
([
'getCurrentUserLastNote'
,
]),
isLoggedIn
()
{
isLoggedIn
()
{
return
window
.
gon
.
current_user_id
;
return
window
.
gon
.
current_user_id
;
},
},
...
@@ -126,13 +129,13 @@
...
@@ -126,13 +129,13 @@
setNoteType
(
type
)
{
setNoteType
(
type
)
{
this
.
noteType
=
type
;
this
.
noteType
=
type
;
},
},
edit
My
LastNote
()
{
edit
CurrentUser
LastNote
()
{
if
(
this
.
note
===
''
)
{
if
(
this
.
note
===
''
)
{
const
myLastNoteId
=
$
(
'.js-my-note'
).
last
().
attr
(
'id'
);
const
lastNote
=
this
.
getCurrentUserLastNote
(
window
.
gon
.
current_user_id
);
debugger
;
console
.
log
(
lastNote
)
if
(
myLastNoteId
)
{
if
(
lastNote
)
{
eventHub
.
$emit
(
'enterEditMode'
,
{
eventHub
.
$emit
(
'enterEditMode'
,
{
noteId
:
parseInt
(
myLastNoteId
.
replace
(
'note_'
,
''
),
10
)
,
noteId
:
lastNote
.
id
,
});
});
}
}
}
}
...
@@ -185,7 +188,7 @@
...
@@ -185,7 +188,7 @@
ref=
"textarea"
ref=
"textarea"
slot=
"textarea"
slot=
"textarea"
placeholder=
"Write a comment or drag your files here..."
placeholder=
"Write a comment or drag your files here..."
@
keydown
.
up=
"edit
MyLastNote
"
@
keydown
.
up=
"edit
CurrentUserLastNote()
"
@
keydown
.
meta
.
enter=
"handleSave()"
>
@
keydown
.
meta
.
enter=
"handleSave()"
>
</textarea>
</textarea>
</markdown-field>
</markdown-field>
...
...
app/assets/javascripts/notes/components/issue_discussion.vue
View file @
2845dad2
...
@@ -164,8 +164,9 @@
...
@@ -164,8 +164,9 @@
<issue-note-form
<issue-note-form
v-if=
"isReplying"
v-if=
"isReplying"
saveButtonTitle=
"Comment"
saveButtonTitle=
"Comment"
:update-handler=
"saveReply"
:discussion=
"note"
:cancel-handler=
"cancelReplyForm"
@
handleFormUpdate=
"saveReply"
@
cancelFormEdition=
"cancelReplyForm"
ref=
"noteForm"
ref=
"noteForm"
/>
/>
<issue-note-signed-out-widget
v-if=
"!canReply"
/>
<issue-note-signed-out-widget
v-if=
"!canReply"
/>
...
...
app/assets/javascripts/notes/components/issue_note.vue
View file @
2845dad2
...
@@ -118,7 +118,8 @@
...
@@ -118,7 +118,8 @@
<li
<li
class=
"note timeline-entry"
class=
"note timeline-entry"
:id=
"noteAnchorId"
:id=
"noteAnchorId"
:class=
"classNameBindings"
>
:class=
"classNameBindings"
:note-id=
"note.id"
>
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-icon"
>
<div
class=
"timeline-icon"
>
<user-avatar-link
<user-avatar-link
...
...
app/assets/javascripts/notes/components/issue_note_body.vue
View file @
2845dad2
...
@@ -19,14 +19,6 @@
...
@@ -19,14 +19,6 @@
required
:
false
,
required
:
false
,
default
:
false
,
default
:
false
,
},
},
formUpdateHandler
:
{
type
:
Function
,
required
:
true
,
},
formCancelHandler
:
{
type
:
Function
,
required
:
true
,
},
},
},
components
:
{
components
:
{
issueNoteEditedText
,
issueNoteEditedText
,
...
@@ -93,7 +85,7 @@
...
@@ -93,7 +85,7 @@
v-if=
"note.last_edited_by"
v-if=
"note.last_edited_by"
:edited-at=
"note.last_edited_at"
:edited-at=
"note.last_edited_at"
:edited-by=
"note.last_edited_by"
:edited-by=
"note.last_edited_by"
action
T
ext=
"Edited"
action
-t
ext=
"Edited"
/>
/>
<issue-note-awards-list
<issue-note-awards-list
v-if=
"note.award_emoji.length"
v-if=
"note.award_emoji.length"
...
...
app/assets/javascripts/notes/components/issue_note_form.vue
View file @
2845dad2
...
@@ -18,6 +18,10 @@
...
@@ -18,6 +18,10 @@
required
:
false
,
required
:
false
,
default
:
'Save comment'
,
default
:
'Save comment'
,
},
},
discussion
:
{
type
:
Array
,
required
:
false
,
}
},
},
data
()
{
data
()
{
const
{
getIssueData
,
getNotesData
}
=
this
.
$store
.
getters
;
const
{
getIssueData
,
getNotesData
}
=
this
.
$store
.
getters
;
...
@@ -44,9 +48,14 @@
...
@@ -44,9 +48,14 @@
},
},
editMyLastNote
()
{
editMyLastNote
()
{
if
(
this
.
note
===
''
)
{
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
discussion
=
$
(
this
.
$el
).
closest
(
'.discussion-notes'
);
const
myLastNoteId
=
discussion
.
find
(
'.js-my-note'
).
last
().
attr
(
'id'
);
const
myLastNoteId
=
discussion
.
find
(
'.js-my-note'
).
last
().
attr
(
'id'
);
debugger
;
const
lastNoteInDiscussion
=
this
.
$store
.
getters
.
getDiscussionLastNote
(
this
.
discussion
);
if
(
myLastNoteId
)
{
if
(
myLastNoteId
)
{
eventHub
.
$emit
(
'enterEditMode'
,
{
eventHub
.
$emit
(
'enterEditMode'
,
{
noteId
:
parseInt
(
myLastNoteId
.
replace
(
'note_'
,
''
),
10
),
noteId
:
parseInt
(
myLastNoteId
.
replace
(
'note_'
,
''
),
10
),
...
@@ -116,7 +125,7 @@
...
@@ -116,7 +125,7 @@
{{
saveButtonTitle
}}
{{
saveButtonTitle
}}
</button>
</button>
<button
<button
@
click=
"cancelHandler"
@
click=
"cancelHandler
()
"
class=
"btn btn-nr btn-cancel note-edit-cancel"
class=
"btn btn-nr btn-cancel note-edit-cancel"
type=
"button"
>
type=
"button"
>
Cancel
Cancel
...
...
app/assets/javascripts/notes/components/issue_notes_app.vue
View file @
2845dad2
...
@@ -60,6 +60,7 @@
...
@@ -60,6 +60,7 @@
setNotesData
:
'setNotesData'
,
setNotesData
:
'setNotesData'
,
setIssueData
:
'setIssueData'
,
setIssueData
:
'setIssueData'
,
setUserData
:
'setUserData'
,
setUserData
:
'setUserData'
,
setLastFetchedAt
:
'setLastFetchedAt'
}),
}),
getComponentName
(
note
)
{
getComponentName
(
note
)
{
if
(
note
.
isPlaceholderNote
)
{
if
(
note
.
isPlaceholderNote
)
{
...
@@ -86,7 +87,10 @@
...
@@ -86,7 +87,10 @@
this
.
checkLocationHash
();
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
()
{
initPolling
()
{
this
.
setLastFetchedAt
(
this
.
getNotesDataByProp
(
'lastFetchedAt'
));
this
.
setLastFetchedAt
(
this
.
getNotesDataByProp
(
'lastFetchedAt'
));
...
@@ -98,7 +102,10 @@
...
@@ -98,7 +102,10 @@
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
this
.
setLastFetchedAt
(
res
.
lastFetchedAt
);
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
);
},
15000
);
},
},
bindEventHubListeners
()
{
bindEventHubListeners
()
{
...
...
app/assets/javascripts/notes/stores/getters.js
View file @
2845dad2
...
@@ -21,3 +21,16 @@ export const notesById = (state) => {
...
@@ -21,3 +21,16 @@ export const notesById = (state) => {
return
notesByIdObject
;
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