mirror of
https://github.com/plankanban/planka.git
synced 2025-08-08 15:05:30 +02:00
ref: Remove board types, refactoring
This commit is contained in:
parent
2b131f76c1
commit
6ffa817b53
182 changed files with 1573 additions and 1239 deletions
|
@ -35,18 +35,8 @@ export const transformCardData = (data) => ({
|
|||
|
||||
/* Actions */
|
||||
|
||||
const getCards = (boardId, data, headers) =>
|
||||
socket.get(`/board/${boardId}/cards`, data, headers).then((body) => ({
|
||||
...body,
|
||||
items: body.items.map(transformCard),
|
||||
included: {
|
||||
...body.included,
|
||||
attachments: body.included.attachments.map(transformAttachment),
|
||||
},
|
||||
}));
|
||||
|
||||
const createCard = (boardId, data, headers) =>
|
||||
socket.post(`/boards/${boardId}/cards`, transformCardData(data), headers).then((body) => ({
|
||||
const createCard = (listId, data, headers) =>
|
||||
socket.post(`/lists/${listId}/cards`, transformCardData(data), headers).then((body) => ({
|
||||
...body,
|
||||
item: transformCard(body.item),
|
||||
}));
|
||||
|
@ -55,6 +45,10 @@ const getCard = (id, headers) =>
|
|||
socket.get(`/cards/${id}`, undefined, headers).then((body) => ({
|
||||
...body,
|
||||
item: transformCard(body.item),
|
||||
included: {
|
||||
...body.included,
|
||||
attachments: body.included.attachments.map(transformAttachment),
|
||||
},
|
||||
}));
|
||||
|
||||
const updateCard = (id, data, headers) =>
|
||||
|
@ -83,7 +77,6 @@ const makeHandleCardUpdate = makeHandleCardCreate;
|
|||
const makeHandleCardDelete = makeHandleCardCreate;
|
||||
|
||||
export default {
|
||||
getCards,
|
||||
createCard,
|
||||
getCard,
|
||||
updateCard,
|
||||
|
|
|
@ -10,11 +10,11 @@ import CardModalContainer from '../../containers/CardModalContainer';
|
|||
import ListAdd from './ListAdd';
|
||||
import { ReactComponent as PlusMathIcon } from '../../assets/images/plus-math-icon.svg';
|
||||
|
||||
import styles from './BoardKanban.module.scss';
|
||||
import styles from './Board.module.scss';
|
||||
|
||||
const parseDndId = (dndId) => dndId.split(':')[1];
|
||||
|
||||
const BoardKanban = React.memo(
|
||||
const Board = React.memo(
|
||||
({ listIds, isCardModalOpened, canEdit, onListCreate, onListMove, onCardMove }) => {
|
||||
const [t] = useTranslation();
|
||||
const [isListAddOpened, setIsListAddOpened] = useState(false);
|
||||
|
@ -166,7 +166,7 @@ const BoardKanban = React.memo(
|
|||
},
|
||||
);
|
||||
|
||||
BoardKanban.propTypes = {
|
||||
Board.propTypes = {
|
||||
listIds: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||
isCardModalOpened: PropTypes.bool.isRequired,
|
||||
canEdit: PropTypes.bool.isRequired,
|
||||
|
@ -175,4 +175,4 @@ BoardKanban.propTypes = {
|
|||
onCardMove: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default BoardKanban;
|
||||
export default Board;
|
|
@ -72,7 +72,7 @@ const ListAdd = React.memo(({ onCreate, onClose }) => {
|
|||
<Button
|
||||
positive
|
||||
content={t('action.addList')}
|
||||
className={styles.submitButton}
|
||||
className={styles.button}
|
||||
onMouseOver={handleControlMouseOver}
|
||||
onMouseOut={handleControlMouseOut}
|
||||
/>
|
|
@ -1,4 +1,9 @@
|
|||
:global(#app) {
|
||||
.button {
|
||||
min-height: 30px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.controls {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
@ -18,11 +23,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.submitButton {
|
||||
min-height: 30px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
background: #e2e4e6;
|
||||
border-radius: 3px;
|
3
client/src/components/Board/index.js
Executable file
3
client/src/components/Board/index.js
Executable file
|
@ -0,0 +1,3 @@
|
|||
import Board from './Board';
|
||||
|
||||
export default Board;
|
|
@ -1,3 +0,0 @@
|
|||
import BoardKanban from './BoardKanban';
|
||||
|
||||
export default BoardKanban;
|
|
@ -1,3 +1,4 @@
|
|||
import { dequal } from 'dequal';
|
||||
import omit from 'lodash/omit';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
@ -10,7 +11,7 @@ import { BoardMembershipRoles } from '../../constants/Enums';
|
|||
import styles from './BoardMembershipPermissionsSelectStep.module.scss';
|
||||
|
||||
const BoardMembershipPermissionsSelectStep = React.memo(
|
||||
({ defaultData, title, buttonContent, onSelect, onBack }) => {
|
||||
({ defaultData, title, buttonContent, onSelect, onBack, onClose }) => {
|
||||
const [t] = useTranslation();
|
||||
|
||||
const [data, setData] = useState(() => ({
|
||||
|
@ -23,7 +24,7 @@ const BoardMembershipPermissionsSelectStep = React.memo(
|
|||
setData((prevData) => ({
|
||||
...prevData,
|
||||
role,
|
||||
canComment: role === BoardMembershipRoles.EDITOR ? null : !!prevData.canComment,
|
||||
canComment: role === BoardMembershipRoles.VIEWER ? !!prevData.canComment : null,
|
||||
}));
|
||||
}, []);
|
||||
|
||||
|
@ -35,8 +36,12 @@ const BoardMembershipPermissionsSelectStep = React.memo(
|
|||
}, []);
|
||||
|
||||
const handleSubmit = useCallback(() => {
|
||||
onSelect(data.role === BoardMembershipRoles.EDITOR ? omit(data, 'canComment') : data);
|
||||
}, [onSelect, data]);
|
||||
if (!dequal(data, defaultData)) {
|
||||
onSelect(data.role === BoardMembershipRoles.VIEWER ? data : omit(data, 'canComment'));
|
||||
}
|
||||
|
||||
onClose();
|
||||
}, [defaultData, onSelect, onClose, data]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -65,7 +70,7 @@ const BoardMembershipPermissionsSelectStep = React.memo(
|
|||
<div className={styles.menuItemDescription}>{t('common.canOnlyViewBoard')}</div>
|
||||
</Menu.Item>
|
||||
</Menu>
|
||||
{data.role !== BoardMembershipRoles.EDITOR && (
|
||||
{data.role === BoardMembershipRoles.VIEWER && (
|
||||
<Segment basic className={styles.settings}>
|
||||
<Radio
|
||||
toggle
|
||||
|
@ -90,6 +95,7 @@ BoardMembershipPermissionsSelectStep.propTypes = {
|
|||
buttonContent: PropTypes.string,
|
||||
onSelect: PropTypes.func.isRequired,
|
||||
onBack: PropTypes.func.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
BoardMembershipPermissionsSelectStep.defaultProps = {
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Loader } from 'semantic-ui-react';
|
||||
|
||||
import { BoardTypes } from '../constants/Enums';
|
||||
import BoardKanbanContainer from '../containers/BoardKanbanContainer';
|
||||
|
||||
const BoardWrapper = React.memo(({ type, isFetching }) => {
|
||||
if (isFetching) {
|
||||
return <Loader active />;
|
||||
}
|
||||
|
||||
if (type === BoardTypes.KANBAN) {
|
||||
return <BoardKanbanContainer />;
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
BoardWrapper.propTypes = {
|
||||
type: PropTypes.string.isRequired,
|
||||
isFetching: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
export default BoardWrapper;
|
|
@ -46,7 +46,6 @@ const AddStep = React.memo(({ onCreate, onClose }) => {
|
|||
const handleSubmit = useCallback(() => {
|
||||
const cleanData = {
|
||||
...data,
|
||||
type: 'kanban',
|
||||
name: data.name.trim(),
|
||||
};
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ const Item = React.memo(({ type, data, createdAt, user }) => {
|
|||
const [t] = useTranslation();
|
||||
|
||||
let contentNode;
|
||||
|
||||
switch (type) {
|
||||
case ActivityTypes.CREATE_CARD:
|
||||
contentNode = (
|
||||
|
|
|
@ -120,6 +120,7 @@ const Attachments = React.memo(
|
|||
withCaption
|
||||
withDownloadButton
|
||||
options={{
|
||||
wheelToZoom: true,
|
||||
showHideAnimationType: 'none',
|
||||
closeTitle: '',
|
||||
zoomTitle: '',
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
text-align: left;
|
||||
text-overflow: ellipsis;
|
||||
transition: background 85ms ease;
|
||||
white-space: nowrap;
|
||||
|
||||
&:hover {
|
||||
background: #dfe3e6;
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import ModalTypes from '../constants/ModalTypes';
|
||||
import FixedContainer from '../containers/FixedContainer';
|
||||
import StaticContainer from '../containers/StaticContainer';
|
||||
import UsersModalContainer from '../containers/UsersModalContainer';
|
||||
import UserSettingsModalContainer from '../containers/UserSettingsModalContainer';
|
||||
import ProjectAddModalContainer from '../containers/ProjectAddModalContainer';
|
||||
import Background from './Background';
|
||||
|
||||
function Core({ currentModal, currentProject }) {
|
||||
return (
|
||||
<>
|
||||
{currentProject && currentProject.background && (
|
||||
<Background
|
||||
type={currentProject.background.type}
|
||||
name={currentProject.background.name}
|
||||
imageUrl={currentProject.backgroundImage && currentProject.backgroundImage.url}
|
||||
/>
|
||||
)}
|
||||
<FixedContainer />
|
||||
<StaticContainer />
|
||||
{currentModal === ModalTypes.USERS && <UsersModalContainer />}
|
||||
{currentModal === ModalTypes.USER_SETTINGS && <UserSettingsModalContainer />}
|
||||
{currentModal === ModalTypes.PROJECT_ADD && <ProjectAddModalContainer />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Core.propTypes = {
|
||||
currentModal: PropTypes.oneOf(Object.values(ModalTypes)),
|
||||
currentProject: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
||||
};
|
||||
|
||||
Core.defaultProps = {
|
||||
currentModal: undefined,
|
||||
currentProject: undefined,
|
||||
};
|
||||
|
||||
export default Core;
|
69
client/src/components/Core/Core.jsx
Executable file
69
client/src/components/Core/Core.jsx
Executable file
|
@ -0,0 +1,69 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useTranslation, Trans } from 'react-i18next';
|
||||
import { Loader } from 'semantic-ui-react';
|
||||
|
||||
import ModalTypes from '../../constants/ModalTypes';
|
||||
import FixedContainer from '../../containers/FixedContainer';
|
||||
import StaticContainer from '../../containers/StaticContainer';
|
||||
import UsersModalContainer from '../../containers/UsersModalContainer';
|
||||
import UserSettingsModalContainer from '../../containers/UserSettingsModalContainer';
|
||||
import ProjectAddModalContainer from '../../containers/ProjectAddModalContainer';
|
||||
import Background from '../Background';
|
||||
|
||||
import styles from './Core.module.scss';
|
||||
|
||||
const Core = React.memo(
|
||||
({ isInitializing, isSocketDisconnected, currentModal, currentProject }) => {
|
||||
const [t] = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
{isInitializing ? (
|
||||
<Loader active size="massive" />
|
||||
) : (
|
||||
<>
|
||||
{currentProject && currentProject.background && (
|
||||
<Background
|
||||
type={currentProject.background.type}
|
||||
name={currentProject.background.name}
|
||||
imageUrl={currentProject.backgroundImage && currentProject.backgroundImage.url}
|
||||
/>
|
||||
)}
|
||||
<FixedContainer />
|
||||
<StaticContainer />
|
||||
{currentModal === ModalTypes.USERS && <UsersModalContainer />}
|
||||
{currentModal === ModalTypes.USER_SETTINGS && <UserSettingsModalContainer />}
|
||||
{currentModal === ModalTypes.PROJECT_ADD && <ProjectAddModalContainer />}
|
||||
</>
|
||||
)}
|
||||
{isSocketDisconnected && (
|
||||
<div className={styles.message}>
|
||||
<div className={styles.messageHeader}>{t('common.noConnectionToServer')}</div>
|
||||
<div className={styles.messageContent}>
|
||||
<Trans i18nKey="common.allChangesWillBeAutomaticallySavedAfterConnectionRestored">
|
||||
All changes will be automatically saved
|
||||
<br />
|
||||
after connection restored
|
||||
</Trans>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Core.propTypes = {
|
||||
isInitializing: PropTypes.bool.isRequired,
|
||||
isSocketDisconnected: PropTypes.bool.isRequired,
|
||||
currentModal: PropTypes.oneOf(Object.values(ModalTypes)),
|
||||
currentProject: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
||||
};
|
||||
|
||||
Core.defaultProps = {
|
||||
currentModal: undefined,
|
||||
currentProject: undefined,
|
||||
};
|
||||
|
||||
export default Core;
|
3
client/src/components/Core/index.js
Normal file
3
client/src/components/Core/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import Core from './Core';
|
||||
|
||||
export default Core;
|
|
@ -1,37 +0,0 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useTranslation, Trans } from 'react-i18next';
|
||||
import { Loader } from 'semantic-ui-react';
|
||||
|
||||
import CoreContainer from '../../containers/CoreContainer';
|
||||
|
||||
import styles from './CoreWrapper.module.scss';
|
||||
|
||||
const CoreWrapper = React.memo(({ isInitializing, isSocketDisconnected }) => {
|
||||
const [t] = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
{isInitializing ? <Loader active size="massive" /> : <CoreContainer />}
|
||||
{isSocketDisconnected && (
|
||||
<div className={styles.message}>
|
||||
<div className={styles.messageHeader}>{t('common.noConnectionToServer')}</div>
|
||||
<div className={styles.messageContent}>
|
||||
<Trans i18nKey="common.allChangesWillBeAutomaticallySavedAfterConnectionRestored">
|
||||
All changes will be automatically saved
|
||||
<br />
|
||||
after connection restored
|
||||
</Trans>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
CoreWrapper.propTypes = {
|
||||
isInitializing: PropTypes.bool.isRequired,
|
||||
isSocketDisconnected: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
export default CoreWrapper;
|
|
@ -1,3 +0,0 @@
|
|||
import CoreWrapper from './CoreWrapper';
|
||||
|
||||
export default CoreWrapper;
|
|
@ -28,8 +28,8 @@ const ActionsStep = React.memo(
|
|||
deleteConfirmationTitle,
|
||||
deleteConfirmationContent,
|
||||
deleteConfirmationButtonContent,
|
||||
canLeave,
|
||||
canEdit,
|
||||
canLeave,
|
||||
onUpdate,
|
||||
onDelete,
|
||||
onClose,
|
||||
|
@ -50,10 +50,8 @@ const ActionsStep = React.memo(
|
|||
if (onUpdate) {
|
||||
onUpdate(data);
|
||||
}
|
||||
|
||||
onClose();
|
||||
},
|
||||
[onUpdate, onClose],
|
||||
[onUpdate],
|
||||
);
|
||||
|
||||
if (step) {
|
||||
|
@ -68,6 +66,7 @@ const ActionsStep = React.memo(
|
|||
buttonContent="action.save"
|
||||
onSelect={handleRoleSelect}
|
||||
onBack={handleBack}
|
||||
onClose={onClose}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -146,8 +145,8 @@ ActionsStep.propTypes = {
|
|||
deleteConfirmationTitle: PropTypes.string,
|
||||
deleteConfirmationContent: PropTypes.string,
|
||||
deleteConfirmationButtonContent: PropTypes.string,
|
||||
canLeave: PropTypes.bool.isRequired,
|
||||
canEdit: PropTypes.bool.isRequired,
|
||||
canLeave: PropTypes.bool.isRequired,
|
||||
onUpdate: PropTypes.func,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
|
|
|
@ -56,10 +56,8 @@ const AddStep = React.memo(
|
|||
userId: step.params.userId,
|
||||
...data,
|
||||
});
|
||||
|
||||
onClose();
|
||||
},
|
||||
[onCreate, onClose, step],
|
||||
[onCreate, step],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -79,6 +77,7 @@ const AddStep = React.memo(
|
|||
buttonContent="action.addMember"
|
||||
onSelect={handleRoleSelect}
|
||||
onBack={handleBack}
|
||||
onClose={onClose}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ const Memberships = React.memo(
|
|||
deleteConfirmationTitle={deleteConfirmationTitle}
|
||||
deleteConfirmationContent={deleteConfirmationContent}
|
||||
deleteConfirmationButtonContent={deleteConfirmationButtonContent}
|
||||
canLeave={items.length > 1 || canLeaveIfLast}
|
||||
canEdit={canEdit}
|
||||
canLeave={items.length > 1 || canLeaveIfLast}
|
||||
onUpdate={(data) => onUpdate(item.id, data)}
|
||||
onDelete={() => onDelete(item.id)}
|
||||
>
|
||||
|
|
|
@ -6,7 +6,7 @@ import { ReduxRouter } from '../lib/redux-router';
|
|||
|
||||
import Paths from '../constants/Paths';
|
||||
import LoginContainer from '../containers/LoginContainer';
|
||||
import CoreWrapperContainer from '../containers/CoreWrapperContainer';
|
||||
import CoreContainer from '../containers/CoreContainer';
|
||||
import NotFound from './NotFound';
|
||||
|
||||
import 'react-datepicker/dist/react-datepicker.css';
|
||||
|
@ -22,10 +22,10 @@ function Root({ store, history }) {
|
|||
<ReduxRouter history={history}>
|
||||
<Routes>
|
||||
<Route path={Paths.LOGIN} element={<LoginContainer />} />
|
||||
<Route path={Paths.ROOT} element={<CoreWrapperContainer />} />
|
||||
<Route path={Paths.PROJECTS} element={<CoreWrapperContainer />} />
|
||||
<Route path={Paths.BOARDS} element={<CoreWrapperContainer />} />
|
||||
<Route path={Paths.CARDS} element={<CoreWrapperContainer />} />
|
||||
<Route path={Paths.ROOT} element={<CoreContainer />} />
|
||||
<Route path={Paths.PROJECTS} element={<CoreContainer />} />
|
||||
<Route path={Paths.BOARDS} element={<CoreContainer />} />
|
||||
<Route path={Paths.CARDS} element={<CoreContainer />} />
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
</ReduxRouter>
|
||||
|
|
|
@ -2,19 +2,19 @@ import React from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import { useTranslation, Trans } from 'react-i18next';
|
||||
import { Icon } from 'semantic-ui-react';
|
||||
import { Icon, Loader } from 'semantic-ui-react';
|
||||
|
||||
import ProjectsContainer from '../../containers/ProjectsContainer';
|
||||
import BoardWrapperContainer from '../../containers/BoardWrapperContainer';
|
||||
import BoardContainer from '../../containers/BoardContainer';
|
||||
|
||||
import styles from './Static.module.scss';
|
||||
|
||||
function Static({ cardId, boardId, projectId }) {
|
||||
function Static({ projectId, cardId, board }) {
|
||||
const [t] = useTranslation();
|
||||
|
||||
if (projectId === undefined) {
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
<div className={styles.wrapper}>
|
||||
<ProjectsContainer />
|
||||
</div>
|
||||
);
|
||||
|
@ -22,7 +22,7 @@ function Static({ cardId, boardId, projectId }) {
|
|||
|
||||
if (cardId === null) {
|
||||
return (
|
||||
<div className={classNames(styles.root, styles.flex)}>
|
||||
<div className={classNames(styles.wrapper, styles.wrapperFlex)}>
|
||||
<div className={styles.message}>
|
||||
<h1>
|
||||
{t('common.cardNotFound', {
|
||||
|
@ -34,9 +34,9 @@ function Static({ cardId, boardId, projectId }) {
|
|||
);
|
||||
}
|
||||
|
||||
if (boardId === null) {
|
||||
if (board === null) {
|
||||
return (
|
||||
<div className={classNames(styles.root, styles.flex)}>
|
||||
<div className={classNames(styles.wrapper, styles.wrapperFlex)}>
|
||||
<div className={styles.message}>
|
||||
<h1>
|
||||
{t('common.boardNotFound', {
|
||||
|
@ -50,7 +50,7 @@ function Static({ cardId, boardId, projectId }) {
|
|||
|
||||
if (projectId === null) {
|
||||
return (
|
||||
<div className={classNames(styles.root, styles.flex)}>
|
||||
<div className={classNames(styles.wrapper, styles.wrapperFlex)}>
|
||||
<div className={styles.message}>
|
||||
<h1>
|
||||
{t('common.projectNotFound', {
|
||||
|
@ -62,9 +62,9 @@ function Static({ cardId, boardId, projectId }) {
|
|||
);
|
||||
}
|
||||
|
||||
if (boardId === undefined) {
|
||||
if (board === undefined) {
|
||||
return (
|
||||
<div className={classNames(styles.board, styles.flex)}>
|
||||
<div className={classNames(styles.wrapper, styles.wrapperFlex, styles.wrapperProject)}>
|
||||
<div className={styles.message}>
|
||||
<Icon inverted name="hand point up outline" size="huge" className={styles.messageIcon} />
|
||||
<h1 className={styles.messageTitle}>
|
||||
|
@ -80,23 +80,31 @@ function Static({ cardId, boardId, projectId }) {
|
|||
);
|
||||
}
|
||||
|
||||
if (board.isFetching) {
|
||||
return (
|
||||
<div className={classNames(styles.wrapper, styles.wrapperLoader, styles.wrapperProject)}>
|
||||
<Loader active size="big" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={classNames(styles.board, styles.flex)}>
|
||||
<BoardWrapperContainer />
|
||||
<div className={classNames(styles.wrapper, styles.wrapperFlex, styles.wrapperBoard)}>
|
||||
<BoardContainer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Static.propTypes = {
|
||||
cardId: PropTypes.string,
|
||||
boardId: PropTypes.string,
|
||||
projectId: PropTypes.string,
|
||||
cardId: PropTypes.string,
|
||||
board: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
||||
};
|
||||
|
||||
Static.defaultProps = {
|
||||
cardId: undefined,
|
||||
boardId: undefined,
|
||||
projectId: undefined,
|
||||
cardId: undefined,
|
||||
board: undefined,
|
||||
};
|
||||
|
||||
export default Static;
|
||||
|
|
|
@ -1,13 +1,4 @@
|
|||
:global(#app) {
|
||||
.board {
|
||||
margin-top: 174px;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.message {
|
||||
align-content: space-between;
|
||||
align-items: center;
|
||||
|
@ -34,7 +25,24 @@
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
.root {
|
||||
.wrapper {
|
||||
height: 100%;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.wrapperBoard {
|
||||
margin-top: 174px;
|
||||
}
|
||||
|
||||
.wrapperFlex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.wrapperLoader {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.wrapperProject {
|
||||
margin-top: 98px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import omit from 'lodash/omit';
|
||||
import isEmail from 'validator/lib/isEmail';
|
||||
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
@ -78,12 +77,16 @@ const UserEmailEditStep = React.memo(
|
|||
return;
|
||||
}
|
||||
|
||||
if (usePasswordConfirmation && !cleanData.currentPassword) {
|
||||
currentPasswordField.current.focus();
|
||||
return;
|
||||
if (usePasswordConfirmation) {
|
||||
if (!cleanData.currentPassword) {
|
||||
currentPasswordField.current.focus();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
delete cleanData.currentPassword;
|
||||
}
|
||||
|
||||
onUpdate(usePasswordConfirmation ? cleanData : omit(cleanData, 'currentPassword'));
|
||||
onUpdate(cleanData);
|
||||
}, [email, usePasswordConfirmation, onUpdate, onClose, data]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import omit from 'lodash/omit';
|
||||
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
@ -78,12 +77,16 @@ const UserUsernameEditStep = React.memo(
|
|||
return;
|
||||
}
|
||||
|
||||
if (usePasswordConfirmation && !cleanData.currentPassword) {
|
||||
currentPasswordField.current.focus();
|
||||
return;
|
||||
if (usePasswordConfirmation) {
|
||||
if (!cleanData.currentPassword) {
|
||||
currentPasswordField.current.focus();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
delete cleanData.currentPassword;
|
||||
}
|
||||
|
||||
onUpdate(usePasswordConfirmation ? cleanData : omit(cleanData, 'currentPassword'));
|
||||
onUpdate(cleanData);
|
||||
}, [username, usePasswordConfirmation, onUpdate, onClose, data]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -3,10 +3,6 @@ export const ProjectBackgroundTypes = {
|
|||
IMAGE: 'image',
|
||||
};
|
||||
|
||||
export const BoardTypes = {
|
||||
KANBAN: 'kanban',
|
||||
};
|
||||
|
||||
export const BoardMembershipRoles = {
|
||||
EDITOR: 'editor',
|
||||
VIEWER: 'viewer',
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import { Button, Popup as SemanticUIPopup } from 'semantic-ui-react';
|
|||
import styles from './Popup.module.css';
|
||||
|
||||
export default (WrappedComponent, defaultProps) => {
|
||||
const Popup = React.memo(({ children, ...props }) => {
|
||||
const Popup = React.memo(({ children, onClose, ...props }) => {
|
||||
const [isOpened, setIsOpened] = useState(false);
|
||||
|
||||
const wrapper = useRef(null);
|
||||
|
@ -18,7 +18,11 @@ export default (WrappedComponent, defaultProps) => {
|
|||
|
||||
const handleClose = useCallback(() => {
|
||||
setIsOpened(false);
|
||||
}, []);
|
||||
|
||||
if (onClose) {
|
||||
onClose();
|
||||
}
|
||||
}, [onClose]);
|
||||
|
||||
const handleMouseDown = useCallback((event) => {
|
||||
event.stopPropagation();
|
||||
|
@ -105,6 +109,11 @@ export default (WrappedComponent, defaultProps) => {
|
|||
|
||||
Popup.propTypes = {
|
||||
children: PropTypes.node.isRequired,
|
||||
onClose: PropTypes.func,
|
||||
};
|
||||
|
||||
Popup.defaultProps = {
|
||||
onClose: undefined,
|
||||
};
|
||||
|
||||
return Popup;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { Model, attr, fk } from 'redux-orm';
|
||||
import { attr, fk } from 'redux-orm';
|
||||
|
||||
import BaseModel from './BaseModel';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
export default class extends BaseModel {
|
||||
static modelName = 'Activity';
|
||||
|
||||
static fields = {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { Model, attr, fk } from 'redux-orm';
|
||||
import { attr, fk } from 'redux-orm';
|
||||
|
||||
import BaseModel from './BaseModel';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
export default class extends BaseModel {
|
||||
static modelName = 'Attachment';
|
||||
|
||||
static fields = {
|
||||
|
|
6
client/src/models/BaseModel.js
Normal file
6
client/src/models/BaseModel.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { Model } from 'redux-orm';
|
||||
|
||||
export default class BaseModel extends Model {
|
||||
// eslint-disable-next-line no-underscore-dangle, class-methods-use-this
|
||||
_onDelete() {}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
import { Model, attr, fk, many } from 'redux-orm';
|
||||
import { attr, fk, many } from 'redux-orm';
|
||||
|
||||
import BaseModel from './BaseModel';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
export default class extends BaseModel {
|
||||
static modelName = 'Board';
|
||||
|
||||
static fields = {
|
||||
id: attr(),
|
||||
type: attr(),
|
||||
position: attr(),
|
||||
name: attr(),
|
||||
isFetching: attr({
|
||||
|
@ -179,7 +179,7 @@ export default class extends Model {
|
|||
return this.lists.orderBy('position');
|
||||
}
|
||||
|
||||
getMembershipModel(userId) {
|
||||
getMembershipModelForUser(userId) {
|
||||
return this.memberships
|
||||
.filter({
|
||||
userId,
|
||||
|
@ -187,7 +187,7 @@ export default class extends Model {
|
|||
.first();
|
||||
}
|
||||
|
||||
hasMemberUser(userId) {
|
||||
hasMembershipForUser(userId) {
|
||||
return this.memberships
|
||||
.filter({
|
||||
userId,
|
||||
|
@ -195,6 +195,12 @@ export default class extends Model {
|
|||
.exists();
|
||||
}
|
||||
|
||||
isAvailableForUser(userId) {
|
||||
return (
|
||||
this.project && (this.project.hasManagerForUser(userId) || this.hasMembershipForUser(userId))
|
||||
);
|
||||
}
|
||||
|
||||
deleteRelated(exceptMemberUserId) {
|
||||
this.memberships.toModelArray().forEach((boardMembershipModel) => {
|
||||
if (boardMembershipModel.userId !== exceptMemberUserId) {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { Model, attr, fk } from 'redux-orm';
|
||||
import { attr, fk } from 'redux-orm';
|
||||
|
||||
import BaseModel from './BaseModel';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
export default class extends BaseModel {
|
||||
static modelName = 'BoardMembership';
|
||||
|
||||
static fields = {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { Model, attr, fk, many, oneToOne } from 'redux-orm';
|
||||
import { attr, fk, many, oneToOne } from 'redux-orm';
|
||||
|
||||
import BaseModel from './BaseModel';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
import Config from '../constants/Config';
|
||||
import { ActivityTypes } from '../constants/Enums';
|
||||
|
||||
export default class extends Model {
|
||||
export default class extends BaseModel {
|
||||
static modelName = 'Card';
|
||||
|
||||
static fields = {
|
||||
|
@ -74,7 +75,11 @@ export default class extends Model {
|
|||
|
||||
break;
|
||||
case ActionTypes.SOCKET_RECONNECT_HANDLE:
|
||||
Card.all().delete();
|
||||
Card.all()
|
||||
.toModelArray()
|
||||
.forEach((cardModel) => {
|
||||
cardModel.deleteWithClearable();
|
||||
});
|
||||
|
||||
if (payload.cards) {
|
||||
payload.cards.forEach((card) => {
|
||||
|
@ -176,7 +181,7 @@ export default class extends Model {
|
|||
|
||||
break;
|
||||
case ActionTypes.CARD_DELETE:
|
||||
Card.withId(payload.id).delete();
|
||||
Card.withId(payload.id).deleteWithRelated();
|
||||
|
||||
break;
|
||||
case ActionTypes.CARD_DELETE__SUCCESS:
|
||||
|
@ -220,15 +225,7 @@ export default class extends Model {
|
|||
isActivitiesDetailsFetching: false,
|
||||
});
|
||||
|
||||
cardModel.activities.toModelArray().forEach((activityModel) => {
|
||||
if (activityModel.notification) {
|
||||
activityModel.update({
|
||||
isInCard: false,
|
||||
});
|
||||
} else {
|
||||
activityModel.delete();
|
||||
}
|
||||
});
|
||||
cardModel.deleteActivities();
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -268,10 +265,37 @@ export default class extends Model {
|
|||
});
|
||||
}
|
||||
|
||||
isAvailableForUser(userId) {
|
||||
return this.board && this.board.isAvailableForUser(userId);
|
||||
}
|
||||
|
||||
deleteClearable() {
|
||||
this.users.clear();
|
||||
this.labels.clear();
|
||||
}
|
||||
|
||||
deleteActivities() {
|
||||
this.activities.toModelArray().forEach((activityModel) => {
|
||||
if (activityModel.notification) {
|
||||
activityModel.update({
|
||||
isInCard: false,
|
||||
});
|
||||
} else {
|
||||
activityModel.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
deleteRelated() {
|
||||
this.deleteClearable();
|
||||
this.tasks.delete();
|
||||
this.attachments.delete();
|
||||
this.activities.delete();
|
||||
this.deleteActivities();
|
||||
}
|
||||
|
||||
deleteWithClearable() {
|
||||
this.deleteClearable();
|
||||
this.delete();
|
||||
}
|
||||
|
||||
deleteWithRelated() {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { Model, attr, fk } from 'redux-orm';
|
||||
import { attr, fk } from 'redux-orm';
|
||||
|
||||
import BaseModel from './BaseModel';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
export default class extends BaseModel {
|
||||
static modelName = 'Label';
|
||||
|
||||
static fields = {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { Model, attr, fk } from 'redux-orm';
|
||||
import { attr, fk } from 'redux-orm';
|
||||
|
||||
import BaseModel from './BaseModel';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
export default class extends BaseModel {
|
||||
static modelName = 'List';
|
||||
|
||||
static fields = {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { Model, attr, fk, oneToOne } from 'redux-orm';
|
||||
import { attr, fk, oneToOne } from 'redux-orm';
|
||||
|
||||
import BaseModel from './BaseModel';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
export default class extends BaseModel {
|
||||
static modelName = 'Notification';
|
||||
|
||||
static fields = {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { Model, attr, many } from 'redux-orm';
|
||||
import { attr, many } from 'redux-orm';
|
||||
|
||||
import BaseModel from './BaseModel';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
import { ProjectBackgroundTypes } from '../constants/Enums';
|
||||
|
||||
export default class extends Model {
|
||||
export default class extends BaseModel {
|
||||
static modelName = 'Project';
|
||||
|
||||
static fields = {
|
||||
|
@ -143,21 +144,21 @@ export default class extends Model {
|
|||
return this.boards.orderBy('position');
|
||||
}
|
||||
|
||||
getOrderedMemberBoardsModelArray(userId) {
|
||||
getOrderedBoardsModelArrayForUser(userId) {
|
||||
return this.getOrderedBoardsQuerySet()
|
||||
.toModelArray()
|
||||
.filter((boardModel) => boardModel.hasMemberUser(userId));
|
||||
.filter((boardModel) => boardModel.hasMembershipForUser(userId));
|
||||
}
|
||||
|
||||
getOrderedAvailableBoardsModelArray(userId) {
|
||||
if (this.hasManagerUser(userId)) {
|
||||
getOrderedBoardsModelArrayAvailableForUser(userId) {
|
||||
if (this.hasManagerForUser(userId)) {
|
||||
return this.getOrderedBoardsQuerySet().toModelArray();
|
||||
}
|
||||
|
||||
return this.getOrderedMemberBoardsModelArray(userId);
|
||||
return this.getOrderedBoardsModelArrayForUser(userId);
|
||||
}
|
||||
|
||||
hasManagerUser(userId) {
|
||||
hasManagerForUser(userId) {
|
||||
return this.managers
|
||||
.filter({
|
||||
userId,
|
||||
|
@ -165,8 +166,12 @@ export default class extends Model {
|
|||
.exists();
|
||||
}
|
||||
|
||||
hasMemberUserForAnyBoard(userId) {
|
||||
return this.boards.toModelArray().some((boardModel) => boardModel.hasMemberUser(userId));
|
||||
hasMembershipInAnyBoardForUser(userId) {
|
||||
return this.boards.toModelArray().some((boardModel) => boardModel.hasMembershipForUser(userId));
|
||||
}
|
||||
|
||||
isAvailableForUser(userId) {
|
||||
return this.hasManagerForUser(userId) || this.hasMembershipInAnyBoardForUser(userId);
|
||||
}
|
||||
|
||||
deleteRelated() {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { Model, attr, fk } from 'redux-orm';
|
||||
import { attr, fk } from 'redux-orm';
|
||||
|
||||
import BaseModel from './BaseModel';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
export default class extends BaseModel {
|
||||
static modelName = 'ProjectManager';
|
||||
|
||||
static fields = {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { Model, attr, fk } from 'redux-orm';
|
||||
import { attr, fk } from 'redux-orm';
|
||||
|
||||
import BaseModel from './BaseModel';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
export default class extends BaseModel {
|
||||
static modelName = 'Task';
|
||||
|
||||
static fields = {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Model, attr } from 'redux-orm';
|
||||
import { attr } from 'redux-orm';
|
||||
|
||||
import BaseModel from './BaseModel';
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
const DEFAULT_EMAIL_UPDATE_FORM = {
|
||||
|
@ -29,7 +30,7 @@ const DEFAULT_USERNAME_UPDATE_FORM = {
|
|||
error: null,
|
||||
};
|
||||
|
||||
export default class extends Model {
|
||||
export default class extends BaseModel {
|
||||
static modelName = 'User';
|
||||
|
||||
static fields = {
|
||||
|
|
|
@ -12,7 +12,6 @@ export function* createCard(listId, data) {
|
|||
|
||||
const nextData = {
|
||||
...data,
|
||||
listId,
|
||||
position: yield select(selectors.selectNextCardPosition, listId),
|
||||
};
|
||||
|
||||
|
@ -22,13 +21,14 @@ export function* createCard(listId, data) {
|
|||
actions.createCard({
|
||||
...nextData,
|
||||
boardId,
|
||||
listId,
|
||||
id: localId,
|
||||
}),
|
||||
);
|
||||
|
||||
let card;
|
||||
try {
|
||||
({ item: card } = yield call(request, api.createCard, boardId, nextData));
|
||||
({ item: card } = yield call(request, api.createCard, listId, nextData));
|
||||
} catch (error) {
|
||||
yield put(actions.createCard.failure(localId, error));
|
||||
return;
|
||||
|
@ -61,8 +61,9 @@ export function* updateCurrentCard(data) {
|
|||
yield call(updateCard, cardId, data);
|
||||
}
|
||||
|
||||
// TODO: handle card transfer
|
||||
export function* handleCardUpdate(card) {
|
||||
yield put(actions.handleCardUpdate(card)); // TODO: handle card transfer
|
||||
yield put(actions.handleCardUpdate(card));
|
||||
}
|
||||
|
||||
export function* moveCard(id, listId, index) {
|
||||
|
|
|
@ -39,8 +39,8 @@ export function* createListInCurrentBoard(data) {
|
|||
yield call(createList, boardId, data);
|
||||
}
|
||||
|
||||
export function* handleListCreate(label) {
|
||||
yield put(actions.handleListCreate(label));
|
||||
export function* handleListCreate(list) {
|
||||
yield put(actions.handleListCreate(list));
|
||||
}
|
||||
|
||||
export function* updateList(id, data) {
|
||||
|
@ -57,8 +57,8 @@ export function* updateList(id, data) {
|
|||
yield put(actions.updateList.success(list));
|
||||
}
|
||||
|
||||
export function* handleListUpdate(label) {
|
||||
yield put(actions.handleListUpdate(label));
|
||||
export function* handleListUpdate(list) {
|
||||
yield put(actions.handleListUpdate(list));
|
||||
}
|
||||
|
||||
export function* moveList(id, index) {
|
||||
|
@ -84,8 +84,8 @@ export function* deleteList(id) {
|
|||
yield put(actions.deleteList.success(list));
|
||||
}
|
||||
|
||||
export function* handleListDelete(label) {
|
||||
yield put(actions.handleListDelete(label));
|
||||
export function* handleListDelete(list) {
|
||||
yield put(actions.handleListDelete(list));
|
||||
}
|
||||
|
||||
export default {
|
||||
|
|
|
@ -69,6 +69,31 @@ export const selectMembershipsForCurrentBoard = createSelector(
|
|||
},
|
||||
);
|
||||
|
||||
export const selectCurrentUserMembershipForCurrentBoard = createSelector(
|
||||
orm,
|
||||
(state) => selectPath(state).boardId,
|
||||
(state) => selectCurrentUserId(state),
|
||||
({ Board }, id, currentUserId) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
const boardMembershipModel = boardModel.getMembershipModelForUser(currentUserId);
|
||||
|
||||
if (!boardMembershipModel) {
|
||||
return boardMembershipModel;
|
||||
}
|
||||
|
||||
return boardMembershipModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const selectLabelsForCurrentBoard = createSelector(
|
||||
orm,
|
||||
(state) => selectPath(state).boardId,
|
||||
|
@ -147,31 +172,6 @@ export const selectFilterLabelsForCurrentBoard = createSelector(
|
|||
},
|
||||
);
|
||||
|
||||
export const selectCurrentUserMembershipForCurrentBoard = createSelector(
|
||||
orm,
|
||||
(state) => selectPath(state).boardId,
|
||||
(state) => selectCurrentUserId(state),
|
||||
({ Board }, id, currentUserId) => {
|
||||
if (!id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
const boardModel = Board.withId(id);
|
||||
|
||||
if (!boardModel) {
|
||||
return boardModel;
|
||||
}
|
||||
|
||||
const boardMembershipModel = boardModel.getMembershipModel(currentUserId);
|
||||
|
||||
if (!boardMembershipModel) {
|
||||
return boardMembershipModel;
|
||||
}
|
||||
|
||||
return boardMembershipModel.ref;
|
||||
},
|
||||
);
|
||||
|
||||
export const selectIsBoardWithIdExists = createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
|
@ -183,10 +183,10 @@ export default {
|
|||
selectBoardById,
|
||||
selectCurrentBoard,
|
||||
selectMembershipsForCurrentBoard,
|
||||
selectCurrentUserMembershipForCurrentBoard,
|
||||
selectLabelsForCurrentBoard,
|
||||
selectListIdsForCurrentBoard,
|
||||
selectFilterUsersForCurrentBoard,
|
||||
selectFilterLabelsForCurrentBoard,
|
||||
selectCurrentUserMembershipForCurrentBoard,
|
||||
selectIsBoardWithIdExists,
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import router from './router';
|
||||
import socket from './socket';
|
||||
import core from './core';
|
||||
import modals from './modals';
|
||||
import users from './users';
|
||||
|
@ -13,6 +14,7 @@ import attachments from './attachments';
|
|||
|
||||
export default {
|
||||
...router,
|
||||
...socket,
|
||||
...core,
|
||||
...modals,
|
||||
...users,
|
||||
|
|
|
@ -67,10 +67,12 @@ export const selectBoardsForCurrentProject = createSelector(
|
|||
return projectModel;
|
||||
}
|
||||
|
||||
return projectModel.getOrderedAvailableBoardsModelArray(currentUserId).map((boardModel) => ({
|
||||
...boardModel.ref,
|
||||
isPersisted: !isLocalId(boardModel.id),
|
||||
}));
|
||||
return projectModel
|
||||
.getOrderedBoardsModelArrayAvailableForUser(currentUserId)
|
||||
.map((boardModel) => ({
|
||||
...boardModel.ref,
|
||||
isPersisted: !isLocalId(boardModel.id),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -89,7 +91,7 @@ export const selectIsCurrentUserManagerForCurrentProject = createSelector(
|
|||
return false;
|
||||
}
|
||||
|
||||
return projectModel.hasManagerUser(currentUserId);
|
||||
return projectModel.hasManagerForUser(currentUserId);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -26,55 +26,35 @@ export const selectPath = createReduxOrmSelector(
|
|||
case Paths.PROJECTS: {
|
||||
const projectModel = Project.withId(pathsMatch.params.id);
|
||||
|
||||
if (!projectModel) {
|
||||
if (!projectModel || !projectModel.isAvailableForUser(currentUserId)) {
|
||||
return {
|
||||
projectId: null,
|
||||
};
|
||||
}
|
||||
|
||||
if (!projectModel.hasManagerUser(currentUserId)) {
|
||||
if (!projectModel.hasMemberUserForAnyBoard(currentUserId)) {
|
||||
return {
|
||||
projectId: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
projectId: projectModel.id,
|
||||
};
|
||||
}
|
||||
case Paths.BOARDS: {
|
||||
const boardModel = Board.withId(pathsMatch.params.id);
|
||||
const projectModel = boardModel && boardModel.project;
|
||||
|
||||
if (!projectModel) {
|
||||
if (!boardModel || !boardModel.isAvailableForUser(currentUserId)) {
|
||||
return {
|
||||
boardId: null,
|
||||
projectId: null,
|
||||
};
|
||||
}
|
||||
|
||||
if (!projectModel.hasManagerUser(currentUserId)) {
|
||||
if (!boardModel.hasMemberUser(currentUserId)) {
|
||||
return {
|
||||
boardId: null,
|
||||
projectId: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
boardId: boardModel.id,
|
||||
projectId: projectModel.id,
|
||||
projectId: boardModel.projectId,
|
||||
};
|
||||
}
|
||||
case Paths.CARDS: {
|
||||
const cardModel = Card.withId(pathsMatch.params.id);
|
||||
const boardModel = cardModel && cardModel.board;
|
||||
const projectModel = boardModel && boardModel.project;
|
||||
|
||||
if (!projectModel) {
|
||||
if (!cardModel || !cardModel.isAvailableForUser(currentUserId)) {
|
||||
return {
|
||||
cardId: null,
|
||||
boardId: null,
|
||||
|
@ -82,20 +62,10 @@ export const selectPath = createReduxOrmSelector(
|
|||
};
|
||||
}
|
||||
|
||||
if (!projectModel.hasManagerUser(currentUserId)) {
|
||||
if (!boardModel.hasMemberUser(currentUserId)) {
|
||||
return {
|
||||
cardId: null,
|
||||
boardId: null,
|
||||
projectId: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
cardId: cardModel.id,
|
||||
boardId: boardModel.id,
|
||||
projectId: projectModel.id,
|
||||
boardId: cardModel.boardId,
|
||||
projectId: cardModel.board.projectId,
|
||||
};
|
||||
}
|
||||
default:
|
||||
|
|
5
client/src/selectors/socket.js
Normal file
5
client/src/selectors/socket.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
export const selectIsSocketDisconnected = ({ socket: { isDisconnected } }) => isDisconnected;
|
||||
|
||||
export default {
|
||||
selectIsSocketDisconnected,
|
||||
};
|
|
@ -52,7 +52,7 @@ export const selectProjectsForCurrentUser = createSelector(
|
|||
}
|
||||
|
||||
return userModel.getOrderedAvailableProjectsModelArray().map((projectModel) => {
|
||||
const boardsModels = projectModel.getOrderedAvailableBoardsModelArray(userModel.id);
|
||||
const boardsModels = projectModel.getOrderedBoardsModelArrayAvailableForUser(userModel.id);
|
||||
|
||||
let notificationsTotal = 0;
|
||||
boardsModels.forEach((boardModel) => {
|
||||
|
@ -86,7 +86,7 @@ export const selectProjectsToListsForCurrentUser = createSelector(
|
|||
|
||||
return userModel.getOrderedAvailableProjectsModelArray().map((projectModel) => ({
|
||||
...projectModel.ref,
|
||||
boards: projectModel.getOrderedMemberBoardsModelArray(id).map((boardModel) => ({
|
||||
boards: projectModel.getOrderedBoardsModelArrayForUser(id).map((boardModel) => ({
|
||||
...boardModel.ref,
|
||||
lists: boardModel.getOrderedListsQuerySet().toRefArray(),
|
||||
})),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue