copy version number to clipboard

Summary: People often want to share Flipper's verison number in bug reports, etc. This makes it as easy as a single click to copy the version number.

Reviewed By: jknoxville

Differential Revision: D15516592

fbshipit-source-id: 72582e2acb23113b3a0af062a83d444031f058d6
This commit is contained in:
Daniel Büchele
2019-05-28 07:37:30 -07:00
committed by Facebook Github Bot
parent e1aa6c4cd8
commit b4f96ae5d9
3 changed files with 34 additions and 10 deletions

View File

@@ -59,10 +59,10 @@ exports[`Empty app state matches snapshot 1`] = `
className="css-12zzrdt"
/>
<span
className="css-lli23c"
className="css-1swhxtd"
onClick={[Function]}
>
4.0.8
-dev
4.0.8-dev
</span>
<div
className="css-1cecbfb"

View File

@@ -32,6 +32,7 @@ import UpdateIndicator from './UpdateIndicator.js';
import config from '../fb-stubs/config.js';
import {isAutoUpdaterEnabled} from '../utils/argvUtils.js';
import isProduction from '../utils/isProduction.js';
import {clipboard} from 'electron';
const AppTitleBar = styled(FlexRow)(({focused}) => ({
background: focused
@@ -74,8 +75,34 @@ const VersionText = styled(Text)({
color: colors.light50,
marginLeft: 4,
marginTop: 2,
cursor: 'pointer',
display: 'block',
padding: '4px 10px',
'&:hover': {
backgroundColor: `rgba(0,0,0,0.05)`,
borderRadius: '999em',
},
});
class Version extends Component<{children: string}, {copied: boolean}> {
state = {
copied: false,
};
_onClick = () => {
clipboard.writeText(this.props.children);
this.setState({copied: true});
setTimeout(() => this.setState({copied: false}), 1000);
};
render() {
return (
<VersionText onClick={this._onClick}>
{this.state.copied ? 'Copied' : this.props.children}
</VersionText>
);
}
}
const Importing = styled(FlexRow)({
color: colors.light50,
alignItems: 'center',
@@ -95,10 +122,7 @@ class TitleBar extends Component<Props> {
</Importing>
)}
<Spacer />
<VersionText>
{this.props.version}
{isProduction() ? '' : '-dev'}
</VersionText>
<Version>{this.props.version + (isProduction() ? '' : '-dev')}</Version>
{isAutoUpdaterEnabled() ? (
<AutoUpdateVersion version={this.props.version} />

View File

@@ -56,10 +56,10 @@ exports[`TitleBar is rendered 1`] = `
className="css-12zzrdt"
/>
<span
className="css-lli23c"
className="css-1swhxtd"
onClick={[Function]}
>
1.0.0
-dev
1.0.0-dev
</span>
<div
className="css-1cecbfb"