Skip to content

Commit

Permalink
Merge pull request #3024 from near/wallet-migration-ux-improvements
Browse files Browse the repository at this point in the history
Wallet migration UX improvements
  • Loading branch information
andy-haynes authored Mar 29, 2023
2 parents 228e062 + d5be4db commit 2106801
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 145 deletions.
38 changes: 19 additions & 19 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
},
"dependencies": {
"@ledgerhq/hw-transport-u2f": "^5.34.0",
"@near-wallet-selector/account-export": "^7.8.2",
"@near-wallet-selector/coin98-wallet": "^7.8.2",
"@near-wallet-selector/core": "^7.8.2",
"@near-wallet-selector/default-wallets": "^7.8.2",
"@near-wallet-selector/here-wallet": "^7.8.2",
"@near-wallet-selector/ledger": "^7.8.2",
"@near-wallet-selector/math-wallet": "^7.8.2",
"@near-wallet-selector/meteor-wallet": "^7.8.2",
"@near-wallet-selector/modal-ui": "^7.8.2",
"@near-wallet-selector/my-near-wallet": "^7.8.2",
"@near-wallet-selector/near-wallet": "^7.8.2",
"@near-wallet-selector/nearfi": "^7.8.2",
"@near-wallet-selector/neth": "^7.8.2",
"@near-wallet-selector/nightly": "^7.8.2",
"@near-wallet-selector/nightly-connect": "^7.8.2",
"@near-wallet-selector/opto-wallet": "^7.8.2",
"@near-wallet-selector/sender": "^7.8.2",
"@near-wallet-selector/wallet-connect": "^7.8.2",
"@near-wallet-selector/welldone-wallet": "^7.8.2",
"@near-wallet-selector/account-export": "^7.9.2",
"@near-wallet-selector/coin98-wallet": "^7.9.2",
"@near-wallet-selector/core": "^7.9.2",
"@near-wallet-selector/default-wallets": "^7.9.2",
"@near-wallet-selector/here-wallet": "^7.9.2",
"@near-wallet-selector/ledger": "^7.9.2",
"@near-wallet-selector/math-wallet": "^7.9.2",
"@near-wallet-selector/meteor-wallet": "^7.9.2",
"@near-wallet-selector/modal-ui": "^7.9.2",
"@near-wallet-selector/my-near-wallet": "^7.9.2",
"@near-wallet-selector/near-wallet": "^7.9.2",
"@near-wallet-selector/nearfi": "^7.9.2",
"@near-wallet-selector/neth": "^7.9.2",
"@near-wallet-selector/nightly": "^7.9.2",
"@near-wallet-selector/nightly-connect": "^7.9.2",
"@near-wallet-selector/opto-wallet": "^7.9.2",
"@near-wallet-selector/sender": "^7.9.2",
"@near-wallet-selector/wallet-connect": "^7.9.2",
"@near-wallet-selector/welldone-wallet": "^7.9.2",
"@near-wallet/feature-flags": "^0.2.0",
"@reduxjs/toolkit": "1.6.2",
"@sentry/browser": "^6.4.1",
Expand Down
7 changes: 6 additions & 1 deletion packages/frontend/src/components/Routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ import { StakingContainer } from './staking/StakingContainer';
import Swap from './swap/Swap';
import Terms from './terms/Terms';
import '../index.css';
import WalletMigration from './wallet-migration/WalletMigration';
import { getMigrationStep } from './wallet-migration/utils';
import WalletMigration, { WALLET_MIGRATION_VIEWS } from './wallet-migration/WalletMigration';
const { fetchTokenFiatValues, getTokenWhiteList } = tokenFiatValueActions;

const {
Expand Down Expand Up @@ -305,6 +306,10 @@ class Routing extends Component {
handleTransferClick = () => {

this.setState({ openTransferPopup: true });
const migrationStep = getMigrationStep();
if (migrationStep === WALLET_MIGRATION_VIEWS.MIGRATE_ACCOUNTS) {
window?.ExportModal?.show();
}
}

closeTransferPopup = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export function WalletSelectorGetAWallet({
showModal,
setShowModal
}) {

const walletWrapperDiv = document.getElementById('near-wallet-selector-modal');
walletWrapperDiv?.classList.add('wallet-selector-get-a-wallet-modal');

if (showModal === 'more-near-wallets') {
const walletWrapperDiv = document.getElementById('near-wallet-selector-modal');
walletWrapperDiv?.classList.add('wallet-selector-get-a-wallet-modal');
}
useEffect(() => {

const initSelector = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ const WalletMigration = ({ open, onClose }) => {
);
}

// If every account(s) given are invalid, show error message and close modal
if (open && !loadingMultisigAccounts) {
if (!accountWithDetails.length) {
dispatch(showCustomAlert({
success: false,
messageCodeHeader: 'error',
errorMessage: 'Unable to fetch required account details for the migration',
}));
onClose();
return null;
}
}

return (
<div>
{state.activeView === WALLET_MIGRATION_VIEWS.DISABLE_2FA && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

import { useExportAccountSelector } from './WalletSelectorExportContext';

export const WalletSelectorContent = () => {
const { ExportModal } = useExportAccountSelector();

const location = useLocation();
useEffect(() => {
//TODO: this is to mute css class injected from WalletSelectorGetAWallet component
const walletWrapperDiv = document.getElementById('near-wallet-selector-modal');
walletWrapperDiv?.classList.remove('wallet-selector-get-a-wallet-modal');
ExportModal?.show();
});
if (ExportModal) {
//TODO: this is to mute css class injected from WalletSelectorGetAWallet component
const walletWrapperDiv = document.getElementById('near-wallet-selector-modal');
walletWrapperDiv?.classList.remove('wallet-selector-get-a-wallet-modal');
ExportModal?.show();
}
}, [ExportModal]);

// On location change, close the modal
useEffect(() => {
ExportModal?.hide();
}, [location]);
return null;
};
Loading

0 comments on commit 2106801

Please sign in to comment.