1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00
planka/client/src/containers/ListContainer.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-08-31 04:07:25 +05:00
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
2022-08-04 13:31:14 +02:00
import selectors from '../selectors';
import entryActions from '../entry-actions';
import { BoardMembershipRoles } from '../constants/Enums';
2019-08-31 04:07:25 +05:00
import List from '../components/List';
const makeMapStateToProps = () => {
2022-08-04 13:31:14 +02:00
const selectListById = selectors.makeSelectListById();
const selectCardIdsByListId = selectors.makeSelectCardIdsByListId();
2019-08-31 04:07:25 +05:00
return (state, { id, index }) => {
2022-08-04 13:31:14 +02:00
const { name, isPersisted } = selectListById(state, id);
const cardIds = selectCardIdsByListId(state, id);
const currentUserMembership = selectors.selectCurrentUserMembershipForCurrentBoard(state);
2019-08-31 04:07:25 +05:00
2022-12-26 21:10:50 +01:00
const isCurrentUserEditor =
!!currentUserMembership && currentUserMembership.role === BoardMembershipRoles.EDITOR;
2019-08-31 04:07:25 +05:00
return {
id,
index,
name,
isPersisted,
cardIds,
2022-12-26 21:10:50 +01:00
canEdit: isCurrentUserEditor,
2019-08-31 04:07:25 +05:00
};
};
};
const mapDispatchToProps = (dispatch, { id }) =>
bindActionCreators(
{
2022-08-04 13:31:14 +02:00
onUpdate: (data) => entryActions.updateList(id, data),
onDelete: () => entryActions.deleteList(id),
onCardCreate: (data, autoOpen) => entryActions.createCard(id, data, autoOpen),
},
dispatch,
);
2019-08-31 04:07:25 +05:00
export default connect(makeMapStateToProps, mapDispatchToProps)(List);