diff options
-rw-r--r-- | app/assets/javascripts/sidebar/event_hub.js | 7 | ||||
-rw-r--r-- | app/assets/javascripts/users_select.js | 14 |
2 files changed, 14 insertions, 7 deletions
diff --git a/app/assets/javascripts/sidebar/event_hub.js b/app/assets/javascripts/sidebar/event_hub.js index 0948c2e5352..f35506fd5de 100644 --- a/app/assets/javascripts/sidebar/event_hub.js +++ b/app/assets/javascripts/sidebar/event_hub.js @@ -1,3 +1,8 @@ import Vue from 'vue'; -export default new Vue(); +const eventHub = new Vue(); + +// TODO: remove eventHub hack after code splitting refactor +window.emitSidebarEvent = (...args) => eventHub.$emit(...args); + +export default eventHub; diff --git a/app/assets/javascripts/users_select.js b/app/assets/javascripts/users_select.js index be29b08c343..38462782007 100644 --- a/app/assets/javascripts/users_select.js +++ b/app/assets/javascripts/users_select.js @@ -1,7 +1,9 @@ /* eslint-disable func-names, space-before-function-paren, one-var, no-var, prefer-rest-params, wrap-iife, quotes, max-len, one-var-declaration-per-line, vars-on-top, prefer-arrow-callback, consistent-return, comma-dangle, object-shorthand, no-shadow, no-unused-vars, no-else-return, no-self-compare, prefer-template, no-unused-expressions, no-lonely-if, yoda, prefer-spread, no-void, camelcase, no-param-reassign */ /* global Issuable */ +/* global emitSidebarEvent */ -import eventHub from './sidebar/event_hub'; +// TODO: remove eventHub hack after code splitting refactor +window.emitSidebarEvent = window.emitSidebarEvent || $.noop; (function() { var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; }, @@ -110,7 +112,7 @@ import eventHub from './sidebar/event_hub'; .find(`input[name='${$dropdown.data('field-name')}'][value=${firstSelectedId}]`); firstSelected.remove(); - eventHub.$emit('sidebar.removeAssignee', { + emitSidebarEvent('sidebar.removeAssignee', { id: firstSelectedId, }); } @@ -330,7 +332,7 @@ import eventHub from './sidebar/event_hub'; defaultLabel: defaultLabel, hidden: function(e) { if ($dropdown.hasClass('js-multiselect')) { - eventHub.$emit('sidebar.saveAssignees'); + emitSidebarEvent('sidebar.saveAssignees'); } if (!$dropdown.data('always-show-selectbox')) { @@ -364,10 +366,10 @@ import eventHub from './sidebar/event_hub'; const id = parseInt(element.value, 10); element.remove(); }); - eventHub.$emit('sidebar.removeAllAssignees'); + emitSidebarEvent('sidebar.removeAllAssignees'); } else if (isActive) { // user selected - eventHub.$emit('sidebar.addAssignee', user); + emitSidebarEvent('sidebar.addAssignee', user); // Remove unassigned selection (if it was previously selected) const unassignedSelected = $dropdown.closest('.selectbox') @@ -383,7 +385,7 @@ import eventHub from './sidebar/event_hub'; } // User unselected - eventHub.$emit('sidebar.removeAssignee', user); + emitSidebarEvent('sidebar.removeAssignee', user); } if (getSelected().find(u => u === gon.current_user_id)) { |