Project managers, board members, auto-update after reconnection, refactoring
This commit is contained in:
10
client/src/selectors/attachment.js
Normal file
10
client/src/selectors/attachment.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const isAttachmentWithIdExistsSelector = createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Attachment }, id) => Attachment.idExists(id),
|
||||
);
|
||||
2
client/src/selectors/auth.js
Normal file
2
client/src/selectors/auth.js
Normal file
@@ -0,0 +1,2 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const accessTokenSelector = ({ auth: { accessToken } }) => accessToken;
|
||||
20
client/src/selectors/board-membership.js
Normal file
20
client/src/selectors/board-membership.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { createSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
|
||||
export const makeBoardMembershipByIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ BoardMembership }, id) => {
|
||||
const boardMembershipModel = BoardMembership.withId(id);
|
||||
|
||||
if (!boardMembershipModel) {
|
||||
return boardMembershipModel;
|
||||
}
|
||||
|
||||
return boardMembershipModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const boardMembershipByIdSelector = makeBoardMembershipByIdSelector();
|
||||
167
client/src/selectors/board.js
Normal file
167
client/src/selectors/board.js
Normal file
@@ -0,0 +1,167 @@
|
||||
import { createSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
import { pathSelector } from './router';
|
||||
import { currentUserIdSelector } from './user';
|
||||
import { isLocalId } from '../utils/local-id';
|
||||
|
||||
export const makeBoardByIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Board }, id) => {
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const boardByIdSelector = makeBoardByIdSelector();
|
||||
|
||||
export const currentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
({ Board }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const membershipsForCurrentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ Board }, id, currentUserId) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel
|
||||
.getOrderedMembershipsQuerySet()
|
||||
.toModelArray()
|
||||
.map((boardMembershipModel) => ({
|
||||
...boardMembershipModel.ref,
|
||||
isPersisted: !isLocalId(boardMembershipModel.id),
|
||||
user: {
|
||||
...boardMembershipModel.user.ref,
|
||||
isCurrent: boardMembershipModel.user.id === currentUserId,
|
||||
},
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const labelsForCurrentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
({ Board }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel.labels.toRefArray().map((label) => ({
|
||||
...label,
|
||||
isPersisted: !isLocalId(label.id),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const listIdsForCurrentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
({ Board }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel
|
||||
.getOrderedListsQuerySet()
|
||||
.toRefArray()
|
||||
.map((list) => list.id);
|
||||
},
|
||||
);
|
||||
|
||||
export const filterUsersForCurrentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
({ Board }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel.filterUsers.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const filterLabelsForCurrentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
({ Board }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel.filterLabels.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const isCurrentUserMemberForCurrentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ Board }, id, currentUserId) => {
|
||||
if (!id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return boardModel.hasMemberUser(currentUserId);
|
||||
},
|
||||
);
|
||||
@@ -1,29 +0,0 @@
|
||||
import { createSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
import { pathSelector } from './path';
|
||||
|
||||
export const isAnyFilterActiveForCurrentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
({ Board }, id) => {
|
||||
if (!id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return boardModel.filterUsers.exists() || boardModel.filterLabels.exists();
|
||||
},
|
||||
);
|
||||
|
||||
export const isAttachmentWithIdExistsSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Attachment }, id) => Attachment.idExists(id),
|
||||
);
|
||||
@@ -1,166 +0,0 @@
|
||||
import { createSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
import { isLocalId } from '../utils/local-id';
|
||||
|
||||
export const makeBoardByIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Board }, id) => {
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const makeListByIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ List }, id) => {
|
||||
const listModel = List.withId(id);
|
||||
|
||||
if (!listModel) {
|
||||
return listModel;
|
||||
}
|
||||
|
||||
return {
|
||||
...listModel.ref,
|
||||
isPersisted: !isLocalId(id),
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const makeCardIdsByListIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ List }, id) => {
|
||||
const listModel = List.withId(id);
|
||||
|
||||
if (!listModel) {
|
||||
return listModel;
|
||||
}
|
||||
|
||||
return listModel.getOrderedFilteredCardsModelArray().map((cardModel) => cardModel.id);
|
||||
},
|
||||
);
|
||||
|
||||
export const makeCardByIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return {
|
||||
...cardModel.ref,
|
||||
coverUrl: cardModel.coverAttachment && cardModel.coverAttachment.coverUrl,
|
||||
isPersisted: !isLocalId(id),
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const makeUsersByCardIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.users.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const makeLabelsByCardIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.labels.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const makeTasksByCardIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.tasks.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const makeLastActionIdByCardIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
const lastActionModel = cardModel.getOrderedInCardActionsQuerySet().last();
|
||||
|
||||
return lastActionModel && lastActionModel.id;
|
||||
},
|
||||
);
|
||||
|
||||
export const makeNotificationsTotalByCardIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.getUnreadNotificationsQuerySet().count();
|
||||
},
|
||||
);
|
||||
|
||||
export const boardByIdSelector = makeBoardByIdSelector();
|
||||
|
||||
export const listByIdSelector = makeListByIdSelector();
|
||||
|
||||
export const cardIdsByListIdSelector = makeCardIdsByListIdSelector();
|
||||
|
||||
export const cardByIdSelector = makeCardByIdSelector();
|
||||
|
||||
export const usersByCardIdSelector = makeUsersByCardIdSelector();
|
||||
|
||||
export const labelsByCardIdSelector = makeLabelsByCardIdSelector();
|
||||
|
||||
export const tasksByCardIdSelector = makeTasksByCardIdSelector();
|
||||
|
||||
export const lastActionIdByCardIdSelector = makeLastActionIdByCardIdSelector();
|
||||
|
||||
export const notificationsTotalByCardIdSelector = makeNotificationsTotalByCardIdSelector();
|
||||
284
client/src/selectors/card.js
Normal file
284
client/src/selectors/card.js
Normal file
@@ -0,0 +1,284 @@
|
||||
import { createSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
import { pathSelector } from './router';
|
||||
import { currentUserIdSelector } from './user';
|
||||
import { isLocalId } from '../utils/local-id';
|
||||
|
||||
export const makeCardByIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return {
|
||||
...cardModel.ref,
|
||||
coverUrl: cardModel.coverAttachment && cardModel.coverAttachment.coverUrl,
|
||||
isPersisted: !isLocalId(id),
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const cardByIdSelector = makeCardByIdSelector();
|
||||
|
||||
export const makeUsersByCardIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.users.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const usersByCardIdSelector = makeUsersByCardIdSelector();
|
||||
|
||||
export const makeLabelsByCardIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.labels.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const labelsByCardIdSelector = makeLabelsByCardIdSelector();
|
||||
|
||||
export const makeTasksByCardIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.tasks.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const tasksByCardIdSelector = makeTasksByCardIdSelector();
|
||||
|
||||
export const makeLastActionIdByCardIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
const lastActionModel = cardModel.getOrderedInCardActionsQuerySet().last();
|
||||
|
||||
return lastActionModel && lastActionModel.id;
|
||||
},
|
||||
);
|
||||
|
||||
export const lastActionIdByCardIdSelector = makeLastActionIdByCardIdSelector();
|
||||
|
||||
export const makeNotificationsByCardIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.getUnreadNotificationsQuerySet().toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const notificationsByCardIdSelector = makeNotificationsByCardIdSelector();
|
||||
|
||||
export const makeNotificationsTotalByCardIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ Card }, id) => {
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.getUnreadNotificationsQuerySet().count();
|
||||
},
|
||||
);
|
||||
|
||||
export const notificationsTotalByCardIdSelector = makeNotificationsTotalByCardIdSelector();
|
||||
|
||||
export const currentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
({ Card }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const usersForCurrentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
({ Card }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.users.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const labelsForCurrentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
({ Card }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.labels.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const tasksForCurrentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
({ Card }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel
|
||||
.getOrderedTasksQuerySet()
|
||||
.toRefArray()
|
||||
.map((task) => ({
|
||||
...task,
|
||||
isPersisted: !isLocalId(task.id),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const attachmentsForCurrentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
({ Card }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel
|
||||
.getOrderedAttachmentsQuerySet()
|
||||
.toRefArray()
|
||||
.map((attachment) => ({
|
||||
...attachment,
|
||||
isCover: attachment.id === cardModel.coverAttachmentId,
|
||||
isPersisted: !isLocalId(attachment.id),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const actionsForCurrentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ Card }, id, currentUserId) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel
|
||||
.getOrderedInCardActionsQuerySet()
|
||||
.toModelArray()
|
||||
.map((actionModel) => ({
|
||||
...actionModel.ref,
|
||||
isPersisted: !isLocalId(actionModel.id),
|
||||
user: {
|
||||
...actionModel.user.ref,
|
||||
isCurrent: actionModel.user.id === currentUserId,
|
||||
},
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const notificationIdsForCurrentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
({ Card }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel
|
||||
.getUnreadNotificationsQuerySet()
|
||||
.toRefArray()
|
||||
.map((notification) => notification.id);
|
||||
},
|
||||
);
|
||||
@@ -1,3 +0,0 @@
|
||||
export const accessTokenSelector = ({ auth: { accessToken } }) => accessToken;
|
||||
|
||||
export const isCoreInitializingSelector = ({ core: { isInitializing } }) => isInitializing;
|
||||
@@ -4,6 +4,8 @@ import isUndefined from 'lodash/isUndefined';
|
||||
import orm from '../orm';
|
||||
import Config from '../constants/Config';
|
||||
|
||||
export const isCoreInitializingSelector = ({ core: { isInitializing } }) => isInitializing;
|
||||
|
||||
const nextPosition = (items, index, excludedId) => {
|
||||
const filteredItems = isUndefined(excludedId)
|
||||
? items
|
||||
@@ -1,442 +0,0 @@
|
||||
import { createSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
import { pathSelector } from './path';
|
||||
import { isLocalId } from '../utils/local-id';
|
||||
|
||||
export const currentModalSelector = ({ core: { currentModal } }) => currentModal;
|
||||
|
||||
export const currentUserIdSelector = ({ auth: { userId } }) => userId;
|
||||
|
||||
export const currentUserSelector = createSelector(
|
||||
orm,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ User }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const userModel = User.withId(id);
|
||||
|
||||
if (!userModel) {
|
||||
return userModel;
|
||||
}
|
||||
|
||||
return userModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const projectsForCurrentUserSelector = createSelector(
|
||||
orm,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ User }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const userModel = User.withId(id);
|
||||
|
||||
if (!userModel) {
|
||||
return userModel;
|
||||
}
|
||||
|
||||
return userModel
|
||||
.getOrderedProjectMembershipsQuerySet()
|
||||
.toModelArray()
|
||||
.map(({ project: projectModel }) => {
|
||||
let notificationsTotal = 0;
|
||||
projectModel.boards.toModelArray().forEach((boardModel) => {
|
||||
boardModel.cards.toModelArray().forEach((cardModel) => {
|
||||
notificationsTotal += cardModel.getUnreadNotificationsQuerySet().count();
|
||||
});
|
||||
});
|
||||
|
||||
const firstBoard = projectModel.boards.first();
|
||||
const firstBoardId = firstBoard && firstBoard.id;
|
||||
|
||||
return {
|
||||
...projectModel.ref,
|
||||
notificationsTotal,
|
||||
firstBoardId,
|
||||
};
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
export const projectsToListsForCurrentUserSelector = createSelector(
|
||||
orm,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ User }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const userModel = User.withId(id);
|
||||
|
||||
if (!userModel) {
|
||||
return userModel;
|
||||
}
|
||||
|
||||
return userModel
|
||||
.getOrderedProjectMembershipsQuerySet()
|
||||
.toModelArray()
|
||||
.map(({ project: projectModel }) => ({
|
||||
...projectModel.ref,
|
||||
boards: projectModel
|
||||
.getOrderedBoardsQuerySet()
|
||||
.toModelArray()
|
||||
.map((boardModel) => ({
|
||||
...boardModel.ref,
|
||||
lists: boardModel.getOrderedListsQuerySet().toRefArray(),
|
||||
})),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const notificationsForCurrentUserSelector = createSelector(
|
||||
orm,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ User }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const userModel = User.withId(id);
|
||||
|
||||
if (!userModel) {
|
||||
return userModel;
|
||||
}
|
||||
|
||||
return userModel
|
||||
.getOrderedUnreadNotificationsQuerySet()
|
||||
.toModelArray()
|
||||
.map((notificationModel) => ({
|
||||
...notificationModel.ref,
|
||||
action: notificationModel.action && {
|
||||
...notificationModel.action.ref,
|
||||
user: notificationModel.action.user.ref,
|
||||
},
|
||||
card: notificationModel.card && notificationModel.card.ref,
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const currentProjectSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).projectId,
|
||||
({ Project }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const projectModel = Project.withId(id);
|
||||
|
||||
if (!projectModel) {
|
||||
return projectModel;
|
||||
}
|
||||
|
||||
return projectModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const membershipsForCurrentProjectSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).projectId,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ Project }, id, currentUserId) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const projectModel = Project.withId(id);
|
||||
|
||||
if (!projectModel) {
|
||||
return projectModel;
|
||||
}
|
||||
|
||||
return projectModel
|
||||
.getOrderedMembershipsQuerySet()
|
||||
.toModelArray()
|
||||
.map((projectMembershipModel) => ({
|
||||
...projectMembershipModel.ref,
|
||||
isPersisted: !isLocalId(projectMembershipModel.id),
|
||||
user: {
|
||||
...projectMembershipModel.user.ref,
|
||||
isCurrent: projectMembershipModel.user.id === currentUserId,
|
||||
},
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const boardsForCurrentProjectSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).projectId,
|
||||
({ Project }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const projectModel = Project.withId(id);
|
||||
|
||||
if (!projectModel) {
|
||||
return projectModel;
|
||||
}
|
||||
|
||||
return projectModel
|
||||
.getOrderedBoardsQuerySet()
|
||||
.toRefArray()
|
||||
.map((board) => ({
|
||||
...board,
|
||||
isPersisted: !isLocalId(board.id),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const currentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
({ Board }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const labelsForCurrentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
({ Board }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel.labels.toRefArray().map((label) => ({
|
||||
...label,
|
||||
isPersisted: !isLocalId(label.id),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const listIdsForCurrentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
({ Board }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel
|
||||
.getOrderedListsQuerySet()
|
||||
.toRefArray()
|
||||
.map((list) => list.id);
|
||||
},
|
||||
);
|
||||
|
||||
export const filterUsersForCurrentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
({ Board }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel.filterUsers.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const filterLabelsForCurrentBoardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).boardId,
|
||||
({ Board }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
return boardModel.filterLabels.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const currentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
({ Card }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const usersForCurrentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
({ Card }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.users.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const labelsForCurrentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
({ Card }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel.labels.toRefArray();
|
||||
},
|
||||
);
|
||||
|
||||
export const tasksForCurrentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
({ Card }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel
|
||||
.getOrderedTasksQuerySet()
|
||||
.toRefArray()
|
||||
.map((task) => ({
|
||||
...task,
|
||||
isPersisted: !isLocalId(task.id),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const attachmentsForCurrentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
({ Card }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel
|
||||
.getOrderedAttachmentsQuerySet()
|
||||
.toRefArray()
|
||||
.map((attachment) => ({
|
||||
...attachment,
|
||||
isCover: attachment.id === cardModel.coverAttachmentId,
|
||||
isPersisted: !isLocalId(attachment.id),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const actionsForCurrentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ Card }, id, currentUserId) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel
|
||||
.getOrderedInCardActionsQuerySet()
|
||||
.toModelArray()
|
||||
.map((actionModel) => ({
|
||||
...actionModel.ref,
|
||||
isPersisted: !isLocalId(actionModel.id),
|
||||
user: {
|
||||
...actionModel.user.ref,
|
||||
isCurrent: actionModel.user.id === currentUserId,
|
||||
},
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const notificationIdsForCurrentCardSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).cardId,
|
||||
({ Card }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const cardModel = Card.withId(id);
|
||||
|
||||
if (!cardModel) {
|
||||
return cardModel;
|
||||
}
|
||||
|
||||
return cardModel
|
||||
.getUnreadNotificationsQuerySet()
|
||||
.toRefArray()
|
||||
.map((notification) => notification.id);
|
||||
},
|
||||
);
|
||||
@@ -1,7 +1,13 @@
|
||||
export * from './common';
|
||||
export * from './all';
|
||||
export * from './path';
|
||||
export * from './current';
|
||||
export * from './by-id';
|
||||
export * from './boolean';
|
||||
export * from './next-position';
|
||||
export * from './router';
|
||||
export * from './auth';
|
||||
export * from './core';
|
||||
export * from './modal';
|
||||
export * from './user';
|
||||
export * from './users';
|
||||
export * from './project';
|
||||
export * from './project-manager';
|
||||
export * from './board';
|
||||
export * from './board-membership';
|
||||
export * from './list';
|
||||
export * from './card';
|
||||
export * from './attachment';
|
||||
|
||||
41
client/src/selectors/list.js
Normal file
41
client/src/selectors/list.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import { createSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
import { isLocalId } from '../utils/local-id';
|
||||
|
||||
export const makeListByIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ List }, id) => {
|
||||
const listModel = List.withId(id);
|
||||
|
||||
if (!listModel) {
|
||||
return listModel;
|
||||
}
|
||||
|
||||
return {
|
||||
...listModel.ref,
|
||||
isPersisted: !isLocalId(id),
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const listByIdSelector = makeListByIdSelector();
|
||||
|
||||
export const makeCardIdsByListIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ List }, id) => {
|
||||
const listModel = List.withId(id);
|
||||
|
||||
if (!listModel) {
|
||||
return listModel;
|
||||
}
|
||||
|
||||
return listModel.getOrderedFilteredCardsModelArray().map((cardModel) => cardModel.id);
|
||||
},
|
||||
);
|
||||
|
||||
export const cardIdsByListIdSelector = makeCardIdsByListIdSelector();
|
||||
2
client/src/selectors/modal.js
Normal file
2
client/src/selectors/modal.js
Normal file
@@ -0,0 +1,2 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const currentModalSelector = ({ core: { currentModal } }) => currentModal;
|
||||
20
client/src/selectors/project-manager.js
Normal file
20
client/src/selectors/project-manager.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { createSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
|
||||
export const makeProjectManagerByIdSelector = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ ProjectManager }, id) => {
|
||||
const projectManagerModel = ProjectManager.withId(id);
|
||||
|
||||
if (!projectManagerModel) {
|
||||
return projectManagerModel;
|
||||
}
|
||||
|
||||
return projectManagerModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const projectManagerByIdSelector = makeProjectManagerByIdSelector();
|
||||
94
client/src/selectors/project.js
Normal file
94
client/src/selectors/project.js
Normal file
@@ -0,0 +1,94 @@
|
||||
import { createSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
import { pathSelector } from './router';
|
||||
import { currentUserIdSelector } from './user';
|
||||
import { isLocalId } from '../utils/local-id';
|
||||
|
||||
export const currentProjectSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).projectId,
|
||||
({ Project }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const projectModel = Project.withId(id);
|
||||
|
||||
if (!projectModel) {
|
||||
return projectModel;
|
||||
}
|
||||
|
||||
return projectModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const managersForCurrentProjectSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).projectId,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ Project }, id, currentUserId) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const projectModel = Project.withId(id);
|
||||
|
||||
if (!projectModel) {
|
||||
return projectModel;
|
||||
}
|
||||
|
||||
return projectModel
|
||||
.getOrderedManagersQuerySet()
|
||||
.toModelArray()
|
||||
.map((projectManagerModel) => ({
|
||||
...projectManagerModel.ref,
|
||||
isPersisted: !isLocalId(projectManagerModel.id),
|
||||
user: {
|
||||
...projectManagerModel.user.ref,
|
||||
isCurrent: projectManagerModel.user.id === currentUserId,
|
||||
},
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const boardsForCurrentProjectSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).projectId,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ Project }, id, currentUserId) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const projectModel = Project.withId(id);
|
||||
|
||||
if (!projectModel) {
|
||||
return projectModel;
|
||||
}
|
||||
|
||||
return projectModel.getOrderedAvailableBoardsModelArray(currentUserId).map((boardModel) => ({
|
||||
...boardModel.ref,
|
||||
isPersisted: !isLocalId(boardModel.id),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const isCurrentUserManagerForCurrentProjectSelector = createSelector(
|
||||
orm,
|
||||
(state) => pathSelector(state).projectId,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ Project }, id, currentUserId) => {
|
||||
if (!id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const projectModel = Project.withId(id);
|
||||
|
||||
if (!projectModel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return projectModel.hasManagerUser(currentUserId);
|
||||
},
|
||||
);
|
||||
@@ -2,6 +2,7 @@ import { createSelector as createReselectSelector } from 'reselect';
|
||||
import { createSelector as createReduxOrmSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
import { currentUserIdSelector } from './user';
|
||||
import matchPaths from '../utils/match-paths';
|
||||
import Paths from '../constants/Paths';
|
||||
|
||||
@@ -18,14 +19,29 @@ export const pathsMatchSelector = createReselectSelector(pathnameSelector, (path
|
||||
export const pathSelector = createReduxOrmSelector(
|
||||
orm,
|
||||
pathsMatchSelector,
|
||||
({ Project, Board, Card }, pathsMatch) => {
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ Project, Board, Card }, pathsMatch, currentUserId) => {
|
||||
if (pathsMatch) {
|
||||
switch (pathsMatch.path) {
|
||||
case Paths.PROJECTS: {
|
||||
const projectModel = Project.withId(pathsMatch.params.id);
|
||||
|
||||
if (!projectModel) {
|
||||
return {
|
||||
projectId: null,
|
||||
};
|
||||
}
|
||||
|
||||
if (!projectModel.hasManagerUser(currentUserId)) {
|
||||
if (!projectModel.hasMemberUserForAnyBoard(currentUserId)) {
|
||||
return {
|
||||
projectId: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
projectId: projectModel && projectModel.id,
|
||||
projectId: projectModel.id,
|
||||
};
|
||||
}
|
||||
case Paths.BOARDS: {
|
||||
@@ -39,6 +55,15 @@ export const pathSelector = createReduxOrmSelector(
|
||||
};
|
||||
}
|
||||
|
||||
if (!projectModel.hasManagerUser(currentUserId)) {
|
||||
if (!boardModel.hasMemberUser(currentUserId)) {
|
||||
return {
|
||||
boardId: null,
|
||||
projectId: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
boardId: boardModel.id,
|
||||
projectId: projectModel.id,
|
||||
@@ -57,6 +82,16 @@ export const pathSelector = createReduxOrmSelector(
|
||||
};
|
||||
}
|
||||
|
||||
if (!projectModel.hasManagerUser(currentUserId)) {
|
||||
if (!boardModel.hasMemberUser(currentUserId)) {
|
||||
return {
|
||||
cardId: null,
|
||||
boardId: null,
|
||||
projectId: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
cardId: cardModel.id,
|
||||
boardId: boardModel.id,
|
||||
108
client/src/selectors/user.js
Normal file
108
client/src/selectors/user.js
Normal file
@@ -0,0 +1,108 @@
|
||||
import { createSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
|
||||
export const currentUserIdSelector = ({ auth: { userId } }) => userId;
|
||||
|
||||
export const currentUserSelector = createSelector(
|
||||
orm,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ User }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const userModel = User.withId(id);
|
||||
|
||||
if (!userModel) {
|
||||
return userModel;
|
||||
}
|
||||
|
||||
return userModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const projectsForCurrentUserSelector = createSelector(
|
||||
orm,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ User }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const userModel = User.withId(id);
|
||||
|
||||
if (!userModel) {
|
||||
return userModel;
|
||||
}
|
||||
|
||||
return userModel.getOrderedAvailableProjectsModelArray().map((projectModel) => {
|
||||
const boardsModels = projectModel.getOrderedAvailableBoardsModelArray(userModel.id);
|
||||
|
||||
let notificationsTotal = 0;
|
||||
boardsModels.forEach((boardModel) => {
|
||||
boardModel.cards.toModelArray().forEach((cardModel) => {
|
||||
notificationsTotal += cardModel.getUnreadNotificationsQuerySet().count();
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
...projectModel.ref,
|
||||
notificationsTotal,
|
||||
firstBoardId: boardsModels[0] && boardsModels[0].id,
|
||||
};
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
export const projectsToListsForCurrentUserSelector = createSelector(
|
||||
orm,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ User }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const userModel = User.withId(id);
|
||||
|
||||
if (!userModel) {
|
||||
return userModel;
|
||||
}
|
||||
|
||||
return userModel.getOrderedAvailableProjectsModelArray().map((projectModel) => ({
|
||||
...projectModel.ref,
|
||||
boards: projectModel.getOrderedMemberBoardsModelArray(id).map((boardModel) => ({
|
||||
...boardModel.ref,
|
||||
lists: boardModel.getOrderedListsQuerySet().toRefArray(),
|
||||
})),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
export const notificationsForCurrentUserSelector = createSelector(
|
||||
orm,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ User }, id) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const userModel = User.withId(id);
|
||||
|
||||
if (!userModel) {
|
||||
return userModel;
|
||||
}
|
||||
|
||||
return userModel
|
||||
.getOrderedUnreadNotificationsQuerySet()
|
||||
.toModelArray()
|
||||
.map((notificationModel) => ({
|
||||
...notificationModel.ref,
|
||||
action: notificationModel.action && {
|
||||
...notificationModel.action.ref,
|
||||
user: notificationModel.action.user.ref,
|
||||
},
|
||||
card: notificationModel.card && notificationModel.card.ref,
|
||||
}));
|
||||
},
|
||||
);
|
||||
10
client/src/selectors/all.js → client/src/selectors/users.js
Executable file → Normal file
10
client/src/selectors/all.js → client/src/selectors/users.js
Executable file → Normal file
@@ -1,19 +1,19 @@
|
||||
import { createSelector } from 'redux-orm';
|
||||
|
||||
import orm from '../orm';
|
||||
import { currentUserIdSelector } from './current';
|
||||
import { currentUserIdSelector } from './user';
|
||||
|
||||
export const allUsersSelector = createSelector(orm, ({ User }) =>
|
||||
export const usersSelector = createSelector(orm, ({ User }) =>
|
||||
User.getOrderedUndeletedQuerySet().toRefArray(),
|
||||
);
|
||||
|
||||
export const allUsersExceptCurrentSelector = createSelector(
|
||||
export const usersExceptCurrentSelector = createSelector(
|
||||
orm,
|
||||
(state) => currentUserIdSelector(state),
|
||||
({ User }, currentUserId) =>
|
||||
({ User }, id) =>
|
||||
User.getOrderedUndeletedQuerySet()
|
||||
.exclude({
|
||||
id: currentUserId,
|
||||
id,
|
||||
})
|
||||
.toRefArray(),
|
||||
);
|
||||
Reference in New Issue
Block a user