diff --git a/src/devTools.js b/src/devTools.js
index fa079486..5510c546 100644
--- a/src/devTools.js
+++ b/src/devTools.js
@@ -3,6 +3,7 @@ const ActionTypes = {
RESET: 'RESET',
ROLLBACK: 'ROLLBACK',
COMMIT: 'COMMIT',
+ IMPORT_STATE: 'IMPORT_STATE',
SWEEP: 'SWEEP',
TOGGLE_ACTION: 'TOGGLE_ACTION',
JUMP_TO_STATE: 'JUMP_TO_STATE',
@@ -121,6 +122,16 @@ function liftReducer(reducer, initialState) {
currentStateIndex = 0;
timestamps = [liftedAction.timestamp];
break;
+ case ActionTypes.IMPORT_STATE:
+ ({
+ stagedActions,
+ skippedActions,
+ computedStates,
+ currentStateIndex,
+ monitorState,
+ timestamps
+ } = liftedAction.nextLiftedState);
+ break;
case ActionTypes.ROLLBACK:
stagedActions = [INIT_ACTION];
skippedActions = {};
@@ -258,6 +269,9 @@ export const ActionCreators = {
commit() {
return { type: ActionTypes.COMMIT, timestamp: Date.now() };
},
+ importState(nextLiftedState) {
+ return { type: ActionTypes.IMPORT_STATE, nextLiftedState };
+ },
sweep() {
return { type: ActionTypes.SWEEP };
},
diff --git a/src/react/LogMonitor.js b/src/react/LogMonitor.js
index c9839de5..dfa2d1f8 100644
--- a/src/react/LogMonitor.js
+++ b/src/react/LogMonitor.js
@@ -1,3 +1,4 @@
+/* eslint-disable no-alert */
import React, { PropTypes, findDOMNode, Component } from 'react';
import LogMonitorEntry from './LogMonitorEntry';
import LogMonitorButton from './LogMonitorButton';
@@ -118,6 +119,21 @@ export default class LogMonitor extends Component {
this.props.commit();
}
+ handleExport() {
+ window.prompt('Current state\'s schema', JSON.stringify(this.props.store.getState()));
+ }
+
+ handleImport() {
+ try {
+ let nextLiftedState = window.prompt('Please paste a valid action log');
+ if (nextLiftedState) {
+ this.props.importState(JSON.parse(nextLiftedState));
+ }
+ } catch (err) {
+ console.warn('There was an error parsing the new state. Please enter a valid schema.');
+ }
+ }
+
handleToggleAction(index) {
this.props.toggleAction(index);
}
@@ -184,6 +200,8 @@ export default class LogMonitor extends Component {