@@ -19,17 +19,11 @@ import {
19
19
sendEventTelemetry ,
20
20
TelemetryEvent ,
21
21
} from 'uiSrc/telemetry'
22
- import {
23
- formatLongName ,
24
- isEqualBuffers ,
25
- replaceSpaces ,
26
- stringToBuffer ,
27
- } from 'uiSrc/utils'
22
+ import { formatLongName , isEqualBuffers , stringToBuffer } from 'uiSrc/utils'
28
23
29
24
import { FlexItem , Row } from 'uiSrc/components/base/layout/flex'
30
25
import { IconButton } from 'uiSrc/components/base/forms/buttons'
31
26
import { CopyIcon } from 'uiSrc/components/base/icons'
32
- import { Text } from 'uiSrc/components/base/text'
33
27
import { RiIcon } from 'uiSrc/components/base/icons/RiIcon'
34
28
import { RiTooltip } from 'uiSrc/components'
35
29
import { TextInput } from 'uiSrc/components/base/inputs'
@@ -40,6 +34,11 @@ const StyledInputWrapper = styled(Row)`
40
34
min-width: 150px;
41
35
`
42
36
37
+ const StyledFlexWrapper = styled ( FlexItem ) `
38
+ max-width: 450px;
39
+ gap: ${ ( { theme } ) => theme . core . space . space050 } ;
40
+ `
41
+
43
42
export interface Props {
44
43
onEditKey : (
45
44
key : RedisResponseBuffer ,
@@ -146,84 +145,69 @@ const KeyDetailsHeaderName = ({ onEditKey }: Props) => {
146
145
}
147
146
148
147
return (
149
- < FlexItem
150
- grow = { 5 }
148
+ < StyledFlexWrapper
149
+ grow = { 10 }
151
150
direction = "row"
152
151
onMouseEnter = { onMouseEnterKey }
153
152
onMouseLeave = { onMouseLeaveKey }
154
153
onClick = { onClickKey }
155
- $gap = "xs"
156
154
data-testid = "edit-key-btn"
157
155
>
158
- { keyIsEditing || keyIsHovering ? (
159
- < RiTooltip
160
- title = "Key Name"
161
- position = "left"
162
- content = { tooltipContent }
163
- anchorClassName = { styles . toolTipAnchorKey }
164
- >
165
- < InlineItemEditor
166
- onApply = { ( ) => applyEditKey ( ) }
167
- isDisabled = { ! keyIsEditable }
168
- disabledTooltipText = { TEXT_UNPRINTABLE_CHARACTERS }
169
- onDecline = { ( event ) => cancelEditKey ( event ) }
170
- viewChildrenMode = { ! keyIsEditing }
171
- isLoading = { loading }
172
- declineOnUnmount = { false }
173
- >
174
- < StyledInputWrapper align = "center" >
175
- < TextInput
176
- name = "key"
177
- id = "key"
178
- ref = { keyNameRef }
179
- className = { cx ( styles . keyInput , {
180
- [ styles . keyInputEditing ] : keyIsEditing ,
181
- 'input-warning' : ! keyIsEditable ,
182
- } ) }
183
- placeholder = { AddCommonFieldsFormConfig ?. keyName ?. placeholder }
184
- value = { key ! }
185
- loading = { loading }
186
- onChange = { onChangeKey }
187
- readOnly = { ! keyIsEditing }
188
- autoComplete = "off"
189
- data-testid = "edit-key-input"
190
- // todo: do not hardcode. align with other components in a single place
191
- style = { { paddingLeft : 9 , lineHeight : '31px' } }
192
- />
193
- { ! keyIsEditing && < RiIcon size = "M" type = "EditIcon" /> }
194
- </ StyledInputWrapper >
195
- </ InlineItemEditor >
196
- </ RiTooltip >
197
- ) : (
198
- < Text
199
- className = { cx ( styles . key , {
200
- [ styles . hidden ] : keyIsEditing || keyIsHovering ,
201
- } ) }
202
- data-testid = "key-name-text"
203
- >
204
- < b className = "truncateText" >
205
- { replaceSpaces ( keyProp ?. substring ( 0 , 200 ) ) }
206
- </ b >
207
- </ Text >
208
- ) }
209
- { keyIsHovering && (
210
- < RiTooltip
211
- position = "right"
212
- content = "Copy"
213
- anchorClassName = { styles . copyKey }
156
+ < RiTooltip
157
+ title = "Key Name"
158
+ position = "left"
159
+ content = { tooltipContent }
160
+ anchorClassName = { styles . toolTipAnchorKey }
161
+ >
162
+ < InlineItemEditor
163
+ onApply = { ( ) => applyEditKey ( ) }
164
+ isDisabled = { ! keyIsEditable }
165
+ disabledTooltipText = { TEXT_UNPRINTABLE_CHARACTERS }
166
+ onDecline = { ( event ) => cancelEditKey ( event ) }
167
+ viewChildrenMode = { ! keyIsEditing }
168
+ isLoading = { loading }
169
+ declineOnUnmount = { false }
214
170
>
215
- < IconButton
216
- icon = { CopyIcon }
217
- id = { COPY_KEY_NAME_ICON }
218
- aria-label = "Copy key name"
219
- onClick = { ( event : any ) =>
220
- handleCopy ( event , key ! , keyIsEditing , keyNameRef )
221
- }
222
- data-testid = "copy-key-name-btn"
223
- />
224
- </ RiTooltip >
225
- ) }
226
- </ FlexItem >
171
+ < StyledInputWrapper align = "center" >
172
+ < TextInput
173
+ name = "key"
174
+ id = "key"
175
+ ref = { keyNameRef }
176
+ className = { cx ( styles . keyInput , {
177
+ [ styles . keyInputEditing ] : keyIsEditing ,
178
+ 'input-warning' : ! keyIsEditable ,
179
+ } ) }
180
+ placeholder = { AddCommonFieldsFormConfig ?. keyName ?. placeholder }
181
+ value = { key ! }
182
+ loading = { loading }
183
+ onChange = { onChangeKey }
184
+ readOnly = { ! keyIsEditing }
185
+ autoComplete = "off"
186
+ data-testid = "edit-key-input"
187
+ // todo: do not hardcode. align with other components in a single place
188
+ style = { { paddingLeft : 9 , lineHeight : '31px' } }
189
+ />
190
+ { ! keyIsEditing && < RiIcon size = "M" type = "EditIcon" /> }
191
+ </ StyledInputWrapper >
192
+ </ InlineItemEditor >
193
+ </ RiTooltip >
194
+ < RiTooltip
195
+ position = "right"
196
+ content = "Copy"
197
+ anchorClassName = { styles . copyKey }
198
+ >
199
+ < IconButton
200
+ icon = { CopyIcon }
201
+ id = { COPY_KEY_NAME_ICON }
202
+ aria-label = "Copy key name"
203
+ onClick = { ( event : any ) =>
204
+ handleCopy ( event , key ! , keyIsEditing , keyNameRef )
205
+ }
206
+ data-testid = "copy-key-name-btn"
207
+ className = { ! keyIsHovering ? styles . hidden : '' }
208
+ />
209
+ </ RiTooltip >
210
+ </ StyledFlexWrapper >
227
211
)
228
212
}
229
213
0 commit comments