Skip to content

Commit c5faa76

Browse files
committed
feat(OUT-1381) : enabled images and attachments in comment card and comment input.
1 parent 1f10853 commit c5faa76

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/components/AttachmentLayout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const AttachmentLayout: React.FC<AttachmentLayoutProps> = ({ selected, src, file
3030
padding: { sm: '4px 8px', md: '4px 12px 4px 8px' },
3131
border: (theme) => `1px solid ${theme.color.gray[selected ? 600 : 150]}`,
3232
background: '#fff',
33-
boxShadow: '0px 3px 4px 0px rgba(16, 17, 19, 0.06), 0px 4px 11px 0px rgba(20, 21, 24, 0.18)',
3433

3534
'@media (max-width: 600px)': {
3635
'&:active': {

src/components/cards/CommentCard.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { DotSeparator } from '@/app/detail/ui/DotSeparator'
44
import { BoldTypography, CommentCardContainer, StyledModal, StyledTypography } from '@/app/detail/ui/styledComponent'
5+
import AttachmentLayout from '@/components/AttachmentLayout'
56
import { ListBtn } from '@/components/buttons/ListBtn'
67
import { PrimaryBtn } from '@/components/buttons/PrimaryBtn'
78
import { MenuBox } from '@/components/inputs/MenuBox'
@@ -127,6 +128,7 @@ export const CommentCard = ({
127128
getContent={() => {}}
128129
readonly
129130
editorClass="tapwrite-comment"
131+
attachmentLayout={AttachmentLayout}
130132
/>
131133

132134
{Array.isArray((comment as LogResponse).details?.replies) &&
@@ -150,6 +152,7 @@ export const CommentCard = ({
150152
getContent={() => {}}
151153
readonly
152154
editorClass="tapwrite-comment"
155+
attachmentLayout={AttachmentLayout}
153156
/>
154157
</Stack>
155158
)
@@ -168,6 +171,7 @@ export const CommentCard = ({
168171
placeholder="Leave a reply..."
169172
suggestions={assigneeSuggestions}
170173
editorClass="tapwrite-reply-input"
174+
attachmentLayout={AttachmentLayout}
171175
/>
172176
<InputAdornment
173177
position="end"

src/components/inputs/CommentInput.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
import { CommentCardContainer } from '@/app/detail/ui/styledComponent'
44
import { CopilotAvatar } from '@/components/atoms/CopilotAvatar'
5+
import AttachmentLayout from '@/components/AttachmentLayout'
6+
import { MAX_UPLOAD_LIMIT } from '@/constants/attachments'
57
import { selectAuthDetails } from '@/redux/features/authDetailsSlice'
68
import { selectTaskBoard } from '@/redux/features/taskBoardSlice'
79
import { selectTaskDetails } from '@/redux/features/taskDetailsSlice'
810
import { CreateComment } from '@/types/dto/comment.dto'
911
import { getMentionsList } from '@/utils/getMentionList'
12+
import { deleteEditorAttachmentsHandler, uploadImageHandler } from '@/utils/inlineImage'
1013
import { ArrowUpward } from '@mui/icons-material'
1114
import { IconButton, InputAdornment, Stack } from '@mui/material'
1215
import { useEffect, useState } from 'react'
@@ -23,7 +26,7 @@ export const CommentInput = ({ createComment, task_id }: Prop) => {
2326
const [isListOrMenuActive, setIsListOrMenuActive] = useState(false)
2427
const { assigneeSuggestions } = useSelector(selectTaskDetails)
2528
const { tokenPayload } = useSelector(selectAuthDetails)
26-
const { assignee } = useSelector(selectTaskBoard)
29+
const { assignee, token, activeTask } = useSelector(selectTaskBoard)
2730
const currentUserId = tokenPayload?.internalUserId ?? tokenPayload?.clientId
2831
const currentUserDetails = assignee.find((el) => el.id === currentUserId)
2932

@@ -77,6 +80,15 @@ export const CommentInput = ({ createComment, task_id }: Prop) => {
7780
}
7881
}, [detail, isListOrMenuActive]) // Depend on detail to ensure the latest state is captured
7982

83+
const uploadFn = token
84+
? async (file: File) => {
85+
if (activeTask) {
86+
const fileUrl = await uploadImageHandler(file, token ?? '', activeTask.workspaceId, task_id)
87+
return fileUrl
88+
}
89+
}
90+
: undefined
91+
8092
return (
8193
<Stack direction="row" columnGap={2} alignItems="flex-start">
8294
<CopilotAvatar
@@ -99,7 +111,7 @@ export const CommentInput = ({ createComment, task_id }: Prop) => {
99111
content={detail}
100112
getContent={setDetail}
101113
placeholder="Leave a comment..."
102-
suggestions={assigneeSuggestions}
114+
// suggestions={assigneeSuggestions} enable this for mentions
103115
editorClass="tapwrite-comment-input"
104116
hardbreak
105117
onActiveStatusChange={(prop) => {
@@ -113,6 +125,11 @@ export const CommentInput = ({ createComment, task_id }: Prop) => {
113125
display: 'flex',
114126
flexDirection: 'column',
115127
}}
128+
uploadFn={uploadFn}
129+
deleteEditorAttachments={(url) => deleteEditorAttachmentsHandler(url, token ?? '', task_id, null)}
130+
attachmentLayout={AttachmentLayout}
131+
addAttachmentButton
132+
maxUploadLimit={MAX_UPLOAD_LIMIT}
116133
/>
117134
<InputAdornment
118135
position="end"

0 commit comments

Comments
 (0)