Manage milestones on multi-projects
This commit is contained in:
parent
7ca6e63680
commit
3324f71544
@ -8,7 +8,7 @@ import { buildKanboard, moveCard } from '../../store/actions/kanboards';
|
|||||||
import { Loader } from '../Loader';
|
import { Loader } from '../Loader';
|
||||||
import { IssueCard } from './IssueCard';
|
import { IssueCard } from './IssueCard';
|
||||||
import { Modal } from '../Modal';
|
import { Modal } from '../Modal';
|
||||||
import { fetchProjectMilestones } from '../../store/actions/projects';
|
import { fetchProjectsMilestones } from '../../store/actions/projects';
|
||||||
|
|
||||||
export interface BoardPageProps extends DispatchProp {
|
export interface BoardPageProps extends DispatchProp {
|
||||||
board: any
|
board: any
|
||||||
@ -52,7 +52,6 @@ export class BoardPage extends React.Component<BoardPageProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleMilestonesChange(e: any) {
|
handleMilestonesChange(e: any) {
|
||||||
console.log("EVT VALUE", e.target.value);
|
|
||||||
let m = (e.target as HTMLInputElement).value;
|
let m = (e.target as HTMLInputElement).value;
|
||||||
this.setState(state => ({ ...state, selectedMilestone: m }), this.requestBuildKanboard);
|
this.setState(state => ({ ...state, selectedMilestone: m }), this.requestBuildKanboard);
|
||||||
//this.requestBuildKanboard();
|
//this.requestBuildKanboard();
|
||||||
@ -69,6 +68,7 @@ export class BoardPage extends React.Component<BoardPageProps> {
|
|||||||
|
|
||||||
renderBoard() {
|
renderBoard() {
|
||||||
const { kanboard, board, milestones } = this.props;
|
const { kanboard, board, milestones } = this.props;
|
||||||
|
const { selectedMilestone } = this.state;
|
||||||
|
|
||||||
if (!kanboard) {
|
if (!kanboard) {
|
||||||
return <Loader></Loader>
|
return <Loader></Loader>
|
||||||
@ -91,7 +91,15 @@ export class BoardPage extends React.Component<BoardPageProps> {
|
|||||||
{
|
{
|
||||||
milestones.length > 0 ? milestones.map((k: any) => {
|
milestones.length > 0 ? milestones.map((k: any) => {
|
||||||
return (
|
return (
|
||||||
<option value={k.title} key={k.id}>{k.title}</option>
|
<optgroup label={k.project}>
|
||||||
|
{
|
||||||
|
k.milestones.map((m: any) => {
|
||||||
|
return (
|
||||||
|
<option value={m.title} key={m.id}>{m.title}</option>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</optgroup>
|
||||||
)
|
)
|
||||||
}) : ""
|
}) : ""
|
||||||
}
|
}
|
||||||
@ -326,9 +334,8 @@ export class BoardPage extends React.Component<BoardPageProps> {
|
|||||||
requestBuildKanboard() {
|
requestBuildKanboard() {
|
||||||
const { board } = this.props;
|
const { board } = this.props;
|
||||||
const { selectedMilestone } = this.state;
|
const { selectedMilestone } = this.state;
|
||||||
console.log("SELECTED MILESTONE", selectedMilestone)
|
|
||||||
if (!board) return;
|
if (!board) return;
|
||||||
this.props.dispatch(fetchProjectMilestones(board.projects[0]));
|
this.props.dispatch(fetchProjectsMilestones(board.projects));
|
||||||
this.props.dispatch(buildKanboard(board, selectedMilestone));
|
this.props.dispatch(buildKanboard(board, selectedMilestone));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,6 @@ export function fetchProjects() {
|
|||||||
return { type: FETCH_PROJECTS_REQUEST };
|
return { type: FETCH_PROJECTS_REQUEST };
|
||||||
};
|
};
|
||||||
|
|
||||||
export function fetchProjectMilestones(project: any) {
|
export function fetchProjectsMilestones(projects: any) {
|
||||||
return { type: FETCH_PROJECT_MILESTONES_REQUEST, project };
|
return { type: FETCH_PROJECT_MILESTONES_REQUEST, projects };
|
||||||
};
|
};
|
@ -2,7 +2,7 @@ import { FETCH_PROJECTS_SUCCESS, FETCH_PROJECT_MILESTONES_SUCCESS } from "../act
|
|||||||
|
|
||||||
export const defaultState = {
|
export const defaultState = {
|
||||||
byName: {},
|
byName: {},
|
||||||
milestones: ""
|
milestones: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
export function projectsReducer(state = defaultState, action: any) {
|
export function projectsReducer(state = defaultState, action: any) {
|
||||||
@ -32,6 +32,7 @@ function handleFetchProjectsSuccess(state: any, action: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleFetchProjectMilestonesSuccess(state: any, action: any) {
|
function handleFetchProjectMilestonesSuccess(state: any, action: any) {
|
||||||
|
console.log(action.milestones);
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
milestones: action.milestones,
|
milestones: action.milestones,
|
||||||
|
@ -39,7 +39,7 @@ export function* buildKanboardSaga(action: any) {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
for (let p, i = 0; (p = board.projects[i]); i++) {
|
for (let p, i = 0; (p = board.projects[i]); i++) {
|
||||||
const { project } = yield fetchIssues(p, "test");
|
const { project } = yield fetchIssues(p, milestones);
|
||||||
yield fetchIssuesSaga({ project: project, milestones: milestones });
|
yield fetchIssuesSaga({ project: project, milestones: milestones });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,11 +15,18 @@ export function* fetchProjectsSaga() {
|
|||||||
yield put({ type: FETCH_PROJECTS_SUCCESS, projects });
|
yield put({ type: FETCH_PROJECTS_SUCCESS, projects });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function* fetchProjectMilestonesSaga(action: any) {
|
export function* fetchProjectsMilestonesSaga(action: any) {
|
||||||
const { project } = action;
|
const { projects } = action;
|
||||||
let milestones;
|
let milestones = [];
|
||||||
try {
|
try {
|
||||||
milestones = yield call(gitea.fetchMilestones.bind(gitea), project)
|
for (var i = 0; i < projects.length; i++) {
|
||||||
|
console.log("PROJECT ", projects[i])
|
||||||
|
milestones.push({
|
||||||
|
project: projects[i],
|
||||||
|
milestones: yield call(gitea.fetchMilestones.bind(gitea), projects[i])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
console.log("MILESTONES", milestones)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
yield put({ type: FETCH_PROJECT_MILESTONES_FAILURE, error });
|
yield put({ type: FETCH_PROJECT_MILESTONES_FAILURE, error });
|
||||||
return;
|
return;
|
||||||
|
@ -5,7 +5,7 @@ import { fetchBoardsSaga, saveBoardSaga, deleteBoardSaga } from './boards';
|
|||||||
import { FETCH_ISSUES_REQUEST, ADD_LABEL_REQUEST, REMOVE_LABEL_REQUEST, CREATE_ISSUE_REQUEST, CREATE_ISSUE_SUCCESS } from '../actions/issues';
|
import { FETCH_ISSUES_REQUEST, ADD_LABEL_REQUEST, REMOVE_LABEL_REQUEST, CREATE_ISSUE_REQUEST, CREATE_ISSUE_SUCCESS } from '../actions/issues';
|
||||||
import { fetchIssuesSaga, addLabelSaga, removeLabelSaga, createIssueSaga } from './issues';
|
import { fetchIssuesSaga, addLabelSaga, removeLabelSaga, createIssueSaga } from './issues';
|
||||||
import { FETCH_PROJECTS_REQUEST, FETCH_PROJECT_MILESTONES_REQUEST } from '../actions/projects';
|
import { FETCH_PROJECTS_REQUEST, FETCH_PROJECT_MILESTONES_REQUEST } from '../actions/projects';
|
||||||
import { fetchProjectMilestonesSaga, fetchProjectsSaga } from './projects';
|
import { fetchProjectsMilestonesSaga, fetchProjectsSaga } from './projects';
|
||||||
import { LOGOUT_REQUEST, LOGOUT_SUCCESS } from '../actions/logout';
|
import { LOGOUT_REQUEST, LOGOUT_SUCCESS } from '../actions/logout';
|
||||||
import { logoutSaga, logoutSuccessSaga } from './logout';
|
import { logoutSaga, logoutSuccessSaga } from './logout';
|
||||||
import { BUILD_KANBOARD_REQUEST, MOVE_CARD } from '../actions/kanboards';
|
import { BUILD_KANBOARD_REQUEST, MOVE_CARD } from '../actions/kanboards';
|
||||||
@ -22,7 +22,7 @@ export function* rootSaga() {
|
|||||||
takeLatest(DELETE_BOARD_REQUEST, deleteBoardSaga),
|
takeLatest(DELETE_BOARD_REQUEST, deleteBoardSaga),
|
||||||
takeLatest(FETCH_ISSUES_REQUEST, fetchIssuesSaga),
|
takeLatest(FETCH_ISSUES_REQUEST, fetchIssuesSaga),
|
||||||
takeLatest(FETCH_PROJECTS_REQUEST, fetchProjectsSaga),
|
takeLatest(FETCH_PROJECTS_REQUEST, fetchProjectsSaga),
|
||||||
takeLatest(FETCH_PROJECT_MILESTONES_REQUEST, fetchProjectMilestonesSaga),
|
takeLatest(FETCH_PROJECT_MILESTONES_REQUEST, fetchProjectsMilestonesSaga),
|
||||||
takeEvery(MOVE_CARD, moveCardSaga),
|
takeEvery(MOVE_CARD, moveCardSaga),
|
||||||
takeEvery(ADD_LABEL_REQUEST, addLabelSaga),
|
takeEvery(ADD_LABEL_REQUEST, addLabelSaga),
|
||||||
takeEvery(REMOVE_LABEL_REQUEST, removeLabelSaga),
|
takeEvery(REMOVE_LABEL_REQUEST, removeLabelSaga),
|
||||||
|
@ -8,7 +8,7 @@ export class GiteaUnauthorizedError extends Error {
|
|||||||
|
|
||||||
export class GiteaClient {
|
export class GiteaClient {
|
||||||
|
|
||||||
fetchIssues(project: any, page = 1, milestones = "") {
|
fetchIssues(project: any, page = "", milestones = "") {
|
||||||
return fetch(`/gitea/api/v1/repos/${project}/issues?page=${page}&milestones=${milestones}`)
|
return fetch(`/gitea/api/v1/repos/${project}/issues?page=${page}&milestones=${milestones}`)
|
||||||
.then(this.assertAuthorization)
|
.then(this.assertAuthorization)
|
||||||
.then(this.assertOk)
|
.then(this.assertOk)
|
||||||
|
Loading…
Reference in New Issue
Block a user