Skip to content

Commit

Permalink
Remove demo wallet login option from production UI
Browse files Browse the repository at this point in the history
  • Loading branch information
refi93 committed Jun 10, 2021
1 parent aab09a2 commit e3c87a5
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 83 deletions.
7 changes: 0 additions & 7 deletions app/frontend/actions/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ export default (store: Store) => {
setState({authMethod})
}

const closeDemoWalletWarningDialog = (state) => {
setState({
shouldShowDemoWalletWarningDialog: false,
})
}

const closeNonShelleyCompatibleDialog = (state) => {
setState({
shouldShowNonShelleyCompatibleDialog: false,
Expand Down Expand Up @@ -142,7 +136,6 @@ export default (store: Store) => {
closeInfoModal,
closePremiumBanner,
setAuthMethod,
closeDemoWalletWarningDialog,
closeNonShelleyCompatibleDialog,
openNonShelleyCompatibleDialog,
closeWalletLoadingErrorModal,
Expand Down
2 changes: 0 additions & 2 deletions app/frontend/actions/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export default (store: Store) => {
await mnemonicToWalletSecretDef(ADALITE_CONFIG.ADALITE_DEMO_WALLET_MNEMONIC)
).rootSecret
const isDemoWallet = walletSecretDef && walletSecretDef.rootSecret.equals(demoRootSecret)
const autoLogin = state.autoLogin
setState({
validStakepoolDataProvider,
accountsInfo,
Expand All @@ -123,7 +122,6 @@ export default (store: Store) => {
},
hwWalletName,
isDemoWallet,
shouldShowDemoWalletWarningDialog: isDemoWallet && !autoLogin,
shouldShowNonShelleyCompatibleDialog: !isShelleyCompatible,
shouldShowWantedAddressesModal,
shouldShowGenerateMnemonicDialog: false,
Expand Down
41 changes: 0 additions & 41 deletions app/frontend/components/pages/login/demoWalletWarningDialog.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions app/frontend/components/pages/login/loginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import {h} from 'preact'
import {useState, useEffect} from 'preact/hooks'
import {useSelector, useActions} from '../../../helpers/connect'
import actions from '../../../actions'
import isLeftClick from '../../../helpers/isLeftClick'
import KeyFileAuth from './keyFileAuth'
import MnemonicAuth from './mnemonicAuth'
import HardwareAuth from './hardwareAuth'
import DemoWalletWarningDialog from './demoWalletWarningDialog'
import GenerateMnemonicDialog from './generateMnemonicDialog'
import LogoutNotification from './logoutNotification'
import LoginPageSidebar from './loginPageSidebar'
Expand Down Expand Up @@ -205,7 +203,6 @@ const LoginPage = () => {
const toggleDropdown = () => setIsDropdownOpen(!isDropdownOpen)
const {
authMethod,
shouldShowDemoWalletWarningDialog,
logoutNotificationOpen,
walletLoadingError,
shouldShowGenerateMnemonicDialog,
Expand All @@ -215,7 +212,6 @@ const LoginPage = () => {
errorBannerContent,
} = useSelector((state: State) => ({
authMethod: state.authMethod,
shouldShowDemoWalletWarningDialog: state.shouldShowDemoWalletWarningDialog,
logoutNotificationOpen: state.logoutNotificationOpen,
walletLoadingError: state.walletLoadingError,
shouldShowGenerateMnemonicDialog: state.shouldShowGenerateMnemonicDialog,
Expand All @@ -226,7 +222,6 @@ const LoginPage = () => {
}))
const {
closeStakingBanner,
loadDemoWallet,
setAuthMethod,
closeWalletLoadingErrorModal,
loadErrorBannerContent,
Expand Down Expand Up @@ -255,15 +250,8 @@ const LoginPage = () => {
toggleDropdown={toggleDropdown}
/>
)}
<div className="page-demo">
Try the{' '}
<a href="#" onMouseDown={(e) => isLeftClick(e, loadDemoWallet)}>
demo wallet
</a>
</div>
</main>
<LoginPageSidebar />
{shouldShowDemoWalletWarningDialog && <DemoWalletWarningDialog />}
{shouldShowGenerateMnemonicDialog && <GenerateMnemonicDialog />}
{logoutNotificationOpen && <LogoutNotification />}
{shouldShowWalletLoadingErrorModal && (
Expand Down
25 changes: 10 additions & 15 deletions app/frontend/components/pages/login/mnemonicAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,14 @@ import {useEffect, useRef} from 'preact/hooks'
const {ADALITE_DEMO_WALLET_MNEMONIC} = ADALITE_CONFIG

const MnemonicAuth = (): h.JSX.Element => {
const {
formData,
shouldShowMnemonicInfoAlert,
autoLogin,
displayWelcome,
shouldShowDemoWalletWarningDialog,
} = useSelector((state) => ({
formData: state.mnemonicAuthForm,
displayWelcome: state.displayWelcome,
shouldShowDemoWalletWarningDialog: state.shouldShowDemoWalletWarningDialog,
shouldShowMnemonicInfoAlert: state.shouldShowMnemonicInfoAlert,
autoLogin: state.autoLogin,
}))
const {formData, shouldShowMnemonicInfoAlert, autoLogin, displayWelcome} = useSelector(
(state) => ({
formData: state.mnemonicAuthForm,
displayWelcome: state.displayWelcome,
shouldShowMnemonicInfoAlert: state.shouldShowMnemonicInfoAlert,
autoLogin: state.autoLogin,
})
)
const {
updateMnemonic,
updateMnemonicValidationError,
Expand All @@ -37,10 +32,10 @@ const MnemonicAuth = (): h.JSX.Element => {
const goBtn = useRef<HTMLButtonElement>(null)

useEffect(() => {
if (!formData.mnemonicInputValue && !displayWelcome && !shouldShowDemoWalletWarningDialog) {
if (!formData.mnemonicInputValue && !displayWelcome) {
mnemonicField.current.focus()
}
}, [formData.mnemonicInputValue, displayWelcome, shouldShowDemoWalletWarningDialog])
}, [formData.mnemonicInputValue, displayWelcome])

useEffect(() => {
// meant only for development in order to speed up the process of unlocking wallet
Expand Down
5 changes: 2 additions & 3 deletions app/frontend/components/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import StakingPage from './pages/staking/stakingPage'
const TopLevelRouter = connect((state) => ({
pathname: state.router.pathname,
walletIsLoaded: state.walletIsLoaded,
shouldShowDemoWalletWarningDialog: state.shouldShowDemoWalletWarningDialog,
}))(({pathname, walletIsLoaded, shouldShowDemoWalletWarningDialog}) => {
}))(({pathname, walletIsLoaded}) => {
// unlock not wrapped in main
const currentTab = pathname.split('/')[1]
if ((!walletIsLoaded || shouldShowDemoWalletWarningDialog) && currentTab !== 'staking') {
if (!walletIsLoaded && currentTab !== 'staking') {
window.history.pushState({}, '/', '/')
return <LoginPage />
}
Expand Down
2 changes: 0 additions & 2 deletions app/frontend/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export interface State {
// login / logout
autoLogin: boolean
authMethod: AuthMethodType | null
shouldShowDemoWalletWarningDialog: boolean
logoutNotificationOpen: boolean
walletIsLoaded: boolean
isShelleyCompatible: any
Expand Down Expand Up @@ -155,7 +154,6 @@ const initialState: State = {
authMethod: ['#trezor', '#hw-wallet'].includes(window.location.hash)
? AuthMethodType.HW_WALLET
: null,
shouldShowDemoWalletWarningDialog: false,
logoutNotificationOpen: false,
walletIsLoaded: false,
isShelleyCompatible: true,
Expand Down
1 change: 0 additions & 1 deletion app/tests/src/actions/wallet-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const expectedStateChanges = {
},
hwWalletName: null,
isDemoWallet: false,
shouldShowDemoWalletWarningDialog: false,
shouldShowGenerateMnemonicDialog: false,
// send form
sendAmount: {assetFamily: AssetFamily.ADA, fieldValue: '', coins: 0},
Expand Down

0 comments on commit e3c87a5

Please sign in to comment.