Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Comment on Hidden card #471

Merged
merged 1 commit into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion frontend/src/components/Board/Card/CardBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,16 @@ const CardBoard = React.memo<CardBoardProps>(
const [editing, setEditing] = useState(false);
const [deleting, setDeleting] = useState(false);

const createdBy = useMemo(() => {
if (Object.hasOwnProperty.call(card, 'items')) {
const cardTyped = card as CardType;
return cardTyped.items[cardTyped.items.length - 1].createdBy;
}
return card.createdBy;
}, [card]);

const handleOpenComments = () => {
if (hideCards && card.createdBy?._id !== userId) return;
if (hideCards && createdBy?._id !== userId) return;
setOpenComments(!isCommentsOpened);
};

Expand Down
19 changes: 14 additions & 5 deletions frontend/src/components/Board/Card/CardFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ const CardFooter = React.memo<FooterProps>(

const handleDeleteVote = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
event.stopPropagation();
if (hideCards && card.createdBy?._id !== userId) return;
if (hideCards && createdBy?._id !== userId) return;
if (user && user.votesCount + countVotes <= 0) return;
setDisableVoteButton(true);
setCountVotes(countVotes - 1);
};

const handleAddVote = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
event.stopPropagation();
if (hideCards && card.createdBy?._id !== userId) return;
if (hideCards && createdBy?._id !== userId) return;
if (maxVotes && user && user.votesCount >= maxVotes) return;
if (maxVotes && user && user.votesCount + countVotes >= maxVotes) return;

Expand Down Expand Up @@ -200,7 +200,12 @@ const CardFooter = React.memo<FooterProps>(
disableVoteButton ||
!isMainboard ||
!!disableVotes ||
!!(user && maxVotes && user.votesCount + countVotes >= maxVotes)
!!(
user &&
maxVotes &&
user.votesCount + countVotes >= maxVotes
) ||
(hideCards && createdBy?._id !== userId)
}
onClick={handleAddVote}
>
Expand Down Expand Up @@ -231,7 +236,8 @@ const CardFooter = React.memo<FooterProps>(
!isMainboard ||
votesInThisCard.length === 0 ||
!!(user && maxVotes && user.votesCount + countVotes <= 0) ||
votesOfUserInThisCard === 0
votesOfUserInThisCard === 0 ||
(hideCards && createdBy?._id !== userId)
}
onClick={handleDeleteVote}
>
Expand All @@ -246,7 +252,10 @@ const CardFooter = React.memo<FooterProps>(
filter: cardFooterBlur(hideCards, createdBy, userId)
}}
>
<StyledButtonIcon onClick={setOpenComments}>
<StyledButtonIcon
disabled={hideCards && createdBy?._id !== userId}
onClick={setOpenComments}
>
<Icon name={isCommentsOpened ? 'comment-filled' : 'comment'} />
</StyledButtonIcon>
<Text
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Board/DragDropArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const DragDropArea: React.FC<Props> = ({ userId, board, socketId }) => {
}
const { droppableId: sourceDroppableId, index: sourceIndex } = source;

if (combine && userId) {
if (combine && userId && board.hideCards === false) {
const { droppableId: combineDroppableId, draggableId: combineDraggableId } = combine;

const changes: MergeCardsDto = {
Expand Down