diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dc43d7a48..7cb52a0421 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ 1. [#3474](https://github.com/influxdata/chronograf/pull/3474): Sort task table on Manage Alert page alphabetically 1. [#3590](https://github.com/influxdata/chronograf/pull/3590): Redesign icons in side navigation +1. [#3659](https://github.com/influxdata/chronograf/pull/3659): Upgrade Data Explorer query text field with syntax highlighting and partial multi-line support 1. [#3663](https://github.com/influxdata/chronograf/pull/3663): Truncate message preview in Alert Rules table ### Bug Fixes diff --git a/ui/src/data_explorer/components/QueryEditor.tsx b/ui/src/data_explorer/components/QueryEditor.tsx index 0f64bdec84..67a3a9340a 100644 --- a/ui/src/data_explorer/components/QueryEditor.tsx +++ b/ui/src/data_explorer/components/QueryEditor.tsx @@ -1,10 +1,14 @@ -import React, {PureComponent, KeyboardEvent} from 'react' +import React, {PureComponent} from 'react' +import {Controlled as ReactCodeMirror, IInstance} from 'react-codemirror2' +import {EditorChange} from 'codemirror' import Dropdown from 'src/shared/components/Dropdown' +import classnames from 'classnames' import {QUERY_TEMPLATES, QueryTemplate} from 'src/data_explorer/constants' import QueryStatus from 'src/shared/components/QueryStatus' import {ErrorHandling} from 'src/shared/decorators/errors' import {QueryConfig} from 'src/types' +import 'src/external/codemirror' interface Props { query: string @@ -14,19 +18,17 @@ interface Props { interface State { value: string + focused: boolean } @ErrorHandling class QueryEditor extends PureComponent { - private editor: React.RefObject - constructor(props) { super(props) this.state = { value: this.props.query, + focused: false, } - - this.editor = React.createRef() } public componentWillReceiveProps(nextProps: Props) { @@ -41,21 +43,34 @@ class QueryEditor extends PureComponent { } = this.props const {value} = this.state + const options = { + tabIndex: 1, + mode: 'influxQL', + readonly: false, + lineNumbers: false, + autoRefresh: true, + theme: 'influxql', + completeSingle: false, + lineWrapping: true, + } + return (
-