Commit 616cec34 authored by Paul Slaughter's avatar Paul Slaughter

Revert "Merge branch 'fe-fix-incorrect-mitt-usage' into 'master'"

This reverts merge request !34242
parent c9d043c6
...@@ -89,10 +89,10 @@ export default { ...@@ -89,10 +89,10 @@ export default {
eventHub.$emit('clearDetailIssue', isMultiSelect); eventHub.$emit('clearDetailIssue', isMultiSelect);
if (isMultiSelect) { if (isMultiSelect) {
eventHub.$emit('newDetailIssue', [this.issue, isMultiSelect]); eventHub.$emit('newDetailIssue', this.issue, isMultiSelect);
} }
} else { } else {
eventHub.$emit('newDetailIssue', [this.issue, isMultiSelect]); eventHub.$emit('newDetailIssue', this.issue, isMultiSelect);
boardsStore.setListDetail(this.list); boardsStore.setListDetail(this.list);
} }
} }
......
...@@ -202,7 +202,7 @@ export default () => { ...@@ -202,7 +202,7 @@ export default () => {
updateTokens() { updateTokens() {
this.filterManager.updateTokens(); this.filterManager.updateTokens();
}, },
updateDetailIssue([newIssue, multiSelect = false]) { updateDetailIssue(newIssue, multiSelect = false) {
const { sidebarInfoEndpoint } = newIssue; const { sidebarInfoEndpoint } = newIssue;
if (sidebarInfoEndpoint && newIssue.subscribed === undefined) { if (sidebarInfoEndpoint && newIssue.subscribed === undefined) {
newIssue.setFetchingState('subscriptions', true); newIssue.setFetchingState('subscriptions', true);
......
...@@ -30,12 +30,9 @@ export default { ...@@ -30,12 +30,9 @@ export default {
doAction() { doAction() {
this.isLoading = true; this.isLoading = true;
eventHub.$emit(`${this.type}.key`, [ eventHub.$emit(`${this.type}.key`, this.deployKey, () => {
this.deployKey, this.isLoading = false;
() => { });
this.isLoading = false;
},
]);
}, },
}, },
}; };
......
...@@ -90,13 +90,13 @@ export default { ...@@ -90,13 +90,13 @@ export default {
return new Flash(s__('DeployKeys|Error getting deploy keys')); return new Flash(s__('DeployKeys|Error getting deploy keys'));
}); });
}, },
enableKey([deployKey]) { enableKey(deployKey) {
this.service this.service
.enableKey(deployKey.id) .enableKey(deployKey.id)
.then(this.fetchKeys) .then(this.fetchKeys)
.catch(() => new Flash(s__('DeployKeys|Error enabling deploy key'))); .catch(() => new Flash(s__('DeployKeys|Error enabling deploy key')));
}, },
disableKey([deployKey, callback]) { disableKey(deployKey, callback) {
if ( if (
// eslint-disable-next-line no-alert // eslint-disable-next-line no-alert
window.confirm(s__('DeployKeys|You are going to remove this deploy key. Are you sure?')) window.confirm(s__('DeployKeys|You are going to remove this deploy key. Are you sure?'))
......
...@@ -123,7 +123,7 @@ export default { ...@@ -123,7 +123,7 @@ export default {
this.updateGroups(res, Boolean(filterGroupsBy)); this.updateGroups(res, Boolean(filterGroupsBy));
}); });
}, },
fetchPage([page, filterGroupsBy, sortBy, archived]) { fetchPage(page, filterGroupsBy, sortBy, archived) {
this.isLoading = true; this.isLoading = true;
return this.fetchGroups({ return this.fetchGroups({
...@@ -169,7 +169,7 @@ export default { ...@@ -169,7 +169,7 @@ export default {
parentGroup.isOpen = false; parentGroup.isOpen = false;
} }
}, },
showLeaveGroupModal([group, parentGroup]) { showLeaveGroupModal(group, parentGroup) {
const { fullName } = group; const { fullName } = group;
this.targetGroup = group; this.targetGroup = group;
this.targetParentGroup = parentGroup; this.targetParentGroup = parentGroup;
......
...@@ -35,12 +35,7 @@ export default { ...@@ -35,12 +35,7 @@ export default {
const filterGroupsParam = getParameterByName('filter'); const filterGroupsParam = getParameterByName('filter');
const sortParam = getParameterByName('sort'); const sortParam = getParameterByName('sort');
const archivedParam = getParameterByName('archived'); const archivedParam = getParameterByName('archived');
eventHub.$emit(`${this.action}fetchPage`, [ eventHub.$emit(`${this.action}fetchPage`, page, filterGroupsParam, sortParam, archivedParam);
page,
filterGroupsParam,
sortParam,
archivedParam,
]);
}, },
}, },
}; };
......
...@@ -37,7 +37,7 @@ export default { ...@@ -37,7 +37,7 @@ export default {
}, },
methods: { methods: {
onLeaveGroup() { onLeaveGroup() {
eventHub.$emit(`${this.action}showLeaveGroupModal`, [this.group, this.parentGroup]); eventHub.$emit(`${this.action}showLeaveGroupModal`, this.group, this.parentGroup);
}, },
}, },
}; };
......
...@@ -3,8 +3,6 @@ import mitt from 'mitt'; ...@@ -3,8 +3,6 @@ import mitt from 'mitt';
export default () => { export default () => {
const emitter = mitt(); const emitter = mitt();
const originalEmit = emitter.emit;
emitter.once = (event, handler) => { emitter.once = (event, handler) => {
const wrappedHandler = evt => { const wrappedHandler = evt => {
handler(evt); handler(evt);
...@@ -13,10 +11,6 @@ export default () => { ...@@ -13,10 +11,6 @@ export default () => {
emitter.on(event, wrappedHandler); emitter.on(event, wrappedHandler);
}; };
emitter.emit = (event, args = []) => {
originalEmit(event, args);
};
emitter.$on = emitter.on; emitter.$on = emitter.on;
emitter.$once = emitter.once; emitter.$once = emitter.once;
emitter.$off = emitter.off; emitter.$off = emitter.off;
......
import createEventHub from '~/helpers/event_hub_factory'; import Vue from 'vue';
const eventHub = createEventHub(); const eventHub = new Vue();
// TODO: remove eventHub hack after code splitting refactor // TODO: remove eventHub hack after code splitting refactor
window.emitSidebarEvent = (...args) => eventHub.$emit(...args); window.emitSidebarEvent = (...args) => eventHub.$emit(...args);
......
/* eslint-disable class-methods-use-this, no-param-reassign */ /* eslint-disable class-methods-use-this, no-param-reassign */
/* /*
no-param-reassign is disabled because one method of BoardsStoreEE no-param-reassign is disabled because one method of BoardsStoreEE
modify the passed parameter in conformity with non-ee BoardsStore. modify the passed parameter in conformity with non-ee BoardsStore.
*/ */
...@@ -190,7 +190,7 @@ class BoardsStoreEE { ...@@ -190,7 +190,7 @@ class BoardsStoreEE {
issue.epic = newEpic; issue.epic = newEpic;
} }
updateWeight([newWeight, id]) { updateWeight(newWeight, id) {
const { issue } = this.store.detail; const { issue } = this.store.detail;
if (issue.id === id && issue.sidebarInfoEndpoint) { if (issue.id === id && issue.sidebarInfoEndpoint) {
issue.setLoadingState('weight', true); issue.setLoadingState('weight', true);
......
...@@ -27,7 +27,7 @@ export default { ...@@ -27,7 +27,7 @@ export default {
}, },
methods: { methods: {
onUpdateWeight([newWeight]) { onUpdateWeight(newWeight) {
this.mediator.updateWeight(newWeight).catch(() => { this.mediator.updateWeight(newWeight).catch(() => {
Flash(__('Error occurred while updating the issue weight')); Flash(__('Error occurred while updating the issue weight'));
}); });
......
...@@ -140,14 +140,14 @@ export default { ...@@ -140,14 +140,14 @@ export default {
$(this.$el).trigger('hidden.gl.dropdown'); $(this.$el).trigger('hidden.gl.dropdown');
if (isNewValue) { if (isNewValue) {
eventHub.$emit('updateWeight', [value, this.id]); eventHub.$emit('updateWeight', value, this.id);
} }
this.showEditField(false); this.showEditField(false);
} }
}, },
removeWeight() { removeWeight() {
eventHub.$emit('updateWeight', ['', this.id]); eventHub.$emit('updateWeight', '', this.id);
}, },
}, },
}; };
......
...@@ -125,7 +125,7 @@ describe('Weight', () => { ...@@ -125,7 +125,7 @@ describe('Weight', () => {
vm.$refs.editableField.dispatchEvent(event); vm.$refs.editableField.dispatchEvent(event);
expect(vm.hasValidInput).toBe(true); expect(vm.hasValidInput).toBe(true);
expect(eventHub.$emit).toHaveBeenCalledWith('updateWeight', [expectedWeightValue, ID]); expect(eventHub.$emit).toHaveBeenCalledWith('updateWeight', expectedWeightValue, ID);
}); });
}); });
...@@ -143,7 +143,7 @@ describe('Weight', () => { ...@@ -143,7 +143,7 @@ describe('Weight', () => {
return vm.$nextTick(() => { return vm.$nextTick(() => {
expect(vm.hasValidInput).toBe(true); expect(vm.hasValidInput).toBe(true);
expect(eventHub.$emit).toHaveBeenCalledWith('updateWeight', ['', ID]); expect(eventHub.$emit).toHaveBeenCalledWith('updateWeight', '', ID);
}); });
}); });
......
...@@ -196,7 +196,7 @@ describe('Board card', () => { ...@@ -196,7 +196,7 @@ describe('Board card', () => {
wrapper.trigger('mousedown'); wrapper.trigger('mousedown');
wrapper.trigger('mouseup'); wrapper.trigger('mouseup');
expect(eventHub.$emit).toHaveBeenCalledWith('newDetailIssue', [wrapper.vm.issue, undefined]); expect(eventHub.$emit).toHaveBeenCalledWith('newDetailIssue', wrapper.vm.issue, undefined);
expect(boardsStore.detail.list).toEqual(wrapper.vm.list); expect(boardsStore.detail.list).toEqual(wrapper.vm.list);
}); });
......
...@@ -32,7 +32,7 @@ describe('Deploy keys action btn', () => { ...@@ -32,7 +32,7 @@ describe('Deploy keys action btn', () => {
wrapper.trigger('click'); wrapper.trigger('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(eventHub.$emit).toHaveBeenCalledWith('enable.key', [deployKey, expect.any(Function)]); expect(eventHub.$emit).toHaveBeenCalledWith('enable.key', deployKey, expect.anything());
}); });
}); });
......
...@@ -88,7 +88,7 @@ describe('Deploy keys app component', () => { ...@@ -88,7 +88,7 @@ describe('Deploy keys app component', () => {
jest.spyOn(wrapper.vm.service, 'getKeys').mockImplementation(() => {}); jest.spyOn(wrapper.vm.service, 'getKeys').mockImplementation(() => {});
jest.spyOn(wrapper.vm.service, 'enableKey').mockImplementation(() => Promise.resolve()); jest.spyOn(wrapper.vm.service, 'enableKey').mockImplementation(() => Promise.resolve());
eventHub.$emit('enable.key', [key]); eventHub.$emit('enable.key', key);
return wrapper.vm.$nextTick(); return wrapper.vm.$nextTick();
}) })
...@@ -106,7 +106,7 @@ describe('Deploy keys app component', () => { ...@@ -106,7 +106,7 @@ describe('Deploy keys app component', () => {
jest.spyOn(wrapper.vm.service, 'getKeys').mockImplementation(() => {}); jest.spyOn(wrapper.vm.service, 'getKeys').mockImplementation(() => {});
jest.spyOn(wrapper.vm.service, 'disableKey').mockImplementation(() => Promise.resolve()); jest.spyOn(wrapper.vm.service, 'disableKey').mockImplementation(() => Promise.resolve());
eventHub.$emit('disable.key', [key]); eventHub.$emit('disable.key', key);
return wrapper.vm.$nextTick(); return wrapper.vm.$nextTick();
}) })
...@@ -124,7 +124,7 @@ describe('Deploy keys app component', () => { ...@@ -124,7 +124,7 @@ describe('Deploy keys app component', () => {
jest.spyOn(wrapper.vm.service, 'getKeys').mockImplementation(() => {}); jest.spyOn(wrapper.vm.service, 'getKeys').mockImplementation(() => {});
jest.spyOn(wrapper.vm.service, 'disableKey').mockImplementation(() => Promise.resolve()); jest.spyOn(wrapper.vm.service, 'disableKey').mockImplementation(() => Promise.resolve());
eventHub.$emit('remove.key', [key]); eventHub.$emit('remove.key', key);
return wrapper.vm.$nextTick(); return wrapper.vm.$nextTick();
}) })
......
...@@ -184,7 +184,7 @@ describe('AppComponent', () => { ...@@ -184,7 +184,7 @@ describe('AppComponent', () => {
jest.spyOn(window.history, 'replaceState').mockImplementation(() => {}); jest.spyOn(window.history, 'replaceState').mockImplementation(() => {});
jest.spyOn($, 'scrollTo').mockImplementation(() => {}); jest.spyOn($, 'scrollTo').mockImplementation(() => {});
const fetchPagePromise = vm.fetchPage([2, null, null, true]); const fetchPagePromise = vm.fetchPage(2, null, null, true);
expect(vm.isLoading).toBe(true); expect(vm.isLoading).toBe(true);
expect(vm.fetchGroups).toHaveBeenCalledWith({ expect(vm.fetchGroups).toHaveBeenCalledWith({
...@@ -275,7 +275,7 @@ describe('AppComponent', () => { ...@@ -275,7 +275,7 @@ describe('AppComponent', () => {
expect(vm.targetGroup).toBe(null); expect(vm.targetGroup).toBe(null);
expect(vm.targetParentGroup).toBe(null); expect(vm.targetParentGroup).toBe(null);
vm.showLeaveGroupModal([group, mockParentGroupItem]); vm.showLeaveGroupModal(group, mockParentGroupItem);
expect(vm.targetGroup).not.toBe(null); expect(vm.targetGroup).not.toBe(null);
expect(vm.targetParentGroup).not.toBe(null); expect(vm.targetParentGroup).not.toBe(null);
...@@ -286,7 +286,7 @@ describe('AppComponent', () => { ...@@ -286,7 +286,7 @@ describe('AppComponent', () => {
expect(vm.showModal).toBe(false); expect(vm.showModal).toBe(false);
expect(vm.groupLeaveConfirmationMessage).toBe(''); expect(vm.groupLeaveConfirmationMessage).toBe('');
vm.showLeaveGroupModal([group, mockParentGroupItem]); vm.showLeaveGroupModal(group, mockParentGroupItem);
expect(vm.showModal).toBe(true); expect(vm.showModal).toBe(true);
expect(vm.groupLeaveConfirmationMessage).toBe( expect(vm.groupLeaveConfirmationMessage).toBe(
...@@ -298,7 +298,7 @@ describe('AppComponent', () => { ...@@ -298,7 +298,7 @@ describe('AppComponent', () => {
describe('hideLeaveGroupModal', () => { describe('hideLeaveGroupModal', () => {
it('hides modal confirmation which is shown before leaving the group', () => { it('hides modal confirmation which is shown before leaving the group', () => {
const group = { ...mockParentGroupItem }; const group = { ...mockParentGroupItem };
vm.showLeaveGroupModal([group, mockParentGroupItem]); vm.showLeaveGroupModal(group, mockParentGroupItem);
expect(vm.showModal).toBe(true); expect(vm.showModal).toBe(true);
vm.hideLeaveGroupModal(); vm.hideLeaveGroupModal();
......
...@@ -41,12 +41,13 @@ describe('GroupsComponent', () => { ...@@ -41,12 +41,13 @@ describe('GroupsComponent', () => {
vm.change(2); vm.change(2);
expect(eventHub.$emit).toHaveBeenCalledWith('fetchPage', [ expect(eventHub.$emit).toHaveBeenCalledWith(
'fetchPage',
2, 2,
expect.any(Object), expect.any(Object),
expect.any(Object), expect.any(Object),
expect.any(Object), expect.any(Object),
]); );
}); });
}); });
}); });
......
...@@ -31,10 +31,11 @@ describe('ItemActionsComponent', () => { ...@@ -31,10 +31,11 @@ describe('ItemActionsComponent', () => {
jest.spyOn(eventHub, '$emit').mockImplementation(() => {}); jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
vm.onLeaveGroup(); vm.onLeaveGroup();
expect(eventHub.$emit).toHaveBeenCalledWith('showLeaveGroupModal', [ expect(eventHub.$emit).toHaveBeenCalledWith(
'showLeaveGroupModal',
vm.group, vm.group,
vm.parentGroup, vm.parentGroup,
]); );
}); });
}); });
}); });
......
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