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
7a251207
Commit
7a251207
authored
Jul 28, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ci skip] Emit events up to prevent accessing refs of refs
parent
b45b604d
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
63 additions
and
71 deletions
+63
-71
app/assets/javascripts/notes/components/issue_comment_form.vue
...ssets/javascripts/notes/components/issue_comment_form.vue
+4
-7
app/assets/javascripts/notes/components/issue_note.vue
app/assets/javascripts/notes/components/issue_note.vue
+13
-14
app/assets/javascripts/notes/components/issue_note_actions.vue
...ssets/javascripts/notes/components/issue_note_actions.vue
+6
-5
app/assets/javascripts/notes/components/issue_note_awards_list.vue
...s/javascripts/notes/components/issue_note_awards_list.vue
+7
-9
app/assets/javascripts/notes/components/issue_note_body.vue
app/assets/javascripts/notes/components/issue_note_body.vue
+13
-9
app/assets/javascripts/notes/components/issue_note_form.vue
app/assets/javascripts/notes/components/issue_note_form.vue
+9
-17
app/assets/javascripts/notes/components/issue_note_header.vue
...assets/javascripts/notes/components/issue_note_header.vue
+1
-1
app/assets/javascripts/notes/components/issue_notes_app.vue
app/assets/javascripts/notes/components/issue_notes_app.vue
+1
-3
app/assets/javascripts/notes/components/issue_placeholder_system_note.vue
...cripts/notes/components/issue_placeholder_system_note.vue
+1
-1
app/assets/javascripts/notes/index.js
app/assets/javascripts/notes/index.js
+2
-0
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/actions.js
+4
-4
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+0
-1
app/views/projects/issues/_discussion.html.haml
app/views/projects/issues/_discussion.html.haml
+2
-0
No files found.
app/assets/javascripts/notes/components/issue_comment_form.vue
View file @
7a251207
...
...
@@ -10,12 +10,12 @@
export
default
{
data
()
{
const
{
getUserData
,
getIssueData
}
=
this
.
$store
.
getters
;
const
{
getUserData
,
getIssueData
,
getNotesData
}
=
this
.
$store
.
getters
;
return
{
note
:
''
,
markdownDocsUrl
:
get
Issue
Data
.
markdownDocs
,
quickActionsDocsUrl
:
get
Issue
Data
.
quickActionsDocs
,
markdownDocsUrl
:
get
Notes
Data
.
markdownDocs
,
quickActionsDocsUrl
:
get
Notes
Data
.
quickActionsDocs
,
markdownPreviewUrl
:
getIssueData
.
preview_note_path
,
noteType
:
constants
.
COMMENT
,
issueState
:
getIssueData
.
state
,
...
...
@@ -89,7 +89,7 @@
this
.
handleError
();
}
}
else
{
this
.
discard
(
);
return
Flash
(
'
Something went wrong while adding your comment. Please try again.
'
);
}
})
.
catch
(()
=>
{
...
...
@@ -126,9 +126,6 @@
setNoteType
(
type
)
{
this
.
noteType
=
type
;
},
handleError
()
{
Flash
(
'
Something went wrong while adding your comment. Please try again.
'
);
},
editMyLastNote
()
{
if
(
this
.
note
===
''
)
{
const
myLastNoteId
=
$
(
'
.js-my-note
'
).
last
().
attr
(
'
id
'
);
...
...
app/assets/javascripts/notes/components/issue_note.vue
View file @
7a251207
...
...
@@ -19,6 +19,7 @@
return
{
isEditing
:
false
,
isDeleting
:
false
,
currentUserId
:
window
.
gon
.
current_user_id
,
};
},
components
:
{
...
...
@@ -38,12 +39,12 @@
return
{
'
is-editing
'
:
this
.
isEditing
,
'
disabled-content
'
:
this
.
isDeleting
,
'
js-my-note
'
:
this
.
author
.
id
===
window
.
gon
.
current_user_i
d
,
'
js-my-note
'
:
this
.
author
.
id
===
this
.
currentUserI
d
,
target
:
this
.
targetNoteHash
===
this
.
noteAnchorId
,
};
},
canReportAsAbuse
()
{
return
this
.
note
.
report_abuse_path
&&
this
.
author
.
id
!==
window
.
gon
.
current_user_i
d
;
return
this
.
note
.
report_abuse_path
&&
this
.
author
.
id
!==
this
.
currentUserI
d
;
},
noteAnchorId
()
{
return
`note_
${
this
.
note
.
id
}
`
;
...
...
@@ -59,8 +60,8 @@
this
.
isEditing
=
true
;
},
deleteHandler
()
{
const
msg
=
'
Are you sure you want to delete this list?
'
;
const
isConfirmed
=
confirm
(
msg
);
// eslint-disable-line
// eslint-disable-next-line no-alert
const
isConfirmed
=
confirm
(
'
Are you sure you want to delete this list?
'
);
if
(
isConfirmed
)
{
this
.
isDeleting
=
true
;
...
...
@@ -88,17 +89,15 @@
this
.
updateNote
(
data
)
.
then
(()
=>
{
this
.
isEditing
=
false
;
// TODO: this could be moved down, by setting a prop
$
(
this
.
$refs
.
noteBody
.
$el
).
renderGFM
();
})
.
catch
(()
=>
Flash
(
'
Something went wrong while editing your comment. Please try again.
'
));
},
formCancelHandler
(
shouldConfirm
)
{
if
(
shouldConfirm
&&
this
.
$refs
.
noteBody
.
$refs
.
noteForm
.
isDirty
)
{
const
msg
=
'
Are you sure you want to cancel editing this comment?
'
;
const
isConfirmed
=
confirm
(
msg
);
// eslint-disable-line
if
(
!
isConfirmed
)
{
return
;
}
formCancelHandler
(
shouldConfirm
,
isDirty
)
{
if
(
shouldConfirm
&&
isDirty
)
{
// eslint-disable-next-line no-alert
if
(
!
confirm
(
'
Are you sure you want to cancel editing this comment?
'
))
return
;
}
this
.
isEditing
=
false
;
...
...
@@ -135,7 +134,7 @@
:author=
"author"
:created-at=
"note.created_at"
:note-id=
"note.id"
action
T
ext=
"commented"
action
-t
ext=
"commented"
/>
<issue-note-actions
:author-id=
"author.id"
...
...
@@ -153,8 +152,8 @@
:note=
"note"
:can-edit=
"note.current_user.can_edit"
:is-editing=
"isEditing"
:form-update-handler
=
"formUpdateHandler"
:form-cancel-handler
=
"formCancelHandler"
@
handleFormUpdate
=
"formUpdateHandler"
@
cancelFormEdition
=
"formCancelHandler"
ref=
"noteBody"
/>
</div>
...
...
app/assets/javascripts/notes/components/issue_note_actions.vue
View file @
7a251207
...
...
@@ -53,6 +53,7 @@
emojiSmiling
,
emojiSmile
,
emojiSmiley
,
currentUserId
:
window
.
gon
.
current_user_id
,
};
},
components
:
{
...
...
@@ -60,13 +61,13 @@
},
computed
:
{
shouldShowActionsDropdown
()
{
return
window
.
gon
.
current_user_i
d
&&
(
this
.
canEdit
||
this
.
canReportAsAbuse
);
return
this
.
currentUserI
d
&&
(
this
.
canEdit
||
this
.
canReportAsAbuse
);
},
canAddAwardEmoji
()
{
return
window
.
gon
.
current_user_i
d
;
return
this
.
currentUserI
d
;
},
isAuthoredBy
Me
()
{
return
this
.
authorId
===
window
.
gon
.
current_user_id
;
isAuthoredBy
CurrentUser
()
{
return
this
.
authorId
===
this
.
currentUserId
},
},
};
...
...
@@ -82,7 +83,7 @@
<a
v-tooltip
v-if=
"canAddAwardEmoji"
:class=
"
{ 'js-user-authored': isAuthoredBy
Me
}"
:class=
"
{ 'js-user-authored': isAuthoredBy
CurrentUser
}"
class="note-action-button note-emoji-button js-add-award js-note-emoji"
data-position="right"
href="#"
...
...
app/assets/javascripts/notes/components/issue_note_awards_list.vue
View file @
7a251207
...
...
@@ -91,7 +91,7 @@
},
getAwardClassBindings
(
awardList
,
awardName
)
{
return
{
active
:
this
.
amIAwarded
(
awardList
),
active
:
this
.
hasReactionByCurrentUser
(
awardList
),
disabled
:
!
this
.
canInteractWithEmoji
(
awardList
,
awardName
),
};
},
...
...
@@ -107,18 +107,16 @@
return
this
.
canAward
&&
isAllowed
;
},
amIAwarded
(
awardList
)
{
const
isAwarded
=
awardList
.
filter
(
award
=>
award
.
user
.
id
===
this
.
myUserId
);
return
isAwarded
.
length
;
hasReactionByCurrentUser
(
awardList
)
{
return
awardList
.
filter
(
award
=>
award
.
user
.
id
===
this
.
myUserId
).
length
;
},
awardTitle
(
awardsList
)
{
const
amIAwarded
=
this
.
amIAwarded
(
awardsList
);
const
TOOLTIP_NAME_COUNT
=
amIAwarded
?
9
:
10
;
const
hasReactionByCurrentUser
=
this
.
hasReactionByCurrentUser
(
awardsList
);
const
TOOLTIP_NAME_COUNT
=
hasReactionByCurrentUser
?
9
:
10
;
let
awardList
=
awardsList
;
// Filter myself from list if I am awarded.
if
(
amIAwarded
)
{
if
(
hasReactionByCurrentUser
)
{
awardList
=
awardList
.
filter
(
award
=>
award
.
user
.
id
!==
this
.
myUserId
);
}
...
...
@@ -129,7 +127,7 @@
const
remainingAwardList
=
awardList
.
slice
(
TOOLTIP_NAME_COUNT
,
awardList
.
length
);
// Add myself to the begining of the list so title will start with You.
if
(
amIAwarded
)
{
if
(
hasReactionByCurrentUser
)
{
namesToShow
.
unshift
(
'
You
'
);
}
...
...
app/assets/javascripts/notes/components/issue_note_body.vue
View file @
7a251207
...
...
@@ -51,11 +51,12 @@
});
}
},
handleFormUpdate
()
{
this
.
formUpdateHandler
({
note
:
this
.
$refs
.
noteForm
.
note
,
});
handleFormUpdate
(
note
)
{
this
.
$emit
(
'
handleFormUpdate
'
,
note
);
},
formCancelHandler
(
shouldConfirm
,
isDirty
)
{
this
.
$emit
(
'
cancelFormEdition
'
,
shouldConfirm
,
isDirty
);
}
},
mounted
()
{
this
.
renderGFM
();
...
...
@@ -78,10 +79,11 @@
<issue-note-form
v-if=
"isEditing"
ref=
"noteForm"
:update-handler
=
"handleFormUpdate"
:cancel-handler
=
"formCancelHandler"
@
handleFormUpdate
=
"handleFormUpdate"
@
cancelFormEdition
=
"formCancelHandler"
:note-body=
"noteBody"
:note-id=
"note.id"
/>
:note-id=
"note.id"
/>
<textarea
v-if=
"canEdit"
v-model=
"note.note"
...
...
@@ -91,12 +93,14 @@
v-if=
"note.last_edited_by"
:edited-at=
"note.last_edited_at"
:edited-by=
"note.last_edited_by"
actionText=
"Edited"
/>
actionText=
"Edited"
/>
<issue-note-awards-list
v-if=
"note.award_emoji.length"
:note-id=
"note.id"
:note-author-id=
"note.author.id"
:awards=
"note.award_emoji"
:toggle-award-path=
"note.toggle_award_path"
/>
:toggle-award-path=
"note.toggle_award_path"
/>
</div>
</
template
>
app/assets/javascripts/notes/components/issue_note_form.vue
View file @
7a251207
...
...
@@ -13,14 +13,6 @@
type
:
Number
,
required
:
false
,
},
updateHandler
:
{
type
:
Function
,
required
:
true
,
},
cancelHandler
:
{
type
:
Function
,
required
:
true
,
},
saveButtonTitle
:
{
type
:
String
,
required
:
false
,
...
...
@@ -42,18 +34,13 @@
markdownField
,
},
computed
:
{
isDirty
()
{
return
this
.
initialNote
!==
this
.
note
;
},
noteHash
()
{
return
`#note_
${
this
.
noteId
}
`
;
},
},
methods
:
{
handleUpdate
()
{
this
.
updateHandler
({
note
:
this
.
note
,
});
this
.
$emit
(
'
handleFormUpdate
'
,
note
);
},
editMyLastNote
()
{
if
(
this
.
note
===
''
)
{
...
...
@@ -67,6 +54,10 @@
}
}
},
cancelHandler
(
shouldConfirm
=
false
)
{
// Sends information about confirm message and if the textarea has changed
this
.
$emit
(
'
cancelFormEdition
'
,
shouldConfirm
,
this
.
initialNote
!==
this
.
note
);
}
},
mounted
()
{
this
.
$refs
.
textarea
.
focus
();
...
...
@@ -95,7 +86,9 @@
rel=
"noopener noreferrer"
>
updated comment
</a>
to ensure information is not lost.
</div>
<form
class=
"edit-note common-note-form"
>
<form
@
submit=
"handleUpdate"
class=
"edit-note common-note-form"
>
<markdown-field
:markdown-preview-url=
"markdownPreviewUrl"
:markdown-docs=
"markdownDocsUrl"
...
...
@@ -118,8 +111,7 @@
</markdown-field>
<div
class=
"note-form-actions clearfix"
>
<button
@
click=
"handleUpdate"
type=
"button"
type=
"submit"
class=
"btn btn-nr btn-save"
>
{{
saveButtonTitle
}}
</button>
...
...
app/assets/javascripts/notes/components/issue_note_header.vue
View file @
7a251207
...
...
@@ -93,7 +93,7 @@
@
click=
"updateTargetNoteHash"
>
<time-ago-tooltip
:time=
"createdAt"
tooltip
P
lacement=
"bottom"
tooltip
-p
lacement=
"bottom"
/>
</a>
</span>
...
...
app/assets/javascripts/notes/components/issue_notes_app.vue
View file @
7a251207
...
...
@@ -47,13 +47,11 @@
},
computed
:
{
...
mapGetters
([
'
notes
'
,
'
getNotesDataByProp
'
,
]),
},
methods
:
{
...
mapGetters
([
'
getNotesDataByProp
'
,
]),
...
mapActions
({
actionFetchNotes
:
'
fetchNotes
'
,
poll
:
'
poll
'
,
...
...
app/assets/javascripts/notes/components/issue_placeholder_system_note.vue
View file @
7a251207
...
...
@@ -14,7 +14,7 @@
<li
class=
"note system-note timeline-entry being-posted fade-in-half"
>
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-content"
>
<
i>
{{
note
.
body
}}
</i
>
<
em>
{{
note
.
body
}}
</em
>
</div>
</div>
</li>
...
...
app/assets/javascripts/notes/index.js
View file @
7a251207
...
...
@@ -18,6 +18,8 @@ document.addEventListener('DOMContentLoaded', () => new Vue({
newSessionPath
:
notesDataset
.
newSessionPath
,
registerPath
:
notesDataset
.
registerPath
,
notesPath
:
notesDataset
.
notesPath
,
markdownDocs
:
notesDataset
.
markdownDocs
,
quickActionsDocs
:
notesDataset
.
quickActionsDocs
,
},
};
},
...
...
app/assets/javascripts/notes/stores/actions.js
View file @
7a251207
...
...
@@ -175,17 +175,17 @@ export const toggleAward = ({ commit, getters, dispatch }, data) => {
constants
.
EMOJI_THUMBSUP
;
const
targetNote
=
getters
.
notesById
[
noteId
];
let
noteHasAward
=
false
;
let
noteHasAward
ByCurrentUser
=
false
;
targetNote
.
award_emoji
.
forEach
((
a
)
=>
{
if
(
a
.
name
===
counterAward
&&
a
.
user
.
id
===
window
.
gon
.
current_user_id
)
{
noteHasAward
=
true
;
noteHasAward
ByCurrentUser
=
true
;
}
});
if
(
noteHasAward
)
{
if
(
noteHasAward
ByCurrentUser
)
{
Object
.
assign
(
data
,
{
awardName
:
counterAward
});
Object
.
assign
(
data
,
{
kipMutalityCheck
:
true
});
Object
.
assign
(
data
,
{
s
kipMutalityCheck
:
true
});
dispatch
(
types
.
TOGGLE_AWARD
,
data
);
}
...
...
app/helpers/issuables_helper.rb
View file @
7a251207
...
...
@@ -214,7 +214,6 @@ module IssuablesHelper
initialDescriptionHtml:
markdown_field
(
issuable
,
:description
),
initialDescriptionText:
issuable
.
description
,
initialTaskStatus:
issuable
.
task_status
,
quickActionsDocs:
help_page_path
(
'user/project/quick_actions'
),
}
data
.
merge!
(
updated_at_by
(
issuable
))
...
...
app/views/projects/issues/_discussion.html.haml
View file @
7a251207
...
...
@@ -7,6 +7,8 @@
#js-vue-notes
{
data:
{
discussions_path:
discussions_namespace_project_issue_path
(
@project
.
namespace
,
@project
,
@issue
,
format: :json
),
register_path:
"#{new_session_path(:user, redirect_to_referer: 'yes')}#register-pane"
,
new_session_path:
new_session_path
(
:user
,
redirect_to_referer:
'yes'
),
markdown_docs:
help_page_path
(
'user/markdown'
),
quick_actions_docs:
help_page_path
(
'user/project/quick_actions'
),
notes_path:
'
#
{
notes_url
}?
full_data
=
1
'
,
last_fetched_at:
Time
.
now
.
to_i
,
issue_data:
serialize_issuable
(
@issue
),
...
...
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