-
Notifications
You must be signed in to change notification settings - Fork 934
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
96 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { Component, PropTypes } from 'react' | ||
import { inject, observer } from 'mobx-react' | ||
import Button from './CommandToolbarButton' | ||
import AppStyles from '../Theme/AppStyles' | ||
|
||
const Styles = { | ||
container: { | ||
...AppStyles.Layout.hbox, | ||
marginLeft: -6 | ||
} | ||
} | ||
|
||
// the tips | ||
const TIP_REPLAY_ACTION = 'Replay this action again.' | ||
|
||
// the buttons (minus the onClick) | ||
const ReplayButton = props => <Button icon='play-circle-outline' onClick={props.onClick} tip={TIP_REPLAY_ACTION} /> | ||
|
||
@inject('session') | ||
@observer | ||
class CommandToolbar extends Component { | ||
|
||
static propTypes = { | ||
command: PropTypes.object.isRequired | ||
} | ||
|
||
// fires when it is time to replay an action | ||
handleReplayAction = (event) => { | ||
const { command, session } = this.props | ||
const { ui } = session | ||
ui.dispatchAction(command.payload.action) | ||
event.stopPropagation() | ||
} | ||
|
||
render () { | ||
const { command } = this.props | ||
const showReplayAction = command.type === 'state.action.complete' | ||
|
||
return ( | ||
<div style={Styles.container}> | ||
{showReplayAction && | ||
<ReplayButton onClick={this.handleReplayAction} /> | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
} | ||
|
||
export default CommandToolbar |
36 changes: 36 additions & 0 deletions
36
packages/reactotron-app/App/Shared/CommandToolbarButton.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, { Component, PropTypes } from 'react' | ||
import Colors from '../Theme/Colors' | ||
import ReactTooltip from 'react-tooltip' | ||
|
||
const Styles = { | ||
container: { | ||
color: Colors.highlight, | ||
marginTop: -2 | ||
}, | ||
iconSize: 24, | ||
icon: { | ||
} | ||
} | ||
|
||
class CommandToolbarButton extends Component { | ||
|
||
static propTypes = { | ||
tip: PropTypes.string, | ||
icon: PropTypes.string.isRequired, | ||
onClick: PropTypes.func.isRequired | ||
} | ||
|
||
render () { | ||
const { tip, icon, onClick } = this.props | ||
const Icon = require(`react-icons/lib/md/${icon}`) | ||
return ( | ||
<div data-tip={tip} onClick={onClick} style={Styles.container}> | ||
<Icon size={Styles.iconSize} style={Styles.icon} /> | ||
<ReactTooltip place='bottom' className='tooltipTheme' /> | ||
</div> | ||
) | ||
} | ||
|
||
} | ||
|
||
export default CommandToolbarButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters