-
Notifications
You must be signed in to change notification settings - Fork 14k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [sqllab] optimizing React * Addressing comments and making npm run dev faster
- Loading branch information
1 parent
64d1964
commit b242063
Showing
20 changed files
with
133 additions
and
75 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
caravel/assets/javascripts/SqlLab/components/AceEditorWrapper.jsx
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,51 @@ | ||
import React from 'react'; | ||
import AceEditor from 'react-ace'; | ||
import 'brace/mode/sql'; | ||
import 'brace/theme/github'; | ||
import 'brace/ext/language_tools'; | ||
|
||
const propTypes = { | ||
sql: React.PropTypes.string.isRequired, | ||
onBlur: React.PropTypes.func, | ||
}; | ||
|
||
const defaultProps = { | ||
onBlur: () => {}, | ||
}; | ||
|
||
class AceEditorWrapper extends React.PureComponent { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
sql: props.sql, | ||
}; | ||
} | ||
textChange(text) { | ||
this.setState({ sql: text }); | ||
} | ||
onBlur() { | ||
this.props.onBlur(this.state.sql); | ||
} | ||
|
||
render() { | ||
return ( | ||
<AceEditor | ||
mode="sql" | ||
theme="github" | ||
onBlur={this.onBlur.bind(this)} | ||
minLines={8} | ||
maxLines={30} | ||
onChange={this.textChange.bind(this)} | ||
height="200px" | ||
width="100%" | ||
editorProps={{ $blockScrolling: true }} | ||
enableBasicAutocompletion | ||
value={this.state.sql} | ||
/> | ||
); | ||
} | ||
} | ||
AceEditorWrapper.defaultProps = defaultProps; | ||
AceEditorWrapper.propTypes = propTypes; | ||
|
||
export default AceEditorWrapper; |
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
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
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
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
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
Oops, something went wrong.