Commit 54e345fb authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'vs/replace-vue-emit-with-single-arg-weight-board' into 'master'

Replace $emit with single arg in board

See merge request gitlab-org/gitlab!66146
parents 0e4fb203 ee37a4eb
...@@ -170,7 +170,7 @@ class BoardsStoreEE { ...@@ -170,7 +170,7 @@ class BoardsStoreEE {
issue.epic = newEpic; issue.epic = newEpic;
} }
updateWeight(newWeight, id) { updateWeight({ id, value: newWeight }) {
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);
......
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
}, },
methods: { methods: {
onUpdateWeight(newWeight) { onUpdateWeight({ value: newWeight }) {
this.mediator.updateWeight(newWeight).catch(() => { this.mediator.updateWeight(newWeight).catch(() => {
createFlash({ createFlash({
message: __('Error occurred while updating the issue weight'), message: __('Error occurred while updating the issue weight'),
......
...@@ -123,14 +123,14 @@ export default { ...@@ -123,14 +123,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', { id: this.id, value });
} }
this.showEditField(false); this.showEditField(false);
} }
}, },
removeWeight() { removeWeight() {
eventHub.$emit('updateWeight', '', this.id); eventHub.$emit('updateWeight', { id: this.id, value: '' });
}, },
}, },
maxDisplayWeight: MAX_DISPLAY_WEIGHT, maxDisplayWeight: MAX_DISPLAY_WEIGHT,
......
...@@ -36,7 +36,7 @@ describe('Sidebar Weight', () => { ...@@ -36,7 +36,7 @@ describe('Sidebar Weight', () => {
mediator: sidebarMediator, mediator: sidebarMediator,
}); });
eventHub.$emit('updateWeight'); eventHub.$emit('updateWeight', { value: '' });
expect(SidebarMediator.prototype.updateWeight).toHaveBeenCalled(); expect(SidebarMediator.prototype.updateWeight).toHaveBeenCalled();
}); });
......
...@@ -130,7 +130,10 @@ describe('Weight', () => { ...@@ -130,7 +130,10 @@ describe('Weight', () => {
await wrapper.vm.$nextTick; await wrapper.vm.$nextTick;
expect(containsInputError()).toBe(false); expect(containsInputError()).toBe(false);
expect(eventHub.$emit).toHaveBeenCalledWith('updateWeight', expectedWeightValue, mockId); expect(eventHub.$emit).toHaveBeenCalledWith('updateWeight', {
id: mockId,
value: expectedWeightValue,
});
}); });
it('emits event on remove weight link click', async () => { it('emits event on remove weight link click', async () => {
...@@ -149,7 +152,7 @@ describe('Weight', () => { ...@@ -149,7 +152,7 @@ describe('Weight', () => {
await wrapper.vm.$nextTick; await wrapper.vm.$nextTick;
expect(containsInputError()).toBe(false); expect(containsInputError()).toBe(false);
expect(eventHub.$emit).toHaveBeenCalledWith('updateWeight', '', mockId); expect(eventHub.$emit).toHaveBeenCalledWith('updateWeight', { id: mockId, value: '' });
}); });
it('triggers error on invalid negative integer value', async () => { it('triggers error on invalid negative integer value', async () => {
......
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