Commit 14eb2aba authored by Fatih Acet's avatar Fatih Acet

IssueNotesRefactor: Implement time tracking sidebar integration with slash commands.

parent 8fa1f65e
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,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'; import loadAwardsHandler from '../../awards_handler';
import sidebarTimeTrackingEventHub from '../../sidebar/event_hub';
const state = { const state = {
notes: [], notes: [],
...@@ -233,16 +234,22 @@ const actions = { ...@@ -233,16 +234,22 @@ const actions = {
Flash('Commands applied', 'notice', $(noteData.flashContainer)); Flash('Commands applied', 'notice', $(noteData.flashContainer));
} }
if (commandsChanges && commandsChanges.emoji_award) { if (commandsChanges) {
const votesBlock = $('.js-awards-block').eq(0); if (commandsChanges.emoji_award) {
const votesBlock = $('.js-awards-block').eq(0);
loadAwardsHandler().then((awardsHandler) => {
awardsHandler.addAwardToEmojiBar(votesBlock, commandsChanges.emoji_award);
awardsHandler.scrollToAwards();
}).catch(() => {
const msg = 'Something went wrong while adding your award. Please try again.';
Flash(msg, $(noteData.flashContainer));
});
}
loadAwardsHandler().then((awardsHandler) => { if (commandsChanges.spend_time || commandsChanges.time_estimate) {
awardsHandler.addAwardToEmojiBar(votesBlock, commandsChanges.emoji_award); sidebarTimeTrackingEventHub.$emit('timeTrackingUpdated', res);
awardsHandler.scrollToAwards(); }
}).catch(() => {
const msg = 'Something went wrong while adding your award. Please try again.';
Flash(msg, $(noteData.flashContainer));
});
} }
if (errors && errors.commands_only) { if (errors && errors.commands_only) {
......
...@@ -4,6 +4,7 @@ import timeTracker from './time_tracker'; ...@@ -4,6 +4,7 @@ import timeTracker from './time_tracker';
import Store from '../../stores/sidebar_store'; import Store from '../../stores/sidebar_store';
import Mediator from '../../sidebar_mediator'; import Mediator from '../../sidebar_mediator';
import eventHub from '../../event_hub';
export default { export default {
data() { data() {
...@@ -18,6 +19,9 @@ export default { ...@@ -18,6 +19,9 @@ export default {
methods: { methods: {
listenForQuickActions() { listenForQuickActions() {
$(document).on('ajax:success', '.gfm-form', this.quickActionListened); $(document).on('ajax:success', '.gfm-form', this.quickActionListened);
eventHub.$on('timeTrackingUpdated', (data) => {
this.quickActionListened(null, data);
});
}, },
quickActionListened(e, data) { quickActionListened(e, data) {
const subscribedCommands = ['spend_time', 'time_estimate']; const subscribedCommands = ['spend_time', 'time_estimate'];
......
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