Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
[WEB-44] Improve signing in UX (#1466)
Browse files Browse the repository at this point in the history
  • Loading branch information
quanglam2807 authored Jul 14, 2021
1 parent a31cc2f commit 71d456f
Show file tree
Hide file tree
Showing 7 changed files with 353 additions and 316 deletions.
2 changes: 1 addition & 1 deletion src/components/dialogs/dialog-license-registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const DialogLicenseRegistration = (props) => {
placeholder="0-0000000000000-00000000-00000000-00000000-00000000"
error={Boolean(licenseKeyError)}
variant="outlined"
helperText={licenseKeyError || 'If you have already purchased WebCatalog Lifetime or Singlebox from our store, you should have received a license key via email to enter above.'}
helperText={licenseKeyError || 'If you have already purchased WebCatalog Lifetime from our store, you should have received a license key via email to enter above.'}
/>

<DialogContentText className={classes.helpContent}>
Expand Down
22 changes: 18 additions & 4 deletions src/components/pages/preferences/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import RotateLeftIcon from '@material-ui/icons/RotateLeft';
import SecurityIcon from '@material-ui/icons/Security';
import UpdateIcon from '@material-ui/icons/Update';
import WidgetsIcon from '@material-ui/icons/Widgets';
import SyncIcon from '@material-ui/icons/Sync';

import connectComponent from '../../../helpers/connect-component';

Expand All @@ -47,7 +48,8 @@ import {
} from '../../../senders';

import DefinedAppBar from './defined-app-bar';
import SectionAccount from './section-account';
import SectionSync from './section-sync';
import SectionLicensing from './section-licensing';

const styles = (theme) => ({
root: {
Expand Down Expand Up @@ -195,10 +197,15 @@ const Preferences = ({
}) => {
const sections = {
account: {
text: 'Account & Licensing',
text: 'Licensing',
Icon: AccountCircleIcon,
ref: useRef(),
},
sync: {
text: 'Sync',
Icon: SyncIcon,
ref: useRef(),
},
general: {
text: 'General',
Icon: WidgetsIcon,
Expand Down Expand Up @@ -265,10 +272,17 @@ const Preferences = ({
</div>
<div className={classes.inner}>
<Typography variant="subtitle2" color="textPrimary" className={classes.sectionTitle} ref={sections.account.ref}>
Account & Licensing
Licensing
</Typography>
<Paper elevation={0} className={classes.paper}>
<SectionLicensing />
</Paper>

<Typography variant="subtitle2" color="textPrimary" className={classes.sectionTitle} ref={sections.sync.ref}>
Sync
</Typography>
<Paper elevation={0} className={classes.paper}>
<SectionAccount />
<SectionSync />
</Paper>

<Typography variant="subtitle2" color="textPrimary" className={classes.sectionTitle} ref={sections.general.ref}>
Expand Down
131 changes: 0 additions & 131 deletions src/components/pages/preferences/section-account.js

This file was deleted.

67 changes: 67 additions & 0 deletions src/components/pages/preferences/section-licensing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/* eslint-disable no-constant-condition */
import React from 'react';
import PropTypes from 'prop-types';

import Divider from '@material-ui/core/Divider';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';

import ChevronRightIcon from '@material-ui/icons/ChevronRight';

import { open as openDialogLicenseRegistration } from '../../../state/dialog-license-registration/actions';

import connectComponent from '../../../helpers/connect-component';

const SectionLicensing = ({
registered,
onOpenDialogLicenseRegistration,
}) => {
const upgradeToLifetimeComponent = !registered && (
<>
<Divider />
<ListItem button onClick={onOpenDialogLicenseRegistration}>
<ListItemText primary="Upgrade to WebCatalog Lifetime" />
<ChevronRightIcon color="action" />
</ListItem>
</>
);

return (
<List dense disablePadding>
<ListItem button disabled>
<ListItemText primary={registered ? 'WebCatalog Lifetime' : 'WebCatalog Basic'} />
</ListItem>
{upgradeToLifetimeComponent}
</List>
);
};

SectionLicensing.defaultProps = {
registered: false,
};

SectionLicensing.propTypes = {
onOpenDialogLicenseRegistration: PropTypes.func.isRequired,
registered: PropTypes.bool,
};

const mapStateToProps = (state) => ({
displayName: state.user.displayName,
isSignedIn: state.user.isSignedIn,
photoURL: state.user.photoURL,
registered: state.preferences.registered,
});

const actionCreators = {
openDialogLicenseRegistration,
};

export default connectComponent(
SectionLicensing,
mapStateToProps,
actionCreators,
);
110 changes: 110 additions & 0 deletions src/components/pages/preferences/section-sync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/* eslint-disable no-constant-condition */
import React from 'react';
import PropTypes from 'prop-types';

import Avatar from '@material-ui/core/Avatar';
import Divider from '@material-ui/core/Divider';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import ListItemText from '@material-ui/core/ListItemText';

import ChevronRightIcon from '@material-ui/icons/ChevronRight';

import {
requestOpenInBrowser,
requestSignInWithPopup,
} from '../../../senders';

import connectComponent from '../../../helpers/connect-component';

import firebase from '../../../firebase';

const SectionSync = ({
displayName,
isSignedIn,
photoURL,
}) => (
<List disablePadding dense>
<ListItem>
<ListItemText secondary="Syncing is under development and requires a WebCatalog account with WebCatalog Pro subscription." />
</ListItem>
<Divider />
{!isSignedIn ? (
<>
<ListItem
button
onClick={() => {
// we don't use logging in with protocol webcatalog://
// as it causes wrong Electron instance to be opened
// e.g. it opens production app instead of dev env
if (window.process.platform === 'linux' || process.env.NODE_ENV !== 'production') {
requestSignInWithPopup();
return;
}
requestOpenInBrowser('https://accounts.webcatalog.app/token');
}}
>
<ListItemText primary="Sign in to WebCatalog" />
<ChevronRightIcon color="action" />
</ListItem>
<Divider />
<ListItem button onClick={() => requestOpenInBrowser('https://forms.gle/AAByYb4hYppP91YRA')}>
<ListItemText primary="Join WebCatalog Pro Waitlist" />
<ChevronRightIcon color="action" />
</ListItem>
</>
) : (
<>
<ListItem alignItems="flex-start">
<ListItemAvatar>
<Avatar alt={displayName} src={photoURL} />
</ListItemAvatar>
</ListItem>
<Divider />
<ListItem button onClick={() => requestOpenInBrowser('https://forms.gle/AAByYb4hYppP91YRA')}>
<ListItemText primary="Join WebCatalog Pro Waitlist" />
<ChevronRightIcon color="action" />
</ListItem>
<Divider />
<ListItem button onClick={() => requestOpenInBrowser('https://accounts.webcatalog.app/settings/profile')}>
<ListItemText primary="Profile & Password" />
<ChevronRightIcon color="action" />
</ListItem>
<Divider />
<ListItem button onClick={() => firebase.auth().signOut()}>
<ListItemText primary="Log Out" />
<ChevronRightIcon color="action" />
</ListItem>
</>
)}
</List>
);

SectionSync.defaultProps = {
displayName: '',
isSignedIn: false,
photoURL: null,
};

SectionSync.propTypes = {
displayName: PropTypes.string,
isSignedIn: PropTypes.bool,
photoURL: PropTypes.string,
};

const mapStateToProps = (state) => ({
displayName: state.user.displayName,
isSignedIn: state.user.isSignedIn,
photoURL: state.user.photoURL,
registered: state.preferences.registered,
});

export default connectComponent(
SectionSync,
mapStateToProps,
null,
);
Loading

0 comments on commit 71d456f

Please sign in to comment.