mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Grafana-UI: Editor UI components (#41136)
* Grafana-UI: Update theme.spacing to support string value when called with just one arugment
This allows theme.spacing("auto") to be valid
* Grafana-UI: Support width="auto" for Select component
This allows for inline Selects that are sized based on their content,
rather than occupying block-width
* Add toOption for creating Select options to @grafana/data
* Add test util
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import React from 'react';
|
||||
import { LegacyForms } from '@grafana/ui';
|
||||
import { TemplateSrv } from '@grafana/runtime';
|
||||
import { SelectableValue } from '@grafana/data';
|
||||
import { SelectableValue, toOption } from '@grafana/data';
|
||||
|
||||
import CloudMonitoringDatasource from '../datasource';
|
||||
import { AnnotationsHelp, LabelFilter, Metrics, Project, QueryEditorRow } from './';
|
||||
import { toOption } from '../functions';
|
||||
import { AnnotationTarget, EditorMode, MetricDescriptor, MetricKind } from '../types';
|
||||
|
||||
const { Input } = LegacyForms;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React, { FunctionComponent, useCallback, useMemo } from 'react';
|
||||
import { flatten } from 'lodash';
|
||||
|
||||
import { SelectableValue } from '@grafana/data';
|
||||
import { SelectableValue, toOption } from '@grafana/data';
|
||||
import { CustomControlProps } from '@grafana/ui/src/components/Select/types';
|
||||
import { Button, HorizontalGroup, Select, VerticalGroup } from '@grafana/ui';
|
||||
import { labelsToGroupedOptions, stringArrayToFilters, toOption } from '../functions';
|
||||
import { labelsToGroupedOptions, stringArrayToFilters } from '../functions';
|
||||
import { Filter } from '../types';
|
||||
import { SELECT_WIDTH } from '../constants';
|
||||
import { QueryEditorRow } from '.';
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { css } from '@emotion/css';
|
||||
import { QueryEditorProps } from '@grafana/data';
|
||||
import { QueryEditorProps, toOption } from '@grafana/data';
|
||||
import { Button, Select } from '@grafana/ui';
|
||||
import { MetricQueryEditor, SLOQueryEditor, QueryEditorRow } from './';
|
||||
import { CloudMonitoringQuery, MetricQuery, QueryType, SLOQuery, EditorMode } from '../types';
|
||||
import { SELECT_WIDTH, QUERY_TYPES } from '../constants';
|
||||
import { defaultQuery } from './MetricQueryEditor';
|
||||
import { defaultQuery as defaultSLOQuery } from './SLO/SLOQueryEditor';
|
||||
import { toOption } from '../functions';
|
||||
import CloudMonitoringDatasource from '../datasource';
|
||||
|
||||
export type Props = QueryEditorProps<CloudMonitoringDatasource, CloudMonitoringQuery>;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { chunk, flatten, initial, startCase, uniqBy } from 'lodash';
|
||||
import { ALIGNMENTS, AGGREGATIONS, SYSTEM_LABELS } from './constants';
|
||||
import { SelectableValue } from '@grafana/data';
|
||||
import CloudMonitoringDatasource from './datasource';
|
||||
import { TemplateSrv, getTemplateSrv } from '@grafana/runtime';
|
||||
import { MetricDescriptor, ValueTypes, MetricKind, AlignmentTypes, PreprocessorType, Filter } from './types';
|
||||
@@ -118,8 +117,6 @@ export const stringArrayToFilters = (filterArray: string[]) =>
|
||||
condition,
|
||||
}));
|
||||
|
||||
export const toOption = (value: string) => ({ label: value, value } as SelectableValue<string>);
|
||||
|
||||
export const formatCloudMonitoringError = (error: any) => {
|
||||
let message = error.statusText ?? '';
|
||||
if (error.data && error.data.error) {
|
||||
|
||||
Reference in New Issue
Block a user