@@ -13,6 +13,8 @@ import { features } from "../../utils/prefs";
1313import {
1414 isPaused as getIsPaused ,
1515 getIsWaitingOnBreak ,
16+ getHistory ,
17+ getHistoryPosition ,
1618 getShouldPauseOnExceptions ,
1719 getShouldIgnoreCaughtExceptions ,
1820 getCanRewind
@@ -113,6 +115,10 @@ type Props = {
113115 isPaused : boolean ,
114116 pauseOnExceptions : ( boolean , boolean ) => void ,
115117 shouldPauseOnExceptions : boolean ,
118+ historyPosition : number ,
119+ history : any ,
120+ timeTravelTo : number => void ,
121+ clearHistory : ( ) => void ,
116122 shouldIgnoreCaughtExceptions : boolean ,
117123 isWaitingOnBreak : boolean ,
118124 horizontal : boolean ,
@@ -153,6 +159,10 @@ class CommandBar extends Component<Props> {
153159 this . props [ action ] ( ) ;
154160 }
155161
162+ setHistory ( offset ) {
163+ this . props . timeTravelTo ( this . props . historyPosition + offset ) ;
164+ }
165+
156166 renderStepButtons ( ) {
157167 const { isPaused } = this . props ;
158168 const className = isPaused ? "active" : "disabled" ;
@@ -187,12 +197,17 @@ class CommandBar extends Component<Props> {
187197 ] ;
188198 }
189199
200+ resume ( ) {
201+ this . props . resume ( ) ;
202+ this . props . clearHistory ( ) ;
203+ }
204+
190205 renderPauseButton ( ) {
191206 const { isPaused , breakOnNext , isWaitingOnBreak } = this . props ;
192207
193208 if ( isPaused ) {
194209 return debugBtn (
195- this . props . resume ,
210+ ( ) => this . resume ( ) ,
196211 "resume" ,
197212 "active" ,
198213 L10N . getFormatStr ( "resumeButtonTooltip" , formatKey ( "resume" ) )
@@ -305,6 +320,55 @@ class CommandBar extends Component<Props> {
305320 ] ;
306321 }
307322
323+ replayPreviousButton ( ) {
324+ const historyLength = this . props . history . length ;
325+ if ( ! historyLength || ! features . replay ) {
326+ return null ;
327+ }
328+ const enabled = this . props . historyPosition === 0 ;
329+ const activeClass = enabled ? "replay-inactive" : "" ;
330+ return debugBtn (
331+ ( ) => this . setHistory ( - 1 ) ,
332+ `replay-previous ${ activeClass } ` ,
333+ "active" ,
334+ L10N . getStr ( "replayPrevious" ) ,
335+ enabled
336+ ) ;
337+ }
338+
339+ replayNextButton ( ) {
340+ const historyLength = this . props . history . length ;
341+ if ( ! historyLength || ! features . replay ) {
342+ return null ;
343+ }
344+ const enabled = this . props . historyPosition + 1 === historyLength ;
345+ const activeClass = enabled ? "replay-inactive" : "" ;
346+ return debugBtn (
347+ ( ) => this . setHistory ( 1 ) ,
348+ `replay-next ${ activeClass } ` ,
349+ "active" ,
350+ L10N . getStr ( "replayNext" ) ,
351+ enabled
352+ ) ;
353+ }
354+
355+ renderStepPosition ( ) {
356+ if ( ! this . props . history . length || ! features . replay ) {
357+ return null ;
358+ }
359+ const position = this . props . historyPosition + 1 ;
360+ const total = this . props . history . length ;
361+ const activePrev = position > 1 ? "replay-active" : "replay-inactive" ;
362+ const activeNext = position < total ? "replay-active" : "replay-inactive" ;
363+ return (
364+ < div className = "step-position" >
365+ < span className = { activePrev } > { position } </ span >
366+ < span > | </ span >
367+ < span className = { activeNext } > { total } </ span >
368+ </ div >
369+ ) ;
370+ }
371+
308372 render ( ) {
309373 return (
310374 < div
@@ -317,6 +381,10 @@ class CommandBar extends Component<Props> {
317381 { this . renderStepButtons ( ) }
318382 { this . renderPauseOnExceptions ( ) }
319383 { this . renderReverseStepButtons ( ) }
384+ < div className = "filler" />
385+ { this . replayPreviousButton ( ) }
386+ { this . renderStepPosition ( ) }
387+ { this . replayNextButton ( ) }
320388 </ div >
321389 ) ;
322390 }
@@ -330,6 +398,8 @@ export default connect(
330398 state => {
331399 return {
332400 isPaused : getIsPaused ( state ) ,
401+ history : getHistory ( state ) ,
402+ historyPosition : getHistoryPosition ( state ) ,
333403 isWaitingOnBreak : getIsWaitingOnBreak ( state ) ,
334404 shouldPauseOnExceptions : getShouldPauseOnExceptions ( state ) ,
335405 shouldIgnoreCaughtExceptions : getShouldIgnoreCaughtExceptions ( state ) ,
0 commit comments