-
Notifications
You must be signed in to change notification settings - Fork 295
/
LegacyNotification.tsx
179 lines (171 loc) · 6.47 KB
/
LegacyNotification.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// @flow
import React, { Component } from 'react';
import { observer } from 'mobx-react';
import { defineMessages, intlShape, FormattedMessage } from 'react-intl';
import { Button } from 'react-polymorph/lib/components/Button';
import { ButtonSkin } from 'react-polymorph/lib/skins/simple/ButtonSkin';
import { Link } from 'react-polymorph/lib/components/Link';
import { LinkSkin } from 'react-polymorph/lib/skins/simple/LinkSkin';
import ButtonLink from '../widgets/ButtonLink';
import styles from './LegacyNotification.scss';
const messages = defineMessages({
moveFundsTitle: {
id: 'wallet.byron.notification.moveFundsTitle',
defaultMessage: '!!!Move funds from {activeWalletName}',
description:
'Title "Move funds from the legacy wallet" on the legacy notification.',
},
addWalletTitle: {
id: 'wallet.byron.notification.addWalletTitle',
defaultMessage: '!!!Create a Shelley wallet',
description: 'Title "Create a Shelley wallet" on the legacy notification.',
},
moveFundsDescriptionLine1: {
id: 'wallet.byron.notification.moveFundsDescription.line1',
defaultMessage:
'!!!"{activeWalletName}"" is a Byron legacy wallet that does not support Shelley delegation features. To earn ada from delegating your stake, please move all funds from this wallet to a new wallet that is Shelley-compatible.',
description: 'Legacy notification description.',
},
moveFundsDescriptionLine2: {
id: 'wallet.byron.notification.moveFundsDescription.line2',
defaultMessage:
'!!!You can create a {moveFundsLink} or move funds to one of your existing wallets.',
description: 'Legacy notification description.',
},
moveFundsLinkLabel: {
id: 'wallet.byron.notification.moveFundsDescription.line2.link.label',
defaultMessage: '!!!brand new wallet',
description: 'Legacy notification link label.',
},
descriptionWithFunds: {
id: 'wallet.legacy.notification.descriptionWithFunds',
defaultMessage:
'!!!"{transferWalletName}"" is a legacy wallet. It does not support Shelley delegation features. To earn ada from delegating your stake, please move all funds from this wallet to a new, Shelley-compatible wallet. You can create a brand new wallet or move funds to one of the existing wallets.',
description: 'Legacy notification description WithFunds.',
},
addWalletDescriptionLine1: {
id: 'wallet.byron.notification.addWalletDescription.line1',
defaultMessage:
'!!!"{activeWalletName}"" is a Byron legacy wallet that does not support Shelley delegation features. To earn ada from delegating your stake, please move all funds from this wallet to a new wallet that is Shelley-compatible.',
description: 'Legacy notification description.',
},
addWalletDescriptionLine2: {
id: 'wallet.byron.notification.addWalletDescription.line2',
defaultMessage:
'!!!Since all of your wallets are Byron legacy wallets you will first need to create a new Shelley wallet.',
description: 'Legacy notification description.',
},
actionLearnMore: {
id: 'wallet.byron.notification.actionLearnMore',
defaultMessage: '!!!Learn more',
description: 'Learn more action of legacy notification.',
},
actionMove: {
id: 'wallet.byron.notification.actionMove',
defaultMessage: '!!!Move ada to an existing wallet',
description: 'Move Move ada from this wallet of legacy notification.',
},
addWallet: {
id: 'wallet.byron.notification.addWallet',
defaultMessage: '!!!Create a new wallet',
description: 'Create a new wallet action of legacy notification.',
},
learnMoreLinkUrl: {
id: 'wallet.byron.notification.learnMore.url',
defaultMessage:
'!!!https://iohk.zendesk.com/hc/en-us/articles/360038726373',
description: '"Learn more" link URL',
},
});
type Props = {
activeWalletName: string,
onLearnMore: Function,
onTransferFunds: Function,
hasRewardsWallets?: boolean,
onWalletAdd?: Function,
};
@observer
export default class LegacyNotification extends Component<Props> {
static contextTypes = {
intl: intlShape.isRequired,
};
onLearnMore = () => {
const { intl } = this.context;
const learnMoreLinkUrl = intl.formatMessage(messages.learnMoreLinkUrl);
this.props.onLearnMore(learnMoreLinkUrl);
};
getValue = (
messageHasRewardsWallets: string,
messageNoRewardsWallets: string,
_values?: Object
) => {
const { hasRewardsWallets, activeWalletName } = this.props;
const message = hasRewardsWallets
? messageHasRewardsWallets
: messageNoRewardsWallets;
const values = {
activeWalletName,
..._values,
};
return <FormattedMessage {...message} values={values} />;
};
render() {
const { intl } = this.context;
const { onTransferFunds, hasRewardsWallets, onWalletAdd } = this.props;
const { getValue, onLearnMore } = this;
const showLearnMoreButton = false;
const moveFundsLink = (
<Link
className={styles.descriptionLink}
onClick={onWalletAdd}
label={intl.formatMessage(messages.moveFundsLinkLabel)}
skin={LinkSkin}
hasIconAfter={false}
/>
);
const title = getValue(messages.moveFundsTitle, messages.addWalletTitle);
const description1 = getValue(
messages.moveFundsDescriptionLine1,
messages.addWalletDescriptionLine1
);
const description2 = getValue(
messages.moveFundsDescriptionLine2,
messages.addWalletDescriptionLine2,
{
moveFundsLink,
}
);
const buttonLabel = getValue(messages.actionMove, messages.addWallet);
const buttonAction = hasRewardsWallets ? onTransferFunds : onWalletAdd;
return (
<div className={styles.component}>
<div className={styles.title}>{title}</div>
<div className={styles.description}>
<p>{description1}</p>
<p>{description2}</p>
</div>
<div className={styles.actions}>
{showLearnMoreButton && (
<ButtonLink
className={styles.actionLearnMore}
onClick={onLearnMore}
skin={ButtonSkin}
label={intl.formatMessage(messages.actionLearnMore)}
linkProps={{
className: styles.externalLink,
hasIconBefore: false,
hasIconAfter: true,
}}
/>
)}
<Button
className={styles.actionMove}
label={buttonLabel}
onClick={buttonAction}
skin={ButtonSkin}
/>
</div>
</div>
);
}
}