@@ -35,6 +35,9 @@ import type { SelectorItems, User } from '../../../../common/types/core';
3535import type { GetAvatarUrlCallback , GetProfileUrlCallback } from '../../../common/flowTypes' ;
3636import type { Translations } from '../../flowTypes' ;
3737
38+ import { type OnAnnotationEdit , type OnCommentEdit } from '../comment/types' ;
39+ import AnnotationActivityLinkProvider from './AnnotationActivityLinkProvider' ;
40+
3841type Props = {
3942 activeFeedItem : FeedItem ,
4043 activeFeedItemRef : { current : null | HTMLElement } ,
@@ -51,20 +54,12 @@ type Props = {
5154 items : FeedItems ,
5255 mentionSelectorContacts ?: SelectorItems < > ,
5356 onAnnotationDelete ?: ( { id : string , permissions : AnnotationPermission } ) => void ,
54- onAnnotationEdit ?: ( id : string , text : string , permissions : AnnotationPermission ) => void ,
57+ onAnnotationEdit ? : OnAnnotationEdit ,
5558 onAnnotationSelect ?: ( annotation : Annotation ) => void ,
5659 onAnnotationStatusChange ?: ( id : string , status : FeedItemStatus , permissions : AnnotationPermission ) => void ,
5760 onAppActivityDelete ?: Function ,
5861 onCommentDelete ?: Function ,
59- onCommentEdit ?: (
60- id : string ,
61- text ?: string ,
62- status ?: FeedItemStatus ,
63- hasMention : boolean ,
64- permissions : BoxCommentPermission ,
65- onSuccess : ?Function ,
66- onError : ?Function ,
67- ) => void ,
62+ onCommentEdit ?: OnCommentEdit ,
6863 onCommentSelect ?: ( id : string | null ) => void ,
6964 onHideReplies ?: ( id : string , replies : Array < CommentType > ) => void ,
7065 onReplyCreate ?: ( parentId : string , parentType : CommentFeedItemType , text : string ) => void ,
@@ -163,6 +158,28 @@ const ActiveState = ({
163158 onReplySelect : onCommentSelectHandler ( item . id ) ,
164159 } ;
165160
161+ const commentAndAnnotationCommonProps = {
162+ ...item ,
163+ ...replyProps ,
164+ currentUser,
165+ getAvatarUrl,
166+ getMentionWithQuery,
167+ getUserProfileUrl,
168+ mentionSelectorContacts,
169+ onHideReplies : shownReplies => onHideReplies ( item . id , shownReplies ) ,
170+ onSelect : onCommentSelectHandler ( item . id ) ,
171+ permissions : {
172+ can_delete : getProp ( item . permissions , 'can_delete' , false ) ,
173+ can_edit : getProp ( item . permissions , 'can_edit' , false ) ,
174+ can_reply : getProp ( item . permissions , 'can_reply' , false ) ,
175+ can_resolve : getProp ( item . permissions , 'can_resolve' , false ) ,
176+ } ,
177+ // TODO: legitimate, pre-existing typing issue that was previously undetected
178+ // $FlowFixMe
179+ repliesTotalCount : item . total_reply_count ,
180+ translations,
181+ } ;
182+
166183 switch ( item . type ) {
167184 case FEED_ITEM_TYPE_COMMENT :
168185 return (
@@ -175,28 +192,15 @@ const ActiveState = ({
175192 ref = { refValue }
176193 >
177194 { hasNewThreadedReplies ? (
195+ // TODO: legitimate, pre-existing typing issue that was previously undetected
196+ // Conflict between BoxCommentPermissions and BoxTaskPermissions
197+ // $FlowFixMe
178198 < BaseComment
179- { ...item }
180- { ...replyProps }
181- currentUser = { currentUser }
182- getAvatarUrl = { getAvatarUrl }
183- getMentionWithQuery = { getMentionWithQuery }
184- getUserProfileUrl = { getUserProfileUrl }
185- mentionSelectorContacts = { mentionSelectorContacts }
199+ { ...commentAndAnnotationCommonProps }
186200 onDelete = { onCommentDelete }
187- onEdit = { onCommentEdit }
201+ onCommentEdit = { onCommentEdit }
188202 onReplyCreate = { reply => onReplyCreate ( item . id , FEED_ITEM_TYPE_COMMENT , reply ) }
189- onSelect = { onCommentSelectHandler ( item . id ) }
190203 onShowReplies = { ( ) => onShowReplies ( item . id , FEED_ITEM_TYPE_COMMENT ) }
191- onHideReplies = { shownReplies => onHideReplies ( item . id , shownReplies ) }
192- permissions = { {
193- can_delete : getProp ( item . permissions , 'can_delete' , false ) ,
194- can_edit : getProp ( item . permissions , 'can_edit' , false ) ,
195- can_reply : getProp ( item . permissions , 'can_reply' , false ) ,
196- can_resolve : getProp ( item . permissions , 'can_resolve' , false ) ,
197- } }
198- repliesTotalCount = { item . total_reply_count }
199- translations = { translations }
200204 />
201205 ) : (
202206 < ActivityThread
@@ -296,45 +300,70 @@ const ActiveState = ({
296300 key = { item . type + item . id }
297301 className = "bcs-activity-feed-annotation-activity"
298302 data-testid = "annotation-activity"
303+ isHoverable
304+ hasNewThreadedReplies = { hasNewThreadedReplies }
299305 isFocused = { isFocused }
300306 ref = { refValue }
301307 >
302- < ActivityThread
303- data-testid = "activity-thread"
304- currentUser = { currentUser }
305- getAvatarUrl = { getAvatarUrl }
306- getMentionWithQuery = { getMentionWithQuery }
307- getUserProfileUrl = { getUserProfileUrl }
308- hasNewThreadedReplies = { hasNewThreadedReplies }
309- hasReplies = { hasReplies }
310- isPending = { item . isPending }
311- isRepliesLoading = { item . isRepliesLoading }
312- mentionSelectorContacts = { mentionSelectorContacts }
313- onHideReplies = { onHideRepliesHandler ( item . id ) }
314- onReplyCreate = { onReplyCreateHandler ( item . id , item . type ) }
315- onReplyDelete = { onReplyDeleteHandler ( item . id ) }
316- onReplyEdit = { onReplyUpdateHandler ( item . id ) }
317- onReplySelect = { onCommentSelectHandler ( item . id ) }
318- onShowReplies = { onShowRepliesHandler ( item . id , item . type ) }
319- repliesTotalCount = { item . total_reply_count }
320- replies = { item . replies }
321- translations = { translations }
322- >
323- < AnnotationActivity
308+ { hasNewThreadedReplies && onAnnotationSelect ? (
309+ // TODO: legitimate, pre-existing typing issue that was previously undetected
310+ // Conflict between BoxCommentPermissions and BoxTaskPermissions
311+ // $FlowFixMe
312+ < BaseComment
313+ { ...commentAndAnnotationCommonProps }
314+ annotationActivityLink = {
315+ < AnnotationActivityLinkProvider
316+ item = { item }
317+ onSelect = { onAnnotationSelect }
318+ isCurrentVersion = { currentFileVersionId === itemFileVersionId }
319+ />
320+ }
321+ onAnnotationEdit = { onAnnotationEdit }
322+ onDelete = { onAnnotationDelete }
323+ onReplyCreate = { reply =>
324+ onReplyCreate ( item . id , FEED_ITEM_TYPE_ANNOTATION , reply )
325+ }
326+ onShowReplies = { ( ) => onShowReplies ( item . id , FEED_ITEM_TYPE_ANNOTATION ) }
327+ tagged_message = { item . description ?. message ?? '' }
328+ />
329+ ) : (
330+ < ActivityThread
331+ data-testid = "activity-thread"
324332 currentUser = { currentUser }
325333 getAvatarUrl = { getAvatarUrl }
326- getUserProfileUrl = { getUserProfileUrl }
327334 getMentionWithQuery = { getMentionWithQuery }
328- hasVersions = { hasVersions }
329- isCurrentVersion = { currentFileVersionId === itemFileVersionId }
330- item = { item }
335+ getUserProfileUrl = { getUserProfileUrl }
336+ hasNewThreadedReplies = { hasNewThreadedReplies }
337+ hasReplies = { hasReplies }
338+ isPending = { item . isPending }
339+ isRepliesLoading = { item . isRepliesLoading }
331340 mentionSelectorContacts = { mentionSelectorContacts }
332- onEdit = { onAnnotationEdit }
333- onDelete = { onAnnotationDelete }
334- onSelect = { onAnnotationSelect }
335- onStatusChange = { onAnnotationStatusChange }
336- />
337- </ ActivityThread >
341+ onHideReplies = { onHideRepliesHandler ( item . id ) }
342+ onReplyCreate = { onReplyCreateHandler ( item . id , item . type ) }
343+ onReplyDelete = { onReplyDeleteHandler ( item . id ) }
344+ onReplyEdit = { onReplyUpdateHandler ( item . id ) }
345+ onReplySelect = { onCommentSelectHandler ( item . id ) }
346+ onShowReplies = { onShowRepliesHandler ( item . id , item . type ) }
347+ repliesTotalCount = { item . total_reply_count }
348+ replies = { item . replies }
349+ translations = { translations }
350+ >
351+ < AnnotationActivity
352+ currentUser = { currentUser }
353+ getAvatarUrl = { getAvatarUrl }
354+ getUserProfileUrl = { getUserProfileUrl }
355+ getMentionWithQuery = { getMentionWithQuery }
356+ hasVersions = { hasVersions }
357+ isCurrentVersion = { currentFileVersionId === itemFileVersionId }
358+ item = { item }
359+ mentionSelectorContacts = { mentionSelectorContacts }
360+ onEdit = { onAnnotationEdit }
361+ onDelete = { onAnnotationDelete }
362+ onSelect = { onAnnotationSelect }
363+ onStatusChange = { onAnnotationStatusChange }
364+ />
365+ </ ActivityThread >
366+ ) }
338367 </ ActivityItem >
339368 ) ;
340369 default :
0 commit comments