Skip to content

Commit bd05295

Browse files
authored
[RI-7074] Replace EuiToolTip with RiTooltip (#4659)
* RI-7074: init RiTooltip * RI-7074: replace EuiTooltip with RITooltip * update unit tests * remove euiTooltip styles * fix failing tests * cleanup TODOs * resolve comments * remove EuiTooltip * expose TOOLTIP_DELAY_LONG constant
1 parent 7f0bbd4 commit bd05295

File tree

191 files changed

+908
-1260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+908
-1260
lines changed

redisinsight/ui/src/components/auto-refresh/AutoRefresh.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,15 @@ describe('AutoRefresh', () => {
316316
render(
317317
<AutoRefresh
318318
{...instance(mockedProps)}
319-
disabled={true}
319+
disabled
320320
disabledRefreshButtonMessage={tooltipText}
321321
/>,
322322
)
323323

324-
fireEvent.mouseOver(screen.getByTestId('refresh-btn'))
324+
fireEvent.focus(screen.getByTestId('refresh-btn'))
325325
await screen.findByTestId('refresh-tooltip')
326326
expect(screen.getByTestId('refresh-tooltip')).toHaveTextContent(
327-
new RegExp(`^${tooltipText}$`),
327+
new RegExp(`^${tooltipText}`),
328328
)
329329
})
330330
})

redisinsight/ui/src/components/auto-refresh/AutoRefresh.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState } from 'react'
2-
import { EuiIcon, EuiPopover, EuiToolTip } from '@elastic/eui'
2+
import { EuiIcon, EuiPopover } from '@elastic/eui'
33
import cx from 'classnames'
44
import { ChevronDownIcon, RefreshIcon } from 'uiSrc/components/base/icons'
55
import {
@@ -14,6 +14,7 @@ import { BrowserStorageItem } from 'uiSrc/constants'
1414
import { IconButton } from 'uiSrc/components/base/forms/buttons'
1515
import { ColorText } from 'uiSrc/components/base/text'
1616
import { SwitchInput } from 'uiSrc/components/base/inputs'
17+
import { RiTooltip } from 'uiSrc/components'
1718
import {
1819
DEFAULT_REFRESH_RATE,
1920
DURATION_FIRST_REFRESH_TIME,
@@ -223,7 +224,7 @@ const AutoRefresh = ({
223224
)}
224225
</ColorText>
225226

226-
<EuiToolTip
227+
<RiTooltip
227228
title={!disabled && 'Last Refresh'}
228229
className={styles.tooltip}
229230
position="top"
@@ -242,7 +243,7 @@ const AutoRefresh = ({
242243
aria-labelledby={getDataTestid('refresh-btn')?.replaceAll?.('-', ' ')}
243244
data-testid={getDataTestid('refresh-btn')}
244245
/>
245-
</EuiToolTip>
246+
</RiTooltip>
246247

247248
<EuiPopover
248249
ownFocus={false}

redisinsight/ui/src/components/base/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ import ExternalLink from './external-link'
22
import { HorizontalRule, LoadingContent } from './layout'
33

44
export { ExternalLink, HorizontalRule, LoadingContent }
5+
6+
export * from './tooltip'
Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { EuiToolTip } from '@elastic/eui'
21
import React from 'react'
32
import { FlexItem, Row } from 'uiSrc/components/base/layout/flex'
43
import { IconButton } from 'uiSrc/components/base/forms/buttons'
54
import { CancelSlimIcon, MinusIcon } from 'uiSrc/components/base/icons'
5+
import { RiTooltip } from 'uiSrc/components'
66

77
type Props = {
88
onClose: () => void
@@ -22,12 +22,7 @@ export const WindowControlGroup = ({
2222
}: Props) => (
2323
<Row gap="m" justify="end">
2424
<FlexItem>
25-
<EuiToolTip
26-
content={hideContent}
27-
position="top"
28-
display="inlineBlock"
29-
anchorClassName="flex-row"
30-
>
25+
<RiTooltip content={hideContent} position="top">
3126
<IconButton
3227
size="S"
3328
icon={MinusIcon}
@@ -36,15 +31,10 @@ export const WindowControlGroup = ({
3631
data-testid={`hide-${id}`}
3732
onClick={onHide}
3833
/>
39-
</EuiToolTip>
34+
</RiTooltip>
4035
</FlexItem>
4136
<FlexItem>
42-
<EuiToolTip
43-
content={closeContent}
44-
position="top"
45-
display="inlineBlock"
46-
anchorClassName="flex-row"
47-
>
37+
<RiTooltip content={closeContent} position="top">
4838
<IconButton
4939
size="S"
5040
icon={CancelSlimIcon}
@@ -53,7 +43,7 @@ export const WindowControlGroup = ({
5343
data-testid={`close-${id}`}
5444
onClick={onClose}
5545
/>
56-
</EuiToolTip>
46+
</RiTooltip>
5747
</FlexItem>
5848
</Row>
5949
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { Text } from './Text'
22
export { ColorText } from './ColorText'
33
export { HealthText } from './HealthText'
4+
export { Title } from './Title'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react'
2+
3+
import { Col } from 'uiSrc/components/base/layout/flex'
4+
import { Title } from 'uiSrc/components/base/text'
5+
6+
interface RiTooltipContentProps {
7+
title?: React.ReactNode
8+
content: React.ReactNode
9+
}
10+
11+
export const HoverContent = ({ title, content }: RiTooltipContentProps) => (
12+
<Col>
13+
{title && <Title size="S">{title}</Title>}
14+
{content}
15+
</Col>
16+
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react'
2+
3+
import { TooltipProvider, Tooltip, TooltipProps } from '@redis-ui/components'
4+
import { HoverContent } from './HoverContent'
5+
6+
export interface RiTooltipProps
7+
extends Omit<TooltipProps, 'placement' | 'openDelayDuration'> {
8+
title?: React.ReactNode
9+
position?: TooltipProps['placement']
10+
delay?: TooltipProps['openDelayDuration']
11+
}
12+
13+
export const RiTooltip = ({
14+
children,
15+
title,
16+
content,
17+
position,
18+
delay,
19+
...props
20+
}: RiTooltipProps) => (
21+
<TooltipProvider>
22+
<Tooltip
23+
{...props}
24+
content={<HoverContent title={title} content={content} />}
25+
placement={position}
26+
openDelayDuration={delay}
27+
>
28+
<span>{children}</span>
29+
</Tooltip>
30+
</TooltipProvider>
31+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './RITooltip'

redisinsight/ui/src/components/consents-settings/ConsentsSettings.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import React, { useEffect, useState } from 'react'
22
import { useDispatch, useSelector } from 'react-redux'
33
import { FormikErrors, useFormik } from 'formik'
44
import { isEmpty, forEach } from 'lodash'
5-
import { EuiToolTip, EuiForm } from '@elastic/eui'
5+
import { EuiForm } from '@elastic/eui'
66
import cx from 'classnames'
77

8-
import { HorizontalRule } from 'uiSrc/components'
8+
import { HorizontalRule, RiTooltip } from 'uiSrc/components'
99
import { compareConsents } from 'uiSrc/utils'
1010
import {
1111
updateUserConfigSettingsAction,
@@ -331,12 +331,11 @@ const ConsentsSettings = ({ onSubmitted }: Props) => {
331331
))}
332332
</FlexItem>
333333
<FlexItem>
334-
<EuiToolTip
334+
<RiTooltip
335335
position="top"
336-
anchorClassName="euiToolTip__btn-disabled"
337336
content={
338337
submitIsDisabled() ? (
339-
<span className="euiToolTip__content">
338+
<span>
340339
{Object.values(errors).map((err) => [
341340
spec?.agreements[err as string]?.requiredText,
342341
<br key={err} />,
@@ -355,7 +354,7 @@ const ConsentsSettings = ({ onSubmitted }: Props) => {
355354
>
356355
Submit
357356
</PrimaryButton>
358-
</EuiToolTip>
357+
</RiTooltip>
359358
</FlexItem>
360359
</Row>
361360
</EuiForm>

redisinsight/ui/src/components/database-list-modules/DatabaseListModules.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable sonarjs/no-nested-template-literals */
22
import React, { useContext } from 'react'
3-
import { EuiIcon, EuiToolTip } from '@elastic/eui'
3+
import { EuiIcon } from '@elastic/eui'
44
import cx from 'classnames'
55

66
import { Theme } from 'uiSrc/constants'
@@ -12,6 +12,7 @@ import { DEFAULT_MODULES_INFO } from 'uiSrc/constants/modules'
1212
import { IconButton } from 'uiSrc/components/base/forms/buttons'
1313
import { UnknownDarkIcon, UnknownLightIcon } from 'uiSrc/components/base/icons'
1414
import { ColorText } from 'uiSrc/components/base/text'
15+
import { RiTooltip } from 'uiSrc/components'
1516
import { AdditionalRedisModule } from 'apiSrc/modules/database/models/additional.redis.module'
1617

1718
import styles from './styles.module.scss'
@@ -141,15 +142,9 @@ const DatabaseListModules = React.memo((props: Props) => {
141142
!inCircle ? (
142143
Module(moduleName, abbreviation, icon, content)
143144
) : (
144-
<EuiToolTip
145-
position="bottom"
146-
display="inlineBlock"
147-
content={Content[i]}
148-
anchorClassName={styles.anchorModuleTooltip}
149-
key={moduleName}
150-
>
145+
<RiTooltip position="bottom" content={Content[i]} key={moduleName}>
151146
<>{Module(moduleName, abbreviation, icon, content)}</>
152-
</EuiToolTip>
147+
</RiTooltip>
153148
),
154149
)
155150

@@ -164,15 +159,14 @@ const DatabaseListModules = React.memo((props: Props) => {
164159
{inCircle ? (
165160
Modules()
166161
) : (
167-
<EuiToolTip
162+
<RiTooltip
168163
position="bottom"
169164
title={tooltipTitle ?? undefined}
170-
display="inlineBlock"
171165
content={Content}
172166
data-testid="modules-tooltip"
173167
>
174168
<>{content ?? Modules()}</>
175-
</EuiToolTip>
169+
</RiTooltip>
176170
)}
177171
</div>
178172
)

0 commit comments

Comments
 (0)