@@ -20,7 +20,7 @@ import {
2020import { i18n } from '@kbn/i18n' ;
2121import type { HostsState } from '../pages/metrics/hosts/hooks/use_unified_search_url_state' ;
2222import { 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
2525const 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} ;
9998const 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
119117export 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 ) {
0 commit comments