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

feat(threaded-replies): hide reply #3447

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// This brittle selector is here in order to only select the parent BaseComment and not the BaseComments which constitute its replies.
& > div {
padding: $bdl-grid-unit * 3 $bdl-grid-unit * 3 $bdl-grid-unit * 5;
padding: $bdl-grid-unit * 3 $bdl-grid-unit * 3 $bdl-grid-unit;
}

&.bcs-is-hoverable:hover {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export const BaseComment = ({
onReplyDelete={onReplyDelete}
onReplySelect={onSelect}
onShowReplies={onShowReplies}
parentStatus={status}
replies={replies}
repliesTotalCount={repliesTotalCount}
/>
Expand All @@ -257,6 +258,7 @@ type RepliesProps = {
onReplyDelete?: ({ id: string, permissions?: BoxCommentPermission }) => void,
onReplySelect?: (isSelected: boolean) => void,
onShowReplies?: () => void,
parentStatus?: string,
replies: CommentType[],
repliesTotalCount?: number,
translations?: Translations,
Expand All @@ -276,6 +278,7 @@ export const Replies = ({
onReplySelect = noop,
onShowReplies,
onHideReplies,
parentStatus,
replies,
repliesTotalCount = 0,
translations,
Expand Down Expand Up @@ -346,7 +349,7 @@ export const Replies = ({
})}
</ol>
</div>
{!!onReplyCreate && (
{parentStatus !== COMMENT_STATUS_RESOLVED && !!onReplyCreate && (
<CreateReply
getMentionWithQuery={getMentionWithQuery}
isDisabled={isParentPending}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@import '../../../common/variables';

.bcs-CreateReply {
margin-bottom: $bdl-grid-unit * 4;

.bcs-CreateReply-toggle {
display: flex;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IntlProvider } from 'react-intl';
import { ContentState, EditorState } from 'draft-js';
import { fireEvent, render, screen, within } from '@testing-library/react';
import { Replies } from '../BaseComment';
import { COMMENT_STATUS_OPEN, COMMENT_STATUS_RESOLVED } from '../../../../../constants';

jest.mock('../../Avatar', () => () => 'Avatar');
jest.mock('react-intl', () => ({
Expand Down Expand Up @@ -221,6 +222,18 @@ describe('elements/content-sidebar/ActivityFeed/comment/Replies', () => {
expect(hideReplies).not.toBeCalled();
});

test('should hide reply button for resolved parent comments', () => {
getWrapper({ parentStatus: COMMENT_STATUS_RESOLVED });

expect(screen.queryByRole('button', { name: 'Reply' })).not.toBeInTheDocument();
});

test('should show reply button for unresolved parent comments', () => {
getWrapper({ parentStatus: COMMENT_STATUS_OPEN });

expect(screen.queryByRole('button', { name: 'Reply' })).toBeInTheDocument();
});

test.each`
onShowReplies | onHideReplies
${showReplies} | ${undefined}
Expand Down
Loading