diff --git a/backend/src/modules/schedules/services/create.schedules.service.ts b/backend/src/modules/schedules/services/create.schedules.service.ts index 4157d48d9..9dde61783 100644 --- a/backend/src/modules/schedules/services/create.schedules.service.ts +++ b/backend/src/modules/schedules/services/create.schedules.service.ts @@ -3,7 +3,6 @@ import { InjectModel } from '@nestjs/mongoose'; import { SchedulerRegistry } from '@nestjs/schedule'; import { CronJob } from 'cron'; import { LeanDocument, Model } from 'mongoose'; -import { DELETE_FAILED } from 'src/libs/exceptions/messages'; import { getDay, getNextMonth } from 'src/libs/utils/dates'; import { Configs, @@ -83,6 +82,11 @@ export class CreateSchedulesService implements CreateSchedulesServiceInterface { new Date().getUTCMonth() === 11 && newMonth === 0 ? new Date().getFullYear() + 1 : new Date().getFullYear(); + + const job = new CronJob(`${minutes} ${hours} ${day} ${newMonth} *`, () => + this.handleComplete(String(ownerId), teamId, String(boardId)) + ); + const cronJobDoc = await this.schedulesModel.create({ board: String(boardId), team: String(teamId), @@ -93,14 +97,10 @@ export class CreateSchedulesService implements CreateSchedulesServiceInterface { if (!cronJobDoc) throw Error('CronJob not created'); - const job = new CronJob(`${minutes} ${hours} ${day} ${newMonth} *`, () => - this.handleComplete(String(ownerId), teamId, cronJobDoc.board.toString()) - ); this.schedulerRegistry.addCronJob(String(boardId), job); job.start(); } catch (e) { - this.logger.log(e); - await this.schedulesModel.deleteOne({ board: boardId }); + this.logger.error(e); } } @@ -136,7 +136,7 @@ export class CreateSchedulesService implements CreateSchedulesServiceInterface { this.createSchedule(oldBoard, deletedSchedule, ownerId, teamId, oldBoardId); } catch (e) { - throw Error(DELETE_FAILED); + this.logger.error(e); } } diff --git a/frontend/src/components/Board/AddCardOrComment.tsx b/frontend/src/components/Board/AddCardOrComment.tsx index 365e847b6..bb3f38aa6 100644 --- a/frontend/src/components/Board/AddCardOrComment.tsx +++ b/frontend/src/components/Board/AddCardOrComment.tsx @@ -63,7 +63,7 @@ const AddCard = React.memo( mode: 'onSubmit', reValidateMode: 'onChange', defaultValues: { - text: '', + text: cardText === 'Write your comment here...' ? '' : cardText, }, resolver: joiResolver(SchemaAddCommentForm), }); diff --git a/frontend/src/components/Board/Card/CardBoard.tsx b/frontend/src/components/Board/Card/CardBoard.tsx index 19782ab8c..99d6b7fd8 100644 --- a/frontend/src/components/Board/Card/CardBoard.tsx +++ b/frontend/src/components/Board/Card/CardBoard.tsx @@ -40,6 +40,7 @@ interface CardBoardProps { hideCards: boolean; isDefaultText: boolean; cardText?: string; + hasAdminRole: boolean; } const CardBoard = React.memo( @@ -57,6 +58,7 @@ const CardBoard = React.memo( isSubmited, hideCards, isDefaultText, + hasAdminRole, }) => { const isCardGroup = card.items.length > 1; const comments = useMemo( @@ -163,11 +165,7 @@ const CardBoard = React.memo( > {card.text} - {isSubmited && ( - - )} - - {!isSubmited && userId === card?.createdBy?._id && ( + {!isSubmited && (userId === card?.createdBy?._id || hasAdminRole) && ( ( newPosition={0} socketId={socketId} userId={userId} + hasAdminRole={hasAdminRole} /> )} @@ -200,6 +199,7 @@ const CardBoard = React.memo( socketId={socketId} userId={userId} isDefaultText={isDefaultText} + hasAdminRole={hasAdminRole} /> )} ( userId={userId} columnId={colId} isDefaultText={isDefaultText} + hasAdminRole={hasAdminRole} /> )} diff --git a/frontend/src/components/Board/Card/CardFooter.tsx b/frontend/src/components/Board/Card/CardFooter.tsx index 2374165fa..6d7406f36 100644 --- a/frontend/src/components/Board/Card/CardFooter.tsx +++ b/frontend/src/components/Board/Card/CardFooter.tsx @@ -152,6 +152,7 @@ const CardFooter = ({ gap="4" css={{ filter: cardFooterBlur(hideCards, createdBy, userId), + maxWidth: '$226', }} > - + {createdBy?.firstName} {createdBy?.lastName} diff --git a/frontend/src/components/Board/Card/CardItem/CardItem.tsx b/frontend/src/components/Board/Card/CardItem/CardItem.tsx index e56a86b80..6baf95069 100644 --- a/frontend/src/components/Board/Card/CardItem/CardItem.tsx +++ b/frontend/src/components/Board/Card/CardItem/CardItem.tsx @@ -28,6 +28,7 @@ interface CardItemProps { isSubmited: boolean; hideCards: boolean; isDefaultText: boolean; + hasAdminRole: boolean; } const Container = styled(Flex, { @@ -53,6 +54,7 @@ const CardItem: React.FC = React.memo( isSubmited, hideCards, isDefaultText, + hasAdminRole, }) => { const [editing, setEditing] = useState(false); const [deleting, setDeleting] = useState(false); @@ -111,6 +113,7 @@ const CardItem: React.FC = React.memo( newPosition={cardGroupPosition} socketId={socketId} userId={userId} + hasAdminRole={hasAdminRole} /> )} diff --git a/frontend/src/components/Board/Card/CardItem/CardItemList.tsx b/frontend/src/components/Board/Card/CardItem/CardItemList.tsx index 06d2d8594..2ba5d048c 100644 --- a/frontend/src/components/Board/Card/CardItem/CardItemList.tsx +++ b/frontend/src/components/Board/Card/CardItem/CardItemList.tsx @@ -17,6 +17,7 @@ interface CardItemListProps { isSubmited: boolean; hideCards: boolean; isDefaultText: boolean; + hasAdminRole: boolean; } const CardItemList: React.FC = ({ @@ -32,6 +33,7 @@ const CardItemList: React.FC = ({ isSubmited, hideCards, isDefaultText, + hasAdminRole, }) => ( {items.map((item, idx) => ( @@ -63,6 +65,7 @@ const CardItemList: React.FC = ({ socketId={socketId} userId={userId} isDefaultText={isDefaultText} + hasAdminRole={hasAdminRole} /> ))} diff --git a/frontend/src/components/Board/Card/PopoverSettings.tsx b/frontend/src/components/Board/Card/PopoverSettings.tsx index 10a4d0791..5f0f9c44d 100644 --- a/frontend/src/components/Board/Card/PopoverSettings.tsx +++ b/frontend/src/components/Board/Card/PopoverSettings.tsx @@ -88,6 +88,7 @@ interface PopoverSettingsProps { hideCards: boolean; userId: string; item: CardItemType; + hasAdminRole: boolean; handleEditing: () => void; handleDeleteCard?: () => void; } @@ -126,6 +127,7 @@ const PopoverCardSettings: React.FC = React.memo( item, userId, hideCards, + hasAdminRole, }) => { const [openPopover, setOpenPopover] = useState(false); @@ -171,7 +173,7 @@ const PopoverCardSettings: React.FC = React.memo( ( isSubmited, hideCards, isDefaultText, + hasAdminRole, }) => ( <> {cards.map((card: CardType, idx) => ( @@ -36,6 +37,7 @@ const CardsList = React.memo( socketId={socketId} userId={userId} isDefaultText={isDefaultText || true} + hasAdminRole={hasAdminRole} /> ))} diff --git a/frontend/src/components/Board/Column/Column.tsx b/frontend/src/components/Board/Column/Column.tsx index 3bf958275..d60845142 100644 --- a/frontend/src/components/Board/Column/Column.tsx +++ b/frontend/src/components/Board/Column/Column.tsx @@ -171,6 +171,7 @@ const Column = React.memo( maxVotes={maxVotes} socketId={socketId} userId={userId} + hasAdminRole={hasAdminRole} /> {provided.placeholder} diff --git a/frontend/src/components/Board/Column/styles.tsx b/frontend/src/components/Board/Column/styles.tsx index bfd9ef227..dec15eca7 100644 --- a/frontend/src/components/Board/Column/styles.tsx +++ b/frontend/src/components/Board/Column/styles.tsx @@ -37,8 +37,7 @@ const Container = styled(Flex, Box, { const OuterContainer = styled(Flex, { height: 'fit-content', - - flex: '1', + flex: '1 1 0', flexGrow: 1, flexShrink: 0, width: '100%', diff --git a/frontend/src/components/Board/Comment/Comment.tsx b/frontend/src/components/Board/Comment/Comment.tsx index b0d846e99..7c00a88df 100644 --- a/frontend/src/components/Board/Comment/Comment.tsx +++ b/frontend/src/components/Board/Comment/Comment.tsx @@ -21,6 +21,7 @@ interface CommentProps { userId: string; columnId: string; isDefaultText: boolean; + hasAdminRole: boolean; } const Comment: React.FC = React.memo( @@ -35,6 +36,7 @@ const Comment: React.FC = React.memo( userId, columnId, isDefaultText, + hasAdminRole, }) => { const { deleteComment } = useComments(); const [editing, setEditing] = useState(false); @@ -88,20 +90,23 @@ const Comment: React.FC = React.memo( }} /> )} - {!isSubmited && userId === comment.createdBy._id && ( + {!isSubmited && (userId === comment.createdBy._id || hasAdminRole) && ( )} - + {!comment.anonymous && ( {comment.createdBy.firstName} {comment.createdBy.lastName} diff --git a/frontend/src/components/Board/Comment/Comments.tsx b/frontend/src/components/Board/Comment/Comments.tsx index ed69de6ac..ad68b7bb6 100644 --- a/frontend/src/components/Board/Comment/Comments.tsx +++ b/frontend/src/components/Board/Comment/Comments.tsx @@ -20,6 +20,7 @@ interface CommentsListProps { userId: string; columnId: string; isDefaultText: boolean; + hasAdminRole: boolean; } const Comments = React.memo( @@ -34,6 +35,7 @@ const Comments = React.memo( userId, columnId, isDefaultText, + hasAdminRole, }: CommentsListProps) => { const [isCreateCommentOpened, setCreateComment] = useState(false); @@ -67,6 +69,7 @@ const Comments = React.memo( userId={userId} columnId={columnId} isDefaultText={isDefaultText} + hasAdminRole={hasAdminRole} cardItemId={ cardItems.find((item) => { if (item && item.comments) diff --git a/frontend/src/components/Boards/TeamHeader.tsx b/frontend/src/components/Boards/TeamHeader.tsx index e3f4d4623..63c19f237 100644 --- a/frontend/src/components/Boards/TeamHeader.tsx +++ b/frontend/src/components/Boards/TeamHeader.tsx @@ -48,7 +48,13 @@ const TeamHeader: React.FC = ({ team, userId, users }) => { Team admin - + )} {!hasTeam && users && ( diff --git a/frontend/src/components/CardBoard/CardAvatars.tsx b/frontend/src/components/CardBoard/CardAvatars.tsx index 3f8a10acf..34966aa8c 100644 --- a/frontend/src/components/CardBoard/CardAvatars.tsx +++ b/frontend/src/components/CardBoard/CardAvatars.tsx @@ -56,6 +56,12 @@ const CardAvatars = React.memo( .filter((user) => user.role === BoardUserRoles.RESPONSIBLE) .map((user) => user.user); + if (teamAdmins && stakeholders) { + return listUsers + .filter((user) => ![TeamUserRoles.MEMBER, BoardUserRoles.MEMBER].includes(user.role)) + .map((user) => user.user); + } + if (teamAdmins) return listUsers .filter((user) => user.role === TeamUserRoles.ADMIN) @@ -193,12 +199,16 @@ const CardAvatars = React.memo( {haveError ? ['-', '-', '-'].map((value, index) => - renderAvatar(value, stakeholders ? stakeholdersColors : undefined, index), + renderAvatar( + value, + stakeholders && !teamAdmins ? stakeholdersColors : undefined, + index, + ), ) : (data.slice(0, numberOfAvatars) as User[]).map((user: User, index: number) => renderAvatar( getInitials(user, index), - stakeholders ? stakeholdersColors : undefined, + stakeholders && !teamAdmins ? stakeholdersColors : undefined, index, ), )} diff --git a/frontend/src/components/Teams/TeamsList/partials/CardTeam/CardBody.tsx b/frontend/src/components/Teams/TeamsList/partials/CardTeam/CardBody.tsx index 6c761a084..96ade7142 100644 --- a/frontend/src/components/Teams/TeamsList/partials/CardTeam/CardBody.tsx +++ b/frontend/src/components/Teams/TeamsList/partials/CardTeam/CardBody.tsx @@ -120,7 +120,13 @@ const CardBody = React.memo(({ userId, teamId, team, isTeamPage } Team admin - +