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

@ -14,118 +14,115 @@ import EditStep from './EditStep';
import styles from './Boards.module.scss';
const Boards = React.memo(
({ items, currentId, canEdit, onCreate, onUpdate, onMove, onDelete, onCopyCard }) => {
const tabsWrapper = useRef(null);
const Boards = React.memo(({ items, currentId, canEdit, onCreate, onUpdate, onMove, onDelete }) => {
const tabsWrapper = useRef(null);
const handleWheel = useCallback(({ deltaY }) => {
tabsWrapper.current.scrollBy({
left: deltaY,
});
}, []);
const handleWheel = useCallback(({ deltaY }) => {
tabsWrapper.current.scrollBy({
left: deltaY,
});
}, []);
const handleDragStart = useCallback(() => {
closePopup();
}, []);
const handleDragStart = useCallback(() => {
closePopup();
}, []);
const handleDragEnd = useCallback(
({ draggableId, source, destination }) => {
if (!destination || source.index === destination.index) {
return;
}
const handleDragEnd = useCallback(
({ draggableId, source, destination }) => {
if (!destination || source.index === destination.index) {
return;
}
onMove(draggableId, destination.index);
},
[onMove],
);
onMove(draggableId, destination.index);
},
[onMove],
);
const handleUpdate = useCallback(
(id, data) => {
onUpdate(id, data);
},
[onUpdate],
);
const handleUpdate = useCallback(
(id, data) => {
onUpdate(id, data);
},
[onUpdate],
);
const handleDelete = useCallback(
(id) => {
onDelete(id);
},
[onDelete],
);
const handleDelete = useCallback(
(id) => {
onDelete(id);
},
[onDelete],
);
const AddPopup = usePopup(AddStep);
const EditPopup = usePopup(EditStep);
const AddPopup = usePopup(AddStep);
const EditPopup = usePopup(EditStep);
const itemsNode = items.map((item, index) => (
<Draggable
key={item.id}
draggableId={item.id}
index={index}
isDragDisabled={!item.isPersisted || !canEdit}
>
{({ innerRef, draggableProps, dragHandleProps }) => (
// eslint-disable-next-line react/jsx-props-no-spreading
<div {...draggableProps} ref={innerRef} className={styles.tabWrapper}>
<div className={classNames(styles.tab, item.id === currentId && styles.tabActive)}>
{item.isPersisted ? (
<>
<Link
{...dragHandleProps} // eslint-disable-line react/jsx-props-no-spreading
to={Paths.BOARDS.replace(':id', item.id)}
title={item.name}
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}>
const itemsNode = items.map((item, index) => (
<Draggable
key={item.id}
draggableId={item.id}
index={index}
isDragDisabled={!item.isPersisted || !canEdit}
>
{({ innerRef, draggableProps, dragHandleProps }) => (
// eslint-disable-next-line react/jsx-props-no-spreading
<div {...draggableProps} ref={innerRef} className={styles.tabWrapper}>
<div className={classNames(styles.tab, item.id === currentId && styles.tabActive)}>
{item.isPersisted ? (
<>
<Link
{...dragHandleProps} // eslint-disable-line react/jsx-props-no-spreading
to={Paths.BOARDS.replace(':id', item.id)}
title={item.name}
className={styles.link}
>
{item.name}
</span>
)}
</div>
</Link>
{canEdit && (
<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>
)}
</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>
)}
</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>
);
});
Boards.propTypes = {
items: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
@ -135,7 +132,6 @@ Boards.propTypes = {
onUpdate: PropTypes.func.isRequired,
onMove: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
onCopyCard: PropTypes.func.isRequired,
};
Boards.defaultProps = {

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

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

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

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

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

Loading…
Cancel
Save