Skip to content

Commit bb55035

Browse files
Merge pull request #3912 from RedisInsight/fe/feature/RI-6161-add-examples-to-pub-sub
RI-6161 replace tooltip with popover in pubsub textarea append icon
2 parents e7e9d47 + 353cb85 commit bb55035

File tree

9 files changed

+94
-49
lines changed

9 files changed

+94
-49
lines changed

redisinsight/ui/src/constants/links.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const EXTERNAL_LINKS = {
1515
rdiQuickStart: 'https://redis.io/docs/latest/integrate/redis-data-integration/ingest/quick-start-guide/',
1616
rdiPipeline: 'https://redis.io/docs/latest/integrate/redis-data-integration/ingest/data-pipelines/data-pipelines/',
1717
rdiPipelineTransforms: 'https://redis.io/docs/latest/integrate/redis-data-integration/ingest/data-pipelines/transform-examples/',
18+
pubSub: 'https://redis.io/docs/latest/commands/psubscribe/',
1819
}
1920

2021
export const UTM_CAMPAINGS: Record<any, string> = {
@@ -23,6 +24,7 @@ export const UTM_CAMPAINGS: Record<any, string> = {
2324
[OAuthSocialSource.Workbench]: 'redisinsight_workbench',
2425
[CloudSsoUtmCampaign.BrowserFilter]: 'browser_filter',
2526
[OAuthSocialSource.EmptyDatabasesList]: 'empty_db_list',
27+
PubSub: 'pub_sub',
2628
Main: 'main',
2729
}
2830

redisinsight/ui/src/pages/pub-sub/components/subscription-panel/SubscriptionPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import NotSubscribedIconLight from 'uiSrc/assets/img/pub-sub/not-subscribed-lt.s
1616

1717
import { DEFAULT_SEARCH_MATCH } from 'uiSrc/constants/api'
1818
import PatternsInfo from './components/patternsInfo'
19-
import AppendInfo from './components/append-info'
19+
import ClickableAppendInfo from './components/clickable-append-info'
2020
import styles from './styles.module.scss'
2121

2222
const SubscriptionPanel = () => {
@@ -95,7 +95,7 @@ const SubscriptionPanel = () => {
9595
placeholder="Enter Pattern"
9696
aria-label="channel names for filtering"
9797
data-testid="channels-input"
98-
append={<AppendInfo title={null} content="Subscribe to one or more channels or patterns by entering them, separated by spaces." />}
98+
append={<ClickableAppendInfo />}
9999
/>
100100
</EuiFlexItem>
101101
<EuiFlexItem grow={false}>

redisinsight/ui/src/pages/pub-sub/components/subscription-panel/components/append-info/AppendInfo.spec.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

redisinsight/ui/src/pages/pub-sub/components/subscription-panel/components/append-info/AppendInfo.tsx

Lines changed: 0 additions & 23 deletions
This file was deleted.

redisinsight/ui/src/pages/pub-sub/components/subscription-panel/components/append-info/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react'
2+
import { fireEvent, render, screen } from 'uiSrc/utils/test-utils'
3+
import ClickableAppendInfo from './ClickableAppendInfo'
4+
5+
describe('ClickableAppendInfo', () => {
6+
it('should render', () => {
7+
expect(
8+
render(
9+
<ClickableAppendInfo />
10+
)
11+
).toBeTruthy()
12+
})
13+
14+
it('should open popover on click', async () => {
15+
render(<ClickableAppendInfo />)
16+
fireEvent.click(screen.getByTestId('append-info-icon'))
17+
expect(screen.getByTestId('pub-sub-examples')).toBeInTheDocument()
18+
})
19+
})
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React, { useState } from 'react'
2+
import { EuiIcon, EuiLink, EuiPopover, EuiText } from '@elastic/eui'
3+
import { getUtmExternalLink } from 'uiSrc/utils/links'
4+
import { EXTERNAL_LINKS, UTM_CAMPAINGS, UTM_MEDIUMS } from 'uiSrc/constants/links'
5+
import styles from './styles.module.scss'
6+
7+
const ClickableAppendInfo = () => {
8+
const [open, setOpen] = useState<boolean>(false)
9+
10+
const onClick = () => {
11+
const newVal = !open
12+
setOpen(newVal)
13+
}
14+
15+
return (
16+
<EuiPopover
17+
id="showPupSubExamples"
18+
ownFocus={false}
19+
button={(
20+
<EuiIcon
21+
size="l"
22+
type="iInCircle"
23+
style={{ cursor: 'pointer' }}
24+
onClick={onClick}
25+
data-testid="append-info-icon"
26+
/>
27+
)}
28+
isOpen={open}
29+
panelClassName={styles.popover}
30+
anchorClassName={styles.infoIcon}
31+
panelPaddingSize="s"
32+
data-testid="pub-sub-examples"
33+
>
34+
<EuiText
35+
color="subdued"
36+
size="s"
37+
>
38+
Supported glob-style patterns are described&nbsp;
39+
<EuiLink
40+
external={false}
41+
target="_blank"
42+
href={getUtmExternalLink(EXTERNAL_LINKS.pubSub, {
43+
medium: UTM_MEDIUMS.Main,
44+
campaign: UTM_CAMPAINGS.PubSub,
45+
})}
46+
>here.
47+
</EuiLink>
48+
</EuiText>
49+
</EuiPopover>
50+
)
51+
}
52+
53+
export default ClickableAppendInfo
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import ClickableAppendInfo from './ClickableAppendInfo'
2+
3+
export default ClickableAppendInfo
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.infoIcon {
2+
display: flex !important;
3+
align-items: center;
4+
justify-content: center;
5+
width: 34px;
6+
color: var(--iconsDefaultColor) !important;
7+
background-color: var(--browserTableRowEven) !important;
8+
}
9+
10+
.popover {
11+
max-width: 200px !important;
12+
background-color: var(--euiTooltipBackgroundColor) !important;
13+
color: var(--euiTooltipTitleTextColor) !important;
14+
border-radius: 4px;
15+
}

0 commit comments

Comments
 (0)