Skip to content

Commit 28a7350

Browse files
authored
Merge pull request #3169 from RedisInsight/fe/feature/RI-5538_Move_new_db_header_to_main_branch
#RI-5538 - Move the new db header to the March release
2 parents a95083f + 01efb2e commit 28a7350

File tree

24 files changed

+175
-404
lines changed

24 files changed

+175
-404
lines changed
Lines changed: 8 additions & 0 deletions
Loading

redisinsight/ui/src/components/insights-trigger/InsightsTrigger.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface Props {
2525

2626
const InsightsTrigger = (props: Props) => {
2727
const { source = 'overview' } = props
28-
const { isOpen: isInsigtsOpen, tabSelected } = useSelector(insightsPanelSelector)
28+
const { isOpen: isInsightsOpen, tabSelected } = useSelector(insightsPanelSelector)
2929
const { isHighlighted, } = useSelector(recommendationsSelector)
3030
const { provider } = useSelector(connectedInstanceSelector)
3131

@@ -58,7 +58,7 @@ const InsightsTrigger = (props: Props) => {
5858
dispatch(toggleInsightsPanel())
5959

6060
sendEventTelemetry({
61-
event: isInsigtsOpen ? TelemetryEvent.INSIGHTS_PANEL_CLOSED : TelemetryEvent.INSIGHTS_PANEL_OPENED,
61+
event: isInsightsOpen ? TelemetryEvent.INSIGHTS_PANEL_CLOSED : TelemetryEvent.INSIGHTS_PANEL_OPENED,
6262
eventData: {
6363
provider,
6464
page,
@@ -73,7 +73,7 @@ const InsightsTrigger = (props: Props) => {
7373

7474
return (
7575
<div
76-
className={cx(styles.container, { [styles.isOpen]: isInsigtsOpen })}
76+
className={cx(styles.container, { [styles.isOpen]: isInsightsOpen })}
7777
>
7878
<HighlightedFeature
7979
isHighlight={insightsHighlighting && !isHighlighted}

redisinsight/ui/src/components/insights-trigger/styles.module.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.container {
22
display: flex;
3-
flex: 1;
43
align-items: center;
54
justify-content: flex-end;
65
user-select: none;

redisinsight/ui/src/components/instance-header/InstanceHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const InstanceHeader = ({ onChangeDbIndex }: Props) => {
9696

9797
return (
9898
<div className={cx(styles.container)}>
99-
<EuiFlexGroup gutterSize="none" responsive={false}>
99+
<EuiFlexGroup gutterSize="none" responsive={false} alignItems="center">
100100
<EuiFlexItem style={{ overflow: 'hidden' }}>
101101
<div className={styles.breadcrumbsContainer} data-testid="breadcrumbs-container">
102102
<div>

redisinsight/ui/src/components/page-header/PageHeader.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { resetDataRedisCloud } from 'uiSrc/slices/instances/cloud'
99
import { ThemeContext } from 'uiSrc/contexts/themeContext'
1010
import { resetDataRedisCluster } from 'uiSrc/slices/instances/cluster'
1111
import { resetDataSentinel } from 'uiSrc/slices/instances/sentinel'
12+
import { CapabilityPromotion } from 'uiSrc/pages/home/components/capability-promotion'
1213

1314
import darkLogo from 'uiSrc/assets/img/dark_logo.svg'
1415
import lightLogo from 'uiSrc/assets/img/light_logo.svg'
@@ -51,6 +52,7 @@ const PageHeader = (props: Props) => {
5152
</EuiTitle>
5253
{subtitle ? <span>{subtitle}</span> : ''}
5354
</div>
55+
<CapabilityPromotion wrapperClassName={cx(styles.section, styles.capabilityPromotion)} />
5456
{logo || (
5557
<div className={styles.pageHeaderLogo}>
5658
<EuiButtonEmpty

redisinsight/ui/src/components/promo-link/PromoLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import { EuiIcon, EuiText } from '@elastic/eui'
33

44
import { Nullable } from 'uiSrc/utils'
5-
import { ReactComponent as CloudIcon } from 'uiSrc/assets/img/oauth/cloud.svg'
5+
import { ReactComponent as CloudIcon } from 'uiSrc/assets/img/oauth/cloud_color.svg'
66

77
import styles from './styles.module.scss'
88

redisinsight/ui/src/components/promo-link/styles.module.scss

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010

1111
.link {
12-
border: 1px solid var(--separatorColorLight);
12+
border: 1px solid var(--euiColorSecondary);
1313
padding: 6px 16px;
1414
letter-spacing: normal;
1515
border-radius: 4px;
@@ -19,7 +19,6 @@
1919
height: 42px;
2020
background-size: cover;
2121
background-position: center;
22-
background-color: var(--euiColorEmptyShade);
2322

2423
&::before {
2524
content: "";
@@ -70,12 +69,7 @@
7069
position: absolute;
7170
width: 28px;
7271
height: 20px;
73-
top: 8px;
74-
left: 10px;
75-
76-
path {
77-
fill: var(--euiColorEmptyShade);
78-
stroke: var(--euiTextSubduedColor);
79-
}
72+
top: 12px;
73+
left: 16px;
8074
}
8175
}

redisinsight/ui/src/pages/home/components/capability-promotion/CapabilityPromotion.spec.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { sendEventTelemetry, TELEMETRY_EMPTY_VALUE, TelemetryEvent } from 'uiSrc
99
import { MOCK_EXPLORE_GUIDES } from 'uiSrc/constants/mocks/mock-explore-guides'
1010
import { findTutorialPath } from 'uiSrc/utils'
1111

12-
import CapabilityPromotion from './CapabilityPromotion'
12+
import { CapabilityPromotion } from './CapabilityPromotion'
1313

1414
jest.mock('uiSrc/telemetry', () => ({
1515
...jest.requireActual('uiSrc/telemetry'),
@@ -43,7 +43,7 @@ describe('CapabilityPromotion', () => {
4343
it('should render capabilities', () => {
4444
render(<CapabilityPromotion />)
4545

46-
MOCK_EXPLORE_GUIDES.forEach(({ tutorialId }) => {
46+
MOCK_EXPLORE_GUIDES.slice(0, 2).forEach(({ tutorialId }) => {
4747
expect(screen.getByTestId(`capability-promotion-${tutorialId}`)).toBeInTheDocument()
4848
})
4949
})
@@ -89,4 +89,28 @@ describe('CapabilityPromotion', () => {
8989

9090
(sendEventTelemetry as jest.Mock).mockRestore()
9191
})
92+
93+
it('should call proper actions after click explore redis', () => {
94+
render(<CapabilityPromotion />)
95+
96+
fireEvent.click(screen.getByTestId('explore-redis-btn'))
97+
98+
const expectedActions = [
99+
changeSelectedTab(InsightsPanelTabs.Explore),
100+
toggleInsightsPanel()
101+
]
102+
103+
expect(store.getActions()).toEqual(expectedActions)
104+
105+
expect(sendEventTelemetry).toBeCalledWith({
106+
event: TelemetryEvent.INSIGHTS_PANEL_OPENED,
107+
eventData: {
108+
databaseId: TELEMETRY_EMPTY_VALUE,
109+
source: 'home page',
110+
tab: InsightsPanelTabs.Explore,
111+
}
112+
});
113+
114+
(sendEventTelemetry as jest.Mock).mockRestore()
115+
})
92116
})
Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,78 @@
11
import React from 'react'
2-
3-
import { EuiIcon, EuiText, EuiTitle } from '@elastic/eui'
2+
import { EuiIcon, EuiText } from '@elastic/eui'
43
import cx from 'classnames'
54
import { useDispatch, useSelector } from 'react-redux'
65
import { useHistory } from 'react-router-dom'
7-
import ClickLearnRocketIcon from 'uiSrc/assets/img/click-learn-rocket.svg'
6+
import { filter } from 'lodash'
87

9-
import { openTutorialByPath } from 'uiSrc/slices/panels/insights'
8+
import { changeSelectedTab, insightsPanelSelector, openTutorialByPath, toggleInsightsPanel } from 'uiSrc/slices/panels/insights'
109
import { sendEventTelemetry, TELEMETRY_EMPTY_VALUE, TelemetryEvent } from 'uiSrc/telemetry'
1110
import { guideLinksSelector } from 'uiSrc/slices/content/guide-links'
1211
import GUIDE_ICONS from 'uiSrc/components/explore-guides/icons'
1312
import { findTutorialPath } from 'uiSrc/utils'
13+
import { InsightsPanelTabs } from 'uiSrc/slices/interfaces/insights'
1414
import styles from './styles.module.scss'
1515

1616
export interface Props {
1717
mode?: 'reduced' | 'wide'
1818
wrapperClassName?: string
19+
capabilityIds?: string[]
1920
}
2021

22+
const displayedCapabilityIds = ['sq-intro', 'ds-json-intro']
23+
2124
const CapabilityPromotion = (props: Props) => {
22-
const { mode = 'wide', wrapperClassName } = props
23-
const { data } = useSelector(guideLinksSelector)
25+
const { mode = 'wide', wrapperClassName, capabilityIds = displayedCapabilityIds } = props
26+
const { data: dataInit } = useSelector(guideLinksSelector)
27+
const { isOpen: isInsightsOpen } = useSelector(insightsPanelSelector)
2428

2529
const dispatch = useDispatch()
2630
const history = useHistory()
2731

28-
const onClickTutorial = (id: string) => {
29-
const tutorialPath = findTutorialPath({ id: id ?? '' })
30-
dispatch(openTutorialByPath(tutorialPath ?? '', history))
32+
// display only RediSearch and JSON. In the future will be configured via github
33+
const data = filter(dataInit, ({ tutorialId }) => capabilityIds.includes(tutorialId))
3134

35+
const sendTelemetry = (id?: string) => {
3236
sendEventTelemetry({
33-
event: TelemetryEvent.INSIGHTS_PANEL_OPENED,
37+
event: isInsightsOpen ? TelemetryEvent.INSIGHTS_PANEL_CLOSED : TelemetryEvent.INSIGHTS_PANEL_OPENED,
3438
eventData: {
3539
databaseId: TELEMETRY_EMPTY_VALUE,
3640
source: 'home page',
37-
tutorialId: id
41+
tutorialId: id || undefined,
42+
tab: id ? undefined : InsightsPanelTabs.Explore,
3843
},
3944
})
4045
}
4146

47+
const onClickTutorial = (id: string) => {
48+
const tutorialPath = findTutorialPath({ id: id ?? '' })
49+
dispatch(openTutorialByPath(tutorialPath ?? '', history))
50+
51+
sendTelemetry(id)
52+
}
53+
54+
const onClickExplore = () => {
55+
sendTelemetry()
56+
dispatch(changeSelectedTab(InsightsPanelTabs.Explore))
57+
dispatch(toggleInsightsPanel())
58+
}
59+
4260
if (!data?.length) {
4361
return null
4462
}
4563

4664
return (
4765
<div className={cx(styles.wrapper, mode, wrapperClassName)} data-testid="capability-promotion">
48-
<img
49-
className={styles.img}
50-
src={ClickLearnRocketIcon}
51-
alt="click and learn"
52-
/>
53-
<EuiTitle size="s" className={styles.title}>
54-
<span>Click & Learn</span>
55-
</EuiTitle>
66+
<div
67+
tabIndex={0}
68+
role="button"
69+
onKeyDown={() => {}}
70+
onClick={onClickExplore}
71+
className={styles.exploreItem}
72+
data-testid="explore-redis-btn"
73+
>
74+
<EuiText>Explore Redis</EuiText>
75+
</div>
5676
<div className={styles.guides}>
5777
{data.map(({ title, tutorialId, icon }) => (
5878
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
@@ -79,4 +99,4 @@ const CapabilityPromotion = (props: Props) => {
7999
)
80100
}
81101

82-
export default CapabilityPromotion
102+
export { CapabilityPromotion }
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
import CapabilityPromotion from './CapabilityPromotion'
2-
3-
export default CapabilityPromotion
1+
export { CapabilityPromotion } from './CapabilityPromotion'

0 commit comments

Comments
 (0)