/** * Copyright 2018-present Facebook. * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * @format */ import {ActiveSheet, LauncherMsg, ShareType} from '../reducers/application.js'; import { colors, Button, ButtonGroup, FlexRow, Spacer, styled, Text, LoadingIndicator, } from 'flipper'; import {connect} from 'react-redux'; import { setActiveSheet, toggleLeftSidebarVisible, toggleRightSidebarVisible, ACTIVE_SHEET_BUG_REPORTER, setFlipperRating, } from '../reducers/application.js'; import RatingButton from './RatingButton.js'; import DevicesButton from './DevicesButton.js'; import ScreenCaptureButtons from './ScreenCaptureButtons.js'; import AutoUpdateVersion from './AutoUpdateVersion.js'; 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'; import React from 'react'; const AppTitleBar = styled(FlexRow)(({focused}) => ({ background: focused ? `linear-gradient(to bottom, ${colors.macOSTitleBarBackgroundTop} 0%, ${ colors.macOSTitleBarBackgroundBottom } 100%)` : colors.macOSTitleBarBackgroundBlur, borderBottom: `1px solid ${ focused ? colors.macOSTitleBarBorder : colors.macOSTitleBarBorderBlur }`, height: 38, flexShrink: 0, width: '100%', alignItems: 'center', paddingLeft: 80, paddingRight: 10, justifyContent: 'space-between', WebkitAppRegion: 'drag', zIndex: 4, })); type OwnProps = { version: string, }; type DispatchFromProps = { toggleLeftSidebarVisible: (visible?: boolean) => void, toggleRightSidebarVisible: (visible?: boolean) => void, setActiveSheet: (sheet: ActiveSheet) => void, setFlipperRating: (rating: number) => void, }; type StateFromProps = { windowIsFocused: boolean, leftSidebarVisible: boolean, rightSidebarVisible: boolean, rightSidebarAvailable: boolean, downloadingImportData: boolean, launcherMsg: LauncherMsg, flipperRating: number | null, share: ShareType | null | undefined, }; 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 React.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 ( {this.state.copied ? 'Copied' : this.props.children} ); } } const Importing = styled(FlexRow)({ color: colors.light50, alignItems: 'center', marginLeft: 10, }); function statusMessageComponent( downloadingImportData: boolean, statusComponent?: React.ReactElement | undefined, ) { if (downloadingImportData) { return (  Importing data... ); } if (statusComponent) { return statusComponent; } return; } type Props = OwnProps & DispatchFromProps & StateFromProps; class TitleBar extends React.Component { render() { const {share} = this.props; return ( {statusMessageComponent( this.props.downloadingImportData, share != null ? share.statusComponent : undefined, )} {config.showFlipperRating ? ( ) : null} {this.props.version + (isProduction() ? '' : '-dev')} {isAutoUpdaterEnabled() ? ( ) : ( )} {config.bugReportButtonVisible && (