2019-08-31 04:07:25 +05:00
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { push } from 'connected-react-router';
|
|
|
|
import omit from 'lodash/omit';
|
|
|
|
|
|
|
|
import {
|
|
|
|
actionsForCurrentCardSelector,
|
|
|
|
currentCardSelector,
|
|
|
|
currentUserSelector,
|
|
|
|
labelsForCurrentBoardSelector,
|
|
|
|
labelsForCurrentCardSelector,
|
|
|
|
membershipsForCurrentProjectSelector,
|
|
|
|
tasksForCurrentCardSelector,
|
|
|
|
usersForCurrentCardSelector,
|
|
|
|
} from '../selectors';
|
|
|
|
import {
|
|
|
|
addLabelToCurrentCard,
|
|
|
|
addUserToCurrentCard,
|
|
|
|
createCommentActionInCurrentCard,
|
|
|
|
createLabelInCurrentBoard,
|
|
|
|
createTaskInCurrentCard,
|
|
|
|
deleteCommentAction,
|
|
|
|
deleteCurrentCard,
|
|
|
|
deleteLabel,
|
|
|
|
deleteTask,
|
|
|
|
fetchActionsInCurrentCard,
|
|
|
|
removeLabelFromCurrentCard,
|
|
|
|
removeUserFromCurrentCard,
|
|
|
|
updateCommentAction,
|
|
|
|
updateCurrentCard,
|
|
|
|
updateLabel,
|
|
|
|
updateTask,
|
|
|
|
} from '../actions/entry';
|
|
|
|
import Paths from '../constants/Paths';
|
|
|
|
import CardModal from '../components/CardModal';
|
|
|
|
|
2020-03-25 00:15:47 +05:00
|
|
|
const mapStateToProps = (state) => {
|
2019-08-31 04:07:25 +05:00
|
|
|
const { isAdmin } = currentUserSelector(state);
|
|
|
|
const allProjectMemberships = membershipsForCurrentProjectSelector(state);
|
|
|
|
const allLabels = labelsForCurrentBoardSelector(state);
|
|
|
|
|
|
|
|
const {
|
|
|
|
name,
|
|
|
|
description,
|
2019-10-05 06:12:36 +05:00
|
|
|
dueDate,
|
2019-08-31 04:07:25 +05:00
|
|
|
timer,
|
|
|
|
isSubscribed,
|
|
|
|
isActionsFetching,
|
|
|
|
isAllActionsFetched,
|
|
|
|
boardId,
|
|
|
|
} = currentCardSelector(state);
|
|
|
|
|
|
|
|
const users = usersForCurrentCardSelector(state);
|
|
|
|
const labels = labelsForCurrentCardSelector(state);
|
|
|
|
const tasks = tasksForCurrentCardSelector(state);
|
|
|
|
const actions = actionsForCurrentCardSelector(state);
|
|
|
|
|
|
|
|
return {
|
|
|
|
name,
|
|
|
|
description,
|
2019-10-05 06:12:36 +05:00
|
|
|
dueDate,
|
2019-08-31 04:07:25 +05:00
|
|
|
timer,
|
|
|
|
isSubscribed,
|
|
|
|
isActionsFetching,
|
|
|
|
isAllActionsFetched,
|
|
|
|
users,
|
|
|
|
labels,
|
|
|
|
tasks,
|
|
|
|
actions,
|
|
|
|
allProjectMemberships,
|
|
|
|
allLabels,
|
|
|
|
boardId,
|
|
|
|
isEditable: isAdmin,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-03-25 00:15:47 +05:00
|
|
|
const mapDispatchToProps = (dispatch) =>
|
2020-02-03 18:42:31 +05:00
|
|
|
bindActionCreators(
|
|
|
|
{
|
|
|
|
onUpdate: updateCurrentCard,
|
|
|
|
onDelete: deleteCurrentCard,
|
|
|
|
onUserAdd: addUserToCurrentCard,
|
|
|
|
onUserRemove: removeUserFromCurrentCard,
|
|
|
|
onLabelAdd: addLabelToCurrentCard,
|
|
|
|
onLabelRemove: removeLabelFromCurrentCard,
|
|
|
|
onLabelCreate: createLabelInCurrentBoard,
|
|
|
|
onLabelUpdate: updateLabel,
|
|
|
|
onLabelDelete: deleteLabel,
|
|
|
|
onTaskCreate: createTaskInCurrentCard,
|
|
|
|
onTaskUpdate: updateTask,
|
|
|
|
onTaskDelete: deleteTask,
|
|
|
|
onActionsFetch: fetchActionsInCurrentCard,
|
|
|
|
onCommentActionCreate: createCommentActionInCurrentCard,
|
|
|
|
onCommentActionUpdate: updateCommentAction,
|
|
|
|
onCommentActionDelete: deleteCommentAction,
|
|
|
|
push,
|
|
|
|
},
|
|
|
|
dispatch,
|
|
|
|
);
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
const mergeProps = (stateProps, dispatchProps) => ({
|
|
|
|
...omit(stateProps, 'boardId'),
|
|
|
|
...omit(dispatchProps, 'push'),
|
|
|
|
onClose: () => dispatchProps.push(Paths.BOARDS.replace(':id', stateProps.boardId)),
|
|
|
|
});
|
|
|
|
|
2020-02-03 18:42:31 +05:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(CardModal);
|