diff --git a/src/core/client/stream/tabs/comments/components/Comment/Comment.css b/src/core/client/stream/tabs/comments/components/Comment/Comment.css index 515dfe5d1..642206f36 100644 --- a/src/core/client/stream/tabs/comments/components/Comment/Comment.css +++ b/src/core/client/stream/tabs/comments/components/Comment/Comment.css @@ -4,7 +4,7 @@ background-color: var(--palette-primary-lightest); padding: var(--spacing-unit); } -.topBar { +.subBar { margin-bottom: calc(0.5 * var(--spacing-unit)); } .footer:not(:empty) { diff --git a/src/core/client/stream/tabs/comments/components/Comment/Comment.tsx b/src/core/client/stream/tabs/comments/components/Comment/Comment.tsx index 6ebb427b9..ad463b581 100644 --- a/src/core/client/stream/tabs/comments/components/Comment/Comment.tsx +++ b/src/core/client/stream/tabs/comments/components/Comment/Comment.tsx @@ -7,6 +7,7 @@ import { Flex, HorizontalGutter } from "talk-ui/components"; import * as styles from "./Comment.css"; import EditedMarker from "./EditedMarker"; +import InReplyTo from "./InReplyTo"; import TopBarLeft from "./TopBarLeft"; import Username from "./Username"; @@ -20,6 +21,7 @@ export interface CommentProps { footer?: React.ReactNode; showEditedMarker?: boolean; highlight?: boolean; + parentAuthorName?: string | null; } const Comment: StatelessComponent = props => { @@ -28,12 +30,7 @@ const Comment: StatelessComponent = props => { role="article" className={cn(styles.root, { [styles.highlight]: props.highlight })} > - + {props.username && {props.username}} @@ -43,6 +40,12 @@ const Comment: StatelessComponent = props => { {props.topBarRight &&
{props.topBarRight}
}
+ {props.parentAuthorName && ( +
+ +
+ )} + {props.body || ""} {props.footer} diff --git a/src/core/client/stream/tabs/comments/components/Comment/InReplyTo.css b/src/core/client/stream/tabs/comments/components/Comment/InReplyTo.css new file mode 100644 index 000000000..3f5a70f00 --- /dev/null +++ b/src/core/client/stream/tabs/comments/components/Comment/InReplyTo.css @@ -0,0 +1,9 @@ +.icon { + color: var(--palette-grey-light); +} +.inReplyTo { + color: var(--palette-grey-light); +} +.username { + color: var(--palette-grey-dark); +} diff --git a/src/core/client/stream/tabs/comments/components/Comment/InReplyTo.spec.tsx b/src/core/client/stream/tabs/comments/components/Comment/InReplyTo.spec.tsx new file mode 100644 index 000000000..71391cf1d --- /dev/null +++ b/src/core/client/stream/tabs/comments/components/Comment/InReplyTo.spec.tsx @@ -0,0 +1,14 @@ +import { shallow } from "enzyme"; +import React from "react"; + +import { PropTypesOf } from "talk-framework/types"; + +import InReplyTo from "./InReplyTo"; + +it("renders correctly", () => { + const props: PropTypesOf = { + username: "Username", + }; + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); +}); diff --git a/src/core/client/stream/tabs/comments/components/Comment/InReplyTo.tsx b/src/core/client/stream/tabs/comments/components/Comment/InReplyTo.tsx new file mode 100644 index 000000000..39fc839f1 --- /dev/null +++ b/src/core/client/stream/tabs/comments/components/Comment/InReplyTo.tsx @@ -0,0 +1,34 @@ +import { Localized } from "fluent-react/compat"; +import React, { StatelessComponent } from "react"; + +import { Flex, Icon, Typography } from "talk-ui/components"; +import styles from "./InReplyTo.css"; + +interface Props { + username: string; +} + +const InReplyTo: StatelessComponent = ({ username }) => { + const Username = () => ( + + {username} + + ); + + return ( + + reply{" "} + }> + + {"In reply to "} + + + + ); +}; + +export default InReplyTo; diff --git a/src/core/client/stream/tabs/comments/components/Comment/__snapshots__/Comment.spec.tsx.snap b/src/core/client/stream/tabs/comments/components/Comment/__snapshots__/Comment.spec.tsx.snap index f1eceef62..d4ab9ae64 100644 --- a/src/core/client/stream/tabs/comments/components/Comment/__snapshots__/Comment.spec.tsx.snap +++ b/src/core/client/stream/tabs/comments/components/Comment/__snapshots__/Comment.spec.tsx.snap @@ -6,7 +6,6 @@ exports[`renders username and body 1`] = ` role="article" > + + reply + + + } + > + + In reply to <username><username> + + + +`; diff --git a/src/core/client/stream/tabs/comments/containers/CommentContainer.spec.tsx b/src/core/client/stream/tabs/comments/containers/CommentContainer.spec.tsx index 44a71647d..c225bd148 100644 --- a/src/core/client/stream/tabs/comments/containers/CommentContainer.spec.tsx +++ b/src/core/client/stream/tabs/comments/containers/CommentContainer.spec.tsx @@ -22,6 +22,7 @@ it("renders username and body", () => { id: "author-id", username: "Marvin", }, + parent: null, body: "Woof", createdAt: "1995-12-17T03:24:00.000Z", editing: { @@ -59,6 +60,7 @@ it("renders body only", () => { id: "author-id", username: null, }, + parent: null, body: "Woof", createdAt: "1995-12-17T03:24:00.000Z", editing: { @@ -94,6 +96,7 @@ it("hide reply button", () => { id: "author-id", username: "Marvin", }, + parent: null, body: "Woof", createdAt: "1995-12-17T03:24:00.000Z", editing: { @@ -138,6 +141,7 @@ it("shows conversation link", () => { id: "author-id", username: "Marvin", }, + parent: null, body: "Woof", createdAt: "1995-12-17T03:24:00.000Z", editing: { @@ -157,3 +161,45 @@ it("shows conversation link", () => { const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); }); + +it("renders in reply to", () => { + const props: PropTypesOf = { + me: null, + asset: { + url: "http://localhost/asset", + }, + comment: { + id: "comment-id", + author: { + id: "author-id", + username: "Marvin", + }, + parent: { + author: { + username: "ParentAuthor", + }, + }, + body: "Woof", + createdAt: "1995-12-17T03:24:00.000Z", + editing: { + edited: false, + editableUntil: "1995-12-17T03:24:30.000Z", + }, + pending: false, + }, + settings: { + reaction: { + icon: "thumb_up_alt", + label: "Respect", + }, + }, + indentLevel: 1, + showAuthPopup: noop as any, + setCommentID: noop as any, + localReply: false, + disableReplies: false, + }; + + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); +}); diff --git a/src/core/client/stream/tabs/comments/containers/CommentContainer.tsx b/src/core/client/stream/tabs/comments/containers/CommentContainer.tsx index daebede42..8d0de18b6 100644 --- a/src/core/client/stream/tabs/comments/containers/CommentContainer.tsx +++ b/src/core/client/stream/tabs/comments/containers/CommentContainer.tsx @@ -165,6 +165,11 @@ export class CommentContainer extends Component { blur={comment.pending || false} showEditedMarker={comment.editing.edited} highlight={highlight} + parentAuthorName={ + comment.parent && + comment.parent.author && + comment.parent.author.username + } topBarRight={ (editable && ( @@ -251,6 +256,11 @@ const enhanced = withSetCommentIDMutation( id username } + parent { + author { + username + } + } body createdAt editing { diff --git a/src/core/client/stream/tabs/comments/containers/__snapshots__/CommentContainer.spec.tsx.snap b/src/core/client/stream/tabs/comments/containers/__snapshots__/CommentContainer.spec.tsx.snap index f637160c9..6921cae4b 100644 --- a/src/core/client/stream/tabs/comments/containers/__snapshots__/CommentContainer.spec.tsx.snap +++ b/src/core/client/stream/tabs/comments/containers/__snapshots__/CommentContainer.spec.tsx.snap @@ -31,6 +31,7 @@ exports[`hide reply button 1`] = ` "edited": false, }, "id": "comment-id", + "parent": null, "pending": false, } } @@ -49,6 +50,7 @@ exports[`hide reply button 1`] = ` } id="comment-comment-id" indentLevel={1} + parentAuthorName={null} showEditedMarker={false} username="Marvin" /> @@ -91,6 +93,7 @@ exports[`renders body only 1`] = ` "edited": false, }, "id": "comment-id", + "parent": null, "pending": false, } } @@ -109,12 +112,79 @@ exports[`renders body only 1`] = ` } id="comment-comment-id" indentLevel={1} + parentAuthorName={null} showEditedMarker={false} username={null} /> `; +exports[`renders in reply to 1`] = ` + + + + + + + + + } + id="comment-comment-id" + indentLevel={1} + parentAuthorName="ParentAuthor" + showEditedMarker={false} + username="Marvin" + /> + +`; + exports[`renders username and body 1`] = ` @@ -211,6 +283,7 @@ exports[`shows conversation link 1`] = ` "edited": false, }, "id": "comment-id", + "parent": null, "pending": false, } } @@ -235,6 +308,7 @@ exports[`shows conversation link 1`] = ` } id="comment-comment-id" indentLevel={1} + parentAuthorName={null} showEditedMarker={false} username="Marvin" /> diff --git a/src/core/client/stream/test/comments/__snapshots__/editComment.spec.tsx.snap b/src/core/client/stream/test/comments/__snapshots__/editComment.spec.tsx.snap index 6df0b04e7..7a62d4e30 100644 --- a/src/core/client/stream/test/comments/__snapshots__/editComment.spec.tsx.snap +++ b/src/core/client/stream/test/comments/__snapshots__/editComment.spec.tsx.snap @@ -256,7 +256,7 @@ exports[`cancel edit: edit canceled 1`] = ` role="article" >
## Profile Tab profile-historyComment-viewConversation = View Conversation