Skip to content
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
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@
"@box/metadata-view": "^1.53.26",
"@box/react-virtualized": "^9.22.3-rc-box.10",
"@box/readable-time": "^2.1.4",
"@box/threaded-annotations": "^2.1.7",
"@box/threaded-annotations": "^3.1.1",
"@box/types": "^2.1.8",
"@box/unified-share-modal": "^2.15.16",
"@box/user-selector": "^2.1.5",
"@box/uploads-manager": "^1.17.2",
"@box/user-selector": "^2.1.5",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"@cfaester/enzyme-adapter-react-18": "^0.8.0",
"@chromatic-com/storybook": "^4.0.1",
"@commitlint/cli": "^19.8.0",
Expand Down Expand Up @@ -314,11 +314,11 @@
"@box/metadata-view": "^1.53.26",
"@box/react-virtualized": "^9.22.3-rc-box.10",
"@box/readable-time": "^2.1.4",
"@box/threaded-annotations": "^2.1.7",
"@box/threaded-annotations": "^3.1.1",
"@box/types": "^2.1.8",
"@box/unified-share-modal": "^2.15.16",
"@box/user-selector": "^2.1.5",
"@box/uploads-manager": "^1.17.2",
"@box/user-selector": "^2.1.5",
"@hapi/address": "^2.1.4",
"@tanstack/react-virtual": "^3.13.12",
"axios": "^0.32.0",
Expand Down
15 changes: 15 additions & 0 deletions src/elements/content-sidebar/ActivitySidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,20 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
}
};

handleCommentSelect = (commentId: string): void => {
const { history, internalSidebarNavigationHandler, routerDisabled } = this.props;

if (routerDisabled && internalSidebarNavigationHandler) {
internalSidebarNavigationHandler({
sidebar: ViewType.ACTIVITY,
activeFeedEntryId: commentId,
activeFeedEntryType: FeedEntryType.COMMENTS,
});
} else {
history.push(this.getActiveCommentPath(commentId));
}
};

handleItemsFiltered = (status?: ActivityFilterItemType) => {
const { onFilterChange } = this.props;

Expand Down Expand Up @@ -1443,6 +1457,7 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
onCommentCopyLink={onCommentCopyLink}
onCommentCreate={this.createComment}
onCommentDelete={this.deleteComment}
onCommentSelect={this.handleCommentSelect}
onCommentUpdate={this.updateComment}
onReplyCreate={this.createReply}
onReplyDelete={this.deleteReply}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const ActivityFeedV2 = ({
onCommentCopyLink,
onCommentCreate,
onCommentDelete,
onCommentSelect,
onCommentUpdate,
onReplyCreate,
onReplyDelete,
Expand All @@ -74,8 +75,6 @@ const ActivityFeedV2 = ({
const intl = useIntl();
const scrollHandle = useActivityFeedScroll();
const currentUserId = currentUser?.id;
const scrollHandleRef = React.useRef<typeof scrollHandle | null>(null);
scrollHandleRef.current = scrollHandle;
const headerTitle = intl.formatMessage(commonMessages.sidebarActivityTitle);

const scrolledEntryIdRef = React.useRef<string | null>(null);
Expand Down Expand Up @@ -359,16 +358,18 @@ const ActivityFeedV2 = ({
viewer.emit('comment_markers', markers);

const handleMarkerSelect = ({ id }: { id: string }) => {
requestAnimationFrame(() => {
scrollHandleRef.current?.scrollTo(id);
});
const item = filteredItems.find(filteredItem => filteredItem.id === id);
// Annotation markers are already handled via the annotator pipeline, so only handle comments here.
if (item?.type === 'comment' && onCommentSelect) {
onCommentSelect(id);
}
};
viewer.addListener('comment_marker_select', handleMarkerSelect);
return () => {
viewer.removeListener('comment_marker_select', handleMarkerSelect);
viewer.emit('comment_markers', []);
};
}, [filteredItems, getViewer, isVideo]);
}, [filteredItems, getViewer, isVideo, onCommentSelect]);

const handleCommentPost = React.useCallback(
async (content: unknown) => {
Expand Down Expand Up @@ -466,6 +467,7 @@ const ActivityFeedV2 = ({
{filteredItems.map(item => (
<FeedItemRow
key={item.id}
activeFeedEntryId={activeFeedEntryId}
currentUserId={currentUserId}
fps={fps}
isDisabled={isDisabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from '../../../constants';

type FeedItemRowProps = {
activeFeedEntryId?: string;
currentUserId?: string;
fps: number;
isDisabled: boolean;
Expand Down Expand Up @@ -81,6 +82,7 @@ const buildReplyPost =
};

const FeedItemRow = ({
activeFeedEntryId,
currentUserId,
fps,
isDisabled,
Expand All @@ -104,6 +106,8 @@ const FeedItemRow = ({
timeFormat,
userSelectorProps,
}: FeedItemRowProps) => {
const isHighlighted = activeFeedEntryId === item.id;

switch (item.type) {
case 'comment': {
const { permissions } = item;
Expand Down Expand Up @@ -150,6 +154,7 @@ const FeedItemRow = ({
annotationTarget={commentAnnotationTarget}
isAnnotations={false}
isEditDisabled={isDisabled || item.isResolved}
isHighlighted={isHighlighted}
isResolved={item.isResolved}
messages={item.messages}
onAnnotationBadgeClick={handleBadgeClick}
Expand Down Expand Up @@ -214,6 +219,7 @@ const FeedItemRow = ({
annotationTarget={annotationBadgeTarget}
isAnnotations={false}
isEditDisabled={isDisabled || item.isResolved}
isHighlighted={isHighlighted}
isResolved={item.isResolved}
messages={item.messages}
onAnnotationBadgeClick={() => onAnnotationSelect?.(item.annotation)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ describe('elements/content-sidebar/activity-feed-v2/FeedItemRow', () => {
expect(lastThreadedAnnotationProps.isAnnotations).toBe(false);
});

test('should pass isHighlighted=true when activeFeedEntryId matches the comment id', () => {
render(<FeedItemRow {...defaultProps} activeFeedEntryId="comment-1" item={mockComment} />);
expect(lastThreadedAnnotationProps.isHighlighted).toBe(true);
});

test('should pass isHighlighted=false when activeFeedEntryId does not match', () => {
render(<FeedItemRow {...defaultProps} activeFeedEntryId="other-id" item={mockComment} />);
expect(lastThreadedAnnotationProps.isHighlighted).toBe(false);
});

test('should call onCommentDelete with id and permissions when onDelete fires', () => {
const onCommentDelete = jest.fn();
render(<FeedItemRow {...defaultProps} item={mockComment} onCommentDelete={onCommentDelete} />);
Expand Down Expand Up @@ -465,6 +475,16 @@ describe('elements/content-sidebar/activity-feed-v2/FeedItemRow', () => {
expect(screen.getByRole('article', { name: 'threaded annotation' })).toBeVisible();
});

test('should pass isHighlighted=true when activeFeedEntryId matches the annotation id', () => {
render(<FeedItemRow {...defaultProps} activeFeedEntryId="annotation-1" item={mockAnnotation} />);
expect(lastThreadedAnnotationProps.isHighlighted).toBe(true);
});

test('should pass isHighlighted=false when activeFeedEntryId does not match', () => {
render(<FeedItemRow {...defaultProps} activeFeedEntryId="other-id" item={mockAnnotation} />);
expect(lastThreadedAnnotationProps.isHighlighted).toBe(false);
});

test('should call onAnnotationSelect when onAnnotationBadgeClick fires', () => {
const onAnnotationSelect = jest.fn();
render(<FeedItemRow {...defaultProps} item={mockAnnotation} onAnnotationSelect={onAnnotationSelect} />);
Expand Down
1 change: 1 addition & 0 deletions src/elements/content-sidebar/activity-feed-v2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export type ActivityFeedV2Props = {
onCommentCopyLink?: (params: { id: string }) => void;
onCommentCreate?: (text: string, hasMention: boolean) => void;
onCommentDelete?: (params: { id: string; permissions: BoxCommentPermission }) => void;
onCommentSelect?: (commentId: string) => void;
onCommentUpdate?: (
id: string,
text: string | undefined,
Expand Down
Loading
Loading