1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +02:00
planka/client/src/containers/CardModalContainer.js

109 lines
3.9 KiB
JavaScript
Raw Normal View History

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';
2022-08-04 13:31:14 +02:00
import selectors from '../selectors';
import entryActions from '../entry-actions';
2019-08-31 04:07:25 +05:00
import Paths from '../constants/Paths';
import { BoardMembershipRoles } from '../constants/Enums';
2019-08-31 04:07:25 +05:00
import CardModal from '../components/CardModal';
2020-03-25 00:15:47 +05:00
const mapStateToProps = (state) => {
2022-08-04 13:31:14 +02:00
const { projectId } = selectors.selectPath(state);
const allProjectsToLists = selectors.selectProjectsToListsForCurrentUser(state);
const isCurrentUserManager = selectors.selectIsCurrentUserManagerForCurrentProject(state);
const allBoardMemberships = selectors.selectMembershipsForCurrentBoard(state);
const allLabels = selectors.selectLabelsForCurrentBoard(state);
const currentUserMembership = selectors.selectCurrentUserMembershipForCurrentBoard(state);
2019-08-31 04:07:25 +05:00
const {
name,
description,
dueDate,
2019-08-31 04:07:25 +05:00
timer,
isSubscribed,
2022-08-04 13:31:14 +02:00
isActivitiesFetching,
isAllActivitiesFetched,
isActivitiesDetailsVisible,
isActivitiesDetailsFetching,
2019-08-31 04:07:25 +05:00
boardId,
listId,
2022-08-04 13:31:14 +02:00
} = selectors.selectCurrentCard(state);
2019-08-31 04:07:25 +05:00
2022-08-04 13:31:14 +02:00
const users = selectors.selectUsersForCurrentCard(state);
const labels = selectors.selectLabelsForCurrentCard(state);
const tasks = selectors.selectTasksForCurrentCard(state);
const attachments = selectors.selectAttachmentsForCurrentCard(state);
const activities = selectors.selectActivitiesForCurrentCard(state);
2019-08-31 04:07:25 +05:00
return {
name,
description,
dueDate,
2019-08-31 04:07:25 +05:00
timer,
isSubscribed,
2022-08-04 13:31:14 +02:00
isActivitiesFetching,
isAllActivitiesFetched,
isActivitiesDetailsVisible,
isActivitiesDetailsFetching,
2020-05-05 01:30:06 +05:00
listId,
boardId,
projectId,
2019-08-31 04:07:25 +05:00
users,
labels,
tasks,
2020-04-21 05:04:34 +05:00
attachments,
2022-08-04 13:31:14 +02:00
activities,
2020-05-05 01:30:06 +05:00
allProjectsToLists,
allBoardMemberships,
2019-08-31 04:07:25 +05:00
allLabels,
canEdit: !!currentUserMembership && currentUserMembership.role === BoardMembershipRoles.EDITOR,
canEditCommentActivities:
!!currentUserMembership &&
(currentUserMembership.role === BoardMembershipRoles.EDITOR ||
currentUserMembership.canComment),
2022-08-04 13:31:14 +02:00
canEditAllCommentActivities: isCurrentUserManager,
2019-08-31 04:07:25 +05:00
};
};
2020-03-25 00:15:47 +05:00
const mapDispatchToProps = (dispatch) =>
bindActionCreators(
{
2022-08-04 13:31:14 +02:00
onUpdate: entryActions.updateCurrentCard,
onMove: entryActions.moveCurrentCard,
onTransfer: entryActions.transferCurrentCard,
onDelete: entryActions.deleteCurrentCard,
onUserAdd: entryActions.addUserToCurrentCard,
onUserRemove: entryActions.removeUserFromCurrentCard,
onBoardFetch: entryActions.fetchBoard,
onLabelAdd: entryActions.addLabelToCurrentCard,
onLabelRemove: entryActions.removeLabelFromCurrentCard,
onLabelCreate: entryActions.createLabelInCurrentBoard,
onLabelUpdate: entryActions.updateLabel,
onLabelDelete: entryActions.deleteLabel,
onTaskCreate: entryActions.createTaskInCurrentCard,
onTaskUpdate: entryActions.updateTask,
onTaskMove: entryActions.moveTask,
onTaskDelete: entryActions.deleteTask,
onAttachmentCreate: entryActions.createAttachmentInCurrentCard,
onAttachmentUpdate: entryActions.updateAttachment,
onAttachmentDelete: entryActions.deleteAttachment,
onActivitiesFetch: entryActions.fetchActivitiesInCurrentCard,
onActivitiesDetailsToggle: entryActions.toggleActivitiesDetailsInCurrentCard,
onCommentActivityCreate: entryActions.createCommentActivityInCurrentCard,
onCommentActivityUpdate: entryActions.updateCommentActivity,
onCommentActivityDelete: entryActions.deleteCommentActivity,
push,
},
dispatch,
);
2019-08-31 04:07:25 +05:00
const mergeProps = (stateProps, dispatchProps) => ({
2020-05-05 01:30:06 +05:00
...stateProps,
2019-08-31 04:07:25 +05:00
...omit(dispatchProps, 'push'),
onClose: () => dispatchProps.push(Paths.BOARDS.replace(':id', stateProps.boardId)),
});
export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(CardModal);