Reply opens auth popup when not logged in

This commit is contained in:
Chi Vinh Le
2018-09-06 00:07:14 +02:00
parent 90a875f40e
commit 46ff3dea89
18 changed files with 165 additions and 73 deletions
@@ -8,6 +8,7 @@ import CommentContainer from "../containers/CommentContainer";
import * as styles from "./PermalinkView.css";
export interface PermalinkViewProps {
me: PropTypesOf<typeof CommentContainer>["me"];
asset: PropTypesOf<typeof CommentContainer>["asset"];
comment: PropTypesOf<typeof CommentContainer>["comment"] | null;
showAllCommentsHref: string | null;
@@ -19,6 +20,7 @@ const PermalinkView: StatelessComponent<PermalinkViewProps> = ({
comment,
asset,
onShowAllComments,
me,
}) => {
return (
<div className={styles.root}>
@@ -44,7 +46,7 @@ const PermalinkView: StatelessComponent<PermalinkViewProps> = ({
<Typography>Comment not found</Typography>
</Localized>
)}
{comment && <CommentContainer comment={comment} asset={asset} />}
{comment && <CommentContainer me={me} comment={comment} asset={asset} />}
</div>
);
};
@@ -10,6 +10,7 @@ import Indent from "./Indent";
export interface ReplyListProps {
asset: PropTypesOf<typeof CommentContainer>["asset"];
me: PropTypesOf<typeof CommentContainer>["me"];
comment: {
id: string;
};
@@ -31,6 +32,7 @@ const ReplyList: StatelessComponent<ReplyListProps> = props => {
{props.comments.map(comment => (
<CommentContainer
key={comment.id}
me={props.me}
comment={comment}
asset={props.asset}
indentLevel={props.indentLevel}
@@ -20,7 +20,7 @@ it("renders correctly", () => {
onLoadMore: noop,
disableLoadMore: false,
hasMore: false,
user: null,
me: null,
};
const wrapper = shallow(<StreamN {...props} />);
expect(wrapper).toMatchSnapshot();
@@ -37,7 +37,7 @@ describe("when use is logged in", () => {
onLoadMore: noop,
disableLoadMore: false,
hasMore: false,
user: {},
me: {},
};
const wrapper = shallow(<StreamN {...props} />);
expect(wrapper).toMatchSnapshot();
@@ -54,7 +54,7 @@ describe("when there is more", () => {
onLoadMore: sinon.spy(),
disableLoadMore: false,
hasMore: true,
user: null,
me: null,
};
const wrapper = shallow(<StreamN {...props} />);
+17 -5
View File
@@ -25,15 +25,19 @@ export interface StreamProps {
onLoadMore?: () => void;
hasMore?: boolean;
disableLoadMore?: boolean;
user: PropTypesOf<typeof UserBoxContainer>["user"] | null;
me:
| PropTypesOf<typeof UserBoxContainer>["me"] &
PropTypesOf<typeof CommentContainer>["me"] &
PropTypesOf<typeof ReplyListContainer>["me"]
| null;
}
const Stream: StatelessComponent<StreamProps> = props => {
return (
<HorizontalGutter className={styles.root} size="double">
<HorizontalGutter size="half">
<UserBoxContainer user={props.user} />
{props.user ? (
<UserBoxContainer me={props.me} />
{props.me ? (
<PostCommentFormContainer assetID={props.asset.id} />
) : (
<PostCommentFormFake />
@@ -46,8 +50,16 @@ const Stream: StatelessComponent<StreamProps> = props => {
>
{props.comments.map(comment => (
<HorizontalGutter key={comment.id}>
<CommentContainer comment={comment} asset={props.asset} />
<ReplyListContainer comment={comment} asset={props.asset} />
<CommentContainer
me={props.me}
comment={comment}
asset={props.asset}
/>
<ReplyListContainer
me={props.me}
comment={comment}
asset={props.asset}
/>
</HorizontalGutter>
))}
{props.hasMore && (
@@ -5,7 +5,7 @@ exports[`renders correctly 1`] = `
id="talk-comments-replyList-log--comment-id"
role="log"
>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -19,7 +19,7 @@ exports[`renders correctly 1`] = `
indentLevel={1}
key="comment-1"
/>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -41,7 +41,7 @@ exports[`when there is more disables load more button 1`] = `
id="talk-comments-replyList-log--comment-id"
role="log"
>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -55,7 +55,7 @@ exports[`when there is more disables load more button 1`] = `
indentLevel={1}
key="comment-1"
/>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -96,7 +96,7 @@ exports[`when there is more renders a load more button 1`] = `
id="talk-comments-replyList-log--comment-id"
role="log"
>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -110,7 +110,7 @@ exports[`when there is more renders a load more button 1`] = `
indentLevel={1}
key="comment-1"
/>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -9,7 +9,7 @@ exports[`renders correctly 1`] = `
size="half"
>
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(Relay(UserBoxContainer)))))))))
user={null}
me={null}
/>
<PostCommentFormFake />
</withPropsOnChange(HorizontalGutter)>
@@ -21,7 +21,7 @@ exports[`renders correctly 1`] = `
<withPropsOnChange(HorizontalGutter)
key="comment-1"
>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -33,6 +33,7 @@ exports[`renders correctly 1`] = `
"id": "comment-1",
}
}
me={null}
/>
<Relay(ReplyListContainer)
asset={
@@ -46,12 +47,13 @@ exports[`renders correctly 1`] = `
"id": "comment-1",
}
}
me={null}
/>
</withPropsOnChange(HorizontalGutter)>
<withPropsOnChange(HorizontalGutter)
key="comment-2"
>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -63,6 +65,7 @@ exports[`renders correctly 1`] = `
"id": "comment-2",
}
}
me={null}
/>
<Relay(ReplyListContainer)
asset={
@@ -76,6 +79,7 @@ exports[`renders correctly 1`] = `
"id": "comment-2",
}
}
me={null}
/>
</withPropsOnChange(HorizontalGutter)>
</withPropsOnChange(HorizontalGutter)>
@@ -91,7 +95,7 @@ exports[`when there is more disables load more button 1`] = `
size="half"
>
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(Relay(UserBoxContainer)))))))))
user={null}
me={null}
/>
<PostCommentFormFake />
</withPropsOnChange(HorizontalGutter)>
@@ -103,7 +107,7 @@ exports[`when there is more disables load more button 1`] = `
<withPropsOnChange(HorizontalGutter)
key="comment-1"
>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -115,6 +119,7 @@ exports[`when there is more disables load more button 1`] = `
"id": "comment-1",
}
}
me={null}
/>
<Relay(ReplyListContainer)
asset={
@@ -128,12 +133,13 @@ exports[`when there is more disables load more button 1`] = `
"id": "comment-1",
}
}
me={null}
/>
</withPropsOnChange(HorizontalGutter)>
<withPropsOnChange(HorizontalGutter)
key="comment-2"
>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -145,6 +151,7 @@ exports[`when there is more disables load more button 1`] = `
"id": "comment-2",
}
}
me={null}
/>
<Relay(ReplyListContainer)
asset={
@@ -158,6 +165,7 @@ exports[`when there is more disables load more button 1`] = `
"id": "comment-2",
}
}
me={null}
/>
</withPropsOnChange(HorizontalGutter)>
<Localized
@@ -187,7 +195,7 @@ exports[`when there is more renders a load more button 1`] = `
size="half"
>
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(Relay(UserBoxContainer)))))))))
user={null}
me={null}
/>
<PostCommentFormFake />
</withPropsOnChange(HorizontalGutter)>
@@ -199,7 +207,7 @@ exports[`when there is more renders a load more button 1`] = `
<withPropsOnChange(HorizontalGutter)
key="comment-1"
>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -211,6 +219,7 @@ exports[`when there is more renders a load more button 1`] = `
"id": "comment-1",
}
}
me={null}
/>
<Relay(ReplyListContainer)
asset={
@@ -224,12 +233,13 @@ exports[`when there is more renders a load more button 1`] = `
"id": "comment-1",
}
}
me={null}
/>
</withPropsOnChange(HorizontalGutter)>
<withPropsOnChange(HorizontalGutter)
key="comment-2"
>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -241,6 +251,7 @@ exports[`when there is more renders a load more button 1`] = `
"id": "comment-2",
}
}
me={null}
/>
<Relay(ReplyListContainer)
asset={
@@ -254,6 +265,7 @@ exports[`when there is more renders a load more button 1`] = `
"id": "comment-2",
}
}
me={null}
/>
</withPropsOnChange(HorizontalGutter)>
<Localized
@@ -283,7 +295,7 @@ exports[`when use is logged in renders correctly 1`] = `
size="half"
>
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(Relay(UserBoxContainer)))))))))
user={Object {}}
me={Object {}}
/>
<withContext(withContext(createMutationContainer(PostCommentFormContainer)))
assetID="asset-id"
@@ -297,7 +309,7 @@ exports[`when use is logged in renders correctly 1`] = `
<withPropsOnChange(HorizontalGutter)
key="comment-1"
>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -309,6 +321,7 @@ exports[`when use is logged in renders correctly 1`] = `
"id": "comment-1",
}
}
me={Object {}}
/>
<Relay(ReplyListContainer)
asset={
@@ -322,12 +335,13 @@ exports[`when use is logged in renders correctly 1`] = `
"id": "comment-1",
}
}
me={Object {}}
/>
</withPropsOnChange(HorizontalGutter)>
<withPropsOnChange(HorizontalGutter)
key="comment-2"
>
<Relay(CommentContainer)
<withContext(createMutationContainer(Relay(CommentContainer)))
asset={
Object {
"id": "asset-id",
@@ -339,6 +353,7 @@ exports[`when use is logged in renders correctly 1`] = `
"id": "comment-2",
}
}
me={Object {}}
/>
<Relay(ReplyListContainer)
asset={
@@ -352,6 +367,7 @@ exports[`when use is logged in renders correctly 1`] = `
"id": "comment-2",
}
}
me={Object {}}
/>
</withPropsOnChange(HorizontalGutter)>
</withPropsOnChange(HorizontalGutter)>