review changes

This commit is contained in:
jessop 2020-01-14 09:57:34 -05:00 committed by Sean Yesmunt
parent 7e2c9dc2b8
commit 94cc7a2d9d
7 changed files with 176 additions and 103 deletions

View file

@ -59,7 +59,7 @@ export function CommentCreate(props: Props) {
return ( return (
<Form onSubmit={handleSubmit}> <Form onSubmit={handleSubmit}>
<ChannelSection channel={channel} onChannelChange={handleChannelChange} includeAnonymous includeNew /> <ChannelSection channel={channel} onChannelChange={handleChannelChange} />
<FormField <FormField
disabled={channel === CHANNEL_NEW} disabled={channel === CHANNEL_NEW}
type="textarea" type="textarea"

View file

@ -183,10 +183,10 @@ const Header = (props: Props) => {
</MenuItem> </MenuItem>
{/* Commented out until new invite system is implemented */} {/* Commented out until new invite system is implemented */}
{/* <MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.INVITE}`)}> <MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.INVITE}`)}>
<Icon aria-hidden icon={ICONS.INVITE} /> <Icon aria-hidden icon={ICONS.INVITE} />
{__('Invite A Friend')} {__('Invites')}
</MenuItem> */} </MenuItem>
{authenticated ? ( {authenticated ? (
<MenuItem onSelect={signOut}> <MenuItem onSelect={signOut}>

View file

@ -15,7 +15,7 @@ type Props = {
isPending: boolean, isPending: boolean,
referralLink: string, referralLink: string,
referralCode: string, referralCode: string,
channels: any, channels: ?Array<ChannelClaim>,
resolvingUris: Array<string>, resolvingUris: Array<string>,
resolveUris: (Array<string>) => void, resolveUris: (Array<string>) => void,
}; };
@ -41,8 +41,9 @@ function InviteNew(props: Props) {
function handleReferralChange(code) { function handleReferralChange(code) {
setReferralSource(code); setReferralSource(code);
// TODO: keep track of this in an array? // TODO: keep track of this in an array?
if (code !== referralCode) { const matchingChannel = channels && channels.find(ch => ch.name === code);
analytics.apiLogPublish(channels.find(ch => ch.name === code)); if (matchingChannel) {
analytics.apiLogPublish(matchingChannel);
} }
} }
@ -55,9 +56,11 @@ function InviteNew(props: Props) {
const topChannel = const topChannel =
channels && channels &&
channels.reduce((top, channel) => channels.reduce((top, channel) => {
(top && top.meta && top.meta.claims_in_channel) > channel.meta.claims_in_channel ? top : channel const topClaimCount = (top && top.meta && top.meta.claims_in_channel) || 0;
); const currentClaimCount = (channel && channel.meta && channel.meta.claims_in_channel) || 0;
return topClaimCount >= currentClaimCount ? top : channel;
});
const referralString = const referralString =
channels && channels.length && referralSource !== referralCode channels && channels.length && referralSource !== referralCode
? lookupUrlByClaimName(referralSource, channels) ? lookupUrlByClaimName(referralSource, channels)
@ -67,7 +70,7 @@ function InviteNew(props: Props) {
useEffect(() => { useEffect(() => {
// resolve once, after we have channel list // resolve once, after we have channel list
if (!hasResolved && !resolveStarted && channelCount) { if (!hasResolved && !resolveStarted && channelCount && uris) {
setResolveStarted(true); setResolveStarted(true);
resolveUris(uris.split(',')); resolveUris(uris.split(','));
} }
@ -93,47 +96,71 @@ function InviteNew(props: Props) {
} }
return ( return (
<Card <div className={'columns'}>
title={__('Invite a Friend')} <Card
subtitle={__('When your friends start using LBRY, the network gets stronger!')} title={__('Refer by Email')}
actions={ subtitle={__('When your friends start using LBRY, the network gets stronger!')}
<React.Fragment> actions={
<Form onSubmit={handleSubmit}> <React.Fragment>
<SelectChannel <Form onSubmit={handleSubmit}>
channel={referralSource} <FormField
onChannelChange={channel => handleReferralChange(channel)} type="text"
label={'Code or Channel'} label="Email"
injected={[referralCode]} placeholder="youremail@example.org"
/> name="email"
value={email}
<CopyableText label={__('Or share this link with your friends')} copyable={referral} /> error={errorMessage}
<FormField inputButton={<Button button="secondary" type="submit" label="Invite" disabled={isPending || !email} />}
type="text" onChange={event => {
label="Email" handleEmailChanged(event);
placeholder="youremail@example.org"
name="email"
value={email}
error={errorMessage}
inputButton={<Button button="secondary" type="submit" label="Invite" disabled={isPending || !email} />}
onChange={event => {
handleEmailChanged(event);
}}
/>
<p className="help">
<I18nMessage
tokens={{
rewards_link: <Button button="link" navigate="/$/rewards" label={__('rewards')} />,
referral_faq_link: <Button button="link" label={__('FAQ')} href="https://lbry.com/faq/referrals" />,
}} }}
> />
Earn %rewards_link% for inviting your friends. Read our %referral_faq_link% to learn more about <p className="help">
referrals. <I18nMessage
</I18nMessage> tokens={{
</p> rewards_link: <Button button="link" navigate="/$/rewards" label={__('rewards')} />,
</Form> referral_faq_link: <Button button="link" label={__('FAQ')} href="https://lbry.com/faq/referrals" />,
</React.Fragment> }}
} >
/> Earn %rewards_link% for inviting your friends. Read our %referral_faq_link% to learn more about
referrals.
</I18nMessage>
</p>
</Form>
</React.Fragment>
}
/>
<Card
title={__('Referral Codes')}
subtitle={__('Users!')}
actions={
<React.Fragment>
<Form onSubmit={handleSubmit}>
<SelectChannel
channel={referralSource}
onChannelChange={channel => handleReferralChange(channel)}
label={'Code or Channel'}
hideNew
hideAnon
injected={[referralCode]}
/>
<CopyableText label={__('Or share this link with your friends')} copyable={referral} />
<p className="help">
<I18nMessage
tokens={{
rewards_link: <Button button="link" navigate="/$/rewards" label={__('rewards')} />,
referral_faq_link: <Button button="link" label={__('FAQ')} href="https://lbry.com/faq/referrals" />,
}}
>
Earn %rewards_link% for inviting your friends. Read our %referral_faq_link% to learn more about
referrals.
</I18nMessage>
</p>
</Form>
</React.Fragment>
}
/>
</div>
); );
} }

View file

@ -71,19 +71,23 @@ function Invited(props: Props) {
if (referrerSetError === ERRORS.ALREADY_CLAIMED) { if (referrerSetError === ERRORS.ALREADY_CLAIMED) {
return ( return (
<Card <Card
title={__(`Welcome!`)} title={__(`Whoa`)}
subtitle={referrerIsChannel ? __(`We've followed your referrer for you. Check it out!`) : __(`Congrats!`)} subtitle={
actions={ referrerIsChannel
<> ? __(`You've already claimed your referrer, but we've followed this channel for you.`)
{referrerIsChannel && ( : __(`You've already claimed your referrer.`)
<div key={refUri} className="claim-preview--channel"> }
<ClaimPreview key={refUri} uri={refUri} actions={''} type={'small'} /> body={
</div> referrerIsChannel && (
)} <div className="claim-preview--channel">
<div className="card__actions"> <ClaimPreview key={refUri} uri={refUri} actions={''} type={'small'} />
<Button button="primary" label={__('Done!')} onClick={handleDone} />
</div> </div>
</> )
}
actions={
<div className="card__actions">
<Button button="primary" label={__('Done!')} onClick={handleDone} />
</div>
} }
/> />
); );
@ -102,10 +106,10 @@ function Invited(props: Props) {
<div className="card__actions"> <div className="card__actions">
<Button <Button
button="primary" button="primary"
label={hasVerifiedEmail ? __('Verify') : __('Sign in')} label={hasVerifiedEmail ? __('Verify') : __('Create Account')}
navigate={`/$/${PAGES.AUTH}?redirect=/$/${PAGES.REWARDS}`} navigate={`/$/${PAGES.AUTH}?redirect=/$/${PAGES.REWARDS}`}
/> />
<Button button="primary" label={__('Explore')} onClick={handleDone} /> <Button button="link" label={__('Explore')} onClick={handleDone} />
</div> </div>
</> </>
} }
@ -117,23 +121,30 @@ function Invited(props: Props) {
return ( return (
<Card <Card
title={__(`You're invited!`)} title={__(`You're invited!`)}
subtitle={__(`A referral reward is waiting for you. Just complete sign-in to claim it.`)} subtitle={
actions={ referrerIsChannel
<> ? __(
{referrerIsChannel && ( `Content freedom and and a present from %channel_name% are waiting for you. Create an account to claim it.`,
<div key={refUri} className="claim-preview--channel"> { channel_name: referrer }
<ClaimPreview key={refUri} uri={refUri} actions={''} type={'small'} /> )
</div> : __(`Content freedom and a present are waiting for you. Create an account to claim it.`)
)} }
<div className="card__actions"> body={
<Button referrerIsChannel && (
button="primary" <div className="claim-preview--channel">
label={hasVerifiedEmail ? __('Verify') : __('Sign in')} <ClaimPreview key={refUri} uri={refUri} actions={''} type={'small'} />
navigate={`/$/${PAGES.AUTH}?redirect=/$/${PAGES.INVITE}/${referrer}`}
/>
<Button button="primary" label={__('Skip')} onClick={handleDone} />
</div> </div>
</> )
}
actions={
<div className="card__actions">
<Button
button="primary"
label={hasVerifiedEmail ? __('Verify') : __('Create Account')}
navigate={`/$/${PAGES.AUTH}?redirect=/$/${PAGES.INVITE}/${referrer}`}
/>
<Button button="link" label={__('Skip')} onClick={handleDone} />
</div>
} }
/> />
); );
@ -143,17 +154,17 @@ function Invited(props: Props) {
<Card <Card
title={__(`Welcome!`)} title={__(`Welcome!`)}
subtitle={referrerIsChannel ? __(`We've followed your referrer for you. Check it out!`) : __(`Congrats!`)} subtitle={referrerIsChannel ? __(`We've followed your referrer for you. Check it out!`) : __(`Congrats!`)}
actions={ body={
<> referrerIsChannel && (
{referrerIsChannel && ( <div className="claim-preview--channel">
<div key={refUri} className="claim-preview--channel"> <ClaimPreview key={refUri} uri={refUri} actions={''} type={'small'} />
<ClaimPreview key={refUri} uri={refUri} actions={''} type={'small'} />
</div>
)}
<div className="card__actions">
<Button button="primary" label={__('Done!')} onClick={handleDone} />
</div> </div>
</> )
}
actions={
<div className="card__actions">
<Button button="primary" label={__('Done!')} onClick={handleDone} />
</div>
} }
/> />
); );

View file

@ -165,12 +165,7 @@ function PublishForm(props: Props) {
<Card <Card
actions={ actions={
<React.Fragment> <React.Fragment>
<SelectChannel <SelectChannel channel={channel} onChannelChange={channel => updatePublishForm({ channel })} />
channel={channel}
onChannelChange={channel => updatePublishForm({ channel })}
includeAnonymous
includeNew
/>
<p className="help"> <p className="help">
{__('This is a username or handle that your content can be found under.')}{' '} {__('This is a username or handle that your content can be found under.')}{' '}
{__('Ex. @Marvel, @TheBeatles, @BooksByJoe')} {__('Ex. @Marvel, @TheBeatles, @BooksByJoe')}

View file

@ -14,11 +14,12 @@ type Props = {
createChannel: (string, number) => Promise<any>, createChannel: (string, number) => Promise<any>,
fetchChannelListMine: () => void, fetchChannelListMine: () => void,
fetchingChannels: boolean, fetchingChannels: boolean,
emailVerified: boolean, hideNew: boolean,
includeAnonymous?: boolean, hideAnon: boolean,
includeNew?: boolean, includeNew?: boolean,
label?: string, label?: string,
injected?: Array<string>, injected?: Array<string>,
emailVerified: boolean,
}; };
type State = { type State = {
@ -73,9 +74,47 @@ class ChannelSection extends React.PureComponent<Props, State> {
render() { render() {
const channel = this.state.addingChannel ? 'new' : this.props.channel; const channel = this.state.addingChannel ? 'new' : this.props.channel;
const { fetchingChannels, channels = [], includeAnonymous, includeNew, label, injected = [] } = this.props; const { fetchingChannels, channels = [], hideNew, hideAnon, label, injected = [] } = this.props;
const { addingChannel } = this.state; const { addingChannel } = this.state;
if (hideNew) {
return (
<Fragment>
{fetchingChannels ? (
<BusyIndicator message="Updating channels" />
) : (
<>
<FormField
name="channel"
label={label || __('Channel')}
type="select"
onChange={this.handleChannelChange}
value={channel}
>
{!hideAnon && <option value={CHANNEL_ANONYMOUS}>{__('Anonymous')}</option>}
{channels &&
channels.map(({ name, claim_id: claimId }) => (
<option key={claimId} value={name}>
{name}
</option>
))}
{injected &&
injected.map(item => (
<option key={item} value={item}>
{item}
</option>
))}
</FormField>
{addingChannel && (
<div className="section">
<ChannelCreate onSuccess={this.handleChangeToNewChannel} />
</div>
)}
</>
)}
</Fragment>
);
}
return ( return (
<Fragment> <Fragment>
{fetchingChannels ? ( {fetchingChannels ? (
@ -90,7 +129,7 @@ class ChannelSection extends React.PureComponent<Props, State> {
onChange={this.handleChannelChange} onChange={this.handleChannelChange}
value={channel} value={channel}
> >
{includeAnonymous && <option value={CHANNEL_ANONYMOUS}>{__('Anonymous')}</option>} {!hideAnon && <option value={CHANNEL_ANONYMOUS}>{__('Anonymous')}</option>}
{channels && {channels &&
channels.map(({ name, claim_id: claimId }) => ( channels.map(({ name, claim_id: claimId }) => (
<option key={claimId} value={name}> <option key={claimId} value={name}>
@ -103,7 +142,7 @@ class ChannelSection extends React.PureComponent<Props, State> {
{item} {item}
</option> </option>
))} ))}
{includeNew && <option value={CHANNEL_NEW}>{__('New channel...')}</option>} <option value={CHANNEL_NEW}>{__('New channel...')}</option>}
</FormField> </FormField>
</div> </div>
{addingChannel && ( {addingChannel && (

View file

@ -3,6 +3,7 @@ import * as React from 'react';
import { FormField, Form } from 'component/common/form'; import { FormField, Form } from 'component/common/form';
import { Modal } from 'modal/modal'; import { Modal } from 'modal/modal';
import Button from 'component/button'; import Button from 'component/button';
import HelpLink from 'component/common/help-link';
type Props = { type Props = {
closeModal: () => void, closeModal: () => void,
@ -49,7 +50,7 @@ class ModalSetReferrer extends React.PureComponent<Props, State> {
<Form onSubmit={this.handleSubmit}> <Form onSubmit={this.handleSubmit}>
<p> <p>
{__('Tell us who referred you and get a reward!')} {__('Tell us who referred you and get a reward!')}
<Button button="link" href="https://lbry.com/faq/referrals" label={__('?')} />. <HelpLink href="https://lbry.com/faq/referrals" />.
</p> </p>
<FormField <FormField
autoFocus autoFocus