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

fix: update comments as responsible #1051

Merged
merged 2 commits into from
Feb 8, 2023
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
15 changes: 9 additions & 6 deletions backend/src/modules/boards/utils/clean-board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export const replaceCard = (
const { anonymous, createdByTeam } = input;
const createdByAsUserDocument = createdBy as UserDocument;

if (hideCards && String(createdByAsUserDocument._id) !== String(userId)) {
if (hideCards && String(createdByAsUserDocument?._id) !== String(userId)) {
text = hideText(input.text);
createdBy = replaceUser(createdByAsUserDocument, userId);
createdBy = createdByAsUserDocument ? replaceUser(createdByAsUserDocument, userId) : null;
}

if (comments?.length > 0) {
Expand Down Expand Up @@ -101,9 +101,9 @@ export const filterVotes = (input: Card | CardItem, userId: string) => {
export const replaceUser = (input: UserDocument, userId: string): LeanDocument<UserDocument> => {
return {
...input,
_id: String(userId) === String(input._id) ? input._id : undefined,
firstName: hideText(input.firstName),
lastName: hideText(input.lastName)
_id: String(userId) === String(input?._id) ? input?._id : undefined,
firstName: hideText(input?.firstName),
lastName: hideText(input?.lastName)
};
};

Expand Down Expand Up @@ -133,7 +133,10 @@ export const replaceComments = (
if (hideCards && String(createdByAsUserDocument._id) !== String(userId)) {
return {
...comment,
createdBy: replaceUser(comment.createdBy as UserDocument, userId),
createdBy:
comment.createdBy && userId
? replaceUser(comment.createdBy as UserDocument, userId)
: null,
text: hideText(text)
};
}
Expand Down
1 change: 0 additions & 1 deletion backend/src/modules/cards/dto/card.item.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default class CardItemDto {
text!: string;

@ApiPropertyOptional({ description: 'User Id' })
@IsNotEmpty()
createdBy?: string;

@ApiProperty({ type: CommentDto, isArray: true })
Expand Down
11 changes: 3 additions & 8 deletions backend/src/modules/comments/services/update.comment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export default class UpdateCommentServiceImpl implements UpdateCommentService {
.findOneAndUpdate(
{
_id: boardId,
'columns.cards.items.comments._id': commentId,
'columns.cards.items.comments.createdBy': userId
'columns.cards.items.comments._id': commentId
},
{
$set: {
Expand All @@ -32,11 +31,7 @@ export default class UpdateCommentServiceImpl implements UpdateCommentService {
}
},
{
arrayFilters: [
{ 'c._id': cardId },
{ 'i._id': cardItemId },
{ 'com._id': commentId, 'com.createdBy': userId }
],
arrayFilters: [{ 'c._id': cardId }, { 'i._id': cardItemId }, { 'com._id': commentId }],
new: true
}
)
Expand Down Expand Up @@ -66,7 +61,7 @@ export default class UpdateCommentServiceImpl implements UpdateCommentService {
}
},
{
arrayFilters: [{ 'c._id': cardId }, { 'com._id': commentId, 'com.createdBy': userId }],
arrayFilters: [{ 'c._id': cardId }, { 'com._id': commentId }],
new: true
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export class SlackMergeBoardApplication implements MergeBoardApplicationInterfac
const message = `<!here>, The board of team ${teamNumber} is ready`;
this.chatHandler.postMessage(responsiblesChannelId, message);

await new Promise((r) => setTimeout(r, 1000));

if (isLastSubBoard) {
const responsiblesMessage = `All sub-boards merged! Here's the complete board: ${this.frontendUrl}/boards/${data.mainBoardId}`;
this.chatHandler.postMessage(responsiblesChannelId, responsiblesMessage);
Expand Down
17 changes: 0 additions & 17 deletions frontend/src/components/Board/Card/CardItem/CardItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, { useState } from 'react';
import { styled } from '@/styles/stitches/stitches.config';

import AddCardOrComment from '@/components/Board/AddCardOrComment';
import Icon from '@/components/icons/Icon';
import Flex from '@/components/Primitives/Flex';
import Text from '@/components/Primitives/Text';
import { CardItemType } from '@/types/card/cardItem';
Expand Down Expand Up @@ -81,22 +80,6 @@ const CardItem: React.FC<CardItemProps> = React.memo(
>
{item.text}
</Text>
{isSubmited && (
<Flex
css={{
position: 'relative',
top: firstOne ? '-35px' : 0,
}}
>
<Icon
name="menu-dots"
css={{
width: '$20',
height: '$20',
}}
/>
</Flex>
)}
{!isSubmited &&
((userId === item?.createdBy?._id && !isMainboard) || hasAdminRole) && (
<PopoverCardSettings
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/Board/Column/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getCardVotes } from '@/helper/board/votes';
import { ColumnBoardType } from '@/types/column';
import { useSetRecoilState } from 'recoil';
import { filteredColumnsState } from '@/store/board/atoms/filterColumns';
import { countColumnCards } from '@/helper/board/countCards';
import AddCardOrComment from '../AddCardOrComment';
import CardsList from './CardsList';
import SortMenu from './partials/SortMenu';
Expand Down Expand Up @@ -127,7 +128,7 @@ const Column = React.memo<ColumMemoProps>(
py: '$2',
}}
>
{cards.length} cards
{countColumnCards(cards)} cards
</Text>
</Flex>
<Flex>
Expand Down
10 changes: 0 additions & 10 deletions frontend/src/components/Board/Comment/Comment.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState } from 'react';

import Icon from '@/components/icons/Icon';
import Flex from '@/components/Primitives/Flex';
import Text from '@/components/Primitives/Text';
import useComments from '@/hooks/useComments';
Expand Down Expand Up @@ -82,15 +81,6 @@ const Comment: React.FC<CommentProps> = React.memo(
>
{comment.text}
</Text>
{isSubmited && userId === comment.createdBy._id && (
<Icon
name="menu-dots"
css={{
width: '$20',
height: '$20',
}}
/>
)}
{!isSubmited &&
((userId === comment.createdBy._id && !isMainboard) || hasAdminRole) && (
<PopoverCommentSettings
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/helper/board/countCards.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import CardType from '@/types/card/card';
import ColumnType from '@/types/column';

export const countBoardCards = (columns: ColumnType[]) =>
Expand All @@ -7,3 +8,9 @@ export const countBoardCards = (columns: ColumnType[]) =>
});
return acc;
}, 0);

export const countColumnCards = (cards: CardType[]) =>
cards.reduce((acc, card) => {
acc += card.items.length;
return acc;
}, 0);
2 changes: 1 addition & 1 deletion frontend/src/hooks/useCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const useCards = () => {
setToastState({
open: true,
type: ToastStateEnum.SUCCESS,
content: 'Card deleted with success!',
content: 'Card deleted!',
});
},
onError: (_, variables) => {
Expand Down