|
|
|
|
@ -7,89 +7,6 @@ import actions from '../../../actions';
|
|
|
|
|
import api from '../../../api';
|
|
|
|
|
import { createLocalId } from '../../../utils/local-id';
|
|
|
|
|
|
|
|
|
|
export function* createBoard(projectId, data) {
|
|
|
|
|
const nextData = {
|
|
|
|
|
...data,
|
|
|
|
|
position: yield select(selectors.selectNextBoardPosition, projectId),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const localId = yield call(createLocalId);
|
|
|
|
|
|
|
|
|
|
yield put(
|
|
|
|
|
actions.createBoard({
|
|
|
|
|
...nextData,
|
|
|
|
|
projectId,
|
|
|
|
|
id: localId,
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let board;
|
|
|
|
|
let boardMemberships;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
({
|
|
|
|
|
item: board,
|
|
|
|
|
included: { boardMemberships },
|
|
|
|
|
} = yield call(request, api.createBoard, projectId, nextData));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put(actions.createBoard.failure(localId, error));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yield put(actions.createBoard.success(localId, board, boardMemberships));
|
|
|
|
|
yield call(goToBoard, board.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* createBoardInCurrentProject(data) {
|
|
|
|
|
const { projectId } = yield select(selectors.selectPath);
|
|
|
|
|
|
|
|
|
|
yield call(createBoard, projectId, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* importBoard(projectId, data) {
|
|
|
|
|
const nextData = {
|
|
|
|
|
...data,
|
|
|
|
|
position: yield select(selectors.selectNextBoardPosition, projectId),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const localId = yield call(createLocalId);
|
|
|
|
|
|
|
|
|
|
yield put(
|
|
|
|
|
actions.createBoard({
|
|
|
|
|
...nextData,
|
|
|
|
|
projectId,
|
|
|
|
|
id: localId,
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let board;
|
|
|
|
|
let boardMemberships;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
({
|
|
|
|
|
item: board,
|
|
|
|
|
included: { boardMemberships },
|
|
|
|
|
} = yield call(request, api.importBoard, projectId, nextData));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put(actions.createBoard.failure(localId, error));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yield put(actions.createBoard.success(localId, board, boardMemberships));
|
|
|
|
|
yield put(actions.fetchBoard(board.id));
|
|
|
|
|
yield call(goToBoard, board.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* importTrelloBoardInCurrentProject(data) {
|
|
|
|
|
const { projectId } = yield select(selectors.selectPath);
|
|
|
|
|
|
|
|
|
|
yield call(importBoard, projectId, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* handleBoardCreate(board) {
|
|
|
|
|
yield put(actions.handleBoardCreate(board));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* fetchBoard(id) {
|
|
|
|
|
yield put(actions.fetchBoard(id));
|
|
|
|
|
|
|
|
|
|
@ -143,6 +60,59 @@ export function* fetchBoard(id) {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* createBoard(projectId, data) {
|
|
|
|
|
const isImport = data && data.file;
|
|
|
|
|
const nextData = {
|
|
|
|
|
...data,
|
|
|
|
|
position: yield select(selectors.selectNextBoardPosition, projectId),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const localId = yield call(createLocalId);
|
|
|
|
|
|
|
|
|
|
yield put(
|
|
|
|
|
actions.createBoard({
|
|
|
|
|
...nextData,
|
|
|
|
|
projectId,
|
|
|
|
|
id: localId,
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let board;
|
|
|
|
|
let boardMemberships;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
({
|
|
|
|
|
item: board,
|
|
|
|
|
included: { boardMemberships },
|
|
|
|
|
} = yield call(request, isImport ? api.importBoard : api.createBoard, projectId, nextData));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
yield put(actions.createBoard.failure(localId, error));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yield put(actions.createBoard.success(localId, board, boardMemberships));
|
|
|
|
|
yield call(goToBoard, board.id);
|
|
|
|
|
if (isImport) {
|
|
|
|
|
yield call(fetchBoard, board.id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* createBoardInCurrentProject(data) {
|
|
|
|
|
const { projectId } = yield select(selectors.selectPath);
|
|
|
|
|
|
|
|
|
|
yield call(createBoard, projectId, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* importTrelloBoardInCurrentProject(data) {
|
|
|
|
|
const { projectId } = yield select(selectors.selectPath);
|
|
|
|
|
|
|
|
|
|
yield call(createBoard, projectId, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* handleBoardCreate(board) {
|
|
|
|
|
yield put(actions.handleBoardCreate(board));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* updateBoard(id, data) {
|
|
|
|
|
yield put(actions.updateBoard(id, data));
|
|
|
|
|
|
|
|
|
|
|