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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
15441f0e
Commit
15441f0e
authored
Aug 08, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ci skip] Init testing vue app for issue notes
parent
b1a2b43f
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
41 deletions
+78
-41
app/assets/javascripts/notes/components/issue_comment_form.vue
...ssets/javascripts/notes/components/issue_comment_form.vue
+2
-2
app/assets/javascripts/notes/components/issue_note.vue
app/assets/javascripts/notes/components/issue_note.vue
+4
-5
app/assets/javascripts/notes/components/issue_note_actions.vue
...ssets/javascripts/notes/components/issue_note_actions.vue
+10
-10
app/assets/javascripts/notes/components/issue_note_form.vue
app/assets/javascripts/notes/components/issue_note_form.vue
+4
-4
app/assets/javascripts/notes/components/issue_notes_app.vue
app/assets/javascripts/notes/components/issue_notes_app.vue
+4
-2
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/actions.js
+10
-1
spec/javascripts/notes/components/issue_note_app_spec.js
spec/javascripts/notes/components/issue_note_app_spec.js
+44
-17
No files found.
app/assets/javascripts/notes/components/issue_comment_form.vue
View file @
15441f0e
...
@@ -175,6 +175,7 @@
...
@@ -175,6 +175,7 @@
this
.
noteType
=
type
;
this
.
noteType
=
type
;
},
},
editCurrentUserLastNote
()
{
editCurrentUserLastNote
()
{
console
.
log
(
'
editCurrentUserLastNote
'
)
if
(
this
.
note
===
''
)
{
if
(
this
.
note
===
''
)
{
const
lastNote
=
this
.
getCurrentUserLastNote
(
window
.
gon
.
current_user_id
);
const
lastNote
=
this
.
getCurrentUserLastNote
(
window
.
gon
.
current_user_id
);
...
@@ -228,9 +229,8 @@
...
@@ -228,9 +229,8 @@
:quick-actions-docs=
"quickActionsDocsUrl"
:quick-actions-docs=
"quickActionsDocsUrl"
:add-spacing-classes=
"false"
>
:add-spacing-classes=
"false"
>
<textarea
<textarea
id=
"note-body"
name=
"note[note]"
name=
"note[note]"
class=
"note-textarea js-gfm-input js-autosize markdown-area"
class=
"note-textarea js-
vue-comment-form js-
gfm-input js-autosize markdown-area"
data-supports-quick-actions=
"true"
data-supports-quick-actions=
"true"
aria-label=
"Description"
aria-label=
"Description"
v-model=
"note"
v-model=
"note"
...
...
app/assets/javascripts/notes/components/issue_note.vue
View file @
15441f0e
...
@@ -60,10 +60,9 @@
...
@@ -60,10 +60,9 @@
},
},
deleteHandler
()
{
deleteHandler
()
{
// eslint-disable-next-line no-alert
// eslint-disable-next-line no-alert
const
isConfirmed
=
confirm
(
'
Are you sure you want to delete this list?
'
);
if
(
confirm
(
'
Are you sure you want to delete this list?
'
))
{
if
(
isConfirmed
)
{
this
.
isDeleting
=
true
;
this
.
isDeleting
=
true
;
this
.
deleteNote
(
this
.
note
)
this
.
deleteNote
(
this
.
note
)
.
then
(()
=>
{
.
then
(()
=>
{
this
.
isDeleting
=
false
;
this
.
isDeleting
=
false
;
...
@@ -149,8 +148,8 @@
...
@@ -149,8 +148,8 @@
:can-delete=
"note.current_user.can_edit"
:can-delete=
"note.current_user.can_edit"
:can-report-as-abuse=
"canReportAsAbuse"
:can-report-as-abuse=
"canReportAsAbuse"
:report-abuse-path=
"note.report_abuse_path"
:report-abuse-path=
"note.report_abuse_path"
:edit-h
andler=
"editHandler"
@
editH
andler=
"editHandler"
:delete-h
andler=
"deleteHandler"
@
deleteH
andler=
"deleteHandler"
/>
/>
</div>
</div>
<issue-note-body
<issue-note-body
...
...
app/assets/javascripts/notes/components/issue_note_actions.vue
View file @
15441f0e
...
@@ -37,14 +37,6 @@
...
@@ -37,14 +37,6 @@
type
:
Boolean
,
type
:
Boolean
,
required
:
true
,
required
:
true
,
},
},
editHandler
:
{
type
:
Function
,
required
:
true
,
},
deleteHandler
:
{
type
:
Function
,
required
:
true
,
},
},
},
directives
:
{
directives
:
{
tooltip
,
tooltip
,
...
@@ -76,6 +68,14 @@
...
@@ -76,6 +68,14 @@
return
this
.
getUserDataByProp
(
'
id
'
);
return
this
.
getUserDataByProp
(
'
id
'
);
},
},
},
},
methods
:
{
onEdit
()
{
this
.
$emit
(
'
editHandler
'
);
},
onDelete
()
{
this
.
$emit
(
'
deleteHandler
'
);
}
}
};
};
</
script
>
</
script
>
...
@@ -125,7 +125,7 @@
...
@@ -125,7 +125,7 @@
<template
v-if=
"canEdit"
>
<template
v-if=
"canEdit"
>
<li>
<li>
<button
<button
@
click=
"
editHandler
"
@
click=
"
onEdit
"
type=
"button"
type=
"button"
class=
"btn btn-transparent js-note-edit"
>
class=
"btn btn-transparent js-note-edit"
>
Edit comment
Edit comment
...
@@ -140,7 +140,7 @@
...
@@ -140,7 +140,7 @@
</li>
</li>
<li
v-if=
"canEdit"
>
<li
v-if=
"canEdit"
>
<button
<button
@
click.prevent=
"
deleteHandler
"
@
click.prevent=
"
onDelete
"
class=
"btn btn-transparent js-note-delete js-note-delete"
class=
"btn btn-transparent js-note-delete js-note-delete"
type=
"button"
>
type=
"button"
>
<span
class=
"text-danger"
>
<span
class=
"text-danger"
>
...
...
app/assets/javascripts/notes/components/issue_note_form.vue
View file @
15441f0e
...
@@ -118,8 +118,7 @@
...
@@ -118,8 +118,7 @@
</div>
</div>
<div
class=
"flash-container timeline-content"
></div>
<div
class=
"flash-container timeline-content"
></div>
<form
<form
class=
"edit-note common-note-form"
class=
"edit-note common-note-form"
>
@
submit=
"handleUpdate"
>
<markdown-field
<markdown-field
:markdown-preview-url=
"markdownPreviewUrl"
:markdown-preview-url=
"markdownPreviewUrl"
:markdown-docs=
"markdownDocsUrl"
:markdown-docs=
"markdownDocsUrl"
...
@@ -128,7 +127,7 @@
...
@@ -128,7 +127,7 @@
<textarea
<textarea
id=
"note-body"
id=
"note-body"
name=
"note[note]"
name=
"note[note]"
class=
"note-textarea js-gfm-input js-autosize markdown-area"
class=
"note-textarea js-gfm-input js-autosize markdown-area
js-vue-issue-note-form
"
:data-supports-quick-actions=
"!isEditing"
:data-supports-quick-actions=
"!isEditing"
aria-label=
"Description"
aria-label=
"Description"
v-model=
"note"
v-model=
"note"
...
@@ -143,8 +142,9 @@
...
@@ -143,8 +142,9 @@
<div
class=
"note-form-actions clearfix"
>
<div
class=
"note-form-actions clearfix"
>
<button
<button
type=
"submit"
type=
"submit"
@
click=
"handleUpdate"
:disabled=
"isDisabled"
:disabled=
"isDisabled"
class=
"
btn btn-nr
btn-save"
>
class=
"
js-vue-issue-save btn
btn-save"
>
{{
saveButtonTitle
}}
{{
saveButtonTitle
}}
</button>
</button>
<button
<button
...
...
app/assets/javascripts/notes/components/issue_notes_app.vue
View file @
15441f0e
...
@@ -113,9 +113,11 @@
...
@@ -113,9 +113,11 @@
mounted
()
{
mounted
()
{
this
.
fetchNotes
();
this
.
fetchNotes
();
this
.
initPolling
();
this
.
initPolling
();
const
parentElement
=
this
.
$el
.
parentElement
;
if
(
this
.
$el
.
parentElement
)
{
if
(
parentElement
&&
this
.
$el
.
parentElement
.
addEventListener
(
'
toggleAward
'
,
(
event
)
=>
{
parentElement
.
classList
.
contains
(
'
js-vue-notes-event
'
))
{
parentElement
.
addEventListener
(
'
toggleAward
'
,
(
event
)
=>
{
const
{
awardName
,
noteId
}
=
event
.
detail
;
const
{
awardName
,
noteId
}
=
event
.
detail
;
this
.
actionToggleAward
({
awardName
,
noteId
});
this
.
actionToggleAward
({
awardName
,
noteId
});
});
});
...
...
app/assets/javascripts/notes/stores/actions.js
View file @
15441f0e
...
@@ -87,7 +87,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
...
@@ -87,7 +87,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
const
commandsChanges
=
res
.
commands_changes
;
const
commandsChanges
=
res
.
commands_changes
;
if
(
hasQuickActions
&&
Object
.
keys
(
errors
).
length
)
{
if
(
hasQuickActions
&&
Object
.
keys
(
errors
).
length
)
{
dispatch
(
'
poll
'
);
dispatch
(
'
fetchData
'
);
$
(
'
.js-gfm-input
'
).
trigger
(
'
clear-commands-cache.atwho
'
);
$
(
'
.js-gfm-input
'
).
trigger
(
'
clear-commands-cache.atwho
'
);
Flash
(
'
Commands applied
'
,
'
notice
'
,
$
(
noteData
.
flashContainer
));
Flash
(
'
Commands applied
'
,
'
notice
'
,
$
(
noteData
.
flashContainer
));
...
@@ -186,6 +186,15 @@ export const poll = ({ commit, state, getters }) => {
...
@@ -186,6 +186,15 @@ export const poll = ({ commit, state, getters }) => {
});
});
};
};
export
const
fetchData
=
({
commit
,
state
,
getters
})
=>
{
const
requestData
=
{
endpoint
:
state
.
notesData
.
notesPath
,
lastFetchedAt
:
state
.
lastFetchedAt
};
service
.
poll
(
requestData
)
.
then
(
resp
=>
resp
.
json
)
.
then
(
data
=>
pollSuccessCallBack
(
data
,
commit
,
state
,
getters
))
.
catch
(()
=>
Flash
(
'
Something went wrong while fetching latest comments.
'
));
};
export
const
toggleAward
=
({
commit
,
state
,
getters
,
dispatch
},
{
awardName
,
noteId
})
=>
{
export
const
toggleAward
=
({
commit
,
state
,
getters
,
dispatch
},
{
awardName
,
noteId
})
=>
{
commit
(
types
.
TOGGLE_AWARD
,
{
awardName
,
note
:
getters
.
notesById
[
noteId
]
});
commit
(
types
.
TOGGLE_AWARD
,
{
awardName
,
note
:
getters
.
notesById
[
noteId
]
});
};
};
...
...
spec/javascripts/notes/components/issue_note_app_spec.js
View file @
15441f0e
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
issueNotesApp
from
'
~/notes/components/issue_notes_app.vue
'
;
import
issueNotesApp
from
'
~/notes/components/issue_notes_app.vue
'
;
import
service
from
'
~/notes/services/issue_notes_service
'
;
import
{
keyboardDownEvent
}
from
'
../../issue_show/helpers
'
;
import
*
as
mockData
from
'
../mock_data
'
;
import
*
as
mockData
from
'
../mock_data
'
;
f
describe
(
'
issue_note_app
'
,
()
=>
{
describe
(
'
issue_note_app
'
,
()
=>
{
let
mountComponent
;
let
mountComponent
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -52,7 +54,7 @@ fdescribe('issue_note_app', () => {
...
@@ -52,7 +54,7 @@ fdescribe('issue_note_app', () => {
});
});
});
});
f
describe
(
'
render
'
,
()
=>
{
describe
(
'
render
'
,
()
=>
{
let
vm
;
let
vm
;
const
responseInterceptor
=
(
request
,
next
)
=>
{
const
responseInterceptor
=
(
request
,
next
)
=>
{
...
@@ -73,8 +75,18 @@ fdescribe('issue_note_app', () => {
...
@@ -73,8 +75,18 @@ fdescribe('issue_note_app', () => {
afterEach
(()
=>
{
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
responseInterceptor
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
responseInterceptor
);
});
});
it
(
'
should render list of notes
'
,
()
=>
{
console
.
log
(
vm
);
it
(
'
should render list of notes
'
,
(
done
)
=>
{
const
note
=
mockData
.
discussionResponse
[
0
].
notes
[
0
];
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.main-notes-list .note-header-author-name
'
).
textContent
.
trim
(),
).
toEqual
(
note
.
author
.
name
);
expect
(
vm
.
$el
.
querySelector
(
'
.main-notes-list .note-text
'
).
innerHTML
).
toEqual
(
note
.
note_html
);
done
();
},
0
);
});
});
it
(
'
should render form
'
,
()
=>
{
it
(
'
should render form
'
,
()
=>
{
...
@@ -109,29 +121,44 @@ fdescribe('issue_note_app', () => {
...
@@ -109,29 +121,44 @@ fdescribe('issue_note_app', () => {
describe
(
'
update note
'
,
()
=>
{
describe
(
'
update note
'
,
()
=>
{
describe
(
'
individual note
'
,
()
=>
{
describe
(
'
individual note
'
,
()
=>
{
describe
(
'
shortup up key
'
,
()
=>
{
let
vm
;
it
(
'
shows correct editing form when user clicks up
'
,
()
=>
{
const
responseInterceptor
=
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
(
mockData
.
discussionResponse
),
{
status
:
200
,
}));
};
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
responseInterceptor
);
vm
=
mountComponent
({
issueData
:
mockData
.
issueDataMock
,
notesData
:
mockData
.
notesDataMock
,
userData
:
mockData
.
userDataMock
,
});
});
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
responseInterceptor
);
});
});
describe
(
'
dropdown
'
,
()
=>
{
it
(
'
renders edit form
'
,
()
=>
{
it
(
'
renders edit form
'
,
()
=>
{
setTimeout
(()
=>
{
vm
.
$el
.
querySelector
(
'
.js-note-edit
'
).
click
();
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-vue-issue-note-form
'
)).
toBeDefined
();
});
});
},
0
);
});
});
it
(
'
updates the note and resets the edit form
'
,
()
=>
{});
it
(
'
updates the note and resets the edit form
'
,
()
=>
{});
});
});
describe
(
'
dicussion note note
'
,
()
=>
{
describe
(
'
dicussion note note
'
,
()
=>
{
describe
(
'
shortup up key
'
,
()
=>
{
it
(
'
shows correct editing form when user clicks up
'
,
()
=>
{
});
});
describe
(
'
dropdown
'
,
()
=>
{
it
(
'
renders edit form
'
,
()
=>
{
it
(
'
renders edit form
'
,
()
=>
{
});
});
});
it
(
'
updates the note and resets the edit form
'
,
()
=>
{});
it
(
'
updates the note and resets the edit form
'
,
()
=>
{});
});
});
...
...
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