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
96ede7f7
Commit
96ede7f7
authored
Jun 16, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IssueNotesRefactor: Implement logic for delete action.
No backend request for now. It’s just client side logic.
parent
66f4af5c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
9 deletions
+62
-9
app/assets/javascripts/notes/components/issue_discussion.vue
app/assets/javascripts/notes/components/issue_discussion.vue
+1
-1
app/assets/javascripts/notes/components/issue_note.vue
app/assets/javascripts/notes/components/issue_note.vue
+21
-2
app/assets/javascripts/notes/components/issue_note_actions.vue
...ssets/javascripts/notes/components/issue_note_actions.vue
+8
-1
app/assets/javascripts/notes/components/issue_system_note.vue
...assets/javascripts/notes/components/issue_system_note.vue
+2
-2
app/assets/javascripts/notes/services/issue_notes_service.js
app/assets/javascripts/notes/services/issue_notes_service.js
+3
-0
app/assets/javascripts/notes/stores/issue_notes_store.js
app/assets/javascripts/notes/stores/issue_notes_store.js
+27
-3
No files found.
app/assets/javascripts/notes/components/issue_discussion.vue
View file @
96ede7f7
...
@@ -48,7 +48,7 @@ export default {
...
@@ -48,7 +48,7 @@ export default {
this
.
$store
.
commit
(
'
toggleDiscussion
'
,
{
this
.
$store
.
commit
(
'
toggleDiscussion
'
,
{
discussionId
:
this
.
note
.
id
,
discussionId
:
this
.
note
.
id
,
});
});
}
}
,
},
},
};
};
</
script
>
</
script
>
...
...
app/assets/javascripts/notes/components/issue_note.vue
View file @
96ede7f7
...
@@ -14,6 +14,7 @@ export default {
...
@@ -14,6 +14,7 @@ export default {
data
()
{
data
()
{
return
{
return
{
isEditing
:
false
,
isEditing
:
false
,
isDeleting
:
false
,
};
};
},
},
components
:
{
components
:
{
...
@@ -26,11 +27,28 @@ export default {
...
@@ -26,11 +27,28 @@ export default {
author
()
{
author
()
{
return
this
.
note
.
author
;
return
this
.
note
.
author
;
},
},
classNameBindings
()
{
return
{
'
is-editing
'
:
this
.
isEditing
,
'
disabled-content
'
:
this
.
isDeleting
,
};
},
},
},
methods
:
{
methods
:
{
editHandler
()
{
editHandler
()
{
this
.
isEditing
=
true
;
this
.
isEditing
=
true
;
},
},
deleteHandler
()
{
this
.
isDeleting
=
true
;
this
.
$store
.
dispatch
(
'
deleteNote
'
,
this
.
note
)
.
then
(()
=>
{
this
.
isDeleting
=
false
;
})
.
catch
(()
=>
{
this
.
isDeleting
=
false
;
});
},
formUpdateHandler
()
{
formUpdateHandler
()
{
// console.log('update requested', data);
// console.log('update requested', data);
},
},
...
@@ -44,7 +62,7 @@ export default {
...
@@ -44,7 +62,7 @@ export default {
<
template
>
<
template
>
<li
<li
class=
"note timeline-entry"
class=
"note timeline-entry"
:class=
"
{ 'is-editing': isEditing }
">
:class=
"
classNameBindings
"
>
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-icon"
>
<div
class=
"timeline-icon"
>
<user-avatar-link
<user-avatar-link
...
@@ -66,7 +84,8 @@ export default {
...
@@ -66,7 +84,8 @@ export default {
:canEdit=
"note.can_edit"
:canEdit=
"note.can_edit"
:canDelete=
"note.can_edit"
:canDelete=
"note.can_edit"
:reportAbusePath=
"note.report_abuse_path"
:reportAbusePath=
"note.report_abuse_path"
:editHandler=
"editHandler"
/>
:editHandler=
"editHandler"
:deleteHandler=
"deleteHandler"
/>
</div>
</div>
<issue-note-body
<issue-note-body
:note=
"note"
:note=
"note"
...
...
app/assets/javascripts/notes/components/issue_note_actions.vue
View file @
96ede7f7
...
@@ -26,6 +26,10 @@ export default {
...
@@ -26,6 +26,10 @@ export default {
type
:
Function
,
type
:
Function
,
required
:
true
,
required
:
true
,
},
},
deleteHandler
:
{
type
:
Function
,
required
:
true
,
},
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -92,7 +96,10 @@ export default {
...
@@ -92,7 +96,10 @@ export default {
</a>
</a>
</li>
</li>
<li>
<li>
<a
class=
"js-note-delete"
>
<a
@
click.prevent=
"deleteHandler"
class=
"js-note-delete"
href=
"#"
>
<span
class=
"text-danger"
>
<span
class=
"text-danger"
>
Delete comment
Delete comment
</span>
</span>
...
...
app/assets/javascripts/notes/components/issue_system_note.vue
View file @
96ede7f7
...
@@ -12,12 +12,12 @@ export default {
...
@@ -12,12 +12,12 @@ export default {
data
()
{
data
()
{
return
{
return
{
svg
:
iconsMap
[
this
.
note
.
system_note_icon_name
],
svg
:
iconsMap
[
this
.
note
.
system_note_icon_name
],
}
}
;
},
},
components
:
{
components
:
{
IssueNoteHeader
,
IssueNoteHeader
,
},
},
}
}
;
</
script
>
</
script
>
<
template
>
<
template
>
...
...
app/assets/javascripts/notes/services/issue_notes_service.js
View file @
96ede7f7
...
@@ -7,4 +7,7 @@ export default {
...
@@ -7,4 +7,7 @@ export default {
fetchNotes
(
endpoint
)
{
fetchNotes
(
endpoint
)
{
return
Vue
.
http
.
get
(
endpoint
);
return
Vue
.
http
.
get
(
endpoint
);
},
},
deleteNote
(
endpoint
)
{
return
Vue
.
http
.
get
(
endpoint
);
},
};
};
app/assets/javascripts/notes/stores/issue_notes_store.js
View file @
96ede7f7
...
@@ -3,9 +3,7 @@
...
@@ -3,9 +3,7 @@
import
service
from
'
../services/issue_notes_service
'
;
import
service
from
'
../services/issue_notes_service
'
;
const
findNoteObjectById
=
(
notes
,
id
)
=>
{
const
findNoteObjectById
=
(
notes
,
id
)
=>
notes
.
filter
(
n
=>
n
.
id
===
id
)[
0
];
return
notes
.
filter
(
n
=>
n
.
id
===
id
)[
0
];
};
const
state
=
{
const
state
=
{
notes
:
[],
notes
:
[],
...
@@ -26,6 +24,20 @@ const mutations = {
...
@@ -26,6 +24,20 @@ const mutations = {
discussion
.
expanded
=
!
discussion
.
expanded
;
discussion
.
expanded
=
!
discussion
.
expanded
;
},
},
deleteNote
(
storeState
,
note
)
{
const
noteObj
=
findNoteObjectById
(
storeState
.
notes
,
note
.
discussion_id
);
if
(
noteObj
.
individual_note
)
{
storeState
.
notes
.
splice
(
storeState
.
notes
.
indexOf
(
noteObj
),
1
);
}
else
{
const
comment
=
findNoteObjectById
(
noteObj
.
notes
,
note
.
id
);
noteObj
.
notes
.
splice
(
noteObj
.
notes
.
indexOf
(
comment
),
1
);
if
(
!
noteObj
.
notes
.
length
)
{
storeState
.
notes
.
splice
(
storeState
.
notes
.
indexOf
(
noteObj
),
1
);
}
}
},
};
};
const
actions
=
{
const
actions
=
{
...
@@ -40,6 +52,18 @@ const actions = {
...
@@ -40,6 +52,18 @@ const actions = {
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
});
});
},
},
deleteNote
(
context
,
note
)
{
// FIXME: Implement request, remove fake delete timer...
return
service
.
deleteNote
(
`
${
document
.
location
.
href
}
.json`
)
.
then
(
res
=>
res
.
json
)
.
then
(()
=>
{
context
.
commit
(
'
deleteNote
'
,
note
);
})
.
catch
(()
=>
{
new
Flash
(
'
Something went wrong while deleting your note. Please try again.
'
);
// eslint-disable-line
});
},
};
};
export
default
{
export
default
{
...
...
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