Skip to content
This repository was archived by the owner on Jun 5, 2020. It is now read-only.

Commit 7d40aab

Browse files
committed
Jump to state
1 parent 9a1cb4f commit 7d40aab

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

src/ActionList.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default class ActionList extends Component {
3838
render() {
3939
const { styling, actions, actionIds, isWideLayout, onToggleAction, skippedActionIds,
4040
selectedActionId, startActionId, onSelect, onSearch, searchValue, currentActionId,
41-
onCommit, onSweep } = this.props;
41+
onCommit, onSweep, onJumpToState } = this.props;
4242
const lowerSearchValue = searchValue && searchValue.toLowerCase();
4343
const filteredActionIds = searchValue ? actionIds.filter(
4444
id => actions[id].action.type.toLowerCase().indexOf(lowerSearchValue) !== -1
@@ -67,7 +67,8 @@ export default class ActionList extends Component {
6767
onSelect={(e) => onSelect(e, actionId)}
6868
timestamps={getTimestamps(actions, actionIds, actionId)}
6969
action={actions[actionId].action}
70-
onViewClick={() => onToggleAction(actionId)}
70+
onToggleClick={() => onToggleAction(actionId)}
71+
onJumpClick={() => onJumpToState(actionId)}
7172
onCommitClick={() => onCommit(actionId)}
7273
isSkipped={skippedActionIds.indexOf(actionId) !== -1} />
7374
)}

src/ActionListRow.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import dateformat from 'dateformat';
44
import RightSlider from './RightSlider';
55

66
const BUTTON_SKIP = 'Skip';
7+
const BUTTON_JUMP = 'Jump';
78

89
export default class ActionListRow extends Component {
910
state = { hover: false };
@@ -64,7 +65,7 @@ export default class ActionListRow extends Component {
6465
</RightSlider>
6566
<RightSlider styling={styling} shown={showButtons} rotate>
6667
<div {...styling('actionListItemSelector')}>
67-
{[BUTTON_SKIP].map(btn => (!isInitAction || btn !== BUTTON_SKIP) &&
68+
{[BUTTON_JUMP, BUTTON_SKIP].map(btn => (!isInitAction || btn !== BUTTON_SKIP) &&
6869
<div key={btn}
6970
onClick={this.handleButtonClick.bind(this, btn)}
7071
{...styling([
@@ -86,7 +87,10 @@ export default class ActionListRow extends Component {
8687

8788
switch(btn) {
8889
case BUTTON_SKIP:
89-
this.props.onViewClick();
90+
this.props.onToggleClick();
91+
break;
92+
case BUTTON_JUMP:
93+
this.props.onJumpClick();
9094
break;
9195
}
9296
}

src/DevtoolsInspector.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getBase16Theme } from 'react-base16-styling';
99
import { reducer, updateMonitorState } from './redux';
1010
import { ActionCreators } from 'redux-devtools';
1111

12-
const { commit, sweep, toggleAction } = ActionCreators;
12+
const { commit, sweep, toggleAction, jumpToState } = ActionCreators;
1313

1414
function getLastActionId(props) {
1515
return props.stagedActionIds[props.stagedActionIds.length - 1];
@@ -168,6 +168,7 @@ export default class DevtoolsInspector extends Component {
168168
onSearch={this.handleSearch}
169169
onSelect={this.handleSelectAction}
170170
onToggleAction={this.handleToggleAction}
171+
onJumpToState={this.handleJumpToState}
171172
onCommit={this.handleCommit}
172173
onSweep={this.handleSweep}
173174
skippedActionIds={skippedActionIds}
@@ -189,6 +190,11 @@ export default class DevtoolsInspector extends Component {
189190
this.props.dispatch(toggleAction(actionId));
190191
};
191192

193+
handleJumpToState = actionId => {
194+
const index = this.props.stagedActionIds.indexOf(actionId);
195+
if (index > 0) this.props.dispatch(jumpToState(index));
196+
};
197+
192198
handleCommit = () => {
193199
this.props.dispatch(commit());
194200
};

0 commit comments

Comments
 (0)