2019-11-28 14:12:48 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { Page } from '../Page';
|
2019-12-01 22:12:13 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import Board from '@lourenci/react-kanban';
|
|
|
|
import { fetchIssues } from '../../store/actions/issues';
|
|
|
|
import { fetchBoards } from '../../store/actions/boards';
|
|
|
|
import { buildKanboard, moveCard } from '../../store/actions/kanboards';
|
2019-12-05 15:59:05 +01:00
|
|
|
import { Loader } from '../Loader';
|
2019-11-28 14:12:48 +01:00
|
|
|
|
|
|
|
export class BoardPage extends React.Component {
|
2019-12-01 22:12:13 +01:00
|
|
|
|
2019-11-28 14:12:48 +01:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Page>
|
2019-12-01 22:12:13 +01:00
|
|
|
<div className="container is-fluid">
|
2019-12-05 15:59:05 +01:00
|
|
|
{this.renderBoard()}
|
2019-12-01 22:12:13 +01:00
|
|
|
</div>
|
2019-11-28 14:12:48 +01:00
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
}
|
2019-12-01 22:12:13 +01:00
|
|
|
|
|
|
|
renderBoard() {
|
|
|
|
const { kanboard } = this.props;
|
2019-12-05 15:59:05 +01:00
|
|
|
|
2019-12-01 22:12:13 +01:00
|
|
|
if (!kanboard) {
|
2019-12-05 15:59:05 +01:00
|
|
|
return <Loader></Loader>
|
2019-12-01 22:12:13 +01:00
|
|
|
}
|
2019-12-05 15:59:05 +01:00
|
|
|
|
2019-12-01 22:12:13 +01:00
|
|
|
return (
|
2019-12-05 15:59:05 +01:00
|
|
|
<div className="kanboard-container is-fullheight">
|
|
|
|
<Board disableLaneDrag={true}
|
|
|
|
renderCard={this.renderCard}
|
|
|
|
renderLaneHeader={this.renderLaneHeader}
|
|
|
|
onCardDragEnd={this.onCardDragEnd.bind(this)}>
|
|
|
|
{kanboard}
|
|
|
|
</Board>
|
|
|
|
</div>
|
2019-12-01 22:12:13 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderCard(card) {
|
|
|
|
return (
|
|
|
|
<div className="kanboard-card">
|
|
|
|
<div className="box">
|
|
|
|
<div className="media">
|
|
|
|
<div className="media-content">
|
|
|
|
<div className="content">
|
|
|
|
<h5 className="is-size-5 is-marginless">{card.title}</h5>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderLaneHeader(lane) {
|
|
|
|
return (
|
|
|
|
<h3 className="kanboard-lane-title is-size-3">{lane.title}</h3>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
onCardDragEnd(source, dest) {
|
|
|
|
const { board } = this.props;
|
|
|
|
this.props.dispatch(moveCard(
|
|
|
|
board.id,
|
|
|
|
source.fromLaneId,
|
|
|
|
source.fromPosition,
|
|
|
|
dest.toLaneId,
|
|
|
|
dest.toPosition
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
const { board } = this.props;
|
|
|
|
if (!board) {
|
|
|
|
this.requestBoardsUpdate();
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
this.requestBuildKanboard();
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
if (prevProps.board !== this.props.board) this.requestBuildKanboard();
|
|
|
|
}
|
|
|
|
|
|
|
|
requestBoardsUpdate() {
|
|
|
|
this.props.dispatch(fetchBoards());
|
|
|
|
}
|
|
|
|
|
|
|
|
requestBuildKanboard() {
|
|
|
|
const { board } = this.props;
|
|
|
|
if (!board) return;
|
|
|
|
this.props.dispatch(buildKanboard(board));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ConnectedBoardPage = connect(function(state, props) {
|
|
|
|
const boardID = props.match.params.id;
|
|
|
|
return {
|
|
|
|
board: state.boards.byID[boardID],
|
|
|
|
kanboard: state.kanboards.byID[boardID]
|
|
|
|
};
|
|
|
|
})(BoardPage);
|