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
993936fb
Commit
993936fb
authored
Jul 07, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IssueNotesRefactor: Implement jumping to target note.
parent
b72db796
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
4 deletions
+60
-4
app/assets/javascripts/lib/utils/common_utils.js
app/assets/javascripts/lib/utils/common_utils.js
+3
-2
app/assets/javascripts/notes/components/issue_note.vue
app/assets/javascripts/notes/components/issue_note.vue
+10
-0
app/assets/javascripts/notes/components/issue_note_header.vue
...assets/javascripts/notes/components/issue_note_header.vue
+6
-1
app/assets/javascripts/notes/components/issue_notes.vue
app/assets/javascripts/notes/components/issue_notes.vue
+18
-0
app/assets/javascripts/notes/components/issue_system_note.vue
...assets/javascripts/notes/components/issue_system_note.vue
+16
-1
app/assets/javascripts/notes/stores/issue_notes_store.js
app/assets/javascripts/notes/stores/issue_notes_store.js
+7
-0
No files found.
app/assets/javascripts/lib/utils/common_utils.js
View file @
993936fb
...
@@ -162,10 +162,11 @@
...
@@ -162,10 +162,11 @@
gl
.
utils
.
scrollToElement
=
function
(
$el
)
{
gl
.
utils
.
scrollToElement
=
function
(
$el
)
{
var
top
=
$el
.
offset
().
top
;
var
top
=
$el
.
offset
().
top
;
gl
.
mrTabsHeight
=
gl
.
mrTabsHeight
||
$
(
'
.merge-request-tabs
'
).
height
();
var
mrTabsHeight
=
$
(
'
.merge-request-tabs
'
).
height
()
||
0
;
var
headerHeight
=
$
(
'
.navbar-gitlab
'
).
height
()
||
0
;
return
$
(
'
body, html
'
).
animate
({
return
$
(
'
body, html
'
).
animate
({
scrollTop
:
top
-
(
gl
.
mrTabsHeight
)
scrollTop
:
top
-
mrTabsHeight
-
headerHeight
},
200
);
},
200
);
};
};
...
...
app/assets/javascripts/notes/components/issue_note.vue
View file @
993936fb
<
script
>
<
script
>
/* global Flash */
/* global Flash */
import
{
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
IssueNoteHeader
from
'
./issue_note_header.vue
'
;
import
IssueNoteHeader
from
'
./issue_note_header.vue
'
;
import
IssueNoteActions
from
'
./issue_note_actions.vue
'
;
import
IssueNoteActions
from
'
./issue_note_actions.vue
'
;
...
@@ -26,6 +27,9 @@ export default {
...
@@ -26,6 +27,9 @@ export default {
IssueNoteBody
,
IssueNoteBody
,
},
},
computed
:
{
computed
:
{
...
mapGetters
([
'
targetNoteHash
'
,
]),
author
()
{
author
()
{
return
this
.
note
.
author
;
return
this
.
note
.
author
;
},
},
...
@@ -33,11 +37,15 @@ export default {
...
@@ -33,11 +37,15 @@ export default {
return
{
return
{
'
is-editing
'
:
this
.
isEditing
,
'
is-editing
'
:
this
.
isEditing
,
'
disabled-content
'
:
this
.
isDeleting
,
'
disabled-content
'
:
this
.
isDeleting
,
target
:
this
.
targetNoteHash
===
this
.
noteAnchorId
,
};
};
},
},
canReportAsAbuse
()
{
canReportAsAbuse
()
{
return
this
.
note
.
report_abuse_path
&&
this
.
author
.
id
!==
window
.
gon
.
current_user_id
;
return
this
.
note
.
report_abuse_path
&&
this
.
author
.
id
!==
window
.
gon
.
current_user_id
;
},
},
noteAnchorId
()
{
return
`note_
${
this
.
note
.
id
}
`
;
},
},
},
methods
:
{
methods
:
{
editHandler
()
{
editHandler
()
{
...
@@ -98,6 +106,7 @@ export default {
...
@@ -98,6 +106,7 @@ export default {
<
template
>
<
template
>
<li
<li
class=
"note timeline-entry"
class=
"note timeline-entry"
:id=
"noteAnchorId"
:class=
"classNameBindings"
>
:class=
"classNameBindings"
>
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-icon"
>
<div
class=
"timeline-icon"
>
...
@@ -115,6 +124,7 @@ export default {
...
@@ -115,6 +124,7 @@ export default {
:noteId=
"note.id"
:noteId=
"note.id"
actionText=
"commented"
/>
actionText=
"commented"
/>
<issue-note-actions
<issue-note-actions
:authorId=
"author.id"
:accessLevel=
"note.human_access"
:accessLevel=
"note.human_access"
:canAward=
"note.emoji_awardable"
:canAward=
"note.emoji_awardable"
:canEdit=
"note.current_user.can_edit"
:canEdit=
"note.current_user.can_edit"
...
...
app/assets/javascripts/notes/components/issue_note_header.vue
View file @
993936fb
...
@@ -56,6 +56,9 @@ export default {
...
@@ -56,6 +56,9 @@ export default {
this
.
isExpanded
=
!
this
.
isExpanded
;
this
.
isExpanded
=
!
this
.
isExpanded
;
this
.
toggleHandler
();
this
.
toggleHandler
();
},
},
updateTargetNoteHash
()
{
this
.
$store
.
commit
(
'
setTargetNoteHash
'
,
this
.
noteTimestampLink
);
},
},
},
};
};
</
script
>
</
script
>
...
@@ -79,7 +82,9 @@ export default {
...
@@ -79,7 +82,9 @@ export default {
v-if=
"actionTextHtml"
v-if=
"actionTextHtml"
v-html=
"actionTextHtml"
v-html=
"actionTextHtml"
class=
"system-note-message"
></span>
class=
"system-note-message"
></span>
<a
:href=
"noteTimestampLink"
>
<a
:href=
"noteTimestampLink"
@
click=
"updateTargetNoteHash"
>
<time-ago-tooltip
<time-ago-tooltip
:time=
"createdAt"
:time=
"createdAt"
tooltipPlacement=
"bottom"
/>
tooltipPlacement=
"bottom"
/>
...
...
app/assets/javascripts/notes/components/issue_notes.vue
View file @
993936fb
...
@@ -43,6 +43,19 @@ export default {
...
@@ -43,6 +43,19 @@ export default {
componentData
(
note
)
{
componentData
(
note
)
{
return
note
.
individual_note
?
note
.
notes
[
0
]
:
note
;
return
note
.
individual_note
?
note
.
notes
[
0
]
:
note
;
},
},
checkLocationHash
()
{
const
hash
=
gl
.
utils
.
getLocationHash
();
const
$el
=
$
(
`#
${
hash
}
`
);
if
(
hash
&&
$el
)
{
const
isInViewport
=
gl
.
utils
.
isInViewport
(
$el
[
0
]);
this
.
$store
.
commit
(
'
setTargetNoteHash
'
,
hash
);
if
(
!
isInViewport
)
{
gl
.
utils
.
scrollToElement
(
$el
);
}
}
},
},
},
mounted
()
{
mounted
()
{
const
{
discussionsPath
,
notesPath
,
lastFetchedAt
}
=
this
.
$el
.
parentNode
.
dataset
;
const
{
discussionsPath
,
notesPath
,
lastFetchedAt
}
=
this
.
$el
.
parentNode
.
dataset
;
...
@@ -50,6 +63,11 @@ export default {
...
@@ -50,6 +63,11 @@ export default {
this
.
$store
.
dispatch
(
'
fetchNotes
'
,
discussionsPath
)
this
.
$store
.
dispatch
(
'
fetchNotes
'
,
discussionsPath
)
.
then
(()
=>
{
.
then
(()
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
// Scroll to note if we have hash fragment in the page URL
Vue
.
nextTick
(()
=>
{
this
.
checkLocationHash
();
});
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
new
Flash
(
'
Something went wrong while fetching issue comments. Please try again.
'
);
// eslint-disable-line
new
Flash
(
'
Something went wrong while fetching issue comments. Please try again.
'
);
// eslint-disable-line
...
...
app/assets/javascripts/notes/components/issue_system_note.vue
View file @
993936fb
<
script
>
<
script
>
import
{
mapGetters
}
from
'
vuex
'
;
import
iconsMap
from
'
./issue_note_icons
'
;
import
iconsMap
from
'
./issue_note_icons
'
;
import
IssueNoteHeader
from
'
./issue_note_header.vue
'
;
import
IssueNoteHeader
from
'
./issue_note_header.vue
'
;
...
@@ -17,11 +18,25 @@ export default {
...
@@ -17,11 +18,25 @@ export default {
components
:
{
components
:
{
IssueNoteHeader
,
IssueNoteHeader
,
},
},
computed
:
{
...
mapGetters
([
'
targetNoteHash
'
,
]),
noteAnchorId
()
{
return
`note_
${
this
.
note
.
id
}
`
;
},
isTargetNote
()
{
return
this
.
targetNoteHash
===
this
.
noteAnchorId
;
},
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<li
class=
"note system-note timeline-entry"
>
<li
:id=
"noteAnchorId"
:class=
"
{ target: isTargetNote }"
class="note system-note timeline-entry">
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-icon"
>
<div
class=
"timeline-icon"
>
<span
v-html=
"svg"
></span>
<span
v-html=
"svg"
></span>
...
...
app/assets/javascripts/notes/stores/issue_notes_store.js
View file @
993936fb
...
@@ -6,18 +6,25 @@ const findNoteObjectById = (notes, id) => notes.filter(n => n.id === id)[0];
...
@@ -6,18 +6,25 @@ const findNoteObjectById = (notes, id) => notes.filter(n => n.id === id)[0];
const
state
=
{
const
state
=
{
notes
:
[],
notes
:
[],
targetNoteHash
:
null
,
};
};
const
getters
=
{
const
getters
=
{
notes
(
storeState
)
{
notes
(
storeState
)
{
return
storeState
.
notes
;
return
storeState
.
notes
;
},
},
targetNoteHash
(
storeState
)
{
return
storeState
.
targetNoteHash
;
},
};
};
const
mutations
=
{
const
mutations
=
{
setInitialNotes
(
storeState
,
notes
)
{
setInitialNotes
(
storeState
,
notes
)
{
storeState
.
notes
=
notes
;
storeState
.
notes
=
notes
;
},
},
setTargetNoteHash
(
storeState
,
hash
)
{
storeState
.
targetNoteHash
=
hash
;
},
toggleDiscussion
(
storeState
,
{
discussionId
})
{
toggleDiscussion
(
storeState
,
{
discussionId
})
{
const
discussion
=
findNoteObjectById
(
storeState
.
notes
,
discussionId
);
const
discussion
=
findNoteObjectById
(
storeState
.
notes
,
discussionId
);
...
...
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