ref: Remove board types, refactoring
parent
2b131f76c1
commit
6ffa817b53
@ -0,0 +1,3 @@
|
||||
import Board from './Board';
|
||||
|
||||
export default Board;
|
||||
@ -1,3 +0,0 @@
|
||||
import BoardKanban from './BoardKanban';
|
||||
|
||||
export default BoardKanban;
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -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);
|
||||
@ -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);
|
||||
@ -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() {}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
export const selectIsSocketDisconnected = ({ socket: { isDisconnected } }) => isDisconnected;
|
||||
|
||||
export default {
|
||||
selectIsSocketDisconnected,
|
||||
};
|
||||
@ -1,74 +0,0 @@
|
||||
const Errors = {
|
||||
BOARD_NOT_FOUND: {
|
||||
boardNotFound: 'Board not found',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
boardId: {
|
||||
type: 'string',
|
||||
regex: /^[0-9]+$/,
|
||||
required: true,
|
||||
},
|
||||
beforeId: {
|
||||
type: 'string',
|
||||
regex: /^[0-9]+$/,
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
boardNotFound: {
|
||||
responseType: 'notFound',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { board } = await sails.helpers.boards
|
||||
.getProjectPath(inputs.boardId)
|
||||
.intercept('pathNotFound', () => Errors.BOARD_NOT_FOUND);
|
||||
|
||||
const isBoardMember = await sails.helpers.users.isBoardMember(currentUser.id, board.id);
|
||||
|
||||
if (!isBoardMember) {
|
||||
throw Errors.BOARD_NOT_FOUND; // Forbidden
|
||||
}
|
||||
|
||||
const cards = await sails.helpers.boards.getCards(board, inputs.beforeId);
|
||||
const cardIds = sails.helpers.utils.mapRecords(cards);
|
||||
|
||||
const cardSubscriptions = await sails.helpers.cardSubscriptions.getMany({
|
||||
cardId: cardIds,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
const isSubscribedByCardId = cardSubscriptions.reduce(
|
||||
(result, cardSubscription) => ({
|
||||
...result,
|
||||
[cardSubscription.cardId]: true,
|
||||
}),
|
||||
{},
|
||||
);
|
||||
|
||||
cards.forEach((card) => {
|
||||
card.isSubscribed = isSubscribedByCardId[card.id] || false; // eslint-disable-line no-param-reassign
|
||||
});
|
||||
|
||||
const cardMemberships = await sails.helpers.cards.getCardMemberships(cardIds);
|
||||
const cardLabels = await sails.helpers.cards.getCardLabels(cardIds);
|
||||
const tasks = await sails.helpers.cards.getTasks(cardIds);
|
||||
const attachments = await sails.helpers.cards.getAttachments(cardIds);
|
||||
|
||||
return {
|
||||
items: cards,
|
||||
included: {
|
||||
cardMemberships,
|
||||
cardLabels,
|
||||
tasks,
|
||||
attachments,
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue