From bc956057c34f660765255247ecc8d361ccc35ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 17 Jan 2019 10:26:08 +0100 Subject: [PATCH] Query editor row react progress, buttons working --- .../dashboard/panel_editor/QueriesTab.tsx | 16 +++-- .../dashboard/panel_editor/QueryEditorRow.tsx | 61 +++++++++++++------ public/sass/components/_query_editor.scss | 39 ++++++++---- 3 files changed, 75 insertions(+), 41 deletions(-) diff --git a/public/app/features/dashboard/panel_editor/QueriesTab.tsx b/public/app/features/dashboard/panel_editor/QueriesTab.tsx index b1d2bd7284b..d6c05e1d18c 100644 --- a/public/app/features/dashboard/panel_editor/QueriesTab.tsx +++ b/public/app/features/dashboard/panel_editor/QueriesTab.tsx @@ -181,18 +181,16 @@ export class QueriesTab extends PureComponent { onRemoveQuery={this.onRemoveQuery} onAddQuery={this.onAddQuery} onMoveQuery={this.onMoveQuery} + inMixedMode={currentDS.meta.mixed} /> ))} -
-
-
- +
+
+
+ + {' '} + {panel.getNextQueryLetter()}
{!isAddingMixed && ( diff --git a/public/app/features/dashboard/panel_editor/QueryEditorRow.tsx b/public/app/features/dashboard/panel_editor/QueryEditorRow.tsx index a7724eed814..1000329cf43 100644 --- a/public/app/features/dashboard/panel_editor/QueryEditorRow.tsx +++ b/public/app/features/dashboard/panel_editor/QueryEditorRow.tsx @@ -1,6 +1,7 @@ // Libraries import React, { PureComponent } from 'react'; import classNames from 'classnames'; +import _ from 'lodash'; // Utils & Services import { getDatasourceSrv } from 'app/features/plugins/datasource_srv'; @@ -18,6 +19,7 @@ interface Props { onRemoveQuery: (query: DataQuery) => void; onMoveQuery: (query: DataQuery, direction: number) => void; datasourceName: string | null; + inMixedMode: boolean; } interface State { @@ -133,47 +135,68 @@ export class QueryEditorRow extends PureComponent { return angularScope && angularScope.toggleEditorMode; } + onRemoveQuery = () => { + this.props.onRemoveQuery(this.props.query); + }; + + onCopyQuery = () => { + const copy = _.cloneDeep(this.props.query); + this.props.onAddQuery(copy); + }; + + onDisableQuery = () => { + this.props.query.hide = !this.props.query.hide; + this.forceUpdate(); + }; + render() { - const { query } = this.props; - const { datasource, isCollapsed, angularScope } = this.state; - const bodyClasses = classNames('query-editor-box__body gf-form-query', { hide: isCollapsed }); + const { query, datasourceName, inMixedMode } = this.props; + const { datasource, isCollapsed } = this.state; + const isDisabled = query.hide; + + const bodyClasses = classNames('query-editor-row__body gf-form-query', { + 'query-editor-row__body--collapsed': isCollapsed, + }); + + const rowClasses = classNames('query-editor-row', { + 'query-editor-row--disabled': isDisabled, + 'gf-form-disabled': isDisabled, + }); if (!datasource) { return null; } - console.log('Query render'); - if (angularScope !== null && angularScope.toggleEditorMode) { - console.log('Query editor has text edit mode'); - } - return ( -
-
-
+
+
+
{isCollapsed && } {!isCollapsed && } {query.refId} + {inMixedMode && ({datasourceName})} + {isDisabled && Disabled}
-
+
{this.hasTextEditMode && ( - )} - - - - -
diff --git a/public/sass/components/_query_editor.scss b/public/sass/components/_query_editor.scss index 7e8eddea414..35abd34a770 100644 --- a/public/sass/components/_query_editor.scss +++ b/public/sass/components/_query_editor.scss @@ -3,12 +3,6 @@ color: $blue; } -.gf-form-disabled { - .query-keyword { - color: darken($blue, 20%); - } -} - .query-segment-operator { color: $orange; } @@ -183,17 +177,24 @@ input[type='text'].tight-form-func-param { display: block; } -.query-editor-box { +.query-editor-row { margin-bottom: 2px; &:hover { - .query-editor-box__actions { + .query-editor-row__actions { display: flex; } } + + &--disabled { + .query-keyword { + color: darken($blue, 20%); + } + } + } -.query-editor-box__header { +.query-editor-row__header { display: flex; padding: 4px 0px 4px 8px; position: relative; @@ -201,7 +202,7 @@ input[type='text'].tight-form-func-param { background: $page-bg; } -.query-editor-box__ref-id { +.query-editor-row__ref-id { font-weight: $font-weight-semi-bold; color: $blue; font-size: $font-size-md; @@ -216,14 +217,14 @@ input[type='text'].tight-form-func-param { } } -.query-editor-box__actions { +.query-editor-row__actions { flex-grow: 1; display: flex; justify-content: flex-end; color: $text-muted; } -.query-editor-box__action { +.query-editor-row__action { margin-left: 3px; background: transparent; border: none; @@ -234,7 +235,19 @@ input[type='text'].tight-form-func-param { } } - .query-editor-box__body { + .query-editor-row__body { margin: 0 0 10px 40px; background: $page-bg; + + &--collapsed { + display: none; + } } + +.query-editor-row__context-info { + font-style: italic; + font-size: $font-size-sm; + color: $text-muted; + padding-left: 10px; +} +