summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2017-07-22 00:55:55 +0300
committerFatih Acet <acetfatih@gmail.com>2017-07-22 00:55:55 +0300
commit14eb2abaa373cfd060e943e60f2b4d75fe45ab67 (patch)
tree65b877173550b74df427154ab09cee713bbedb7d
parent8fa1f65e71d5462fe08dce06df4f8bd77be375e4 (diff)
downloadgitlab-ce-14eb2abaa373cfd060e943e60f2b4d75fe45ab67.tar.gz
IssueNotesRefactor: Implement time tracking sidebar integration with slash commands.
-rw-r--r--app/assets/javascripts/notes/stores/issue_notes_store.js25
-rw-r--r--app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js4
2 files changed, 20 insertions, 9 deletions
diff --git a/app/assets/javascripts/notes/stores/issue_notes_store.js b/app/assets/javascripts/notes/stores/issue_notes_store.js
index 17b8da380a5..25ffbdd9e16 100644
--- a/app/assets/javascripts/notes/stores/issue_notes_store.js
+++ b/app/assets/javascripts/notes/stores/issue_notes_store.js
@@ -3,6 +3,7 @@
import service from '../services/issue_notes_service';
import utils from './issue_notes_utils';
import loadAwardsHandler from '../../awards_handler';
+import sidebarTimeTrackingEventHub from '../../sidebar/event_hub';
const state = {
notes: [],
@@ -233,16 +234,22 @@ const actions = {
Flash('Commands applied', 'notice', $(noteData.flashContainer));
}
- if (commandsChanges && commandsChanges.emoji_award) {
- const votesBlock = $('.js-awards-block').eq(0);
+ if (commandsChanges) {
+ 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) => {
- 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));
- });
+ if (commandsChanges.spend_time || commandsChanges.time_estimate) {
+ sidebarTimeTrackingEventHub.$emit('timeTrackingUpdated', res);
+ }
}
if (errors && errors.commands_only) {
diff --git a/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js b/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js
index 650e935b116..efedea32d1e 100644
--- a/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js
+++ b/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.js
@@ -4,6 +4,7 @@ import timeTracker from './time_tracker';
import Store from '../../stores/sidebar_store';
import Mediator from '../../sidebar_mediator';
+import eventHub from '../../event_hub';
export default {
data() {
@@ -18,6 +19,9 @@ export default {
methods: {
listenForQuickActions() {
$(document).on('ajax:success', '.gfm-form', this.quickActionListened);
+ eventHub.$on('timeTrackingUpdated', (data) => {
+ this.quickActionListened(null, data);
+ });
},
quickActionListened(e, data) {
const subscribedCommands = ['spend_time', 'time_estimate'];