Chore: Remove deprecated Layout components (#89376)

* Removed depricated HorizontalLayout from PrometheusMetricsBrowser

* Removed commented import

* typo fix

* Removed depricated HorizontalLayout from RawInfluxQLEditor

* Replaced InlineFormLabel to InlineField in RawInlfuxEditor.tsx

* Removed depricated HorizontalLayout from GraphiteFunctionEditor

* Changed div to instead use stack

* Changed htmlFor attribute from selectElementId to aliasElementId

* Updated the betterer results

* Updated prettier write to the updated files

* Changed htmlFor label to fix the text
pull/89635/head
Chirag Gomber 11 months ago committed by GitHub
parent 07389d1030
commit ca1afff886
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      .betterer.results
  2. 10
      packages/grafana-prometheus/src/components/PrometheusMetricsBrowser.tsx
  3. 14
      public/app/plugins/datasource/graphite/components/GraphiteFunctionEditor.tsx
  4. 56
      public/app/plugins/datasource/influxdb/components/editor/query/influxql/code/RawInfluxQLEditor.tsx

@ -447,9 +447,6 @@ exports[`better eslint`] = {
"packages/grafana-prometheus/src/components/PromQueryField.tsx:5381": [ "packages/grafana-prometheus/src/components/PromQueryField.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"packages/grafana-prometheus/src/components/PrometheusMetricsBrowser.tsx:5381": [
[0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"]
],
"packages/grafana-prometheus/src/datasource.ts:5381": [ "packages/grafana-prometheus/src/datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -6430,8 +6427,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "0"] [0, 0, 0, "Styles should be written using objects.", "0"]
], ],
"public/app/plugins/datasource/graphite/components/GraphiteFunctionEditor.tsx:5381": [ "public/app/plugins/datasource/graphite/components/GraphiteFunctionEditor.tsx:5381": [
[0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"]
[0, 0, 0, "Styles should be written using objects.", "1"]
], ],
"public/app/plugins/datasource/graphite/components/GraphiteQueryEditor.tsx:5381": [ "public/app/plugins/datasource/graphite/components/GraphiteQueryEditor.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
@ -6571,9 +6567,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"] [0, 0, 0, "Styles should be written using objects.", "1"]
], ],
"public/app/plugins/datasource/influxdb/components/editor/query/influxql/code/RawInfluxQLEditor.tsx:5381": [
[0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"]
],
"public/app/plugins/datasource/influxdb/components/editor/query/influxql/visual/VisualInfluxQLEditor.tsx:5381": [ "public/app/plugins/datasource/influxdb/components/editor/query/influxql/visual/VisualInfluxQLEditor.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"] [0, 0, 0, "Styles should be written using objects.", "0"]
], ],

@ -8,7 +8,7 @@ import { selectors } from '@grafana/e2e-selectors';
import { import {
BrowserLabel as PromLabel, BrowserLabel as PromLabel,
Button, Button,
HorizontalGroup, Stack,
Input, Input,
Label, Label,
LoadingPlaceholder, LoadingPlaceholder,
@ -488,7 +488,7 @@ export class UnthemedPrometheusMetricsBrowser extends React.Component<BrowserPro
return ( return (
<div className={styles.wrapper}> <div className={styles.wrapper}>
<HorizontalGroup align="flex-start" spacing="lg"> <Stack gap={3}>
<div> <div>
<div className={styles.section}> <div className={styles.section}>
<Label description="Once a metric is selected only possible labels are shown.">1. Select a metric</Label> <Label description="Once a metric is selected only possible labels are shown.">1. Select a metric</Label>
@ -631,7 +631,7 @@ export class UnthemedPrometheusMetricsBrowser extends React.Component<BrowserPro
</div> </div>
</div> </div>
</div> </div>
</HorizontalGroup> </Stack>
<div className={styles.section}> <div className={styles.section}>
<Label>4. Resulting selector</Label> <Label>4. Resulting selector</Label>
@ -639,7 +639,7 @@ export class UnthemedPrometheusMetricsBrowser extends React.Component<BrowserPro
{selector} {selector}
</div> </div>
{validationStatus && <div className={styles.validationStatus}>{validationStatus}</div>} {validationStatus && <div className={styles.validationStatus}>{validationStatus}</div>}
<HorizontalGroup> <Stack>
<Button <Button
data-testid={selectors.components.DataSource.Prometheus.queryEditor.code.metricsBrowser.useQuery} data-testid={selectors.components.DataSource.Prometheus.queryEditor.code.metricsBrowser.useQuery}
aria-label="Use selector for query button" aria-label="Use selector for query button"
@ -677,7 +677,7 @@ export class UnthemedPrometheusMetricsBrowser extends React.Component<BrowserPro
<div className={cx(styles.status, (status || error) && styles.statusShowing)}> <div className={cx(styles.status, (status || error) && styles.statusShowing)}>
<span className={error ? styles.error : ''}>{error || status}</span> <span className={error ? styles.error : ''}>{error || status}</span>
</div> </div>
</HorizontalGroup> </Stack>
</div> </div>
</div> </div>
); );

@ -2,7 +2,7 @@ import { css, cx } from '@emotion/css';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { GrafanaTheme2 } from '@grafana/data'; import { GrafanaTheme2 } from '@grafana/data';
import { HorizontalGroup, InlineLabel, useStyles2 } from '@grafana/ui'; import { Stack, InlineLabel, useStyles2 } from '@grafana/ui';
import { FuncInstance } from '../gfunc'; import { FuncInstance } from '../gfunc';
import { actions } from '../state/actions'; import { actions } from '../state/actions';
@ -42,7 +42,7 @@ export function GraphiteFunctionEditor({ func }: FunctionEditorProps) {
onMouseOver={() => setIsMouseOver(true)} onMouseOver={() => setIsMouseOver(true)}
onMouseOut={() => setIsMouseOver(false)} onMouseOut={() => setIsMouseOver(false)}
> >
<HorizontalGroup spacing="none"> <Stack gap={0} alignItems={'baseline'}>
<FunctionEditor <FunctionEditor
func={func} func={func}
onMoveLeft={() => { onMoveLeft={() => {
@ -55,7 +55,9 @@ export function GraphiteFunctionEditor({ func }: FunctionEditorProps) {
dispatch(actions.removeFunction({ func })); dispatch(actions.removeFunction({ func }));
}} }}
/> />
<InlineLabel className={styles.label}>(</InlineLabel> <InlineLabel className={styles.label} width={'auto'}>
(
</InlineLabel>
{params.map((editableParam: EditableParam, index: number) => { {params.map((editableParam: EditableParam, index: number) => {
return ( return (
<React.Fragment key={index}> <React.Fragment key={index}>
@ -75,8 +77,10 @@ export function GraphiteFunctionEditor({ func }: FunctionEditorProps) {
</React.Fragment> </React.Fragment>
); );
})} })}
<InlineLabel className={styles.label}>)</InlineLabel> <InlineLabel className={styles.label} width={'auto'}>
</HorizontalGroup> )
</InlineLabel>
</Stack>
</div> </div>
); );
} }

@ -1,6 +1,6 @@
import React, { useId } from 'react'; import React, { useId } from 'react';
import { HorizontalGroup, InlineFormLabel, Input, Select, TextArea } from '@grafana/ui'; import { Stack, InlineField, Input, Select, TextArea } from '@grafana/ui';
import { InfluxQuery } from '../../../../../types'; import { InfluxQuery } from '../../../../../types';
import { DEFAULT_RESULT_FORMAT, RESULT_FORMATS } from '../../../constants'; import { DEFAULT_RESULT_FORMAT, RESULT_FORMATS } from '../../../constants';
@ -34,7 +34,7 @@ export const RawInfluxQLEditor = ({ query, onChange, onRunQuery }: Props): JSX.E
}; };
return ( return (
<div> <Stack direction={'column'}>
<TextArea <TextArea
aria-label="query" aria-label="query"
rows={3} rows={3}
@ -46,30 +46,32 @@ export const RawInfluxQLEditor = ({ query, onChange, onRunQuery }: Props): JSX.E
}} }}
value={currentQuery ?? ''} value={currentQuery ?? ''}
/> />
<HorizontalGroup> <Stack>
<InlineFormLabel htmlFor={selectElementId}>Format as</InlineFormLabel> <InlineField htmlFor={selectElementId} label="Format as">
<Select <Select
inputId={selectElementId} inputId={selectElementId}
onChange={(v) => { onChange={(v) => {
onChange({ ...query, resultFormat: v.value }); onChange({ ...query, resultFormat: v.value });
onRunQuery(); onRunQuery();
}} }}
value={resultFormat} value={resultFormat}
options={RESULT_FORMATS} options={RESULT_FORMATS}
/> />
<InlineFormLabel htmlFor={aliasElementId}>Alias by</InlineFormLabel> </InlineField>
<Input <InlineField htmlFor={aliasElementId} label="Alias by">
id={aliasElementId} <Input
type="text" id={aliasElementId}
spellCheck={false} type="text"
placeholder="Naming pattern" spellCheck={false}
onBlur={applyDelayedChangesAndRunQuery} placeholder="Naming pattern"
onChange={(e) => { onBlur={applyDelayedChangesAndRunQuery}
setCurrentAlias(e.currentTarget.value); onChange={(e) => {
}} setCurrentAlias(e.currentTarget.value);
value={currentAlias ?? ''} }}
/> value={currentAlias ?? ''}
</HorizontalGroup> />
</div> </InlineField>
</Stack>
</Stack>
); );
}; };

Loading…
Cancel
Save