/* @flow */ import React from 'react'; import styled from 'styled-components'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import { Button, Tooltip, H5, P, Icon, icons, colors } from 'trezor-ui-components'; import ReactJson from 'react-json-view'; import { FormattedMessage } from 'react-intl'; import * as LogActions from 'actions/LogActions'; import type { State, Dispatch } from 'flowtype'; import l10nMessages from './index.messages'; type OwnProps = {||}; type StateProps = {| log: $ElementType, |}; type DispatchProps = {| toggle: typeof LogActions.toggle, copyToClipboard: typeof LogActions.copyToClipboard, resetCopyState: typeof LogActions.resetCopyState, |}; type Props = {| ...OwnProps, ...StateProps, ...DispatchProps |}; const Wrapper = styled.div` position: relative; color: ${colors.INFO_PRIMARY}; background: ${colors.INFO_SECONDARY}; padding: 24px; display: flex; flex-direction: column; text-align: left; width: 100%; `; const Click = styled.div` cursor: pointer; position: absolute; top: 0; right: 0; padding-right: inherit; padding-top: inherit; color: inherit; transition: opacity 0.3s; &:active, &:hover { opacity: 0.6; color: inherit; } `; const StyledParagraph = styled(P)` margin: 10px 0; `; const LogWrapper = styled.div` background: white; padding: 25px; height: 300px; overflow: scroll; `; const CopyWrapper = styled.div``; const ButtonCopy = styled(Button)` margin-top: 10px; `; const Log = (props: Props) => { if (!props.log.opened) return null; const copyBtn = ( props.copyToClipboard()}> ); return (
{props.log.copied ? ( } afterVisibleChange={props.resetCopyState} > {copyBtn} ) : ( {copyBtn} )}
); }; export default connect( (state: State): StateProps => ({ log: state.log, }), (dispatch: Dispatch): DispatchProps => ({ toggle: bindActionCreators(LogActions.toggle, dispatch), copyToClipboard: bindActionCreators(LogActions.copyToClipboard, dispatch), resetCopyState: bindActionCreators(LogActions.resetCopyState, dispatch), }) )(Log);