Commit 0555d691 authored by Fatih Acet's avatar Fatih Acet

IssueNotesRefactor: Handle /award quick action.

parent 8a130d85
...@@ -78,10 +78,6 @@ export default { ...@@ -78,10 +78,6 @@ export default {
data-position="right" data-position="right"
href="#" href="#"
title="Add reaction"> title="Add reaction">
<i
aria-hidden="true"
data-hidden="true"
class="fa fa-spinner fa-spin"></i>
<span <span
v-html="emojiSmiling" v-html="emojiSmiling"
class="link-highlight award-control-icon-neutral"></span> class="link-highlight award-control-icon-neutral"></span>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import service from '../services/issue_notes_service'; import service from '../services/issue_notes_service';
import utils from './issue_notes_utils'; import utils from './issue_notes_utils';
import loadAwardsHandler from '../../awards_handler';
const state = { const state = {
notes: [], notes: [],
...@@ -225,12 +226,25 @@ const actions = { ...@@ -225,12 +226,25 @@ const actions = {
.then((res) => { .then((res) => {
const { errors } = res; const { errors } = res;
if (hasQuickActions) { if (hasQuickActions && Object.keys(errors).length) {
context.dispatch('poll'); context.dispatch('poll');
$('.js-gfm-input').trigger('clear-commands-cache.atwho'); $('.js-gfm-input').trigger('clear-commands-cache.atwho');
new Flash('Commands applied', 'notice', $(noteData.flashContainer)); // eslint-disable-line new Flash('Commands applied', 'notice', $(noteData.flashContainer)); // eslint-disable-line
} }
if (res.commands_changes.emoji_award) {
const votesBlock = $('.js-awards-block').eq(0);
loadAwardsHandler().then((awardsHandler) => {
awardsHandler.addAwardToEmojiBar(votesBlock, res.commands_changes.emoji_award);
awardsHandler.scrollToAwards();
}).catch(() => {
const msg = 'Something went wrong while adding your award. Please try again.';
new Flash(msg, $(noteData.flashContainer)); // eslint-disable-line
});
}
if (errors && errors.commands_only) { if (errors && errors.commands_only) {
new Flash(errors.commands_only, 'notice', $(noteData.flashContainer)); // eslint-disable-line new Flash(errors.commands_only, 'notice', $(noteData.flashContainer)); // eslint-disable-line
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment