Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 1f37f97

Browse files
authored
Merge pull request #1694 from blockstack/hotfix/minor-fixes-onboarding-september
Additional fixes for v34
2 parents 5d83779 + 9e0448d commit 1f37f97

File tree

9 files changed

+94
-49
lines changed

9 files changed

+94
-49
lines changed

app/js/App.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ class AppContainer extends Component {
193193
}
194194
}
195195

196-
197196
onSupportClick = () => {
198197
openInNewTab('https://forum.blockstack.org/t/frequently-ask-questions/2123')
199198
}
@@ -215,15 +214,17 @@ class AppContainer extends Component {
215214
return (
216215
<div className={`body-main ${noHeader ? 'no-header' : ''}`}>
217216
<div className="wrapper footer-padding">{children}</div>
218-
<SupportButton onClick={this.onSupportClick} />
219217
<NotificationsSystem theme={NotificationsTheme} />
220218
</div>
221219
)
222220
}
223221
}
224222

225223
const App = withRouter(
226-
connect(mapStateToProps, mapDispatchToProps)(AppContainer)
224+
connect(
225+
mapStateToProps,
226+
mapDispatchToProps
227+
)(AppContainer)
227228
)
228229

229230
export default hot(module)(App)

app/js/components/ui/components/form/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const Textarea = styled.textarea`
4141
box-sizing: border-box;
4242
resize: vertical;
4343
min-height: ${({ mh }) => (mh ? `${mh}px` : '48px')};
44-
margin-top: 5px;
44+
margin-top: 15px;
4545
color: rgba(39, 16, 51, 0.7);
4646
`
4747

@@ -150,9 +150,13 @@ const ErrorMessage = styled.div`
150150
left: 0;
151151
top: -5px !important;
152152
153+
${Textarea} ~ & {
154+
top: -20px !important;
155+
}
156+
153157
${Input}:not(:focus) ~ &,
154158
${Textarea}:not(:focus) ~ & {
155-
top: 10px;
159+
156160
${({ overlay }) =>
157161
overlay &&
158162
css`
@@ -184,9 +188,11 @@ const PositiveMessage = styled.div`
184188
top: -5px !important;
185189
font-size: 12px;
186190
font-weight: 500;
191+
${Textarea} ~ & {
192+
top: -20px !important;
193+
}
187194
${Input}:not(:focus) ~ &,
188195
${Textarea}:not(:focus) ~ & {
189-
top: 10px;
190196
${({ overlay }) =>
191197
overlay &&
192198
css`

app/js/components/ui/containers/button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const Button = ({
5858
)
5959
return (
6060
<ButtonComponent {...rest} loading={loading} height={height} to={to}>
61-
<StyledButton.Label {...labelProps}>{content}</StyledButton.Label>
61+
<StyledButton.Label style={{whiteSpace: 'nowrap'}} {...labelProps}>{content}</StyledButton.Label>
6262
{renderIcon()}
6363
</ButtonComponent>
6464
)

app/js/components/ui/containers/profile.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,29 @@ import { UserAvatar } from '@components/ui/containers/user'
44
import { Type } from '@components/ui/components/typography'
55

66
export const Title = ({ user, ...p }) => (
7-
<Box {...p}>
8-
<Type.h2>
7+
<Flex
8+
{...p}
9+
alignItems="center"
10+
justifyContent="center"
11+
style={{ overflow: 'hidden' }}
12+
width="100%"
13+
>
14+
<Type.h2
15+
display="block"
16+
style={{
17+
textAlign: 'center',
18+
overflow: 'hidden',
19+
whiteSpace: 'nowrap',
20+
textOverflow: 'ellipsis'
21+
}}
22+
width='100%'
23+
maxWidth={['calc(100% - 60px)', 'calc(100% - 40px)']}
24+
>
925
{user.username && user.username.includes('.')
1026
? user.username.split('.')[0]
1127
: user.username}
1228
</Type.h2>
13-
</Box>
29+
</Flex>
1430
)
1531
export const Suffix = ({ user, ...p }) => (
1632
<Box opacity={0.5} {...p}>
@@ -25,11 +41,9 @@ export const Line = p => (
2541
)
2642
export const ProfileScreen = ({ children, user, ...p }) => {
2743
const avatarUrl =
28-
user &&
29-
user.profile &&
30-
user.profile.image &&
31-
user.profile.image.length ?
32-
user.profile.image[0].contentUrl : undefined
44+
user && user.profile && user.profile.image && user.profile.image.length
45+
? user.profile.image[0].contentUrl
46+
: undefined
3347

3448
return (
3549
<Flex

app/js/sign-in/views/_initial.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ import { validateAndCleanRecoveryInput } from '@utils/encryption-utils'
77

88
const validateInput = async value =>
99
import(/* webpackChunkName: 'bip39' */ 'bip39').then(bip39 => {
10-
{
11-
// Raw mnemonic phrase
12-
if (bip39.validateMnemonic(value)) {
13-
console.log('valid mnemonic')
14-
return true
15-
}
16-
// Base64 encoded encrypted phrase
17-
return /[a-zA-Z0-9+/]=$/.test(value)
10+
// Raw mnemonic phrase
11+
if (bip39.validateMnemonic(value)) {
12+
console.log('valid mnemonic')
13+
return true
1814
}
15+
// Base64 encoded encrypted phrase
16+
return /[a-zA-Z0-9+/]=$/.test(value)
1917
})
2018

2119
const validationSchema = Yup.object({
@@ -83,7 +81,7 @@ export default class InitialSignInScreen extends React.PureComponent {
8381
validationSchema,
8482
initialValues: { recoveryKey: value },
8583
onSubmit: values => {
86-
next(values.recoveryKey)
84+
next(validateAndCleanRecoveryInput(values.recoveryKey).cleaned)
8785
},
8886
fields: [
8987
{

app/js/sign-up/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class Onboarding extends React.Component {
128128
emailsSending: false,
129129
emailsSent: false,
130130
recoveryEmailError: null,
131+
recoveryEmailErrorCount: 0,
131132
restoreEmailError: null,
132133
loading: false,
133134
view: VIEWS.INITIAL,
@@ -344,7 +345,10 @@ class Onboarding extends React.Component {
344345
await sendEmail(email, id, encodedPhrase)
345346
this.setState({ recoveryEmailError: null })
346347
} catch (err) {
347-
this.setState({ recoveryEmailError: err })
348+
this.setState({
349+
recoveryEmailError: err,
350+
recoveryEmailErrorCount: this.state.recoveryEmailErrorCount + 1
351+
})
348352
}
349353

350354
return this.setState({
@@ -540,6 +544,7 @@ class Onboarding extends React.Component {
540544
app,
541545
restoreEmailError: this.state.restoreEmailError,
542546
emailsSending: this.state.emailsSending,
547+
recoveryEmailErrorCount: this.state.recoveryEmailErrorCount,
543548
sendRestoreEmail: () => this.sendEmails('restore'),
544549
next: () => this.infoNext()
545550
}

app/js/sign-up/views/_recovery-information.js

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,36 @@ import React from 'react'
77
import { ShellScreen, Type, Shell } from '@blockstack/ui'
88
import PropTypes from 'prop-types'
99
class RecoverInformationScreen extends React.Component {
10-
sendEmailAgain = () => {
11-
if (!this.props.emailsSending) {
12-
this.props.sendRestoreEmail()
13-
}
14-
}
15-
1610
render() {
17-
const { next, email, emailsSending, ...rest } = this.props
11+
const {
12+
next,
13+
email,
14+
emailsSending,
15+
recoveryEmailErrorCount,
16+
...rest
17+
} = this.props
1818

1919
const title = 'Recovery email failed to send'
20-
const body = (
21-
<>
22-
<Type.p>
23-
We tried to send recovery info to {email} but something went wrong.
24-
You can{' '}
25-
<Type.a onClick={() => this.sendEmailAgain()}>
26-
try to resend the email
27-
</Type.a>
28-
, or manually save your Secret Recovery Key.
29-
</Type.p>
30-
</>
31-
)
20+
const body =
21+
recoveryEmailErrorCount > 1 ? (
22+
<>
23+
<Type.p>
24+
We tried to send recovery info to {email} but something went wrong.
25+
You must manually save your Secret Recovery Key.
26+
</Type.p>
27+
</>
28+
) : (
29+
<>
30+
<Type.p>
31+
We tried to send recovery info to {email} but something went wrong.
32+
You can{' '}
33+
<Type.a onClick={() => this.props.backView()}>
34+
try to resend the email
35+
</Type.a>
36+
, or manually save your Secret Recovery Key.
37+
</Type.p>
38+
</>
39+
)
3240

3341
const props = {
3442
title: {
@@ -41,7 +49,7 @@ class RecoverInformationScreen extends React.Component {
4149
actions: {
4250
items: [
4351
{
44-
label: 'Secret Recover Key',
52+
label: 'Secret Recovery Key',
4553
onClick: () => next(),
4654
primary: true
4755
}
@@ -63,7 +71,7 @@ RecoverInformationScreen.propTypes = {
6371
next: PropTypes.func.isRequired,
6472
toggleConsent: PropTypes.func.isRequired,
6573
email: PropTypes.string.isRequired,
66-
consent: PropTypes.bool.isRequired,
74+
recoveryEmailErrorCount: PropTypes.number.isRequired,
6775
restoreEmailError: PropTypes.oneOfType([
6876
PropTypes.string,
6977
PropTypes.instanceOf(Error)

app/js/sign-up/views/_username.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,29 @@ class UsernameView extends React.Component {
7474

7575
if (values.username !== this.state.username && !noValues) {
7676
const MIN_USERNAME_LENGTH = 8
77-
const validLength = values.username.length >= MIN_USERNAME_LENGTH
77+
const MAX_USERNAME_LENGTH = 38
78+
const validMinLength = values.username.length >= MIN_USERNAME_LENGTH
79+
const validMaxLength = values.username.length < MAX_USERNAME_LENGTH
7880

7981
const minLengthErrorMessage = `Must be at least ${8} characters.`
82+
const maxLengthErrorMessage = 'Username is too long.'
8083

81-
if (!validLength) {
84+
if (!validMinLength) {
8285
this.setState({
8386
status: STATUS.ERROR
8487
})
8588
errors.username = minLengthErrorMessage
8689
throw errors
8790
}
8891

92+
if (!validMaxLength) {
93+
this.setState({
94+
status: STATUS.ERROR
95+
})
96+
errors.username = maxLengthErrorMessage
97+
throw errors
98+
}
99+
89100
const invalidChars = values.username.match(/\W+/g)
90101

91102
if (invalidChars) {
@@ -178,7 +189,8 @@ class UsernameView extends React.Component {
178189
children: (
179190
<>
180191
<Type.small pt={3}>
181-
This will be your unique, public identity for any Blockstack&nbsp;app.
192+
This will be your unique, public identity for any
193+
Blockstack&nbsp;app.
182194
</Type.small>
183195
{canSkip && (
184196
<Type.small pt={3}>

app/js/utils/encryption-utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export function validateAndCleanRecoveryInput(input) {
3838
.join(' ')
3939

4040
if (bip39.validateMnemonic(cleanedMnemonic)) {
41+
logger.debug('This is a valid mnemonic.')
4142
return {
4243
isValid: true,
4344
type: RECOVERY_TYPE.MNEMONIC,

0 commit comments

Comments
 (0)