update sign in page with analytics toggle
This commit is contained in:
parent
92ea75b1d8
commit
091d6caf07
5 changed files with 46 additions and 29 deletions
|
@ -69,7 +69,7 @@
|
|||
"@babel/register": "^7.0.0",
|
||||
"@exponent/electron-cookies": "^2.0.0",
|
||||
"@hot-loader/react-dom": "^16.8",
|
||||
"@lbry/components": "^3.0.11",
|
||||
"@lbry/components": "^3.0.12",
|
||||
"@reach/menu-button": "^0.1.18",
|
||||
"@reach/rect": "^0.2.1",
|
||||
"@reach/tabs": "^0.1.5",
|
||||
|
|
|
@ -988,5 +988,7 @@
|
|||
"Sign In to lbry.tv to Earn Rewards From Inviting Your Friends": "Sign In to lbry.tv to Earn Rewards From Inviting Your Friends",
|
||||
"Email %help_link% or join our %chat_link% if you encounter any trouble verifying.": "Email %help_link% or join our %chat_link% if you encounter any trouble verifying.",
|
||||
"You are signed into lbry.tv which automatically shares data with LBRY inc. %signout_button%": "You are signed into lbry.tv which automatically shares data with LBRY inc. %signout_button%",
|
||||
"You are signed into lbry.tv which automatically shares data with LBRY inc. %signout_button%.": "You are signed into lbry.tv which automatically shares data with LBRY inc. %signout_button%."
|
||||
"You are signed into lbry.tv which automatically shares data with LBRY inc. %signout_button%.": "You are signed into lbry.tv which automatically shares data with LBRY inc. %signout_button%.",
|
||||
"Share usage data with LBRY inc.": "Share usage data with LBRY inc.",
|
||||
"Required": "Required"
|
||||
}
|
|
@ -1,19 +1,23 @@
|
|||
import * as SETTINGS from 'constants/settings';
|
||||
import { connect } from 'react-redux';
|
||||
import { selectEmailNewIsPending, selectEmailNewErrorMessage, doUserEmailNew } from 'lbryinc';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { DAEMON_SETTINGS } from 'lbry-redux';
|
||||
import { doSetClientSetting, doSetDaemonSetting } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting, selectDaemonSettings } from 'redux/selectors/settings';
|
||||
import UserEmailNew from './view';
|
||||
|
||||
const select = state => ({
|
||||
isPending: selectEmailNewIsPending(state),
|
||||
errorMessage: selectEmailNewErrorMessage(state),
|
||||
syncEnabled: makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state),
|
||||
daemonSettings: selectDaemonSettings(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
addUserEmail: email => dispatch(doUserEmailNew(email)),
|
||||
setSync: value => dispatch(doSetClientSetting(SETTINGS.ENABLE_SYNC, value)),
|
||||
setShareDiagnosticData: shouldShareData =>
|
||||
dispatch(doSetDaemonSetting(DAEMON_SETTINGS.SHARE_USAGE_DATA, shouldShareData)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
|
|
@ -4,7 +4,6 @@ import { FormField, Form } from 'component/common/form';
|
|||
import Button from 'component/button';
|
||||
import analytics from 'analytics';
|
||||
import { EMAIL_REGEX } from 'constants/email';
|
||||
import I18nMessage from 'component/i18nMessage';
|
||||
|
||||
type Props = {
|
||||
errorMessage: ?string,
|
||||
|
@ -13,17 +12,26 @@ type Props = {
|
|||
syncEnabled: boolean,
|
||||
setSync: boolean => void,
|
||||
balance: number,
|
||||
daemonSettings: { share_usage_data: boolean },
|
||||
setShareDiagnosticData: boolean => void,
|
||||
};
|
||||
|
||||
function UserEmailNew(props: Props) {
|
||||
const { errorMessage, isPending, addUserEmail, setSync } = props;
|
||||
const { errorMessage, isPending, addUserEmail, setSync, daemonSettings, setShareDiagnosticData } = props;
|
||||
const { share_usage_data: shareUsageData } = daemonSettings;
|
||||
const [newEmail, setEmail] = useState('');
|
||||
const [localShareUsageData, setLocalShareUsageData] = React.useState(false);
|
||||
const [formSyncEnabled, setFormSyncEnabled] = useState(true);
|
||||
const valid = newEmail.match(EMAIL_REGEX);
|
||||
|
||||
function handleUsageDataChange() {
|
||||
setLocalShareUsageData(!shareUsageData);
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
setSync(formSyncEnabled);
|
||||
addUserEmail(newEmail);
|
||||
setShareDiagnosticData(true);
|
||||
analytics.emailProvidedEvent();
|
||||
}
|
||||
|
||||
|
@ -64,27 +72,30 @@ function UserEmailNew(props: Props) {
|
|||
onChange={() => setFormSyncEnabled(!formSyncEnabled)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{!shareUsageData && (
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="share_data_checkbox"
|
||||
checked={localShareUsageData}
|
||||
onChange={handleUsageDataChange}
|
||||
label={
|
||||
<React.Fragment>
|
||||
{__('Share usage data with LBRY inc.')}{' '}
|
||||
<Button button="link" href="https://lbry.com/faq/account-sync" label={__('Learn More')} />
|
||||
{!localShareUsageData && <span className="error-text"> ({__('Required')})</span>}
|
||||
</React.Fragment>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<div className="card__actions">
|
||||
<Button button="primary" type="submit" label={__('Continue')} disabled={!newEmail || !valid || isPending} />
|
||||
<Button
|
||||
button="primary"
|
||||
type="submit"
|
||||
label={__('Continue')}
|
||||
disabled={!newEmail || !valid || !setShareDiagnosticData || isPending}
|
||||
/>
|
||||
</div>
|
||||
<p className="help">
|
||||
<React.Fragment>
|
||||
<I18nMessage
|
||||
tokens={{
|
||||
terms: (
|
||||
<Button
|
||||
tabIndex="2"
|
||||
button="link"
|
||||
href="https://www.lbry.com/termsofservice"
|
||||
label={__('Terms of Service')}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
>
|
||||
By continuing, I agree to the %terms% and confirm I am over the age of 13.
|
||||
</I18nMessage>
|
||||
</React.Fragment>
|
||||
</p>
|
||||
</Form>
|
||||
</React.Fragment>
|
||||
);
|
||||
|
|
|
@ -1033,10 +1033,10 @@
|
|||
prop-types "^15.6.2"
|
||||
scheduler "^0.15.0"
|
||||
|
||||
"@lbry/components@^3.0.11":
|
||||
version "3.0.11"
|
||||
resolved "https://registry.yarnpkg.com/@lbry/components/-/components-3.0.11.tgz#e3c1363d26059fa2a5fa47a4e9b1cd4a61e7cf1d"
|
||||
integrity sha512-dGSv5A3uQkHmmMkZfJ3bG6blEARLFn3lBU9dnTiXXABVR2QQXiDn+Wu3rUjraHvC/0JBzoeiCv1mniRFiGBOGw==
|
||||
"@lbry/components@^3.0.12":
|
||||
version "3.0.12"
|
||||
resolved "https://registry.yarnpkg.com/@lbry/components/-/components-3.0.12.tgz#9ba4598edf26496060a97023ca0132d39c388c3b"
|
||||
integrity sha512-Nz4HhvMACByz9aKFc3tWpvSbkWNxdybICmOv/r/H5ThXb8DGURw+yx01/PynO/hnRFFQZz7TurmNzHLlaO29gw==
|
||||
|
||||
"@mapbox/hast-util-table-cell-style@^0.1.3":
|
||||
version "0.1.3"
|
||||
|
|
Loading…
Add table
Reference in a new issue