Migration du client sur Typescript
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
import { put, call } from 'redux-saga/effects';
|
||||
import { FETCH_BOARDS_SUCCESS, SAVE_BOARD_SUCCESS, SAVE_BOARD_FAILURE, FETCH_BOARDS_FAILURE, DELETE_BOARD_FAILURE, DELETE_BOARD_SUCCESS } from '../actions/boards';
|
||||
import {
|
||||
FETCH_BOARDS_SUCCESS, SAVE_BOARD_SUCCESS,
|
||||
SAVE_BOARD_FAILURE, FETCH_BOARDS_FAILURE,
|
||||
DELETE_BOARD_FAILURE, DELETE_BOARD_SUCCESS
|
||||
} from '../actions/boards';
|
||||
import { api } from '../../util/api';
|
||||
|
||||
export function* fetchBoardsSaga() {
|
||||
@ -15,7 +19,7 @@ export function* fetchBoardsSaga() {
|
||||
yield put({ type: FETCH_BOARDS_SUCCESS, boards });
|
||||
}
|
||||
|
||||
export function* saveBoardSaga(action) {
|
||||
export function* saveBoardSaga(action: any) {
|
||||
let { board } = action;
|
||||
|
||||
try {
|
||||
@ -29,11 +33,11 @@ export function* saveBoardSaga(action) {
|
||||
}
|
||||
|
||||
|
||||
export function* deleteBoardSaga(action) {
|
||||
export function* deleteBoardSaga(action: any) {
|
||||
let { id } = action;
|
||||
|
||||
try {
|
||||
board = yield call(api.deleteBoard, id)
|
||||
yield call(api.deleteBoard, id)
|
||||
} catch(error) {
|
||||
yield put({ type: DELETE_BOARD_FAILURE, error });
|
||||
return
|
@ -1,8 +1,13 @@
|
||||
import { put, call, retry } from 'redux-saga/effects';
|
||||
import { FETCH_ISSUES_SUCCESS, FETCH_ISSUES_FAILURE, ADD_LABEL_FAILURE, ADD_LABEL_SUCCESS, REMOVE_LABEL_FAILURE, REMOVE_LABEL_SUCCESS, CREATE_ISSUE_FAILURE, CREATE_ISSUE_SUCCESS } from '../actions/issues';
|
||||
import {
|
||||
FETCH_ISSUES_SUCCESS, FETCH_ISSUES_FAILURE,
|
||||
ADD_LABEL_FAILURE, ADD_LABEL_SUCCESS,
|
||||
REMOVE_LABEL_FAILURE, REMOVE_LABEL_SUCCESS,
|
||||
CREATE_ISSUE_FAILURE, CREATE_ISSUE_SUCCESS
|
||||
} from '../actions/issues';
|
||||
import { gitea } from '../../util/gitea';
|
||||
|
||||
export function* fetchIssuesSaga(action) {
|
||||
export function* fetchIssuesSaga(action: any) {
|
||||
const { project } = action;
|
||||
|
||||
let issues = [];
|
||||
@ -25,10 +30,10 @@ export function* fetchIssuesSaga(action) {
|
||||
yield put({ type: FETCH_ISSUES_SUCCESS, project, issues });
|
||||
}
|
||||
|
||||
export function* addLabelSaga(action) {
|
||||
export function* addLabelSaga(action: any) {
|
||||
const { project, issueNumber, label } = action;
|
||||
const labels = yield call(gitea.fetchProjectLabels.bind(gitea), project);
|
||||
const giteaLabel = labels.find(l => l.name === label)
|
||||
const giteaLabel = labels.find((l: any) => l.name === label)
|
||||
|
||||
if (!giteaLabel) {
|
||||
yield put({ type: ADD_LABEL_FAILURE, error: new Error(`Label "${label}" not found !`) });
|
||||
@ -45,10 +50,10 @@ export function* addLabelSaga(action) {
|
||||
yield put({ type: ADD_LABEL_SUCCESS, project, issueNumber, label });
|
||||
}
|
||||
|
||||
export function* removeLabelSaga(action) {
|
||||
export function* removeLabelSaga(action: any) {
|
||||
const { project, issueNumber, label } = action;
|
||||
const labels = yield call(gitea.fetchProjectLabels.bind(gitea), project);
|
||||
const giteaLabel = labels.find(l => l.name === label)
|
||||
const giteaLabel = labels.find((l: any) => l.name === label)
|
||||
|
||||
if (!giteaLabel) {
|
||||
yield put({ type: REMOVE_LABEL_FAILURE, error: new Error(`Label "${label}" not found !`) });
|
||||
@ -66,10 +71,10 @@ export function* removeLabelSaga(action) {
|
||||
yield put({ type: REMOVE_LABEL_SUCCESS, project, issueNumber, label });
|
||||
}
|
||||
|
||||
export function* createIssueSaga(action) {
|
||||
export function* createIssueSaga(action: any) {
|
||||
const { project, title, label, body } = action;
|
||||
const labels = yield call(gitea.fetchProjectLabels.bind(gitea), project);
|
||||
const giteaLabel = labels.find(l => l.name === label)
|
||||
const giteaLabel = labels.find((l: any) => l.name === label)
|
||||
|
||||
if (!giteaLabel) {
|
||||
yield put({ type: CREATE_ISSUE_FAILURE, error: new Error(`Label "${label}" not found !`) });
|
@ -1,9 +1,9 @@
|
||||
import { select, put } from 'redux-saga/effects';
|
||||
import { fetchIssues, addLabel, removeLabel } from '../actions/issues';
|
||||
import { fetchIssuesSaga } from './issues';
|
||||
import { BUILD_KANBOARD_SUCCESS, buildKanboard } from '../actions/kanboards';
|
||||
import { BUILD_KANBOARD_SUCCESS, buildKanboard, BUILD_KANBOARD_FAILURE } from '../actions/kanboards';
|
||||
|
||||
export function* moveCardSaga(action) {
|
||||
export function* moveCardSaga(action: any) {
|
||||
const {
|
||||
boardID, fromLaneID,
|
||||
fromPosition, toLaneID,
|
||||
@ -29,14 +29,15 @@ export function* moveCardSaga(action) {
|
||||
|
||||
}
|
||||
|
||||
export function* buildKanboardSaga(action) {
|
||||
export function* buildKanboardSaga(action: any) {
|
||||
const { board } = action;
|
||||
|
||||
let kanboard;
|
||||
try {
|
||||
|
||||
for (let p, i = 0; (p = board.projects[i]); i++) {
|
||||
yield* fetchIssuesSaga(fetchIssues(p));
|
||||
const { project } = yield fetchIssues(p);
|
||||
yield fetchIssuesSaga({ project });
|
||||
}
|
||||
|
||||
const issues = yield select(state => state.issues);
|
||||
@ -51,25 +52,25 @@ export function* buildKanboardSaga(action) {
|
||||
yield put({ type: BUILD_KANBOARD_SUCCESS, kanboard });
|
||||
}
|
||||
|
||||
export function* refreshKanboardSaga(action) {
|
||||
export function* refreshKanboardSaga(action: any) {
|
||||
const { project } = action;
|
||||
const boards = yield select(state => state.boards);
|
||||
const boardValues = Object.values(boards.byID);
|
||||
|
||||
for (let b, i = 0; (b = boardValues[i]); i++) {
|
||||
for (let b: any, i = 0; (b = boardValues[i]); i++) {
|
||||
const hasProject = b.projects.indexOf(project) !== -1;
|
||||
if (!hasProject) continue;
|
||||
yield put(buildKanboard(b));
|
||||
}
|
||||
}
|
||||
|
||||
function createCards(projects, issues, lane) {
|
||||
function createCards(projects: any[], issues: any, lane: any) {
|
||||
return projects.reduce((laneCards, p) => {
|
||||
|
||||
const projectIssues = p in issues.byProject ? issues.byProject[p] : [];
|
||||
|
||||
return projectIssues.reduce((projectCards, issue) => {
|
||||
const hasLabel = issue.labels.some(l => l.name === lane.issueLabel);
|
||||
return projectIssues.reduce((projectCards: any, issue: any) => {
|
||||
const hasLabel = issue.labels.some((l: any) => l.name === lane.issueLabel);
|
||||
|
||||
if (hasLabel) {
|
||||
projectCards.push({
|
||||
@ -87,7 +88,7 @@ function createCards(projects, issues, lane) {
|
||||
}, []);
|
||||
}
|
||||
|
||||
function createLane(projects, issues, lane, index) {
|
||||
function createLane(projects: any, issues: any, lane: any, index: any) {
|
||||
return {
|
||||
id: index,
|
||||
title: lane.title,
|
||||
@ -95,7 +96,7 @@ function createLane(projects, issues, lane, index) {
|
||||
}
|
||||
}
|
||||
|
||||
function createKanboard(board, issues) {
|
||||
function createKanboard(board: any, issues: any) {
|
||||
if (!board) return null;
|
||||
|
||||
const kanboard = {
|
@ -30,8 +30,8 @@ export function* rootSaga() {
|
||||
]);
|
||||
}
|
||||
|
||||
export function patternFromRegExp(re) {
|
||||
return (action) => {
|
||||
export function patternFromRegExp(re: any) {
|
||||
return (action: any) => {
|
||||
return re.test(action.type);
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user