-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import-Export States to your DevTools
- Loading branch information
pabloalonso
committed
Sep 18, 2015
1 parent
fc839a0
commit da5e376
Showing
3 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { PropTypes, findDOMNode, Component } from 'react'; | ||
|
||
const EXPORT_CONTAINER_HEIGHT = 150; | ||
const ELEMENTS_CONTAINER_TOP = 38; | ||
|
||
var styles = { | ||
exportContainer: { | ||
width: '100%', | ||
height: EXPORT_CONTAINER_HEIGHT | ||
}, | ||
exportArea: { | ||
position: 'relative', | ||
resize: 'none', | ||
width: '100%', | ||
height: 112, | ||
backgroundColor: '#4F5A66', | ||
color: 'white' | ||
} | ||
}; | ||
|
||
export default class LogMonitorTextarea extends Component { | ||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
parseInput(event) { | ||
try { | ||
this.props.handleImport(JSON.parse(event.target.value)) | ||
} catch(err) { | ||
console.warn('There was an error parsing the new state. Please enter a valid schema.'); | ||
} | ||
} | ||
|
||
render() { | ||
let { handleImport, currentState, theme } = this.props; | ||
return currentState.monitorState.exportMode ? ( | ||
<div style={{...styles.exportContainer, backgroundColor: theme.base00}}> | ||
<textarea style={styles.exportArea} value={JSON.stringify(currentState)} onChange={::this.parseInput} /> | ||
</div> | ||
) : null; | ||
} | ||
} |