[next] UserBox with respect to auth settings (#2079)

* feat: adapt userbox according to settings in embed stream

* fix: lint and test

* feat: respect allowRegistration
This commit is contained in:
Kiwi
2018-11-20 17:56:02 +01:00
committed by GitHub
parent 6fa0c7f538
commit 13147c4ba4
26 changed files with 534 additions and 43 deletions
@@ -20,7 +20,8 @@ export interface PermalinkViewProps {
PropTypesOf<typeof ReplyListContainer>["comment"]
| null;
settings: PropTypesOf<typeof ConversationThreadContainer>["settings"] &
PropTypesOf<typeof ReplyListContainer>["settings"];
PropTypesOf<typeof ReplyListContainer>["settings"] &
PropTypesOf<typeof UserBoxContainer>["settings"];
showAllCommentsHref: string | null;
onShowAllComments: (e: MouseEvent<any>) => void;
}
@@ -35,7 +36,7 @@ const PermalinkView: StatelessComponent<PermalinkViewProps> = ({
}) => {
return (
<HorizontalGutter className={styles.root} size="double">
<UserBoxContainer me={me} />
<UserBoxContainer me={me} settings={settings} />
<Flex alignItems="center" justifyContent="center" direction="column">
<Localized id="comments-permalinkView-currentViewing">
<Typography className={styles.title1}>
@@ -19,7 +19,8 @@ export interface StreamProps {
} & PropTypesOf<typeof CommentContainer>["story"] &
PropTypesOf<typeof ReplyListContainer>["story"];
settings: PropTypesOf<typeof CommentContainer>["settings"] &
PropTypesOf<typeof ReplyListContainer>["settings"];
PropTypesOf<typeof ReplyListContainer>["settings"] &
PropTypesOf<typeof UserBoxContainer>["settings"];
comments: ReadonlyArray<
{ id: string } & PropTypesOf<typeof CommentContainer>["comment"] &
PropTypesOf<typeof ReplyListContainer>["comment"]
@@ -38,7 +39,7 @@ const Stream: StatelessComponent<StreamProps> = props => {
return (
<HorizontalGutter className={styles.root} size="double">
<HorizontalGutter size="half">
<UserBoxContainer me={props.me} />
<UserBoxContainer me={props.me} settings={props.settings} />
{props.me ? (
<PostCommentFormContainer storyID={props.story.id} />
) : (
@@ -7,6 +7,7 @@ exports[`renders comment not found 1`] = `
>
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(Relay(UserBoxContainer)))))))))
me={Object {}}
settings={Object {}}
/>
<withPropsOnChange(Flex)
alignItems="center"
@@ -64,6 +65,7 @@ exports[`renders correctly 1`] = `
>
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(Relay(UserBoxContainer)))))))))
me={Object {}}
settings={Object {}}
/>
<withPropsOnChange(Flex)
alignItems="center"
@@ -10,6 +10,14 @@ exports[`renders correctly 1`] = `
>
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(Relay(UserBoxContainer)))))))))
me={null}
settings={
Object {
"reaction": Object {
"icon": "thumb_up_alt",
"label": "Respect",
},
}
}
/>
<PostCommentFormFake />
</withPropsOnChange(HorizontalGutter)>
@@ -128,6 +136,14 @@ exports[`when there is more disables load more button 1`] = `
>
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(Relay(UserBoxContainer)))))))))
me={null}
settings={
Object {
"reaction": Object {
"icon": "thumb_up_alt",
"label": "Respect",
},
}
}
/>
<PostCommentFormFake />
</withPropsOnChange(HorizontalGutter)>
@@ -260,6 +276,14 @@ exports[`when there is more renders a load more button 1`] = `
>
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(Relay(UserBoxContainer)))))))))
me={null}
settings={
Object {
"reaction": Object {
"icon": "thumb_up_alt",
"label": "Respect",
},
}
}
/>
<PostCommentFormFake />
</withPropsOnChange(HorizontalGutter)>
@@ -392,6 +416,14 @@ exports[`when use is logged in renders correctly 1`] = `
>
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(Relay(UserBoxContainer)))))))))
me={Object {}}
settings={
Object {
"reaction": Object {
"icon": "thumb_up_alt",
"label": "Respect",
},
}
}
/>
<withContext(withContext(createMutationContainer(PostCommentFormContainer)))
storyID="story-id"
@@ -88,6 +88,7 @@ const enhanced = withContext(ctx => ({
fragment PermalinkViewContainer_settings on Settings {
...ConversationThreadContainer_settings
...ReplyListContainer1_settings
...UserBoxContainer_settings
}
`,
})(PermalinkViewContainer)
@@ -112,6 +112,7 @@ const enhanced = withPaginationContainer<
fragment StreamContainer_settings on Settings {
...ReplyListContainer1_settings
...CommentContainer_settings
...UserBoxContainer_settings
}
`,
},
@@ -12,6 +12,7 @@ it("renders correctly", () => {
const props: PropTypesOf<typeof ProfileN> = {
story: {},
me: {},
settings: {},
};
const wrapper = shallow(<ProfileN {...props} />);
expect(wrapper).toMatchSnapshot();
@@ -9,12 +9,13 @@ export interface ProfileProps {
story: PropTypesOf<typeof CommentHistoryContainer>["story"];
me: PropTypesOf<typeof UserBoxContainer>["me"] &
PropTypesOf<typeof CommentHistoryContainer>["me"];
settings: PropTypesOf<typeof UserBoxContainer>["settings"];
}
const Profile: StatelessComponent<ProfileProps> = props => {
return (
<HorizontalGutter size="double">
<UserBoxContainer me={props.me} />
<UserBoxContainer me={props.me} settings={props.settings} />
<CommentHistoryContainer me={props.me} story={props.story} />
</HorizontalGutter>
);
@@ -6,6 +6,7 @@ exports[`renders correctly 1`] = `
>
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(Relay(UserBoxContainer)))))))))
me={Object {}}
settings={Object {}}
/>
<Relay(CommentHistoryContainer)
me={Object {}}
@@ -3,18 +3,26 @@ import { graphql } from "react-relay";
import { withFragmentContainer } from "talk-framework/lib/relay";
import { ProfileContainer_me as MeData } from "talk-stream/__generated__/ProfileContainer_me.graphql";
import { ProfileContainer_settings as SettingsData } from "talk-stream/__generated__/ProfileContainer_settings.graphql";
import { ProfileContainer_story as StoryData } from "talk-stream/__generated__/ProfileContainer_story.graphql";
import Profile from "../components/Profile";
interface ProfileContainerProps {
me: MeData;
settings: SettingsData;
story: StoryData;
}
export class StreamContainer extends React.Component<ProfileContainerProps> {
public render() {
return <Profile me={this.props.me} story={this.props.story} />;
return (
<Profile
me={this.props.me}
story={this.props.story}
settings={this.props.settings}
/>
);
}
}
const enhanced = withFragmentContainer<ProfileContainerProps>({
@@ -29,6 +37,11 @@ const enhanced = withFragmentContainer<ProfileContainerProps>({
...CommentHistoryContainer_me
}
`,
settings: graphql`
fragment ProfileContainer_settings on Settings {
...UserBoxContainer_settings
}
`,
})(StreamContainer);
export default enhanced;
@@ -40,7 +40,13 @@ export const render = ({
</Localized>
);
}
return <ProfileContainer me={props.me} story={props.story} />;
return (
<ProfileContainer
me={props.me}
story={props.story}
settings={props.settings}
/>
);
}
return <Spinner />;
@@ -58,6 +64,9 @@ const ProfileQuery: StatelessComponent<InnerProps> = ({
me {
...ProfileContainer_me
}
settings {
...ProfileContainer_settings
}
}
`}
variables={{