From d258c239077f81a758757a92a41f884b95409ae6 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Thu, 10 Aug 2017 17:10:38 -0700 Subject: [PATCH] Separate QueryEditor from SchemaExplorer --- ui/src/dashboards/components/QueryMaker.js | 33 ++++++--- .../dashboards/components/SchemaExplorer.js | 70 +++++-------------- 2 files changed, 44 insertions(+), 59 deletions(-) diff --git a/ui/src/dashboards/components/QueryMaker.js b/ui/src/dashboards/components/QueryMaker.js index 8e7dda73c..cfe04ecad 100644 --- a/ui/src/dashboards/components/QueryMaker.js +++ b/ui/src/dashboards/components/QueryMaker.js @@ -2,16 +2,26 @@ import React, {PropTypes} from 'react' import EmptyQuery from 'src/dashboards/components/EmptyQuery' import QueryTabList from 'src/dashboards/components/QueryTabList' +import QueryEditor from 'src/data_explorer/components/QueryEditor' import SchemaExplorer from 'src/dashboards/components/SchemaExplorer' +import buildInfluxQLQuery from 'utils/influxql' + +const TEMPLATE_RANGE = {upper: null, lower: ':dashboardTime:'} +const rawTextBinder = (links, id, action) => text => + action(links.queries, id, text) + +const buildText = (rawText, range, q) => + rawText || buildInfluxQLQuery(range || TEMPLATE_RANGE, q) || '' const QueryMaker = ({ - source, + source: {links}, actions, queries, timeRange, templates, onAddQuery, activeQuery, + activeQuery: {id, range, rawText}, onDeleteQuery, activeQueryIndex, setActiveQueryIndex, @@ -27,13 +37,20 @@ const QueryMaker = ({ setActiveQueryIndex={setActiveQueryIndex} /> {activeQuery - ? + ?
+ + +
: } ) diff --git a/ui/src/dashboards/components/SchemaExplorer.js b/ui/src/dashboards/components/SchemaExplorer.js index 6ed482075..1b9b6087a 100644 --- a/ui/src/dashboards/components/SchemaExplorer.js +++ b/ui/src/dashboards/components/SchemaExplorer.js @@ -3,81 +3,49 @@ import React, {PropTypes} from 'react' import DatabaseList from 'src/data_explorer/components/DatabaseList' import MeasurementList from 'src/data_explorer/components/MeasurementList' import FieldList from 'src/data_explorer/components/FieldList' -import QueryEditor from 'src/data_explorer/components/QueryEditor' -import buildInfluxQLQuery from 'utils/influxql' - -const TEMPLATE_RANGE = {upper: null, lower: ':dashboardTime:'} const actionBinder = (id, action) => item => action(id, item) -const rawTextBinder = (links, id, action) => text => - action(links.queries, id, text) - const SchemaExplorer = ({ - source: {links}, query, - query: {id, range}, - templates, + query: {id}, actions: { chooseTag, groupByTag, groupByTime, chooseNamespace, - editRawTextAsync, chooseMeasurement, applyFuncsToField, toggleTagAcceptance, toggleFieldWithGroupByInterval, }, }) => -
- + + + -
- - - -
-const {arrayOf, func, shape, string} = PropTypes +const {func, shape, string} = PropTypes SchemaExplorer.propTypes = { - source: shape({ - links: shape({ - queries: string.isRequired, - }).isRequired, - }).isRequired, query: shape({ id: string, }).isRequired, - templates: arrayOf( - shape({ - tempVar: string.isRequired, - }) - ), actions: shape({ chooseNamespace: func.isRequired, chooseMeasurement: func.isRequired,