11import React , { useState } from 'react' ;
2- import { Input , LegacyForms , Select } from '@grafana/ui' ;
2+ import { Input , LegacyForms , Select , useStyles2 } from '@grafana/ui' ;
33import { QueryEditorProps , SelectableValue } from '@grafana/data' ;
4+ import { css } from '@emotion/css' ;
45import { DataSource } from './datasource' ;
56import { MyDataSourceOptions , MyQuery } from './shared/types' ;
67import { useFetchSpaces } from 'shared/hooks/useFetchSpaces' ;
7- import './styles.css' ;
88import { useFetchRooms } from 'shared/hooks/useFetchRooms' ;
99import { useFetchContexts } from 'shared/hooks/useFetchContexts' ;
1010import { useFetchNodes } from 'shared/hooks/useFetchNodes' ;
@@ -17,7 +17,24 @@ type Props = QueryEditorProps<DataSource, MyQuery, MyDataSourceOptions>;
1717
1818const { FormField } = LegacyForms ;
1919
20+ const getStyles = ( ) => ( {
21+ mt : css `
22+ margin-top : 1em ;
23+ ` ,
24+ flex : css `
25+ display : flex;
26+ justify-content : space-between;
27+ & > * {
28+ flex : 1 ;
29+ }
30+ & .gf-form-input {
31+ width : 100% !important ;
32+ }
33+ ` ,
34+ } ) ;
35+
2036const QueryEditor : React . FC < Props > = ( { datasource, query, range, onChange, onRunQuery } ) => {
37+ const styles = useStyles2 ( getStyles ) ;
2138 const { baseUrl } = datasource ;
2239 const from = range ! . from . valueOf ( ) ;
2340 const to = range ! . to . valueOf ( ) ;
@@ -266,7 +283,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, range, onChange, onRu
266283
267284 return (
268285 < >
269- < div className = " flex mt" >
286+ < div className = { ` ${ styles . flex } ${ styles . mt } ` } >
270287 < FormField
271288 label = "Space*"
272289 inputEl = {
@@ -282,7 +299,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, range, onChange, onRu
282299 />
283300 </ div >
284301
285- < div className = "mt" >
302+ < div className = { styles . mt } >
286303 < FormField
287304 label = "Nodes"
288305 tooltip = "No selected Nodes means 'All Nodes' from the Room"
@@ -298,7 +315,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, range, onChange, onRu
298315 }
299316 />
300317 </ div >
301- < div className = " flex mt" >
318+ < div className = { ` ${ styles . flex } ${ styles . mt } ` } >
302319 < FormField
303320 label = "Context*"
304321 inputEl = {
@@ -327,7 +344,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, range, onChange, onRu
327344 />
328345 </ div >
329346
330- < div className = " flex mt" >
347+ < div className = { ` ${ styles . flex } ${ styles . mt } ` } >
331348 < FormField
332349 label = "Grouping by*"
333350 inputEl = {
@@ -371,7 +388,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, range, onChange, onRu
371388 />
372389 </ div >
373390
374- < div className = " flex mt" >
391+ < div className = { ` ${ styles . flex } ${ styles . mt } ` } >
375392 < FormField
376393 label = "Filter by"
377394 inputEl = {
@@ -399,7 +416,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, range, onChange, onRu
399416 />
400417 </ div >
401418
402- < div className = " flex mt" >
419+ < div className = { ` ${ styles . flex } ${ styles . mt } ` } >
403420 < FormField label = "Unit" labelWidth = { 8 } inputEl = { < Input value = { units } disabled /> } />
404421 < div />
405422 </ div >
0 commit comments