Copy backup button #1638
5 changed files with 85 additions and 6 deletions
7
src/renderer/component/copyableText/index.js
Normal file
7
src/renderer/component/copyableText/index.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { doNotify } from 'lbry-redux';
|
||||
import Address from './view';
|
||||
|
||||
export default connect(null, {
|
||||
doNotify,
|
||||
})(Address);
|
55
src/renderer/component/copyableText/view.jsx
Normal file
55
src/renderer/component/copyableText/view.jsx
Normal file
|
@ -0,0 +1,55 @@
|
|||
// @flow
|
||||
import * as React from 'react';
|
||||
import { clipboard } from 'electron';
|
||||
import { FormRow } from 'component/common/form';
|
||||
import Button from 'component/button';
|
||||
import * as icons from 'constants/icons';
|
||||
|
||||
type Props = {
|
||||
copyable: string,
|
||||
doNotify: ({ message: string, displayType: Array<string> }) => void,
|
||||
};
|
||||
|
||||
export default class CopyableInput extends React.PureComponent<Props> {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.input = null;
|
||||
}
|
||||
|
||||
input: ?HTMLInputElement;
|
||||
|
||||
render() {
|
||||
const { copyable, doNotify } = this.props;
|
||||
|
||||
return (
|
||||
<FormRow verticallyCentered padded stretch>
|
||||
<input
|
||||
className="input-copyable form-field__input"
|
||||
readOnly
|
||||
value={copyable || ''}
|
||||
ref={input => {
|
||||
this.input = input;
|
||||
}}
|
||||
onFocus={() => {
|
||||
if (this.input) {
|
||||
this.input.select();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
noPadding
|
||||
button="secondary"
|
||||
icon={icons.CLIPBOARD}
|
||||
onClick={() => {
|
||||
clipboard.writeText(copyable);
|
||||
doNotify({
|
||||
message: __('Text copied'),
|
||||
|
||||
displayType: ['snackbar'],
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</FormRow>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ import * as React from 'react';
|
|||
import QRCode from 'component/common/qr-code';
|
||||
import { FormRow } from 'component/common/form';
|
||||
import * as statuses from 'constants/shape_shift';
|
||||
import Address from 'component/address';
|
||||
import CopyableText from 'component/copyableText';
|
||||
import Button from 'component/button';
|
||||
import type { Dispatch } from 'redux/actions/shape_shift';
|
||||
import ShiftMarketInfo from './market_info';
|
||||
|
@ -94,7 +94,7 @@ class ActiveShapeShift extends React.PureComponent<Props> {
|
|||
{shiftDepositAddress && (
|
||||
<FormRow verticallyCentered padded>
|
||||
<QRCode value={shiftDepositAddress} paddingRight />
|
||||
<Address address={shiftDepositAddress} showCopyButton padded />
|
||||
<CopyableText copyable={shiftDepositAddress} showCopyButton padded />
|
||||
</FormRow>
|
||||
)}
|
||||
</div>
|
||||
|
@ -145,3 +145,4 @@ class ActiveShapeShift extends React.PureComponent<Props> {
|
|||
}
|
||||
|
||||
export default ActiveShapeShift;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
import React from 'react';
|
||||
import Button from 'component/button';
|
||||
import Address from 'component/address';
|
||||
import CopyableText from 'component/copyableText';
|
||||
import QRCode from 'component/common/qr-code';
|
||||
import * as icons from 'constants/icons';
|
||||
|
||||
|
@ -48,7 +48,7 @@ class WalletAddress extends React.PureComponent<Props> {
|
|||
</p>
|
||||
|
||||
<div className="card__content">
|
||||
<Address address={receiveAddress} showCopyButton />
|
||||
<CopyableText copyable={receiveAddress} showCopyButton />
|
||||
</div>
|
||||
|
||||
<div className="card__actions">
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
import * as React from 'react';
|
||||
import Button from 'component/button';
|
||||
import Page from 'component/page';
|
||||
import { shell } from 'electron';
|
||||
import CopyableText from 'component/copyableText';
|
||||
|
||||
type Props = {
|
||||
daemonSettings: {
|
||||
|
@ -37,10 +39,24 @@ class BackupPage extends React.PureComponent<Props> {
|
|||
</p>
|
||||
<p>
|
||||
{__(
|
||||
'However, it is fairly easy to back up manually. To backup your wallet, make a copy of the folder listed below:'
|
||||
'However, it is fairly easy to back up manually. To backup your wallet, click the button below to open your wallet directory, and copy the files to a safe location.'
|
||||
)}
|
||||
</p>
|
||||
<p className="card__success-msg">{lbryumWalletDir}</p>
|
||||
<div className="walletbackup__actions">
|
||||
<Button
|
||||
button="primary"
|
||||
label={__('Open Wallet Directory')}
|
||||
onClick={() => shell.showItemInFolder(lbryumWalletDir)}
|
||||
/>
|
||||
</div>
|
||||
<p>
|
||||
{__(
|
||||
'Alternatively, you may navigate to this folder on your hard drive and copy the contents:'
|
||||
)}
|
||||
</p>
|
||||
<div className="card__content">
|
||||
<CopyableText copyable={lbryumWalletDir} showCopyButton />
|
||||
</div>
|
||||
<p>
|
||||
{__(
|
||||
'Access to these files are equivalent to having access to your credits. Keep any copies you make of your wallet in a secure place.'
|
||||
|
|
Loading…
Reference in a new issue
We can default to
Text copied
but we should be able to pass in any message to use. Ex: on the wallet overview/shapeshift, we should sayAddress copied
.