Skip to content
Permalink
Browse files

[DDW-983] Add wallet button in case no new wallets

  • Loading branch information...
daniloprates committed Nov 8, 2019
1 parent f0e6e51 commit 8cf6aa86c7572ac34678fdb41d7d6aa86a740d1d
@@ -17,6 +17,8 @@ type Props = {
children?: ?Node,
activeWallet?: ?Wallet,
onTransferFunds?: Function,
onWalletAdd?: Function,
hasAnyWallets?: boolean,
};

@observer
@@ -28,6 +30,8 @@ export default class TopBar extends Component<Props> {
activeWallet,
children,
onTransferFunds,
hasAnyWallets,
onWalletAdd,
} = this.props;

const topBarStyles = classNames([
@@ -39,7 +43,7 @@ export default class TopBar extends Component<Props> {
activeWallet &&
activeWallet.isLegacy &&
activeWallet.amount > 0 &&
onTransferFunds;
((hasAnyWallets && onTransferFunds) || onWalletAdd);

const topBarTitle = activeWallet ? (
<span className={styles.walletInfo}>
@@ -79,6 +83,8 @@ export default class TopBar extends Component<Props> {
<LegacyNotification
onLearnMore={() => null}
onTransferFunds={() => onTransferFunds(activeWallet.id)}
hasAnyWallets={hasAnyWallets}
onWalletAdd={onWalletAdd}
/>
)}
</header>
@@ -29,11 +29,18 @@ const messages = defineMessages({
defaultMessage: '!!!Move all of the ada from this wallet',
description: 'Move all ada action of legacy notification.',
},
addWallet: {
id: 'wallet.legacy.notification.addWallet',
defaultMessage: '!!!Move all of the ada from this wallet',
description: 'Add wallet action of legacy notification.',
},
});

type Props = {
onLearnMore: Function,
onTransferFunds: Function,
hasAnyWallets?: boolean,
onWalletAdd?: boolean,
};

@observer
@@ -44,11 +51,21 @@ export default class LegacyNotification extends Component<Props> {

render() {
const { intl } = this.context;
const { onLearnMore, onTransferFunds } = this.props;
const {
onLearnMore,
onTransferFunds,
hasAnyWallets,
onWalletAdd,
} = this.props;
const title = intl.formatMessage(messages.title);
const description = intl.formatMessage(messages.description);
const actionLearnMore = intl.formatMessage(messages.actionLearnMore);
const actionMove = intl.formatMessage(messages.actionMove);

const buttonLabel = hasAnyWallets
? intl.formatMessage(messages.actionMove)
: intl.formatMessage(messages.addWallet);

const buttonAction = hasAnyWallets ? onTransferFunds : onWalletAdd;

return (
<div className={styles.component}>
@@ -61,12 +78,14 @@ export default class LegacyNotification extends Component<Props> {
onClick={onLearnMore}
skin={ButtonSkin}
/>
<Button
className={styles.actionMove}
label={actionMove}
onClick={onTransferFunds}
skin={ButtonSkin}
/>
{
<Button
className={styles.actionMove}
label={buttonLabel}
onClick={buttonAction}
skin={ButtonSkin}
/>
}
</div>
</div>
);
@@ -4,6 +4,7 @@ import { observer, inject } from 'mobx-react';
import TopBar from '../components/layout/TopBar';
import NodeSyncStatusIcon from '../components/widgets/NodeSyncStatusIcon';
import NewsFeedIcon from '../components/widgets/NewsFeedIcon';
import WalletCreateDialog from '../components/wallet/WalletCreateDialog';
import WalletTestEnvironmentLabel from '../components/widgets/WalletTestEnvironmentLabel';
import type { InjectedProps } from '../types/injectedPropsType';
import menuIconOpened from '../assets/images/menu-opened-ic.inline.svg';
@@ -41,6 +42,10 @@ export default class TopBarContainer extends Component<Props> {
<WalletTestEnvironmentLabel network={network} />
) : null;

const onWalletAdd = actions.router.goToRoute.trigger({
route: ROUTES.WALLETS.ADD,
});

const onTransferFunds = (sourceWalletId: string) =>
actions.wallets.transferFundsSetSourceWalletId.trigger({
sourceWalletId,
@@ -55,6 +60,8 @@ export default class TopBarContainer extends Component<Props> {
onLeftIconClick={actions.sidebar.toggleSubMenus.trigger}
activeWallet={activeWallet}
onTransferFunds={onTransferFunds}
hasAnyWallets={hasAnyWallets}
onWalletAdd={onWalletAdd}
>
{testnetLabel}
<NodeSyncStatusIcon networkStatus={networkStatus} />
@@ -35,7 +35,7 @@ export default class WalletAddPage extends Component<Props> {
environment: { isMainnet, isTestnet },
} = app;

const walletCreationAction = useNewWalletCreationProcess
const onWalletAdd = useNewWalletCreationProcess
? () => actions.wallets.createWalletBegin.trigger()
: // TODO: Remove once the new wallet creation process is ready
() => actions.dialogs.open.trigger({ dialog: WalletCreateDialog });
@@ -59,7 +59,7 @@ export default class WalletAddPage extends Component<Props> {
<WalletAdd
isMainnet={isMainnet}
isTestnet={isTestnet}
onCreate={walletCreationAction}
onCreate={onWalletAdd}
onRestore={() =>
actions.dialogs.open.trigger({ dialog: WalletRestoreDialog })
}
@@ -457,6 +457,7 @@
"wallet.legacy.badge.label": "Legacy",
"wallet.legacy.notification.actionLearnMore": "Learn more",
"wallet.legacy.notification.actionMove": "Move all of the ada from this wallet",
"wallet.legacy.notification.addWallet": "Add wallet",
"wallet.legacy.notification.description": "This is a legacy wallet which uses legacy addresses and does not support new features. Please move all of the ada from this legacy wallet to one of the wallets where new features are available. You can also create a brand new wallet for your ada in case you don’t want to move ada to one of your existing wallets. A sequence of screens will guide you through the process.",
"wallet.legacy.notification.title": "Move funds from the legacy wallet",
"wallet.navigation.more": "More",
@@ -619,4 +620,4 @@
"wallet.transferFunds.dialog2.passphraseFieldPlaceholder": "Type your spending password",
"wallet.transferFunds.dialog2.passphraseLabel": "Spending password",
"wallet.transferFunds.dialog2.title": "Transfer funds from the legacy wallet"
}
}
@@ -457,6 +457,7 @@
"wallet.legacy.badge.label": "",
"wallet.legacy.notification.actionLearnMore": "もっと知る",
"wallet.legacy.notification.actionMove": "すべてのADAをこのウォレットから移す",
"wallet.legacy.notification.addWallet": "ウォレットを追加",
"wallet.legacy.notification.description": "これは旧アドレスを使用している旧タイプのウォレットであり、新機能をサポートしていません。 このウォレットに含まれるすべてのADAを、新機能の使用が可能な新タイプのウォレットに移してください。既存のウォレットへ移動させたくない場合は、新規にウォレットを作成することもできます。画面の指示に従って手続きをしてください。",
"wallet.legacy.notification.title": "旧ウォレットから資金を移してください",
"wallet.navigation.more": "その他",
@@ -619,4 +620,4 @@
"wallet.transferFunds.dialog2.passphraseFieldPlaceholder": "送信時パスワードを入力してください",
"wallet.transferFunds.dialog2.passphraseLabel": "送信時パスワード",
"wallet.transferFunds.dialog2.title": "旧ウォレットから資金を移し替える"
}
}
@@ -5,6 +5,7 @@ import { observable, runInAction } from 'mobx';
import { observer, inject } from 'mobx-react';
import { get } from 'lodash';
import { action } from '@storybook/addon-actions';
import { boolean } from '@storybook/addon-knobs';

// Assets and helpers
import { CATEGORIES_BY_NAME } from '../../../source/renderer/app/config/sidebarConfig';
@@ -185,6 +186,8 @@ export default class StoryLayout extends Component<Props> {
showSubMenus={this.isShowingSubMenus}
leftIcon={this.isShowingSubMenus ? menuIconOpened : menuIconClosed}
onTransferFunds={action('onTransferFunds')}
onWalletAdd={action('onWalletAdd')}
hasAnyWallets={boolean('hasAnyWallets', true)}
>
<NodeSyncStatusIcon
networkStatus={{

0 comments on commit 8cf6aa8

Please sign in to comment.
You can’t perform that action at this time.