Code cleanup. Removed onCopyCard where it was not necessary.

pull/705/head
Jens Frost 3 years ago
parent 1de9deae6d
commit 863bf71b72

@ -25,7 +25,6 @@ const Filters = React.memo(
onLabelUpdate, onLabelUpdate,
onLabelMove, onLabelMove,
onLabelDelete, onLabelDelete,
// onCopyCard,
}) => { }) => {
const [t] = useTranslation(); const [t] = useTranslation();
@ -122,7 +121,6 @@ Filters.propTypes = {
onLabelUpdate: PropTypes.func.isRequired, onLabelUpdate: PropTypes.func.isRequired,
onLabelMove: PropTypes.func.isRequired, onLabelMove: PropTypes.func.isRequired,
onLabelDelete: PropTypes.func.isRequired, onLabelDelete: PropTypes.func.isRequired,
// onCopyCard: PropTypes.func.isRequired,
}; };
export default Filters; export default Filters;

@ -14,118 +14,115 @@ import EditStep from './EditStep';
import styles from './Boards.module.scss'; import styles from './Boards.module.scss';
const Boards = React.memo( const Boards = React.memo(({ items, currentId, canEdit, onCreate, onUpdate, onMove, onDelete }) => {
({ items, currentId, canEdit, onCreate, onUpdate, onMove, onDelete, onCopyCard }) => { const tabsWrapper = useRef(null);
const tabsWrapper = useRef(null);
const handleWheel = useCallback(({ deltaY }) => { const handleWheel = useCallback(({ deltaY }) => {
tabsWrapper.current.scrollBy({ tabsWrapper.current.scrollBy({
left: deltaY, left: deltaY,
}); });
}, []); }, []);
const handleDragStart = useCallback(() => { const handleDragStart = useCallback(() => {
closePopup(); closePopup();
}, []); }, []);
const handleDragEnd = useCallback( const handleDragEnd = useCallback(
({ draggableId, source, destination }) => { ({ draggableId, source, destination }) => {
if (!destination || source.index === destination.index) { if (!destination || source.index === destination.index) {
return; return;
} }
onMove(draggableId, destination.index); onMove(draggableId, destination.index);
}, },
[onMove], [onMove],
); );
const handleUpdate = useCallback( const handleUpdate = useCallback(
(id, data) => { (id, data) => {
onUpdate(id, data); onUpdate(id, data);
}, },
[onUpdate], [onUpdate],
); );
const handleDelete = useCallback( const handleDelete = useCallback(
(id) => { (id) => {
onDelete(id); onDelete(id);
}, },
[onDelete], [onDelete],
); );
const AddPopup = usePopup(AddStep); const AddPopup = usePopup(AddStep);
const EditPopup = usePopup(EditStep); const EditPopup = usePopup(EditStep);
const itemsNode = items.map((item, index) => ( const itemsNode = items.map((item, index) => (
<Draggable <Draggable
key={item.id} key={item.id}
draggableId={item.id} draggableId={item.id}
index={index} index={index}
isDragDisabled={!item.isPersisted || !canEdit} isDragDisabled={!item.isPersisted || !canEdit}
> >
{({ innerRef, draggableProps, dragHandleProps }) => ( {({ innerRef, draggableProps, dragHandleProps }) => (
// eslint-disable-next-line react/jsx-props-no-spreading // eslint-disable-next-line react/jsx-props-no-spreading
<div {...draggableProps} ref={innerRef} className={styles.tabWrapper}> <div {...draggableProps} ref={innerRef} className={styles.tabWrapper}>
<div className={classNames(styles.tab, item.id === currentId && styles.tabActive)}> <div className={classNames(styles.tab, item.id === currentId && styles.tabActive)}>
{item.isPersisted ? ( {item.isPersisted ? (
<> <>
<Link <Link
{...dragHandleProps} // eslint-disable-line react/jsx-props-no-spreading {...dragHandleProps} // eslint-disable-line react/jsx-props-no-spreading
to={Paths.BOARDS.replace(':id', item.id)} to={Paths.BOARDS.replace(':id', item.id)}
title={item.name} title={item.name}
className={styles.link} className={styles.link}
> >
{item.name}
</Link>
{canEdit && (
<EditPopup
defaultData={pick(item, 'name')}
onUpdate={(data) => handleUpdate(item.id, data)}
onDelete={() => handleDelete(item.id)}
onCopyCard={onCopyCard}
>
<Button className={classNames(styles.editButton, styles.target)}>
<Icon fitted name="pencil" size="small" />
</Button>
</EditPopup>
)}
</>
) : (
// eslint-disable-next-line react/jsx-props-no-spreading
<span {...dragHandleProps} className={styles.link}>
{item.name} {item.name}
</span> </Link>
)} {canEdit && (
</div> <EditPopup
defaultData={pick(item, 'name')}
onUpdate={(data) => handleUpdate(item.id, data)}
onDelete={() => handleDelete(item.id)}
>
<Button className={classNames(styles.editButton, styles.target)}>
<Icon fitted name="pencil" size="small" />
</Button>
</EditPopup>
)}
</>
) : (
// eslint-disable-next-line react/jsx-props-no-spreading
<span {...dragHandleProps} className={styles.link}>
{item.name}
</span>
)}
</div> </div>
)}
</Draggable>
));
return (
<div className={styles.wrapper} onWheel={handleWheel}>
<div ref={tabsWrapper} className={styles.tabsWrapper}>
<DragDropContext onDragStart={handleDragStart} onDragEnd={handleDragEnd}>
<Droppable droppableId="boards" type={DroppableTypes.BOARD} direction="horizontal">
{({ innerRef, droppableProps, placeholder }) => (
// eslint-disable-next-line react/jsx-props-no-spreading
<div {...droppableProps} ref={innerRef} className={styles.tabs}>
{itemsNode}
{placeholder}
{canEdit && (
<AddPopup onCreate={onCreate} onCopyCard={onCopyCard}>
<Button icon="plus" className={styles.addButton} />
</AddPopup>
)}
</div>
)}
</Droppable>
</DragDropContext>
</div> </div>
)}
</Draggable>
));
return (
<div className={styles.wrapper} onWheel={handleWheel}>
<div ref={tabsWrapper} className={styles.tabsWrapper}>
<DragDropContext onDragStart={handleDragStart} onDragEnd={handleDragEnd}>
<Droppable droppableId="boards" type={DroppableTypes.BOARD} direction="horizontal">
{({ innerRef, droppableProps, placeholder }) => (
// eslint-disable-next-line react/jsx-props-no-spreading
<div {...droppableProps} ref={innerRef} className={styles.tabs}>
{itemsNode}
{placeholder}
{canEdit && (
<AddPopup onCreate={onCreate}>
<Button icon="plus" className={styles.addButton} />
</AddPopup>
)}
</div>
)}
</Droppable>
</DragDropContext>
</div> </div>
); </div>
}, );
); });
Boards.propTypes = { Boards.propTypes = {
items: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types items: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
@ -135,7 +132,6 @@ Boards.propTypes = {
onUpdate: PropTypes.func.isRequired, onUpdate: PropTypes.func.isRequired,
onMove: PropTypes.func.isRequired, onMove: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired, onDelete: PropTypes.func.isRequired,
onCopyCard: PropTypes.func.isRequired,
}; };
Boards.defaultProps = { Boards.defaultProps = {

@ -132,7 +132,6 @@ const ActionsStep = React.memo(
onUserSelect={onUserAdd} onUserSelect={onUserAdd}
onUserDeselect={onUserRemove} onUserDeselect={onUserRemove}
onBack={handleBack} onBack={handleBack}
onCopyCard={onCopyCard}
/> />
); );
case StepTypes.LABELS: case StepTypes.LABELS:
@ -147,7 +146,6 @@ const ActionsStep = React.memo(
onMove={onLabelMove} onMove={onLabelMove}
onDelete={onLabelDelete} onDelete={onLabelDelete}
onBack={handleBack} onBack={handleBack}
onCopyCard={onCopyCard}
/> />
); );
case StepTypes.EDIT_DUE_DATE: case StepTypes.EDIT_DUE_DATE:
@ -157,7 +155,6 @@ const ActionsStep = React.memo(
onUpdate={handleDueDateUpdate} onUpdate={handleDueDateUpdate}
onBack={handleBack} onBack={handleBack}
onClose={onClose} onClose={onClose}
onCopyCard={onCopyCard}
/> />
); );
case StepTypes.EDIT_STOPWATCH: case StepTypes.EDIT_STOPWATCH:
@ -167,7 +164,6 @@ const ActionsStep = React.memo(
onUpdate={handleStopwatchUpdate} onUpdate={handleStopwatchUpdate}
onBack={handleBack} onBack={handleBack}
onClose={onClose} onClose={onClose}
onCopyCard={onCopyCard}
/> />
); );
case StepTypes.MOVE: case StepTypes.MOVE:
@ -180,7 +176,6 @@ const ActionsStep = React.memo(
onBoardFetch={onBoardFetch} onBoardFetch={onBoardFetch}
onBack={handleBack} onBack={handleBack}
onClose={onClose} onClose={onClose}
onCopyCard={onCopyCard}
/> />
); );
case StepTypes.DELETE: case StepTypes.DELETE:
@ -191,7 +186,6 @@ const ActionsStep = React.memo(
buttonContent="action.deleteCard" buttonContent="action.deleteCard"
onConfirm={onDelete} onConfirm={onDelete}
onBack={handleBack} onBack={handleBack}
onCopyCard={onCopyCard}
/> />
); );
case StepTypes.COPY: case StepTypes.COPY:

@ -259,7 +259,6 @@ const CardModal = React.memo(
currentUserIds={userIds} currentUserIds={userIds}
onUserSelect={onUserAdd} onUserSelect={onUserAdd}
onUserDeselect={onUserRemove} onUserDeselect={onUserRemove}
onCopyCard={onCopyCard}
> >
<User name={user.name} avatarUrl={user.avatarUrl} /> <User name={user.name} avatarUrl={user.avatarUrl} />
</BoardMembershipsPopup> </BoardMembershipsPopup>
@ -274,7 +273,6 @@ const CardModal = React.memo(
currentUserIds={userIds} currentUserIds={userIds}
onUserSelect={onUserAdd} onUserSelect={onUserAdd}
onUserDeselect={onUserRemove} onUserDeselect={onUserRemove}
onCopyCard={onCopyCard}
> >
<button <button
type="button" type="button"
@ -306,7 +304,6 @@ const CardModal = React.memo(
onUpdate={onLabelUpdate} onUpdate={onLabelUpdate}
onMove={onLabelMove} onMove={onLabelMove}
onDelete={onLabelDelete} onDelete={onLabelDelete}
onCopyCard={onCopyCard}
> >
<Label name={label.name} color={label.color} /> <Label name={label.name} color={label.color} />
</LabelsPopup> </LabelsPopup>
@ -325,7 +322,6 @@ const CardModal = React.memo(
onUpdate={onLabelUpdate} onUpdate={onLabelUpdate}
onMove={onLabelMove} onMove={onLabelMove}
onDelete={onLabelDelete} onDelete={onLabelDelete}
onCopyCard={onCopyCard}
> >
<button <button
type="button" type="button"
@ -346,15 +342,11 @@ const CardModal = React.memo(
</div> </div>
<span className={styles.attachment}> <span className={styles.attachment}>
{canEdit ? ( {canEdit ? (
<DueDateEditPopup <DueDateEditPopup defaultValue={dueDate} onUpdate={handleDueDateUpdate}>
defaultValue={dueDate} <DueDate value={dueDate} />
onUpdate={handleDueDateUpdate}
onCopyCard={onCopyCard}
>
<DueDate value={dueDate} onCopyCard={onCopyCard} />
</DueDateEditPopup> </DueDateEditPopup>
) : ( ) : (
<DueDate value={dueDate} onCopyCard={onCopyCard} /> <DueDate value={dueDate} />
)} )}
</span> </span>
</div> </div>
@ -372,18 +364,10 @@ const CardModal = React.memo(
defaultValue={stopwatch} defaultValue={stopwatch}
onUpdate={handleStopwatchUpdate} onUpdate={handleStopwatchUpdate}
> >
<Stopwatch <Stopwatch startedAt={stopwatch.startedAt} total={stopwatch.total} />
startedAt={stopwatch.startedAt}
total={stopwatch.total}
onCopyCard={onCopyCard}
/>
</StopwatchEditPopup> </StopwatchEditPopup>
) : ( ) : (
<Stopwatch <Stopwatch startedAt={stopwatch.startedAt} total={stopwatch.total} />
startedAt={stopwatch.startedAt}
total={stopwatch.total}
onCopyCard={onCopyCard}
/>
)} )}
</span> </span>
{canEdit && ( {canEdit && (
@ -409,11 +393,7 @@ const CardModal = React.memo(
<Icon name="align justify" className={styles.moduleIcon} /> <Icon name="align justify" className={styles.moduleIcon} />
<div className={styles.moduleHeader}>{t('common.description')}</div> <div className={styles.moduleHeader}>{t('common.description')}</div>
{canEdit ? ( {canEdit ? (
<DescriptionEdit <DescriptionEdit defaultValue={description} onUpdate={handleDescriptionUpdate}>
defaultValue={description}
onUpdate={handleDescriptionUpdate}
onCopyCard={onCopyCard}
>
{description ? ( {description ? (
<button <button
type="button" type="button"
@ -453,7 +433,6 @@ const CardModal = React.memo(
onUpdate={onTaskUpdate} onUpdate={onTaskUpdate}
onMove={onTaskMove} onMove={onTaskMove}
onDelete={onTaskDelete} onDelete={onTaskDelete}
onCopyCard={onCopyCard}
/> />
</div> </div>
</div> </div>
@ -471,7 +450,6 @@ const CardModal = React.memo(
onCoverUpdate={handleCoverUpdate} onCoverUpdate={handleCoverUpdate}
onGalleryOpen={handleGalleryOpen} onGalleryOpen={handleGalleryOpen}
onGalleryClose={handleGalleryClose} onGalleryClose={handleGalleryClose}
onCopyCard={onCopyCard}
/> />
</div> </div>
</div> </div>
@ -489,7 +467,6 @@ const CardModal = React.memo(
onCommentCreate={onCommentActivityCreate} onCommentCreate={onCommentActivityCreate}
onCommentUpdate={onCommentActivityUpdate} onCommentUpdate={onCommentActivityUpdate}
onCommentDelete={onCommentActivityDelete} onCommentDelete={onCommentActivityDelete}
onCopyCard={onCopyCard}
/> />
</Grid.Column> </Grid.Column>
{canEdit && ( {canEdit && (
@ -501,7 +478,6 @@ const CardModal = React.memo(
currentUserIds={userIds} currentUserIds={userIds}
onUserSelect={onUserAdd} onUserSelect={onUserAdd}
onUserDeselect={onUserRemove} onUserDeselect={onUserRemove}
onCopyCard={onCopyCard}
> >
<Button fluid className={styles.actionButton}> <Button fluid className={styles.actionButton}>
<Icon name="user outline" className={styles.actionIcon} /> <Icon name="user outline" className={styles.actionIcon} />
@ -517,18 +493,13 @@ const CardModal = React.memo(
onUpdate={onLabelUpdate} onUpdate={onLabelUpdate}
onMove={onLabelMove} onMove={onLabelMove}
onDelete={onLabelDelete} onDelete={onLabelDelete}
onCopyCard={onCopyCard}
> >
<Button fluid className={styles.actionButton}> <Button fluid className={styles.actionButton}>
<Icon name="bookmark outline" className={styles.actionIcon} /> <Icon name="bookmark outline" className={styles.actionIcon} />
{t('common.labels')} {t('common.labels')}
</Button> </Button>
</LabelsPopup> </LabelsPopup>
<DueDateEditPopup <DueDateEditPopup defaultValue={dueDate} onUpdate={handleDueDateUpdate}>
defaultValue={dueDate}
onUpdate={handleDueDateUpdate}
onCopyCard={onCopyCard}
>
<Button fluid className={styles.actionButton}> <Button fluid className={styles.actionButton}>
<Icon name="calendar check outline" className={styles.actionIcon} /> <Icon name="calendar check outline" className={styles.actionIcon} />
{t('common.dueDate', { {t('common.dueDate', {
@ -536,17 +507,13 @@ const CardModal = React.memo(
})} })}
</Button> </Button>
</DueDateEditPopup> </DueDateEditPopup>
<StopwatchEditPopup <StopwatchEditPopup defaultValue={stopwatch} onUpdate={handleStopwatchUpdate}>
defaultValue={stopwatch}
onUpdate={handleStopwatchUpdate}
onCopyCard={onCopyCard}
>
<Button fluid className={styles.actionButton}> <Button fluid className={styles.actionButton}>
<Icon name="clock outline" className={styles.actionIcon} /> <Icon name="clock outline" className={styles.actionIcon} />
{t('common.stopwatch')} {t('common.stopwatch')}
</Button> </Button>
</StopwatchEditPopup> </StopwatchEditPopup>
<AttachmentAddPopup onCreate={onAttachmentCreate} onCopyCard={onCopyCard}> <AttachmentAddPopup onCreate={onAttachmentCreate}>
<Button fluid className={styles.actionButton}> <Button fluid className={styles.actionButton}>
<Icon name="attach" className={styles.actionIcon} /> <Icon name="attach" className={styles.actionIcon} />
{t('common.attachment')} {t('common.attachment')}
@ -573,7 +540,6 @@ const CardModal = React.memo(
onMove={onMove} onMove={onMove}
onTransfer={onTransfer} onTransfer={onTransfer}
onBoardFetch={onBoardFetch} onBoardFetch={onBoardFetch}
onCopyCard={onCopyCard}
> >
<Button <Button
fluid fluid

@ -32,7 +32,6 @@ const LabelsStep = React.memo(
onMove, onMove,
onDelete, onDelete,
onBack, onBack,
onCopyCard,
}) => { }) => {
const [t] = useTranslation(); const [t] = useTranslation();
const [step, openStep, handleBack] = useSteps(); const [step, openStep, handleBack] = useSteps();
@ -119,7 +118,6 @@ const LabelsStep = React.memo(
}} }}
onCreate={onCreate} onCreate={onCreate}
onBack={handleBack} onBack={handleBack}
onCopyCard={onCopyCard}
/> />
); );
case StepTypes.EDIT: { case StepTypes.EDIT: {
@ -132,7 +130,6 @@ const LabelsStep = React.memo(
onUpdate={(data) => handleUpdate(currentItem.id, data)} onUpdate={(data) => handleUpdate(currentItem.id, data)}
onDelete={() => handleDelete(currentItem.id)} onDelete={() => handleDelete(currentItem.id)}
onBack={handleBack} onBack={handleBack}
onCopyCard={onCopyCard}
/> />
); );
} }
@ -183,7 +180,6 @@ const LabelsStep = React.memo(
onSelect={() => handleSelect(item.id)} onSelect={() => handleSelect(item.id)}
onDeselect={() => handleDeselect(item.id)} onDeselect={() => handleDeselect(item.id)}
onEdit={() => handleEdit(item.id)} onEdit={() => handleEdit(item.id)}
onCopyCard={onCopyCard}
/> />
))} ))}
{placeholder} {placeholder}
@ -231,14 +227,12 @@ LabelsStep.propTypes = {
onMove: PropTypes.func.isRequired, onMove: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired, onDelete: PropTypes.func.isRequired,
onBack: PropTypes.func, onBack: PropTypes.func,
onCopyCard: PropTypes.func,
}; };
LabelsStep.defaultProps = { LabelsStep.defaultProps = {
title: 'common.labels', title: 'common.labels',
canEdit: true, canEdit: true,
onBack: undefined, onBack: undefined,
onCopyCard: undefined,
}; };
export default LabelsStep; export default LabelsStep;

@ -16,18 +16,7 @@ import { ReactComponent as PlusMathIcon } from '../../assets/images/plus-math-ic
import styles from './List.module.scss'; import styles from './List.module.scss';
const List = React.memo( const List = React.memo(
({ ({ id, index, name, isPersisted, cardIds, canEdit, onUpdate, onDelete, onCardCreate }) => {
id,
index,
name,
isPersisted,
cardIds,
canEdit,
onUpdate,
onDelete,
onCardCreate,
onCopyCard,
}) => {
const [t] = useTranslation(); const [t] = useTranslation();
const [isAddCardOpened, setIsAddCardOpened] = useState(false); const [isAddCardOpened, setIsAddCardOpened] = useState(false);
const [selectedOption, setSelectedOption] = useState('name'); const [selectedOption, setSelectedOption] = useState('name');
@ -134,8 +123,6 @@ const List = React.memo(
onSort={onSort} onSort={onSort}
selectedOption={selectedOption} selectedOption={selectedOption}
setSelectedOption={setSelectedOption} setSelectedOption={setSelectedOption}
onCopyCard={onCopyCard}
id={id}
> >
<Button className={classNames(styles.headerButton, styles.target)}> <Button className={classNames(styles.headerButton, styles.target)}>
<Icon fitted name="pencil" size="small" /> <Icon fitted name="pencil" size="small" />
@ -183,11 +170,6 @@ List.propTypes = {
onUpdate: PropTypes.func.isRequired, onUpdate: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired, onDelete: PropTypes.func.isRequired,
onCardCreate: PropTypes.func.isRequired, onCardCreate: PropTypes.func.isRequired,
onCopyCard: PropTypes.func,
};
List.defaultProps = {
onCopyCard: undefined,
}; };
export default List; export default List;

@ -25,7 +25,6 @@ const mapDispatchToProps = (dispatch) =>
onMove: entryActions.moveBoard, onMove: entryActions.moveBoard,
onDelete: entryActions.deleteBoard, onDelete: entryActions.deleteBoard,
onSort: entryActions.sortBoard, onSort: entryActions.sortBoard,
onCopyCard: entryActions.copyCard,
}, },
dispatch, dispatch,
); );

Loading…
Cancel
Save