From eaa04a31935b7d803b1780e0dcaa17f12becec7e Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Fri, 11 May 2018 14:43:22 -0700 Subject: [PATCH] Convert QueryEditor to ts --- .../data_explorer/components/QueryEditor.tsx | 105 +++++++++++++ ui/src/data_explorer/constants/index.ts | 139 ++++++++++++++++++ 2 files changed, 244 insertions(+) create mode 100644 ui/src/data_explorer/components/QueryEditor.tsx create mode 100644 ui/src/data_explorer/constants/index.ts diff --git a/ui/src/data_explorer/components/QueryEditor.tsx b/ui/src/data_explorer/components/QueryEditor.tsx new file mode 100644 index 0000000000..08af3ca365 --- /dev/null +++ b/ui/src/data_explorer/components/QueryEditor.tsx @@ -0,0 +1,105 @@ +import React, {PureComponent, KeyboardEvent} from 'react' + +import Dropdown from 'src/shared/components/Dropdown' +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' + +interface Props { + query: string + config: QueryConfig + onUpdate: (value: string) => void +} + +interface State { + value: string +} + +@ErrorHandling +class QueryEditor extends PureComponent { + private editor: React.RefObject + + constructor(props) { + super(props) + this.state = { + value: this.props.query, + } + + this.editor = React.createRef() + } + + public componentWillReceiveProps(nextProps) { + if (this.props.query !== nextProps.query) { + this.setState({value: nextProps.query}) + } + } + + public render() { + const { + config: {status}, + } = this.props + const {value} = this.state + + return ( +
+