mirror of
https://github.com/plankanban/planka.git
synced 2025-12-26 09:15:01 +03:00
ref: Remove board types, refactoring
This commit is contained in:
@@ -15,13 +15,16 @@ const mapStateToProps = (state) => {
|
||||
const filterLabels = selectors.selectFilterLabelsForCurrentBoard(state);
|
||||
const currentUserMembership = selectors.selectCurrentUserMembershipForCurrentBoard(state);
|
||||
|
||||
const isCurrentUserEditor =
|
||||
!!currentUserMembership && currentUserMembership.role === BoardMembershipRoles.EDITOR;
|
||||
|
||||
return {
|
||||
memberships,
|
||||
labels,
|
||||
filterUsers,
|
||||
filterLabels,
|
||||
allUsers,
|
||||
canEdit: !!currentUserMembership && currentUserMembership.role === BoardMembershipRoles.EDITOR,
|
||||
canEdit: isCurrentUserEditor,
|
||||
canEditMemberships: isCurrentUserManager,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,17 +4,20 @@ import { connect } from 'react-redux';
|
||||
import selectors from '../selectors';
|
||||
import entryActions from '../entry-actions';
|
||||
import { BoardMembershipRoles } from '../constants/Enums';
|
||||
import BoardKanban from '../components/BoardKanban';
|
||||
import Board from '../components/Board';
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const { cardId } = selectors.selectPath(state);
|
||||
const currentUserMembership = selectors.selectCurrentUserMembershipForCurrentBoard(state);
|
||||
const listIds = selectors.selectListIdsForCurrentBoard(state);
|
||||
|
||||
const isCurrentUserEditor =
|
||||
!!currentUserMembership && currentUserMembership.role === BoardMembershipRoles.EDITOR;
|
||||
|
||||
return {
|
||||
listIds,
|
||||
isCardModalOpened: !!cardId,
|
||||
canEdit: !!currentUserMembership && currentUserMembership.role === BoardMembershipRoles.EDITOR,
|
||||
canEdit: isCurrentUserEditor,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -28,4 +31,4 @@ const mapDispatchToProps = (dispatch) =>
|
||||
dispatch,
|
||||
);
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(BoardKanban);
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Board);
|
||||
@@ -1,15 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import selectors from '../selectors';
|
||||
import BoardWrapper from '../components/BoardWrapper';
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const { type, isFetching } = selectors.selectCurrentBoard(state);
|
||||
|
||||
return {
|
||||
type,
|
||||
isFetching,
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(BoardWrapper);
|
||||
@@ -30,6 +30,9 @@ const makeMapStateToProps = () => {
|
||||
const tasks = selectTasksByCardId(state, id);
|
||||
const notificationsTotal = selectNotificationsTotalByCardId(state, id);
|
||||
|
||||
const isCurrentUserEditor =
|
||||
!!currentUserMembership && currentUserMembership.role === BoardMembershipRoles.EDITOR;
|
||||
|
||||
return {
|
||||
id,
|
||||
index,
|
||||
@@ -48,8 +51,7 @@ const makeMapStateToProps = () => {
|
||||
allProjectsToLists,
|
||||
allBoardMemberships,
|
||||
allLabels,
|
||||
canEdit:
|
||||
!!currentUserMembership && currentUserMembership.role === BoardMembershipRoles.EDITOR,
|
||||
canEdit: isCurrentUserEditor,
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -37,6 +37,14 @@ const mapStateToProps = (state) => {
|
||||
const attachments = selectors.selectAttachmentsForCurrentCard(state);
|
||||
const activities = selectors.selectActivitiesForCurrentCard(state);
|
||||
|
||||
let isCurrentUserEditor = false;
|
||||
let isCurrentUserEditorOrCanComment = false;
|
||||
|
||||
if (currentUserMembership) {
|
||||
isCurrentUserEditor = currentUserMembership.role === BoardMembershipRoles.EDITOR;
|
||||
isCurrentUserEditorOrCanComment = isCurrentUserEditor || currentUserMembership.canComment;
|
||||
}
|
||||
|
||||
return {
|
||||
name,
|
||||
description,
|
||||
@@ -58,11 +66,8 @@ const mapStateToProps = (state) => {
|
||||
allProjectsToLists,
|
||||
allBoardMemberships,
|
||||
allLabels,
|
||||
canEdit: !!currentUserMembership && currentUserMembership.role === BoardMembershipRoles.EDITOR,
|
||||
canEditCommentActivities:
|
||||
!!currentUserMembership &&
|
||||
(currentUserMembership.role === BoardMembershipRoles.EDITOR ||
|
||||
currentUserMembership.canComment),
|
||||
canEdit: isCurrentUserEditor,
|
||||
canEditCommentActivities: isCurrentUserEditorOrCanComment,
|
||||
canEditAllCommentActivities: isCurrentUserManager,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,12 +4,16 @@ import selectors from '../selectors';
|
||||
import Core from '../components/Core';
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const isCoreInitializing = selectors.selectIsCoreInitializing(state);
|
||||
const isSocketDisconnected = selectors.selectIsSocketDisconnected(state);
|
||||
const currentModal = selectors.selectCurrentModal(state);
|
||||
const currentProject = selectors.selectCurrentProject(state);
|
||||
|
||||
return {
|
||||
isSocketDisconnected,
|
||||
currentModal,
|
||||
currentProject,
|
||||
isInitializing: isCoreInitializing,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import selectors from '../selectors';
|
||||
import CoreWrapper from '../components/CoreWrapper';
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const isCoreInitializing = selectors.selectIsCoreInitializing(state);
|
||||
|
||||
return {
|
||||
isInitializing: isCoreInitializing,
|
||||
isSocketDisconnected: state.socket.isDisconnected,
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(CoreWrapper);
|
||||
@@ -15,14 +15,16 @@ const makeMapStateToProps = () => {
|
||||
const cardIds = selectCardIdsByListId(state, id);
|
||||
const currentUserMembership = selectors.selectCurrentUserMembershipForCurrentBoard(state);
|
||||
|
||||
const isCurrentUserEditor =
|
||||
!!currentUserMembership && currentUserMembership.role === BoardMembershipRoles.EDITOR;
|
||||
|
||||
return {
|
||||
id,
|
||||
index,
|
||||
name,
|
||||
isPersisted,
|
||||
cardIds,
|
||||
canEdit:
|
||||
!!currentUserMembership && currentUserMembership.role === BoardMembershipRoles.EDITOR,
|
||||
canEdit: isCurrentUserEditor,
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,12 +4,13 @@ import selectors from '../selectors';
|
||||
import Static from '../components/Static';
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const { cardId, boardId, projectId } = selectors.selectPath(state);
|
||||
const { cardId, projectId } = selectors.selectPath(state);
|
||||
const currentBoard = selectors.selectCurrentBoard(state);
|
||||
|
||||
return {
|
||||
cardId,
|
||||
boardId,
|
||||
projectId,
|
||||
cardId,
|
||||
board: currentBoard,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user