Skip to content

Commit b984ce1

Browse files
Merge pull request #1562 from RedisInsight/feature/RI-3941_redisstack_icon
Feature/ri 3941 redisstack icon
2 parents 29d15cd + 9e0f074 commit b984ce1

File tree

4 files changed

+76
-15
lines changed

4 files changed

+76
-15
lines changed

redisinsight/ui/src/constants/dbAnalysisRecommendations.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
"bigSets": {
283283
"id": "bigSets",
284284
"title": "Switch to Bloom filter, cuckoo filter, or HyperLogLog",
285+
"redisStack": true,
285286
"content": [
286287
{
287288
"id": "1",
@@ -409,6 +410,29 @@
409410
"href": "https://docs.redis.com/latest/ri/memory-optimizations/",
410411
"name": "Read more"
411412
}
413+
},
414+
{
415+
"id": "11",
416+
"type": "spacer",
417+
"value": "l"
418+
},
419+
{
420+
"id": "12",
421+
"type": "span",
422+
"value": "Create a "
423+
},
424+
{
425+
"id": "13",
426+
"type": "link",
427+
"value": {
428+
"href": "https://redis.com/try-free/?utm_source=redis&utm_medium=app&utm_campaign=redisinsight/",
429+
"name": "free Redis Stack database"
430+
}
431+
},
432+
{
433+
"id": "14",
434+
"type": "span",
435+
"value": " to use modern data models and processing engines."
412436
}
413437
],
414438
"badges": ["configuration_changes"]
@@ -492,7 +516,7 @@
492516
"id": "4",
493517
"type": "link",
494518
"value": {
495-
"href": "https://redis.com/try-free/?utm_source=redis&utm_medium=app&utm_campaign=redisinsight_recommendations/",
519+
"href": "https://redis.com/try-free/?utm_source=redis&utm_medium=app&utm_campaign=redisinsight/",
496520
"name": "free Redis Stack database"
497521
}
498522
},

redisinsight/ui/src/pages/databaseAnalysis/components/recommendations-view/Recommendations.spec.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,18 @@ describe('Recommendations', () => {
330330

331331
expect(screen.queryByTestId('badges-legend')).toBeInTheDocument()
332332
})
333+
334+
it('should render redisstack link', () => {
335+
(dbAnalysisSelector as jest.Mock).mockImplementation(() => ({
336+
...mockdbAnalysisSelector,
337+
data: {
338+
recommendations: [{ name: 'bigSets' }]
339+
}
340+
}))
341+
342+
render(<Recommendations />)
343+
344+
expect(screen.queryByTestId('bigSets-redis-stack-link')).toBeInTheDocument()
345+
expect(screen.queryByTestId('bigSets-redis-stack-link')).toHaveAttribute('href', 'https://redis.io/docs/stack/')
346+
})
333347
})

redisinsight/ui/src/pages/databaseAnalysis/components/recommendations-view/Recommendations.tsx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import {
66
EuiAccordion,
77
EuiPanel,
88
EuiText,
9+
EuiToolTip,
910
EuiFlexGroup,
1011
EuiFlexItem,
1112
EuiIcon,
13+
EuiLink,
1214
} from '@elastic/eui'
1315
import { ThemeContext } from 'uiSrc/contexts/themeContext'
1416
import { dbAnalysisSelector } from 'uiSrc/slices/analytics/dbAnalysis'
@@ -38,19 +40,36 @@ const Recommendations = () => {
3840
}
3941
})
4042

43+
const onRedisStackClick = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => event.stopPropagation()
44+
4145
const sortedRecommendations = sortBy(recommendations, ({ name }) =>
4246
(recommendationsContent[name]?.redisStack ? -1 : 0))
4347

44-
const renderButtonContent = (redisStack: boolean, title: string, badges: string[]) => (
48+
const renderButtonContent = (redisStack: boolean, title: string, badges: string[], id: string) => (
4549
<EuiFlexGroup className={styles.accordionButton} responsive={false} alignItems="center" justifyContent="spaceBetween">
4650
<EuiFlexGroup alignItems="center">
47-
<EuiFlexItem grow={false}>
51+
<EuiFlexItem onClick={onRedisStackClick} grow={false}>
4852
{redisStack && (
49-
<EuiIcon
50-
type={theme === Theme.Dark ? RediStackDarkMin : RediStackLightMin}
51-
className={styles.redisStack}
52-
data-testid="redis-stack-icon"
53-
/>
53+
<EuiLink
54+
external={false}
55+
target="_blank"
56+
href="https://redis.io/docs/stack/"
57+
className={styles.redisStackLink}
58+
data-testid={`${id}-redis-stack-link`}
59+
>
60+
<EuiToolTip
61+
content="Redis Stack"
62+
position="top"
63+
display="inlineBlock"
64+
anchorClassName="flex-row"
65+
>
66+
<EuiIcon
67+
type={theme === Theme.Dark ? RediStackDarkMin : RediStackLightMin}
68+
className={styles.redisStackIcon}
69+
data-testid={`${id}-redis-stack-icon`}
70+
/>
71+
</EuiToolTip>
72+
</EuiLink>
5473
)}
5574
</EuiFlexItem>
5675
<EuiFlexItem grow={false}>
@@ -97,7 +116,7 @@ const Recommendations = () => {
97116
<EuiAccordion
98117
id={name}
99118
arrowDisplay="right"
100-
buttonContent={renderButtonContent(redisStack, title, badges)}
119+
buttonContent={renderButtonContent(redisStack, title, badges, id)}
101120
buttonClassName={styles.accordionBtn}
102121
buttonProps={{ 'data-test-subj': `${id}-button` }}
103122
className={styles.accordion}

redisinsight/ui/src/pages/databaseAnalysis/components/recommendations-view/styles.module.scss

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@
4141

4242
.accordionButton :global(.euiFlexItem) {
4343
margin: 0;
44+
45+
.redisStackLink {
46+
margin-right: 16px;
47+
animation: none !important;
48+
}
49+
50+
.redisStackIcon {
51+
width: 20px;
52+
height: 20px;
53+
}
4454
}
4555

4656
:global(.euiAccordion__buttonReverse .euiAccordion__iconWrapper) {
@@ -116,10 +126,4 @@
116126
.span {
117127
display: inline;
118128
}
119-
120-
.redisStack {
121-
width: 20px;
122-
height: 20px;
123-
margin-right: 16px;
124-
}
125129
}

0 commit comments

Comments
 (0)