Skip to content

Commit ca1afff

Browse files
authored
Chore: Remove deprecated Layout components (grafana#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
1 parent 07389d1 commit ca1afff

File tree

4 files changed

+44
-45
lines changed

4 files changed

+44
-45
lines changed

.betterer.results

+1-8
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,6 @@ exports[`better eslint`] = {
447447
"packages/grafana-prometheus/src/components/PromQueryField.tsx:5381": [
448448
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
449449
],
450-
"packages/grafana-prometheus/src/components/PrometheusMetricsBrowser.tsx:5381": [
451-
[0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"]
452-
],
453450
"packages/grafana-prometheus/src/datasource.ts:5381": [
454451
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
455452
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@@ -6430,8 +6427,7 @@ exports[`better eslint`] = {
64306427
[0, 0, 0, "Styles should be written using objects.", "0"]
64316428
],
64326429
"public/app/plugins/datasource/graphite/components/GraphiteFunctionEditor.tsx:5381": [
6433-
[0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"],
6434-
[0, 0, 0, "Styles should be written using objects.", "1"]
6430+
[0, 0, 0, "Styles should be written using objects.", "0"]
64356431
],
64366432
"public/app/plugins/datasource/graphite/components/GraphiteQueryEditor.tsx:5381": [
64376433
[0, 0, 0, "Styles should be written using objects.", "0"],
@@ -6571,9 +6567,6 @@ exports[`better eslint`] = {
65716567
[0, 0, 0, "Styles should be written using objects.", "0"],
65726568
[0, 0, 0, "Styles should be written using objects.", "1"]
65736569
],
6574-
"public/app/plugins/datasource/influxdb/components/editor/query/influxql/code/RawInfluxQLEditor.tsx:5381": [
6575-
[0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"]
6576-
],
65776570
"public/app/plugins/datasource/influxdb/components/editor/query/influxql/visual/VisualInfluxQLEditor.tsx:5381": [
65786571
[0, 0, 0, "Styles should be written using objects.", "0"]
65796572
],

packages/grafana-prometheus/src/components/PrometheusMetricsBrowser.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { selectors } from '@grafana/e2e-selectors';
88
import {
99
BrowserLabel as PromLabel,
1010
Button,
11-
HorizontalGroup,
11+
Stack,
1212
Input,
1313
Label,
1414
LoadingPlaceholder,
@@ -488,7 +488,7 @@ export class UnthemedPrometheusMetricsBrowser extends React.Component<BrowserPro
488488

489489
return (
490490
<div className={styles.wrapper}>
491-
<HorizontalGroup align="flex-start" spacing="lg">
491+
<Stack gap={3}>
492492
<div>
493493
<div className={styles.section}>
494494
<Label description="Once a metric is selected only possible labels are shown.">1. Select a metric</Label>
@@ -631,15 +631,15 @@ export class UnthemedPrometheusMetricsBrowser extends React.Component<BrowserPro
631631
</div>
632632
</div>
633633
</div>
634-
</HorizontalGroup>
634+
</Stack>
635635

636636
<div className={styles.section}>
637637
<Label>4. Resulting selector</Label>
638638
<div aria-label="selector" className={styles.selector}>
639639
{selector}
640640
</div>
641641
{validationStatus && <div className={styles.validationStatus}>{validationStatus}</div>}
642-
<HorizontalGroup>
642+
<Stack>
643643
<Button
644644
data-testid={selectors.components.DataSource.Prometheus.queryEditor.code.metricsBrowser.useQuery}
645645
aria-label="Use selector for query button"
@@ -677,7 +677,7 @@ export class UnthemedPrometheusMetricsBrowser extends React.Component<BrowserPro
677677
<div className={cx(styles.status, (status || error) && styles.statusShowing)}>
678678
<span className={error ? styles.error : ''}>{error || status}</span>
679679
</div>
680-
</HorizontalGroup>
680+
</Stack>
681681
</div>
682682
</div>
683683
);

public/app/plugins/datasource/graphite/components/GraphiteFunctionEditor.tsx

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { css, cx } from '@emotion/css';
22
import React, { useState } from 'react';
33

44
import { GrafanaTheme2 } from '@grafana/data';
5-
import { HorizontalGroup, InlineLabel, useStyles2 } from '@grafana/ui';
5+
import { Stack, InlineLabel, useStyles2 } from '@grafana/ui';
66

77
import { FuncInstance } from '../gfunc';
88
import { actions } from '../state/actions';
@@ -42,7 +42,7 @@ export function GraphiteFunctionEditor({ func }: FunctionEditorProps) {
4242
onMouseOver={() => setIsMouseOver(true)}
4343
onMouseOut={() => setIsMouseOver(false)}
4444
>
45-
<HorizontalGroup spacing="none">
45+
<Stack gap={0} alignItems={'baseline'}>
4646
<FunctionEditor
4747
func={func}
4848
onMoveLeft={() => {
@@ -55,7 +55,9 @@ export function GraphiteFunctionEditor({ func }: FunctionEditorProps) {
5555
dispatch(actions.removeFunction({ func }));
5656
}}
5757
/>
58-
<InlineLabel className={styles.label}>(</InlineLabel>
58+
<InlineLabel className={styles.label} width={'auto'}>
59+
(
60+
</InlineLabel>
5961
{params.map((editableParam: EditableParam, index: number) => {
6062
return (
6163
<React.Fragment key={index}>
@@ -75,8 +77,10 @@ export function GraphiteFunctionEditor({ func }: FunctionEditorProps) {
7577
</React.Fragment>
7678
);
7779
})}
78-
<InlineLabel className={styles.label}>)</InlineLabel>
79-
</HorizontalGroup>
80+
<InlineLabel className={styles.label} width={'auto'}>
81+
)
82+
</InlineLabel>
83+
</Stack>
8084
</div>
8185
);
8286
}

public/app/plugins/datasource/influxdb/components/editor/query/influxql/code/RawInfluxQLEditor.tsx

+29-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useId } from 'react';
22

3-
import { HorizontalGroup, InlineFormLabel, Input, Select, TextArea } from '@grafana/ui';
3+
import { Stack, InlineField, Input, Select, TextArea } from '@grafana/ui';
44

55
import { InfluxQuery } from '../../../../../types';
66
import { DEFAULT_RESULT_FORMAT, RESULT_FORMATS } from '../../../constants';
@@ -34,7 +34,7 @@ export const RawInfluxQLEditor = ({ query, onChange, onRunQuery }: Props): JSX.E
3434
};
3535

3636
return (
37-
<div>
37+
<Stack direction={'column'}>
3838
<TextArea
3939
aria-label="query"
4040
rows={3}
@@ -46,30 +46,32 @@ export const RawInfluxQLEditor = ({ query, onChange, onRunQuery }: Props): JSX.E
4646
}}
4747
value={currentQuery ?? ''}
4848
/>
49-
<HorizontalGroup>
50-
<InlineFormLabel htmlFor={selectElementId}>Format as</InlineFormLabel>
51-
<Select
52-
inputId={selectElementId}
53-
onChange={(v) => {
54-
onChange({ ...query, resultFormat: v.value });
55-
onRunQuery();
56-
}}
57-
value={resultFormat}
58-
options={RESULT_FORMATS}
59-
/>
60-
<InlineFormLabel htmlFor={aliasElementId}>Alias by</InlineFormLabel>
61-
<Input
62-
id={aliasElementId}
63-
type="text"
64-
spellCheck={false}
65-
placeholder="Naming pattern"
66-
onBlur={applyDelayedChangesAndRunQuery}
67-
onChange={(e) => {
68-
setCurrentAlias(e.currentTarget.value);
69-
}}
70-
value={currentAlias ?? ''}
71-
/>
72-
</HorizontalGroup>
73-
</div>
49+
<Stack>
50+
<InlineField htmlFor={selectElementId} label="Format as">
51+
<Select
52+
inputId={selectElementId}
53+
onChange={(v) => {
54+
onChange({ ...query, resultFormat: v.value });
55+
onRunQuery();
56+
}}
57+
value={resultFormat}
58+
options={RESULT_FORMATS}
59+
/>
60+
</InlineField>
61+
<InlineField htmlFor={aliasElementId} label="Alias by">
62+
<Input
63+
id={aliasElementId}
64+
type="text"
65+
spellCheck={false}
66+
placeholder="Naming pattern"
67+
onBlur={applyDelayedChangesAndRunQuery}
68+
onChange={(e) => {
69+
setCurrentAlias(e.currentTarget.value);
70+
}}
71+
value={currentAlias ?? ''}
72+
/>
73+
</InlineField>
74+
</Stack>
75+
</Stack>
7476
);
7577
};

0 commit comments

Comments
 (0)