-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4326 from LiskHQ/4294-implement-setup-password-su…
…ccess Implement setup password success - Closes #4294
- Loading branch information
Showing
5 changed files
with
149 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './setPasswordSuccess'; |
52 changes: 52 additions & 0 deletions
52
src/modules/auth/components/setPasswordSuccess/setPasswordSuccess.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
@import '../../../../../setup/react/app/mixins.css'; | ||
|
||
.container { | ||
flex-grow: 1; | ||
justify-content: center; | ||
text-align: center; | ||
} | ||
|
||
.content { | ||
padding: 64px 64px 50px !important; | ||
|
||
& h1 { | ||
margin: 0 0 16px 0; | ||
} | ||
|
||
& > .subheader { | ||
@mixin contentLargest; | ||
|
||
color: var(--color-blue-gray); | ||
margin: 0; | ||
font-size: var(--subtitle-font-size-s); | ||
} | ||
|
||
& > .jsonFile { | ||
@mixin contentNormal; | ||
|
||
margin: 8px 0 32px 0; | ||
color: var(--color-blue-gray); | ||
} | ||
|
||
& > .downloadLisk { | ||
display: flex; | ||
width: 100%; | ||
padding: 16px 0; | ||
justify-content: center; | ||
|
||
& > p { | ||
@mixin contentLarge bold; | ||
|
||
color: var(--color-blue-gray); | ||
margin: 20px; | ||
text-align: left; | ||
word-spacing: 8px; | ||
} | ||
} | ||
|
||
& > .continueButton { | ||
@mixin contentNormal; | ||
|
||
width: 100%; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/modules/auth/components/setPasswordSuccess/setPasswordSuccess.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { PrimaryButton, TertiaryButton } from 'src/theme/buttons'; | ||
import { downloadJSON, transactionToJSON } from '@transaction/utils'; | ||
import Box from 'src/theme/box'; | ||
import BoxContent from 'src/theme/box/content'; | ||
import Icon from 'src/theme/Icon'; | ||
import styles from './setPasswordSuccess.css'; | ||
|
||
function SetPasswordSuccess({ onClose, encryptedPhrase }) { | ||
const { t } = useTranslation(); | ||
|
||
const onDownload = () => { | ||
const encryptedJSON = JSON.parse(transactionToJSON(encryptedPhrase)); | ||
downloadJSON(encryptedJSON, 'encrypted_secret_recovery_phrase'); | ||
}; | ||
|
||
const onContinue = () => onClose(); | ||
|
||
return ( | ||
<Box className={styles.container}> | ||
<BoxContent className={styles.content}> | ||
<h1>{t("Perfect! You're all set")}</h1> | ||
<p className={styles.subheader}> | ||
{t( | ||
'You can now download your encrypted secret recovery phrase and use it to add your account on other devices.', | ||
)} | ||
</p> | ||
<div className={styles.downloadLisk}> | ||
<Icon name="fileOutline" /> | ||
<p className="option-value">encrypted_secret_recovery_phrase.json</p> | ||
<TertiaryButton | ||
className={styles.downloadBtn} | ||
size="xs" | ||
onClick={onDownload} | ||
> | ||
{t('Download')} | ||
</TertiaryButton> | ||
</div> | ||
<PrimaryButton className={styles.continueButton} onClick={onContinue}> | ||
{t('Continue to Dashboard')} | ||
</PrimaryButton> | ||
</BoxContent> | ||
</Box> | ||
); | ||
} | ||
|
||
SetPasswordSuccess.defaultProps = { | ||
encryptedPhrase: { | ||
error: 'no encrypted backup found', | ||
}, | ||
}; | ||
|
||
export default SetPasswordSuccess; |
39 changes: 39 additions & 0 deletions
39
src/modules/auth/components/setPasswordSuccess/setPasswordSuccess.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import * as txUtils from '@transaction/utils/transaction'; | ||
import SetPasswordSuccess from './index'; | ||
|
||
describe('Setup password success and JSON download component', () => { | ||
const props = { | ||
onClose: jest.fn(), | ||
encryptedPhrase: { | ||
name: 'encrypted recovery phrase', | ||
phrase: 'encrypted_phrase', | ||
}, | ||
}; | ||
|
||
it('should render properly', () => { | ||
const wrapper = mount(<SetPasswordSuccess {...props} />); | ||
expect(wrapper).toContainMatchingElement('.container'); | ||
expect(wrapper).toContainMatchingElement('.content'); | ||
expect(wrapper).toContainMatchingElement('.subheader'); | ||
expect(wrapper).toContainMatchingElement('.downloadLisk'); | ||
expect(wrapper).toContainMatchingElement('.downloadBtn'); | ||
expect(wrapper).toContainMatchingElement('.continueButton'); | ||
}); | ||
|
||
it('should download JSON when download button is clicked', () => { | ||
const spyOnJSONDownload = jest.spyOn(txUtils, 'downloadJSON'); | ||
const wrapper = mount(<SetPasswordSuccess {...props} />); | ||
wrapper.find('.downloadBtn').at(0).simulate('click'); | ||
expect(spyOnJSONDownload).toHaveBeenCalledWith( | ||
props.encryptedPhrase, | ||
'encrypted_secret_recovery_phrase', | ||
); | ||
}); | ||
|
||
it('should close modal when continue button is clicked', () => { | ||
const wrapper = mount(<SetPasswordSuccess {...props} />); | ||
wrapper.find('.continueButton').at(0).simulate('click'); | ||
}); | ||
}); |