diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-01-30 13:54:33 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-01-31 09:40:31 +0100 |
| commit | 1c19d571fd94dabacec31f94cdbba1fe98bafa7b (patch) | |
| tree | 6b00639a95b57598b6ab4ec281f37462b5d08b12 /gui | |
| parent | e4cf31a509d43c90ba35ea9281ce35d62190f7d1 (diff) | |
| download | mullvadvpn-1c19d571fd94dabacec31f94cdbba1fe98bafa7b.tar.xz mullvadvpn-1c19d571fd94dabacec31f94cdbba1fe98bafa7b.zip | |
Copy WireGuard key when clicking
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/src/renderer/components/ClipboardLabel.tsx | 4 | ||||
| -rw-r--r-- | gui/src/renderer/components/WireguardKeys.tsx | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/gui/src/renderer/components/ClipboardLabel.tsx b/gui/src/renderer/components/ClipboardLabel.tsx index fdb9982b3f..e801538c29 100644 --- a/gui/src/renderer/components/ClipboardLabel.tsx +++ b/gui/src/renderer/components/ClipboardLabel.tsx @@ -3,6 +3,7 @@ import { Clipboard, Component, Text, Types } from 'reactxp'; interface IProps { value: string; + displayValue?: string; delay: number; message: string; style?: Types.TextStyleRuleSet; @@ -31,9 +32,10 @@ export default class ClipboardLabel extends Component<IProps, IState> { } public render() { + const displayValue = this.props.displayValue || this.props.value; return ( <Text style={this.props.style} onPress={this.handlePress}> - {this.state.showsMessage ? this.props.message : this.props.value} + {this.state.showsMessage ? this.props.message : displayValue} </Text> ); } diff --git a/gui/src/renderer/components/WireguardKeys.tsx b/gui/src/renderer/components/WireguardKeys.tsx index f51287ce52..cbc19909d9 100644 --- a/gui/src/renderer/components/WireguardKeys.tsx +++ b/gui/src/renderer/components/WireguardKeys.tsx @@ -6,6 +6,7 @@ import { sprintf } from 'sprintf-js'; import { messages } from '../../shared/gettext'; import { IWgKey, WgKeyState } from '../redux/settings/reducers'; import * as AppButton from './AppButton'; +import ClipboardLabel from './ClipboardLabel'; import ImageView from './ImageView'; import { Container, Layout } from './Layout'; import { BackBarItem, NavigationBar, NavigationContainer, NavigationItems } from './NavigationBar'; @@ -166,10 +167,15 @@ export default class WireguardKeys extends Component<IProps> { case 'being-verified': case 'key-set': // mimicking the truncating of the key from website + const publicKey = this.props.keyState.key.publicKey; return ( <View title={this.props.keyState.key.publicKey}> <Text style={styles.wgkeys__row_value}> - {this.props.keyState.key.publicKey.substring(0, 20) + '...'} + <ClipboardLabel + value={publicKey} + displayValue={publicKey.substring(0, 20) + '...'} + message={messages.pgettext('account-view', 'COPIED TO CLIPBOARD!')} + /> </Text> </View> ); |
