Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a replay action button. #139

Merged
merged 1 commit into from
Aug 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/demo-react-js/src/Redux/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export default () => {
isActionImportant: action => action.type === LogoTypes.Size && action.size > 100
})
const enhancers = compose(
applyMiddleware(logger, sagaMiddleware),
tracker
tracker,
applyMiddleware(logger, sagaMiddleware)
)

const store = createStore(rootReducer, enhancers)
Expand Down
4 changes: 2 additions & 2 deletions packages/demo-react-native/App/Redux/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export default () => {
const sagaMiddleware = createSagaMiddleware()
const tracker = createTrackingEnhancer(Reactotron, {})
const enhancers = compose(
applyMiddleware(logger, sagaMiddleware),
tracker
tracker,
applyMiddleware(logger, sagaMiddleware)
)

const store = createStore(rootReducer, enhancers)
Expand Down
9 changes: 5 additions & 4 deletions packages/reactotron-app/App/Shared/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import AppStyles from '../Theme/AppStyles'
import Timestamp from '../Shared/Timestamp'
import { observer } from 'mobx-react'
import { isNilOrEmpty } from 'ramdasauce'
import { merge, is } from 'ramda'
import { merge } from 'ramda'
import CommandToolbar from './CommandToolbar'

const IconOpen = require('react-icons/lib/md/expand-more')
const IconClosed = require('react-icons/lib/md/chevron-right')

Expand Down Expand Up @@ -114,9 +116,8 @@ class Command extends Component {

render () {
const { isOpen } = this.state
const { command, children, title, subtitle, preview } = this.props
const { command, children, title, preview } = this.props
const { important } = command
const hasSubtitle = !isNilOrEmpty(subtitle)
const { date } = command
const titleTextStyle = merge(Styles.titleText, important ? Styles.titleTextInverse : {})
const topRowStyle = Styles.topRow
Expand All @@ -131,8 +132,8 @@ class Command extends Component {
<div style={Styles.title}>
<span style={titleTextStyle}>{title}</span>
</div>
{isOpen && hasSubtitle && <span style={Styles.subtitle}>{subtitle}</span>}
{!isOpen && <span style={Styles.preview}>{preview}</span>}
{isOpen && <CommandToolbar command={command} />}
{isOpen && <span style={Styles.spacer}></span>}
<Icon size={20} style={Styles.icon} />
</div>
Expand Down
50 changes: 50 additions & 0 deletions packages/reactotron-app/App/Shared/CommandToolbar.js
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 packages/reactotron-app/App/Shared/CommandToolbarButton.js
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
2 changes: 1 addition & 1 deletion packages/reactotron-app/App/Stores/SessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import UiStore from './UiStore'
import { createServer } from 'reactotron-core-server'
import { computed, reaction } from 'mobx'
import { last, isNil, reject, reverse, pipe, propEq } from 'ramda'
import { dotPath, log } from 'ramdasauce'
import { dotPath } from 'ramdasauce'

class Session {

Expand Down