@@ -4,12 +4,14 @@ import { EuiIcon, EuiSuperSelect, EuiSuperSelectOption, EuiText, EuiTextColor, E
4
4
import { useDispatch , useSelector } from 'react-redux'
5
5
import { useParams } from 'react-router-dom'
6
6
7
- import { KeyValueFormat , Theme } from 'uiSrc/constants'
7
+ import { KeyTypes , KeyValueFormat , TEXT_DISABLED_STRING_FORMATTING , Theme } from 'uiSrc/constants'
8
8
import { ThemeContext } from 'uiSrc/contexts/themeContext'
9
9
import { keysSelector , selectedKeyDataSelector , selectedKeySelector , setViewFormat } from 'uiSrc/slices/browser/keys'
10
10
import { getBasedOnViewTypeEvent , sendEventTelemetry , TelemetryEvent } from 'uiSrc/telemetry'
11
11
import FormattersLight from 'uiSrc/assets/img/icons/formatter_light.svg'
12
12
import FormattersDark from 'uiSrc/assets/img/icons/formatter_dark.svg'
13
+ import { stringDataSelector } from 'uiSrc/slices/browser/string'
14
+ import { isFullStringLoaded } from 'uiSrc/utils'
13
15
import { getKeyValueFormatterOptions } from './constants'
14
16
import { MIDDLE_SCREEN_RESOLUTION } from '../../KeyDetailsHeader'
15
17
import styles from './styles.module.scss'
@@ -24,21 +26,26 @@ const KeyValueFormatter = (props: Props) => {
24
26
const { theme } = useContext ( ThemeContext )
25
27
const { viewType } = useSelector ( keysSelector )
26
28
const { viewFormat } = useSelector ( selectedKeySelector )
27
- const { type : keyType } = useSelector ( selectedKeyDataSelector ) ?? { }
29
+ const { type : keyType , length } = useSelector ( selectedKeyDataSelector ) ?? { }
30
+ const { value : keyValue } = useSelector ( stringDataSelector )
28
31
29
32
const [ isSelectOpen , setIsSelectOpen ] = useState < boolean > ( false )
30
33
const [ typeSelected , setTypeSelected ] = useState < KeyValueFormat > ( viewFormat )
31
34
const [ options , setOptions ] = useState < EuiSuperSelectOption < KeyValueFormat > [ ] > ( [ ] )
32
35
33
36
const dispatch = useDispatch ( )
34
37
38
+ const isStringFormattingEnabled = keyType === KeyTypes . String
39
+ ? isFullStringLoaded ( keyValue ?. data ?. length , length )
40
+ : true
41
+
35
42
useEffect ( ( ) => {
36
43
const newOptions : EuiSuperSelectOption < KeyValueFormat > [ ] = getKeyValueFormatterOptions ( keyType ) . map (
37
44
( { value, text } ) => ( {
38
45
value,
39
46
inputDisplay : (
40
47
< EuiToolTip
41
- content = { typeSelected }
48
+ content = { ! isStringFormattingEnabled ? TEXT_DISABLED_STRING_FORMATTING : typeSelected }
42
49
position = "top"
43
50
display = "inlineBlock"
44
51
anchorClassName = "flex-row"
@@ -63,7 +70,7 @@ const KeyValueFormatter = (props: Props) => {
63
70
)
64
71
65
72
setOptions ( newOptions )
66
- } , [ viewFormat , keyType , width ] )
73
+ } , [ viewFormat , keyType , width , isStringFormattingEnabled ] )
67
74
68
75
const onChangeType = ( value : KeyValueFormat ) => {
69
76
sendEventTelemetry ( {
@@ -92,6 +99,7 @@ const KeyValueFormatter = (props: Props) => {
92
99
< div className = { cx ( styles . container , { [ styles . fullWidth ] : width > MIDDLE_SCREEN_RESOLUTION } ) } >
93
100
< div className = { styles . selectWrapper } >
94
101
< EuiSuperSelect
102
+ disabled = { ! isStringFormattingEnabled }
95
103
fullWidth
96
104
isOpen = { isSelectOpen }
97
105
options = { options }
0 commit comments