Migration du client sur Typescript
This commit is contained in:
@ -1,13 +1,19 @@
|
||||
import React from 'react';
|
||||
import { Page } from '../Page';
|
||||
import { connect } from 'react-redux';
|
||||
import { connect, DispatchProp } from 'react-redux';
|
||||
import { selectFlagsIsLoading } from '../../store/selectors/flags';
|
||||
import { fetchBoards, saveBoard, deleteBoard } from '../../store/actions/boards';
|
||||
import { fetchProjects } from '../../store/actions/projects';
|
||||
import uuidv4 from 'uuid/v4';
|
||||
import { Loader } from '../Loader';
|
||||
import { RouteComponentProps } from 'react-router';
|
||||
|
||||
export class EditBoardPage extends React.Component {
|
||||
export interface EditorBoardPageProps extends DispatchProp, RouteComponentProps {
|
||||
isLoading: boolean
|
||||
projects: any
|
||||
}
|
||||
|
||||
export class EditBoardPage extends React.Component<EditorBoardPageProps> {
|
||||
|
||||
state = {
|
||||
edited: false,
|
||||
@ -20,7 +26,12 @@ export class EditBoardPage extends React.Component {
|
||||
},
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps(props, state) {
|
||||
onBoardTitleChange: (evt: any) => void;
|
||||
onBoardDescriptionChange: (evt: any) => void;
|
||||
onBoardLaneTitleChange: (laneIndex: any, evt: any) => void;
|
||||
onBoardLaneIssueLabelChange: (laneIndex: any, evt: any) => void;
|
||||
|
||||
static getDerivedStateFromProps(props: any, state: any) {
|
||||
const { board, isLoading } = props;
|
||||
|
||||
if (isLoading || !board || state.edited) return state;
|
||||
@ -32,12 +43,12 @@ export class EditBoardPage extends React.Component {
|
||||
title: board.title,
|
||||
description: board.description,
|
||||
projects: [ ...board.projects ],
|
||||
lanes: [ ...board.lanes.map(l => ({ ...l })) ]
|
||||
lanes: [ ...board.lanes.map((l: any) => ({ ...l })) ]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.onBoardTitleChange = this.onBoardAttrChange.bind(this, 'title');
|
||||
this.onBoardDescriptionChange = this.onBoardAttrChange.bind(this, 'description');
|
||||
@ -129,15 +140,15 @@ export class EditBoardPage extends React.Component {
|
||||
const { projects } = this.props;
|
||||
const { board } = this.state;
|
||||
|
||||
const projectSelectField = (projectIndex, value, withDeleteAddon) => {
|
||||
const projectSelectField = (projectIndex: number, value: any, withDeleteAddon: boolean) => {
|
||||
return (
|
||||
<div key={`project-${projectIndex}`} className="field has-addons">
|
||||
<div className="control is-expanded">
|
||||
<div className="select is-fullwidth">
|
||||
<select value={value} onChange={this.onBoardProjectChange.bind(this, projectIndex)}>
|
||||
<option value></option>
|
||||
<option value=""></option>
|
||||
{
|
||||
projects.map(p => {
|
||||
projects.map((p: any) => {
|
||||
return <option key={`project-${p}`} value={p}>{p}</option>;
|
||||
})
|
||||
}
|
||||
@ -179,7 +190,7 @@ export class EditBoardPage extends React.Component {
|
||||
|
||||
const { board } = this.state;
|
||||
|
||||
const laneSection = (laneIndex, lane) => {
|
||||
const laneSection = (laneIndex: number, lane: any) => {
|
||||
return (
|
||||
<React.Fragment key={`board-lane-${laneIndex}`}>
|
||||
<div className="columns">
|
||||
@ -266,7 +277,7 @@ export class EditBoardPage extends React.Component {
|
||||
}
|
||||
|
||||
onBoardLaneAdd() {
|
||||
this.setState(state => {
|
||||
this.setState((state: any) => {
|
||||
const lanes = [
|
||||
...state.board.lanes,
|
||||
{ id: uuidv4(), title: "", issueLabel: "" }
|
||||
@ -282,8 +293,8 @@ export class EditBoardPage extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
onBoardProjectDelete(projectIndex) {
|
||||
this.setState(state => {
|
||||
onBoardProjectDelete(projectIndex: number) {
|
||||
this.setState((state: any) => {
|
||||
const projects = [ ...state.board.projects ]
|
||||
projects.splice(projectIndex, 1);
|
||||
return {
|
||||
@ -297,8 +308,8 @@ export class EditBoardPage extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
onBoardLaneMove(laneIndex, direction) {
|
||||
this.setState(state => {
|
||||
onBoardLaneMove(laneIndex: number, direction: number) {
|
||||
this.setState((state: any) => {
|
||||
const lanes = [ ...state.board.lanes ];
|
||||
|
||||
const nextLaneIndex = laneIndex+direction;
|
||||
@ -321,8 +332,8 @@ export class EditBoardPage extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
onBoardLaneDelete(laneIndex) {
|
||||
this.setState(state => {
|
||||
onBoardLaneDelete(laneIndex: number) {
|
||||
this.setState((state: any) => {
|
||||
const lanes = [ ...state.board.lanes ]
|
||||
lanes.splice(laneIndex, 1);
|
||||
return {
|
||||
@ -336,9 +347,9 @@ export class EditBoardPage extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
onBoardProjectChange(projectIndex, evt) {
|
||||
const value = evt.target.value;
|
||||
this.setState(state => {
|
||||
onBoardProjectChange(projectIndex: number, evt: React.ChangeEvent) {
|
||||
const value = (evt.target as HTMLInputElement).value ;
|
||||
this.setState((state: any) => {
|
||||
const projects = [ ...state.board.projects ];
|
||||
projects[projectIndex] = value;
|
||||
return {
|
||||
@ -352,9 +363,9 @@ export class EditBoardPage extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
onBoardAttrChange(attrName, evt) {
|
||||
const value = evt.target.value;
|
||||
this.setState(state => {
|
||||
onBoardAttrChange(attrName: string, evt: React.ChangeEvent) {
|
||||
const value = (evt.target as HTMLInputElement).value;
|
||||
this.setState((state: any) => {
|
||||
return {
|
||||
...state,
|
||||
edited: true,
|
||||
@ -366,9 +377,9 @@ export class EditBoardPage extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
onBoardLaneAttrChange(attrName, laneIndex, evt) {
|
||||
const value = evt.target.value;
|
||||
this.setState(state => {
|
||||
onBoardLaneAttrChange(attrName: string, laneIndex: number, evt: React.ChangeEvent) {
|
||||
const value = (evt.target as HTMLInputElement).value;
|
||||
this.setState((state: any) => {
|
||||
const lanes = [ ...state.board.lanes ];
|
||||
lanes[laneIndex] = {
|
||||
...state.board.lanes[laneIndex],
|
||||
@ -406,7 +417,7 @@ export class EditBoardPage extends React.Component {
|
||||
|
||||
}
|
||||
|
||||
export const ConnectedEditBoardPage = connect(function(state, props) {
|
||||
export const ConnectedEditBoardPage = connect(function(state: any, props: any) {
|
||||
const boardID = props.match.params.id;
|
||||
const board = boardID ? state.boards.byID[boardID] : null;
|
||||
|
@ -1,7 +1,5 @@
|
||||
import React from 'react';
|
||||
|
||||
const issueURLPattern = /(^https?:\/\/([^\/]))$/i;
|
||||
|
||||
export class IssueCard extends React.PureComponent {
|
||||
render() {
|
||||
const { card } = this.props;
|
@ -1,6 +1,10 @@
|
||||
import React from 'react';
|
||||
|
||||
export class BoardCard extends React.PureComponent {
|
||||
export interface BoardProps {
|
||||
board: any
|
||||
}
|
||||
|
||||
export class BoardCard extends React.PureComponent<BoardProps> {
|
||||
render() {
|
||||
const { board } = this.props;
|
||||
return (
|
@ -1,12 +1,17 @@
|
||||
import React from 'react';
|
||||
import { Page } from '../Page';
|
||||
import { BoardCard } from './BoardCard';
|
||||
import { connect } from 'react-redux';
|
||||
import { connect, DispatchProp } from 'react-redux';
|
||||
import { fetchBoards } from '../../store/actions/boards';
|
||||
import { fetchProjects } from '../../store/actions/projects';
|
||||
import { selectBoardByUserProjects } from '../../store/selectors/boards';
|
||||
|
||||
export class HomePage extends React.Component {
|
||||
export interface HomePageProps extends DispatchProp {
|
||||
boards: any[]
|
||||
}
|
||||
|
||||
|
||||
export class HomePage extends React.Component<HomePageProps> {
|
||||
render() {
|
||||
return (
|
||||
<Page title="GenGitKan - Accueil">
|
||||
@ -40,8 +45,8 @@ export class HomePage extends React.Component {
|
||||
boardRows[boardRows.length-1].push(board);
|
||||
return boardRows;
|
||||
}, [])
|
||||
.map((row, rowIndex) => {
|
||||
const tiles = row.map((board) => {
|
||||
.map((row: any, rowIndex: number) => {
|
||||
const tiles = row.map((board: any) => {
|
||||
return (
|
||||
<div key={`board-${board.id}`} className={`tile is-parent is-4`}>
|
||||
<div className="tile is-child">
|
||||
@ -72,7 +77,7 @@ export class HomePage extends React.Component {
|
||||
|
||||
}
|
||||
|
||||
export const ConnectedHomePage = connect(function(state) {
|
||||
export const ConnectedHomePage = connect(function(state: any) {
|
||||
return {
|
||||
boards: selectBoardByUserProjects(state.boards.byID, state.projects.byName)
|
||||
};
|
@ -1,6 +1,12 @@
|
||||
import React from 'react';
|
||||
import React, { PropsWithChildren } from 'react';
|
||||
|
||||
export class Modal extends React.PureComponent {
|
||||
export interface ModalProps {
|
||||
active: boolean
|
||||
showCloseButton: boolean
|
||||
onClose: (evt: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
|
||||
}
|
||||
|
||||
export class Modal extends React.PureComponent<PropsWithChildren<ModalProps>> {
|
||||
render() {
|
||||
const { children, active, showCloseButton, onClose } = this.props;
|
||||
return (
|
@ -1,7 +1,11 @@
|
||||
import React from 'react';
|
||||
import { Navbar } from './Navbar';
|
||||
|
||||
export class Page extends React.PureComponent {
|
||||
export interface PageProps {
|
||||
title?: string
|
||||
}
|
||||
|
||||
export class Page extends React.PureComponent<PageProps> {
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment>
|
4
client/src/custom.d.ts
vendored
Normal file
4
client/src/custom.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
declare module "*.svg" {
|
||||
const content: any;
|
||||
export default content;
|
||||
}
|
@ -10,7 +10,7 @@ export const SAVE_BOARD_REQUEST = "SAVE_BOARD_REQUEST";
|
||||
export const SAVE_BOARD_SUCCESS = "SAVE_BOARD_SUCCESS";
|
||||
export const SAVE_BOARD_FAILURE = "SAVE_BOARD_FAILURE";
|
||||
|
||||
export function saveBoard(board) {
|
||||
export function saveBoard(board: any) {
|
||||
return { type: SAVE_BOARD_REQUEST, board };
|
||||
};
|
||||
|
||||
@ -18,6 +18,6 @@ export const DELETE_BOARD_REQUEST = "DELETE_BOARD_REQUEST";
|
||||
export const DELETE_BOARD_SUCCESS = "DELETE_BOARD_SUCCESS";
|
||||
export const DELETE_BOARD_FAILURE = "DELETE_BOARD_FAILURE";
|
||||
|
||||
export function deleteBoard(id) {
|
||||
export function deleteBoard(id: any) {
|
||||
return { type: DELETE_BOARD_REQUEST, id };
|
||||
};
|
@ -2,7 +2,7 @@ export const FETCH_ISSUES_REQUEST = "FETCH_ISSUES_REQUEST";
|
||||
export const FETCH_ISSUES_SUCCESS = "FETCH_ISSUES_SUCCESS";
|
||||
export const FETCH_ISSUES_FAILURE = "FETCH_ISSUES_FAILURE";
|
||||
|
||||
export function fetchIssues(project) {
|
||||
export function fetchIssues(project: any) {
|
||||
return { type: FETCH_ISSUES_REQUEST, project };
|
||||
};
|
||||
|
||||
@ -10,7 +10,7 @@ export const ADD_LABEL_REQUEST = "ADD_LABEL_REQUEST";
|
||||
export const ADD_LABEL_SUCCESS = "ADD_LABEL_SUCCESS";
|
||||
export const ADD_LABEL_FAILURE = "ADD_LABEL_FAILURE";
|
||||
|
||||
export function addLabel(project, issueNumber, label) {
|
||||
export function addLabel(project: any, issueNumber: any, label: string) {
|
||||
return { type: ADD_LABEL_REQUEST, project, issueNumber, label };
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ export const REMOVE_LABEL_REQUEST = "REMOVE_LABEL_REQUEST";
|
||||
export const REMOVE_LABEL_SUCCESS = "REMOVE_LABEL_SUCCESS";
|
||||
export const REMOVE_LABEL_FAILURE = "REMOVE_LABEL_FAILURE";
|
||||
|
||||
export function removeLabel(project, issueNumber, label) {
|
||||
export function removeLabel(project: any, issueNumber: any, label: string) {
|
||||
return { type: REMOVE_LABEL_REQUEST, project, issueNumber, label };
|
||||
}
|
||||
|
||||
@ -26,6 +26,6 @@ export const CREATE_ISSUE_REQUEST = "CREATE_ISSUE_REQUEST";
|
||||
export const CREATE_ISSUE_SUCCESS = "CREATE_ISSUE_SUCCESS";
|
||||
export const CREATE_ISSUE_FAILURE = "CREATE_ISSUE_FAILURE";
|
||||
|
||||
export function createIssue(project, title, body, label) {
|
||||
export function createIssue(project: any, title: string, body: any, label: string) {
|
||||
return { type: CREATE_ISSUE_REQUEST, project, title, body, label };
|
||||
};
|
@ -2,12 +2,12 @@ export const BUILD_KANBOARD_REQUEST = "BUILD_KANBOARD_REQUEST";
|
||||
export const BUILD_KANBOARD_SUCCESS = "BUILD_KANBOARD_SUCCESS";
|
||||
export const BUILD_KANBOARD_FAILURE = "BUILD_KANBOARD_FAILURE";
|
||||
|
||||
export function buildKanboard(board) {
|
||||
export function buildKanboard(board: string) {
|
||||
return { type: BUILD_KANBOARD_REQUEST, board };
|
||||
};
|
||||
|
||||
export const MOVE_CARD = "MOVE_CARD";
|
||||
|
||||
export function moveCard(boardID, fromLaneID, fromPosition, toLaneID, toPosition) {
|
||||
export function moveCard(boardID: string, fromLaneID: string, fromPosition: any, toLaneID: any, toPosition: any) {
|
||||
return { type: MOVE_CARD, boardID, fromLaneID, fromPosition, toLaneID, toPosition };
|
||||
};
|
@ -4,7 +4,7 @@ export const defaultState = {
|
||||
byID: {},
|
||||
};
|
||||
|
||||
export function boardsReducer(state = defaultState, action) {
|
||||
export function boardsReducer(state = defaultState, action: any) {
|
||||
switch(action.type) {
|
||||
case SAVE_BOARD_SUCCESS:
|
||||
return handleSaveBoardSuccess(state, action);
|
||||
@ -15,7 +15,7 @@ export function boardsReducer(state = defaultState, action) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleSaveBoardSuccess(state, action) {
|
||||
function handleSaveBoardSuccess(state: any, action: any) {
|
||||
const { board } = action;
|
||||
return {
|
||||
...state,
|
||||
@ -28,8 +28,8 @@ function handleSaveBoardSuccess(state, action) {
|
||||
};
|
||||
}
|
||||
|
||||
function handleFetchBoardsSuccess(state, action) {
|
||||
const boardsByID = action.boards.reduce((byID, board) => {
|
||||
function handleFetchBoardsSuccess(state: any, action: any) {
|
||||
const boardsByID = action.boards.reduce((byID: any, board: any) => {
|
||||
byID[board.id] = board;
|
||||
return byID;
|
||||
}, {});
|
@ -2,7 +2,7 @@ const defaultState = {
|
||||
actions: {}
|
||||
};
|
||||
|
||||
export function flagsReducer(state = defaultState, action) {
|
||||
export function flagsReducer(state = defaultState, action: any) {
|
||||
const matches = (/^(.*)_((SUCCESS)|(FAILURE)|(REQUEST))$/).exec(action.type);
|
||||
|
||||
if(!matches) return state;
|
@ -4,7 +4,7 @@ const defaultState = {
|
||||
byProject: {}
|
||||
};
|
||||
|
||||
export function issuesReducer(state = defaultState, action) {
|
||||
export function issuesReducer(state = defaultState, action: any) {
|
||||
switch(action.type) {
|
||||
case FETCH_ISSUES_SUCCESS:
|
||||
return handleFetchIssuesSuccess(state, action);
|
||||
@ -16,7 +16,7 @@ export function issuesReducer(state = defaultState, action) {
|
||||
|
||||
}
|
||||
|
||||
function handleFetchIssuesSuccess(state, action) {
|
||||
function handleFetchIssuesSuccess(state: any, action: any) {
|
||||
return {
|
||||
...state,
|
||||
byProject: {
|
||||
@ -28,7 +28,7 @@ function handleFetchIssuesSuccess(state, action) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleCreateIssueSuccess(state, action) {
|
||||
function handleCreateIssueSuccess(state: any, action: any) {
|
||||
return {
|
||||
...state,
|
||||
byProject: {
|
@ -5,7 +5,7 @@ export const defaultState = {
|
||||
byID: {},
|
||||
};
|
||||
|
||||
export function kanboardsReducer(state = defaultState, action) {
|
||||
export function kanboardsReducer(state = defaultState, action: any) {
|
||||
switch(action.type) {
|
||||
case BUILD_KANBOARD_SUCCESS:
|
||||
return handleBuildKanboardSuccess(state, action);
|
||||
@ -16,7 +16,7 @@ export function kanboardsReducer(state = defaultState, action) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleBuildKanboardSuccess(state, action) {
|
||||
function handleBuildKanboardSuccess(state: any, action: any) {
|
||||
return {
|
||||
...state,
|
||||
byID: {
|
||||
@ -28,7 +28,7 @@ function handleBuildKanboardSuccess(state, action) {
|
||||
};
|
||||
}
|
||||
|
||||
function handleMoveCard(state, action) {
|
||||
function handleMoveCard(state: any, action: any) {
|
||||
const {
|
||||
boardID, fromLaneID,
|
||||
fromPosition, toLaneID,
|
@ -4,7 +4,7 @@ export const defaultState = {
|
||||
byName: {},
|
||||
};
|
||||
|
||||
export function projectsReducer(state = defaultState, action) {
|
||||
export function projectsReducer(state = defaultState, action: any) {
|
||||
switch(action.type) {
|
||||
case FETCH_PROJECTS_SUCCESS:
|
||||
return handleFetchProjectsSuccess(state, action);
|
||||
@ -13,8 +13,8 @@ export function projectsReducer(state = defaultState, action) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleFetchProjectsSuccess(state, action) {
|
||||
const projectsByName = action.projects.reduce((byName, project) => {
|
||||
function handleFetchProjectsSuccess(state: any, action: any) {
|
||||
const projectsByName = action.projects.reduce((byName: any, project: any) => {
|
||||
byName[project.full_name] = project;
|
||||
return byName;
|
||||
}, {});
|
@ -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);
|
||||
};
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
export function selectBoardByUserProjects(boardsByID, projectsByName) {
|
||||
export function selectBoardByUserProjects(boardsByID: any, projectsByName: any) {
|
||||
const userProjects = Object.keys(projectsByName);
|
||||
return Object.keys(boardsByID).reduce((filteredBoardsByID, boardID) => {
|
||||
return Object.keys(boardsByID).reduce((filteredBoardsByID: any, boardID: string) => {
|
||||
const board = boardsByID[boardID];
|
||||
const hasProject = board.projects.length === 0 || board.projects.some(p => userProjects.indexOf(p) !== -1);
|
||||
const hasProject = board.projects.length === 0 || board.projects.some((p: any) => userProjects.indexOf(p) !== -1);
|
||||
if (hasProject) {
|
||||
filteredBoardsByID[boardID] = board;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
export function selectFlagsIsLoading(state, ...actionPrefixes) {
|
||||
export function selectFlagsIsLoading(state: any, ...actionPrefixes: any[]) {
|
||||
const { actions } = state.flags;
|
||||
return actionPrefixes.reduce((isLoading, prefix) => {
|
||||
if (!(prefix in actions)) return isLoading;
|
@ -1,14 +1,13 @@
|
||||
|
||||
export class GiteaUnauthorizedError extends Error {
|
||||
constructor(...args) {
|
||||
constructor(...args: any[]) {
|
||||
super(...args)
|
||||
Error.captureStackTrace(this, GiteaUnauthorizedError)
|
||||
}
|
||||
}
|
||||
|
||||
export class GiteaClient {
|
||||
|
||||
fetchIssues(project, page = 1) {
|
||||
fetchIssues(project: any, page = 1) {
|
||||
return fetch(`/gitea/api/v1/repos/${project}/issues?page=${page}`)
|
||||
.then(this.assertAuthorization)
|
||||
.then(this.assertOk)
|
||||
@ -24,7 +23,7 @@ export class GiteaClient {
|
||||
;
|
||||
}
|
||||
|
||||
addIssueLabel(project, issueNumber, labelID) {
|
||||
addIssueLabel(project: any, issueNumber: any, labelID: any) {
|
||||
return fetch(`/gitea/api/v1/repos/${project}/issues/${issueNumber}/labels`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@ -37,7 +36,7 @@ export class GiteaClient {
|
||||
.then(res => res.json())
|
||||
}
|
||||
|
||||
fetchProjectLabels(project) {
|
||||
fetchProjectLabels(project: any) {
|
||||
return fetch(`/gitea/api/v1/repos/${project}/labels`)
|
||||
.then(this.assertAuthorization)
|
||||
.then(this.assertOk)
|
||||
@ -45,7 +44,7 @@ export class GiteaClient {
|
||||
;
|
||||
}
|
||||
|
||||
removeIssueLabel(project, issueNumber, labelID) {
|
||||
removeIssueLabel(project: any, issueNumber: any, labelID: any) {
|
||||
return fetch(`/gitea/api/v1/repos/${project}/issues/${issueNumber}/labels/${labelID}`, {
|
||||
method: 'DELETE'
|
||||
})
|
||||
@ -53,7 +52,7 @@ export class GiteaClient {
|
||||
.then(this.assertOk)
|
||||
}
|
||||
|
||||
createIssue(project, title, body, labelID) {
|
||||
createIssue(project: any, title: any, body: any, labelID: any) {
|
||||
return fetch(`/gitea/api/v1/repos/${project}/issues`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@ -70,12 +69,12 @@ export class GiteaClient {
|
||||
.then(res => res.json())
|
||||
}
|
||||
|
||||
assertOk(res) {
|
||||
assertOk(res: any) {
|
||||
if (!res.ok) return Promise.reject(new Error('Request failed'));
|
||||
return res;
|
||||
}
|
||||
|
||||
assertAuthorization(res) {
|
||||
assertAuthorization(res: any) {
|
||||
if (res.status === 401 || res.status === 404) return Promise.reject(new GiteaUnauthorizedError());
|
||||
return res;
|
||||
}
|
Reference in New Issue
Block a user