diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/editor/editor_component.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/editor/editor_component.tsx index 51c1ec6f9e4..da7db58567f 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/editor/editor_component.tsx +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/editor/editor_component.tsx @@ -1,11 +1,9 @@ import KustoQueryField from './KustoQueryField'; import Kusto from './kusto'; -import React, {Component} from 'react'; +import React, { Component } from 'react'; import coreModule from 'app/core/core_module'; - - class Editor extends Component { constructor(props) { super(props); @@ -37,7 +35,7 @@ class Editor extends Component { const { edited, query } = this.state; return ( -
+
', '<', '==', '<>', '<=', '>=', '~', '!~']; -export const DURATION = [ - 'SECONDS', - 'MINUTES', - 'HOURS', - 'DAYS', - 'WEEKS', - 'MONTHS', - 'YEARS' -]; +export const DURATION = ['SECONDS', 'MINUTES', 'HOURS', 'DAYS', 'WEEKS', 'MONTHS', 'YEARS']; const tokenizer = { comment: { @@ -70,7 +96,7 @@ const tokenizer = { number: /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i, operator: /-|\+|\*|\/|>|<|==|<=?|>=?|<>|!~|~|=|\|/, punctuation: /[{};(),.:]/, - variable: /(\[\[(.+?)\]\])|(\$(.+?))\b/ + variable: /(\[\[(.+?)\]\])|(\$(.+?))\b/, }; tokenizer['function-context'].inside = { diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/editor/query_field.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/editor/query_field.tsx index 8a66802ce13..1c883a40c31 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/editor/query_field.tsx +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/editor/query_field.tsx @@ -17,7 +17,6 @@ import ReactDOM from 'react-dom'; import React from 'react'; import _ from 'lodash'; - function flattenSuggestions(s) { return s ? s.reduce((acc, g) => acc.concat(g.items), []) : []; } @@ -107,14 +106,14 @@ class QueryField extends React.Component { }); window.requestAnimationFrame(this.onTypeahead); - } + }; request = (url?) => { if (this.props.request) { return this.props.request(url); } return fetch(url); - } + }; onChangeQuery = () => { // Send text change to parent @@ -122,7 +121,7 @@ class QueryField extends React.Component { if (onQueryChange) { onQueryChange(Plain.serialize(this.state.value)); } - } + }; onKeyDown = (event, change) => { const { typeaheadIndex, suggestions } = this.state; @@ -147,6 +146,7 @@ class QueryField extends React.Component { break; } + case 'Tab': case 'Enter': { if (this.menuEl) { // Dont blur input @@ -191,13 +191,15 @@ class QueryField extends React.Component { } } return undefined; - } + }; onTypeahead = (change?, item?) => { return change || this.state.value.change(); - } + }; - applyTypeahead(change?, suggestion?): { value: object } { return { value: {} }; } + applyTypeahead(change?, suggestion?): { value: object } { + return { value: {} }; + } resetTypeahead = () => { this.setState({ @@ -206,7 +208,7 @@ class QueryField extends React.Component { typeaheadPrefix: '', typeaheadContext: null, }); - } + }; handleBlur = () => { const { onBlur } = this.props; @@ -216,14 +218,14 @@ class QueryField extends React.Component { if (onBlur) { onBlur(); } - } + }; handleFocus = () => { const { onFocus } = this.props; if (onFocus) { onFocus(); } - } + }; onClickItem = item => { const { suggestions } = this.state; @@ -241,7 +243,7 @@ class QueryField extends React.Component { // Manually triggering change const change = this.applyTypeahead(this.state.value.change(), suggestion); this.onChange(change); - } + }; updateMenu = () => { const { suggestions } = this.state; @@ -275,11 +277,11 @@ class QueryField extends React.Component { menu.style.left = `${rect.left + scrollX - 2}px`; }); } - } + }; menuRef = el => { this.menuEl = el; - } + }; renderMenu = () => { const { portalPrefix } = this.props; @@ -308,7 +310,7 @@ class QueryField extends React.Component { /> ); - } + }; render() { return (