diff --git a/caravel/assets/javascripts/SqlLab/actions.js b/caravel/assets/javascripts/SqlLab/actions.js
index eb2b6d511bd..a2361368d11 100644
--- a/caravel/assets/javascripts/SqlLab/actions.js
+++ b/caravel/assets/javascripts/SqlLab/actions.js
@@ -22,7 +22,7 @@ export const REMOVE_WORKSPACE_QUERY = 'REMOVE_WORKSPACE_QUERY';
export const SET_ACTIVE_QUERY_EDITOR = 'SET_ACTIVE_QUERY_EDITOR';
export function resetState() {
- return { type: RESET_STATE };
+ return { type: RESET_STATE };
}
export function addQueryEditor(queryEditor) {
diff --git a/caravel/assets/javascripts/SqlLab/components/ButtonWithTooltip.jsx b/caravel/assets/javascripts/SqlLab/components/ButtonWithTooltip.jsx
index 36220e6b4ff..622c721f6d3 100644
--- a/caravel/assets/javascripts/SqlLab/components/ButtonWithTooltip.jsx
+++ b/caravel/assets/javascripts/SqlLab/components/ButtonWithTooltip.jsx
@@ -1,33 +1,31 @@
import React from 'react';
import { Button, OverlayTrigger, Tooltip } from 'react-bootstrap';
-
-class ButtonWithTooltip extends React.Component {
- render() {
- let tooltip = (
-
- {this.props.tooltip}
-
- );
- return (
- {
+ let tooltip = (
+
+ {props.tooltip}
+
+ );
+ return (
+
+
- );
- }
-}
+ {props.children}
+
+
+ );
+};
+
ButtonWithTooltip.defaultProps = {
onClick: () => {},
disabled: false,
diff --git a/caravel/assets/javascripts/SqlLab/components/LeftPane.jsx b/caravel/assets/javascripts/SqlLab/components/LeftPane.jsx
index 27e441aac11..cebeb282880 100644
--- a/caravel/assets/javascripts/SqlLab/components/LeftPane.jsx
+++ b/caravel/assets/javascripts/SqlLab/components/LeftPane.jsx
@@ -8,51 +8,52 @@ import QueryLink from './QueryLink';
// CSS
import 'react-select/dist/react-select.css';
-class LeftPane extends React.Component {
- render() {
- let queryElements;
- if (this.props.workspaceQueries.length > 0) {
- queryElements = this.props.workspaceQueries.map((q) => );
- } else {
- queryElements = (
-
- Use the save button on the SQL editor to save a query into this section for
- future reference
-
- );
- }
- return (
-
-
-
-
- SQL Lab
-
-
-
-
-
-
-
-
- Saved Queries
-
-
- {queryElements}
-
-
-
- Reset State
-
-
-
-
+const LeftPane = (props) => {
+ let queryElements;
+ if (props.workspaceQueries.length > 0) {
+ queryElements = props.workspaceQueries.map((q) => );
+ } else {
+ queryElements = (
+
+ Use the save button on the SQL editor to save a query into this section for
+ future reference
+
);
}
-}
+ return (
+
+
+
+
+ SQL Lab
+
+
+
+
+
+
+
+
+ Saved Queries
+
+
+ {queryElements}
+
+
+
+ Reset State
+
+
+
+
+ );
+};
+
LeftPane.propTypes = {
workspaceQueries: React.PropTypes.array,
+ actions: React.PropTypes.object,
};
+
LeftPane.defaultProps = {
workspaceQueries: [],
};
diff --git a/caravel/assets/javascripts/SqlLab/components/QueryLog.jsx b/caravel/assets/javascripts/SqlLab/components/QueryHistory.jsx
similarity index 54%
rename from caravel/assets/javascripts/SqlLab/components/QueryLog.jsx
rename to caravel/assets/javascripts/SqlLab/components/QueryHistory.jsx
index bc83a4627c6..071c4352c03 100644
--- a/caravel/assets/javascripts/SqlLab/components/QueryLog.jsx
+++ b/caravel/assets/javascripts/SqlLab/components/QueryHistory.jsx
@@ -7,30 +7,29 @@ import * as Actions from '../actions';
import QueryTable from './QueryTable';
import { Alert } from 'react-bootstrap';
-class QueryLog extends React.Component {
- render() {
- const activeQeId = this.props.tabHistory[this.props.tabHistory.length - 1];
- const queries = this.props.queries.filter((q) => (q.sqlEditorId === activeQeId));
- if (queries.length > 0) {
- return (
-
- );
- }
+const QueryHistory = (props) => {
+ const activeQeId = props.tabHistory[props.tabHistory.length - 1];
+ const queries = props.queries.filter((q) => (q.sqlEditorId === activeQeId));
+ if (queries.length > 0) {
return (
-
- No query history yet...
-
+
);
}
-}
-QueryLog.defaultProps = {
+ return (
+
+ No query history yet...
+
+ );
+};
+
+QueryHistory.defaultProps = {
queries: [],
};
-QueryLog.propTypes = {
+QueryHistory.propTypes = {
queries: React.PropTypes.array,
tabHistory: React.PropTypes.array,
actions: React.PropTypes.object,
@@ -48,4 +47,4 @@ function mapDispatchToProps(dispatch) {
};
}
-export default connect(mapStateToProps, mapDispatchToProps)(QueryLog);
+export default connect(mapStateToProps, mapDispatchToProps)(QueryHistory);
diff --git a/caravel/assets/javascripts/SqlLab/components/QueryTable.jsx b/caravel/assets/javascripts/SqlLab/components/QueryTable.jsx
index 7b06220e22e..6aa8edd4cc8 100644
--- a/caravel/assets/javascripts/SqlLab/components/QueryTable.jsx
+++ b/caravel/assets/javascripts/SqlLab/components/QueryTable.jsx
@@ -1,12 +1,9 @@
import React from 'react';
-import { Alert, Modal } from 'react-bootstrap';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as Actions from '../actions';
-import Select from 'react-select';
-
import moment from 'moment';
import { Table } from 'reactable';
@@ -14,6 +11,7 @@ import SyntaxHighlighter from 'react-syntax-highlighter';
import { github } from 'react-syntax-highlighter/dist/styles';
import Link from './Link';
+import VisualizeModal from './VisualizeModal';
// TODO move to CSS
const STATE_COLOR_MAP = {
@@ -35,9 +33,7 @@ class QueryTable extends React.Component {
}
showVisualizeModal(query) {
this.setState({ showVisualizeModal: true });
- this.state.activeQuery = query;
- }
- changeChartType(event) {
+ this.setState({ activeQuery: query });
}
render() {
const data = this.props.queries.map((query) => {
@@ -87,58 +83,13 @@ class QueryTable extends React.Component {
return q;
}).reverse();
- let visualizeModalBody;
- if (this.state.activeQuery) {
- const cols = this.state.activeQuery.results.columns;
- visualizeModalBody = (
-