Commit 912eb3ad authored by Marvin Karegyeya's avatar Marvin Karegyeya Committed by Martin Wortschack

Remove all references of BoardService in the list.js file

parent 69268559
...@@ -93,7 +93,7 @@ class List { ...@@ -93,7 +93,7 @@ class List {
entityType = 'milestone_id'; entityType = 'milestone_id';
} }
return gl.boardService return boardsStore
.createList(entity.id, entityType) .createList(entity.id, entityType)
.then(res => res.data) .then(res => res.data)
.then(data => { .then(data => {
...@@ -111,14 +111,14 @@ class List { ...@@ -111,14 +111,14 @@ class List {
boardsStore.state.lists.splice(index, 1); boardsStore.state.lists.splice(index, 1);
boardsStore.updateNewListDropdown(this.id); boardsStore.updateNewListDropdown(this.id);
gl.boardService.destroyList(this.id).catch(() => { boardsStore.destroyList(this.id).catch(() => {
// TODO: handle request error // TODO: handle request error
}); });
} }
update() { update() {
const collapsed = !this.isExpanded; const collapsed = !this.isExpanded;
return gl.boardService.updateList(this.id, this.position, collapsed).catch(() => { return boardsStore.updateList(this.id, this.position, collapsed).catch(() => {
// TODO: handle request error // TODO: handle request error
}); });
} }
...@@ -147,7 +147,7 @@ class List { ...@@ -147,7 +147,7 @@ class List {
this.loading = true; this.loading = true;
} }
return gl.boardService return boardsStore
.getIssuesForList(this.id, data) .getIssuesForList(this.id, data)
.then(res => res.data) .then(res => res.data)
.then(data => { .then(data => {
...@@ -168,7 +168,7 @@ class List { ...@@ -168,7 +168,7 @@ class List {
this.addIssue(issue, null, 0); this.addIssue(issue, null, 0);
this.issuesSize += 1; this.issuesSize += 1;
return gl.boardService return boardsStore
.newIssue(this.id, issue) .newIssue(this.id, issue)
.then(res => res.data) .then(res => res.data)
.then(data => this.onNewIssueResponse(issue, data)); .then(data => this.onNewIssueResponse(issue, data));
...@@ -276,7 +276,7 @@ class List { ...@@ -276,7 +276,7 @@ class List {
this.issues.splice(oldIndex, 1); this.issues.splice(oldIndex, 1);
this.issues.splice(newIndex, 0, issue); this.issues.splice(newIndex, 0, issue);
gl.boardService.moveIssue(issue.id, null, null, moveBeforeId, moveAfterId).catch(() => { boardsStore.moveIssue(issue.id, null, null, moveBeforeId, moveAfterId).catch(() => {
// TODO: handle request error // TODO: handle request error
}); });
} }
...@@ -287,7 +287,7 @@ class List { ...@@ -287,7 +287,7 @@ class List {
}); });
this.issues.splice(newIndex, 0, ...issues); this.issues.splice(newIndex, 0, ...issues);
gl.boardService boardsStore
.moveMultipleIssues({ .moveMultipleIssues({
ids: issues.map(issue => issue.id), ids: issues.map(issue => issue.id),
fromListId: null, fromListId: null,
...@@ -299,15 +299,13 @@ class List { ...@@ -299,15 +299,13 @@ class List {
} }
updateIssueLabel(issue, listFrom, moveBeforeId, moveAfterId) { updateIssueLabel(issue, listFrom, moveBeforeId, moveAfterId) {
gl.boardService boardsStore.moveIssue(issue.id, listFrom.id, this.id, moveBeforeId, moveAfterId).catch(() => {
.moveIssue(issue.id, listFrom.id, this.id, moveBeforeId, moveAfterId) // TODO: handle request error
.catch(() => { });
// TODO: handle request error
});
} }
updateMultipleIssues(issues, listFrom, moveBeforeId, moveAfterId) { updateMultipleIssues(issues, listFrom, moveBeforeId, moveAfterId) {
gl.boardService boardsStore
.moveMultipleIssues({ .moveMultipleIssues({
ids: issues.map(issue => issue.id), ids: issues.map(issue => issue.id),
fromListId: listFrom.id, fromListId: listFrom.id,
...@@ -359,7 +357,7 @@ class List { ...@@ -359,7 +357,7 @@ class List {
if (this.issuesSize > 1) { if (this.issuesSize > 1) {
const moveBeforeId = this.issues[1].id; const moveBeforeId = this.issues[1].id;
gl.boardService.moveIssue(issue.id, null, null, null, moveBeforeId); boardsStore.moveIssue(issue.id, null, null, null, moveBeforeId);
} }
} }
} }
......
---
title: Removes references of BoardService in list file
merge_request: 20145
author: nuwe1
type: other
...@@ -11,7 +11,7 @@ import '~/boards/models/list'; ...@@ -11,7 +11,7 @@ import '~/boards/models/list';
import '~/boards/services/board_service'; import '~/boards/services/board_service';
import boardsStore from '~/boards/stores/boards_store'; import boardsStore from '~/boards/stores/boards_store';
import eventHub from '~/boards/eventhub'; import eventHub from '~/boards/eventhub';
import { listObj, listObjDuplicate, boardsMockInterceptor, mockBoardService } from './mock_data'; import { listObj, listObjDuplicate, boardsMockInterceptor } from './mock_data';
import waitForPromises from '../../frontend/helpers/wait_for_promises'; import waitForPromises from '../../frontend/helpers/wait_for_promises';
describe('Store', () => { describe('Store', () => {
...@@ -20,17 +20,16 @@ describe('Store', () => { ...@@ -20,17 +20,16 @@ describe('Store', () => {
beforeEach(() => { beforeEach(() => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
mock.onAny().reply(boardsMockInterceptor); mock.onAny().reply(boardsMockInterceptor);
gl.boardService = mockBoardService();
boardsStore.create(); boardsStore.create();
spyOn(gl.boardService, 'moveIssue').and.callFake( spyOn(boardsStore, 'moveIssue').and.callFake(
() => () =>
new Promise(resolve => { new Promise(resolve => {
resolve(); resolve();
}), }),
); );
spyOn(gl.boardService, 'moveMultipleIssues').and.callFake( spyOn(boardsStore, 'moveMultipleIssues').and.callFake(
() => () =>
new Promise(resolve => { new Promise(resolve => {
resolve(); resolve();
...@@ -263,7 +262,7 @@ describe('Store', () => { ...@@ -263,7 +262,7 @@ describe('Store', () => {
expect(listOne.issues.length).toBe(0); expect(listOne.issues.length).toBe(0);
expect(listTwo.issues.length).toBe(2); expect(listTwo.issues.length).toBe(2);
expect(listTwo.issues[0].id).toBe(2); expect(listTwo.issues[0].id).toBe(2);
expect(gl.boardService.moveIssue).toHaveBeenCalledWith(2, listOne.id, listTwo.id, null, 1); expect(boardsStore.moveIssue).toHaveBeenCalledWith(2, listOne.id, listTwo.id, null, 1);
done(); done();
}, 0); }, 0);
...@@ -286,7 +285,7 @@ describe('Store', () => { ...@@ -286,7 +285,7 @@ describe('Store', () => {
expect(listOne.issues.length).toBe(0); expect(listOne.issues.length).toBe(0);
expect(listTwo.issues.length).toBe(2); expect(listTwo.issues.length).toBe(2);
expect(listTwo.issues[1].id).toBe(2); expect(listTwo.issues[1].id).toBe(2);
expect(gl.boardService.moveIssue).toHaveBeenCalledWith(2, listOne.id, listTwo.id, 1, null); expect(boardsStore.moveIssue).toHaveBeenCalledWith(2, listOne.id, listTwo.id, 1, null);
done(); done();
}, 0); }, 0);
...@@ -311,7 +310,7 @@ describe('Store', () => { ...@@ -311,7 +310,7 @@ describe('Store', () => {
boardsStore.moveIssueInList(list, issue, 0, 1, [1, 2]); boardsStore.moveIssueInList(list, issue, 0, 1, [1, 2]);
expect(list.issues[0].id).toBe(2); expect(list.issues[0].id).toBe(2);
expect(gl.boardService.moveIssue).toHaveBeenCalledWith(2, null, null, 1, null); expect(boardsStore.moveIssue).toHaveBeenCalledWith(2, null, null, 1, null);
done(); done();
}); });
...@@ -495,7 +494,7 @@ describe('Store', () => { ...@@ -495,7 +494,7 @@ describe('Store', () => {
expect(list.issues[0].id).toBe(issue1.id); expect(list.issues[0].id).toBe(issue1.id);
expect(gl.boardService.moveMultipleIssues).toHaveBeenCalledWith({ expect(boardsStore.moveMultipleIssues).toHaveBeenCalledWith({
ids: [issue1.id, issue2.id], ids: [issue1.id, issue2.id],
fromListId: null, fromListId: null,
toListId: null, toListId: null,
......
...@@ -12,7 +12,7 @@ import '~/boards/models/issue'; ...@@ -12,7 +12,7 @@ import '~/boards/models/issue';
import '~/boards/models/list'; import '~/boards/models/list';
import '~/boards/services/board_service'; import '~/boards/services/board_service';
import boardsStore from '~/boards/stores/boards_store'; import boardsStore from '~/boards/stores/boards_store';
import { listObj, listObjDuplicate, boardsMockInterceptor, mockBoardService } from './mock_data'; import { listObj, listObjDuplicate, boardsMockInterceptor } from './mock_data';
describe('List model', () => { describe('List model', () => {
let list; let list;
...@@ -21,9 +21,6 @@ describe('List model', () => { ...@@ -21,9 +21,6 @@ describe('List model', () => {
beforeEach(() => { beforeEach(() => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
mock.onAny().reply(boardsMockInterceptor); mock.onAny().reply(boardsMockInterceptor);
gl.boardService = mockBoardService({
bulkUpdatePath: '/test/issue-boards/board/1/lists',
});
boardsStore.create(); boardsStore.create();
list = new List(listObj); list = new List(listObj);
...@@ -110,11 +107,11 @@ describe('List model', () => { ...@@ -110,11 +107,11 @@ describe('List model', () => {
list.issues.push(issue); list.issues.push(issue);
listDup.issues.push(issue); listDup.issues.push(issue);
spyOn(gl.boardService, 'moveIssue').and.callThrough(); spyOn(boardsStore, 'moveIssue').and.callThrough();
listDup.updateIssueLabel(issue, list); listDup.updateIssueLabel(issue, list);
expect(gl.boardService.moveIssue).toHaveBeenCalledWith( expect(boardsStore.moveIssue).toHaveBeenCalledWith(
issue.id, issue.id,
list.id, list.id,
listDup.id, listDup.id,
...@@ -172,7 +169,7 @@ describe('List model', () => { ...@@ -172,7 +169,7 @@ describe('List model', () => {
describe('newIssue', () => { describe('newIssue', () => {
beforeEach(() => { beforeEach(() => {
spyOn(gl.boardService, 'newIssue').and.returnValue( spyOn(boardsStore, 'newIssue').and.returnValue(
Promise.resolve({ Promise.resolve({
data: { data: {
id: 42, id: 42,
......
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