Skip to content

Commit fb279e8

Browse files
committed
[CI] Auto-commit changed files from 'node scripts/eslint_all_files --no-cache --fix'
1 parent 99a7d08 commit fb279e8

4 files changed

Lines changed: 54 additions & 43 deletions

File tree

x-pack/solutions/observability/plugins/infra/public/components/schema_selector.tsx

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
import { i18n } from '@kbn/i18n';
2121
import type { HostsState } from '../pages/metrics/hosts/hooks/use_unified_search_url_state';
2222
import { METRIC_SCHEMA_ECS, METRIC_SCHEMA_SEMCONV } from '../../common/constants';
23-
import { SchemaTypes } from '../../common/http_api/shared/schema_type';
23+
import type { SchemaTypes } from '../../common/http_api/shared/schema_type';
2424

2525
const SCHEMA_NOT_AVAILABLE = i18n.translate('xpack.infra.schemaSelector.notAvailable', {
2626
defaultMessage: 'Selected schema is not available for this query.',
@@ -36,9 +36,13 @@ const PrependLabel = ({ count }: { count: number }) => (
3636
</EuiText>
3737
</EuiFlexItem>
3838
<EuiFlexItem grow={false}>
39-
<EuiBadge color="primary" data-test-subj="infraSchemaSelectorCount" aria-label={i18n.translate('xpack.infra.schemaSelector.count', {
40-
defaultMessage: 'Schemas available',
41-
})}>
39+
<EuiBadge
40+
color="primary"
41+
data-test-subj="infraSchemaSelectorCount"
42+
aria-label={i18n.translate('xpack.infra.schemaSelector.count', {
43+
defaultMessage: 'Schemas available',
44+
})}
45+
>
4246
{count}
4347
</EuiBadge>
4448
</EuiFlexItem>
@@ -57,9 +61,7 @@ const InvalidDropdownDisplay = ({ value }: { value: string }) => {
5761
return (
5862
<>
5963
<EuiText size="s">{value}</EuiText>
60-
<EuiText size="xs">
61-
{SCHEMA_NOT_AVAILABLE}
62-
</EuiText>
64+
<EuiText size="xs">{SCHEMA_NOT_AVAILABLE}</EuiText>
6365
</>
6466
);
6567
};
@@ -71,10 +73,7 @@ const InvalidDisplay = ({ value }: { value: string }) => {
7173
<EuiText size="s">{value}</EuiText>
7274
</EuiFlexItem>
7375
<EuiFlexItem grow={false}>
74-
<EuiToolTip
75-
position="top"
76-
content={SCHEMA_NOT_AVAILABLE}
77-
>
76+
<EuiToolTip position="top" content={SCHEMA_NOT_AVAILABLE}>
7877
<EuiToken
7978
iconType="alert"
8079
tabIndex={0}
@@ -98,23 +97,22 @@ const InvalidDisplay = ({ value }: { value: string }) => {
9897
};
9998
const schemaTranslationMap = {
10099
[METRIC_SCHEMA_ECS]: i18n.translate('xpack.infra.schemaSelector.ecsDisplay', {
101-
defaultMessage: 'Elastic System Integration',
102-
}),
100+
defaultMessage: 'Elastic System Integration',
101+
}),
103102
[METRIC_SCHEMA_SEMCONV]: i18n.translate('xpack.infra.schemaSelector.semconvDisplay', {
104-
defaultMessage: 'OpenTelemetry',
105-
}),
106-
};
107-
103+
defaultMessage: 'OpenTelemetry',
104+
}),
105+
};
108106

109-
const getInputDisplay = (schema: SchemaTypes) => {
110-
const translation = schemaTranslationMap[schema];
111-
if (translation) {
112-
return translation;
113-
}
114-
return i18n.translate('xpack.infra.schemaSelector.unknownDisplay', {
115-
defaultMessage: 'Unknown schema',
116-
});
117-
};
107+
const getInputDisplay = (schema: SchemaTypes) => {
108+
const translation = schemaTranslationMap[schema];
109+
if (translation) {
110+
return translation;
111+
}
112+
return i18n.translate('xpack.infra.schemaSelector.unknownDisplay', {
113+
defaultMessage: 'Unknown schema',
114+
});
115+
};
118116

119117
export const SchemaSelector = ({
120118
onChange,
@@ -139,17 +137,18 @@ export const SchemaSelector = ({
139137
const isInvalid = !!value && !options.some((opt) => opt.value === value);
140138

141139
// If only one schema is available and it's not the preferred, show both in the dropdown
142-
const displayOptions = options.length === 1 && isInvalid
143-
? [
144-
{
145-
inputDisplay: <InvalidDisplay value={getInputDisplay(value)} />,
146-
value,
147-
disabled: true,
148-
dropdownDisplay: <InvalidDropdownDisplay value={getInputDisplay(value)} />,
149-
},
150-
...options,
151-
]
152-
: options;
140+
const displayOptions =
141+
options.length === 1 && isInvalid
142+
? [
143+
{
144+
inputDisplay: <InvalidDisplay value={getInputDisplay(value)} />,
145+
value,
146+
disabled: true,
147+
dropdownDisplay: <InvalidDropdownDisplay value={getInputDisplay(value)} />,
148+
},
149+
...options,
150+
]
151+
: options;
153152

154153
const onSelect = (selectedValue: string) => {
155154
if (selectedValue) {

x-pack/solutions/observability/plugins/infra/public/pages/metrics/hosts/components/search_bar/unified_search_bar.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import { SchemaSelector } from '../../../../../components/schema_selector';
2222
import { useTimeRangeMetadataContext } from '../../../../../hooks/use_time_range_metadata';
2323
import { isPending } from '../../../../../hooks/use_fetcher';
2424
import { METRIC_SCHEMA_SEMCONV } from '../../../../../../common/constants';
25-
import { SchemaTypes } from '../../../../../../common/http_api/shared/schema_type';
26-
25+
import type { SchemaTypes } from '../../../../../../common/http_api/shared/schema_type';
2726

2827
export const UnifiedSearchBar = () => {
2928
const {
@@ -39,7 +38,10 @@ export const UnifiedSearchBar = () => {
3938

4039
const { data: timeRangeMetadata, status } = useTimeRangeMetadataContext();
4140

42-
const schemas: SchemaTypes[] = useMemo(() => timeRangeMetadata?.schemas || [], [timeRangeMetadata]);
41+
const schemas: SchemaTypes[] = useMemo(
42+
() => timeRangeMetadata?.schemas || [],
43+
[timeRangeMetadata]
44+
);
4345

4446
// Set preferredSchema in URL if not set and hostOtelEnabled
4547
useEffect(() => {
@@ -50,7 +52,13 @@ export const UnifiedSearchBar = () => {
5052
const next = schemas.includes(METRIC_SCHEMA_SEMCONV) ? METRIC_SCHEMA_SEMCONV : schemas[0];
5153
onPreferredSchemaChange(next);
5254
}
53-
}, [timeRangeMetadata, searchCriteria.preferredSchema, onPreferredSchemaChange, schemas, featureFlags.hostOtelEnabled]);
55+
}, [
56+
timeRangeMetadata,
57+
searchCriteria.preferredSchema,
58+
onPreferredSchemaChange,
59+
schemas,
60+
featureFlags.hostOtelEnabled,
61+
]);
5462

5563
const handleRefresh = useCallback(
5664
(payload: { dateRange: TimeRange }, isUpdate?: boolean) => {

x-pack/solutions/observability/plugins/infra/public/pages/metrics/hosts/hooks/use_unified_search_url_state.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ const HostsStateRT = rt.type({
147147
query: HostsQueryStateRT,
148148
dateRange: StringDateRangeRT,
149149
limit: rt.number,
150-
preferredSchema: rt.union([rt.literal(METRIC_SCHEMA_ECS), rt.literal(METRIC_SCHEMA_SEMCONV), rt.null]),
150+
preferredSchema: rt.union([
151+
rt.literal(METRIC_SCHEMA_ECS),
152+
rt.literal(METRIC_SCHEMA_SEMCONV),
153+
rt.null,
154+
]),
151155
});
152156

153157
export type HostsState = rt.TypeOf<typeof HostsStateRT>;

x-pack/solutions/observability/plugins/infra/public/services/telemetry/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import type { AnalyticsServiceSetup, RootSchema } from '@kbn/core/public';
9-
import { SchemaTypes } from '../../../common/http_api/shared/schema_type';
9+
import type { SchemaTypes } from '../../../common/http_api/shared/schema_type';
1010

1111
export interface TelemetryServiceSetupParams {
1212
analytics: AnalyticsServiceSetup;

0 commit comments

Comments
 (0)