@@ -9,15 +9,15 @@ import { getBase16Theme } from 'react-base16-styling';
99import { reducer , updateMonitorState } from './redux' ;
1010import { ActionCreators } from 'redux-devtools' ;
1111
12- const { commit, sweep, toggleAction } = ActionCreators ;
12+ const { commit, sweep, toggleAction, jumpToAction , jumpToState } = ActionCreators ;
1313
1414function getLastActionId ( props ) {
1515 return props . stagedActionIds [ props . stagedActionIds . length - 1 ] ;
1616}
1717
1818function getCurrentActionId ( props , monitorState ) {
1919 return monitorState . selectedActionId === null ?
20- getLastActionId ( props ) : monitorState . selectedActionId ;
20+ props . stagedActionIds [ props . currentStateIndex ] : monitorState . selectedActionId ;
2121}
2222
2323function getFromState ( actionIndex , stagedActionIds , computedStates , monitorState ) {
@@ -149,10 +149,12 @@ export default class DevtoolsInspector extends Component {
149149
150150 render ( ) {
151151 const { stagedActionIds : actionIds , actionsById : actions , computedStates,
152- tabs, invertTheme, skippedActionIds, monitorState } = this . props ;
152+ tabs, invertTheme, skippedActionIds, currentStateIndex , monitorState } = this . props ;
153153 const { selectedActionId, startActionId, searchValue, tabName } = monitorState ;
154154 const inspectedPathType = tabName === 'Action' ? 'inspectedActionPath' : 'inspectedStatePath' ;
155- const { themeState, isWideLayout, action, nextState, delta, error } = this . state ;
155+ const {
156+ themeState, isWideLayout, action, nextState, delta, error
157+ } = this . state ;
156158 const { base16Theme, styling } = themeState ;
157159
158160 return (
@@ -166,9 +168,11 @@ export default class DevtoolsInspector extends Component {
166168 onSearch = { this . handleSearch }
167169 onSelect = { this . handleSelectAction }
168170 onToggleAction = { this . handleToggleAction }
171+ onJumpToState = { this . handleJumpToState }
169172 onCommit = { this . handleCommit }
170173 onSweep = { this . handleSweep }
171174 skippedActionIds = { skippedActionIds }
175+ currentActionId = { actionIds [ currentStateIndex ] }
172176 lastActionId = { getLastActionId ( this . props ) } />
173177 < ActionPreview { ...{
174178 base16Theme, invertTheme, isWideLayout, tabs, tabName, delta, error, nextState,
@@ -186,6 +190,15 @@ export default class DevtoolsInspector extends Component {
186190 this . props . dispatch ( toggleAction ( actionId ) ) ;
187191 } ;
188192
193+ handleJumpToState = actionId => {
194+ if ( jumpToAction ) {
195+ this . props . dispatch ( jumpToAction ( actionId ) ) ;
196+ } else { // Fallback for redux-devtools-instrument < 1.5
197+ const index = this . props . stagedActionIds . indexOf ( actionId ) ;
198+ if ( index !== - 1 ) this . props . dispatch ( jumpToState ( index ) ) ;
199+ }
200+ } ;
201+
189202 handleCommit = ( ) => {
190203 this . props . dispatch ( commit ( ) ) ;
191204 } ;
0 commit comments