Skip to content

Commit cae1c64

Browse files
Merge pull request #2941 from RedisInsight/fe/feature/RI-5196-highlighting
#RI-5196- add highlighting for explore panel
2 parents ad090bb + 772fe2b commit cae1c64

File tree

3 files changed

+46
-25
lines changed

3 files changed

+46
-25
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { recommendationsSelector, resetRecommendationsHighlighting } from 'uiSrc
88
import { InsightsPanelTabs } from 'uiSrc/slices/interfaces/insights'
99
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
1010
import { Pages } from 'uiSrc/constants'
11+
import { removeFeatureFromHighlighting } from 'uiSrc/slices/app/features'
1112
import InsightsTrigger from './InsightsTrigger'
1213

1314
let store: typeof mockedStore
@@ -49,7 +50,7 @@ describe('InsightsTrigger', () => {
4950

5051
fireEvent.click(screen.getByTestId('insights-trigger'))
5152

52-
expect(store.getActions()).toEqual([toggleInsightsPanel()])
53+
expect(store.getActions()).toEqual([toggleInsightsPanel(), removeFeatureFromHighlighting('insights')])
5354
})
5455

5556
it('should call proper actions after click on the button when there are any recommendations', () => {
@@ -63,7 +64,8 @@ describe('InsightsTrigger', () => {
6364
expect(store.getActions()).toEqual([
6465
resetRecommendationsHighlighting(),
6566
changeSelectedTab(InsightsPanelTabs.Recommendations),
66-
toggleInsightsPanel()
67+
toggleInsightsPanel(),
68+
removeFeatureFromHighlighting('insights')
6769
])
6870
})
6971

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

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@ import { recommendationsSelector, resetRecommendationsHighlighting } from 'uiSrc
1212
import { InsightsPanelTabs } from 'uiSrc/slices/interfaces/insights'
1313
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
1414
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
15+
import HighlightedFeature from 'uiSrc/components/hightlighted-feature/HighlightedFeature'
16+
import { BUILD_FEATURES } from 'uiSrc/constants/featuresHighlighting'
17+
import { appFeatureHighlightingSelector, removeFeatureFromHighlighting } from 'uiSrc/slices/app/features'
18+
import { getHighlightingFeatures } from 'uiSrc/utils/highlighting'
1519
import styles from './styles.module.scss'
1620

1721
const InsightsTrigger = () => {
1822
const { isOpen: isInsigtsOpen, tabSelected } = useSelector(insightsPanelSelector)
1923
const { isHighlighted, } = useSelector(recommendationsSelector)
2024
const { provider } = useSelector(connectedInstanceSelector)
2125

26+
const { features } = useSelector(appFeatureHighlightingSelector)
27+
const { insights: insightsHighlighting } = getHighlightingFeatures(features)
28+
2229
const dispatch = useDispatch()
2330
const { pathname, search } = useLocation()
2431
const { instanceId } = useParams<{ instanceId: string }>()
@@ -54,37 +61,45 @@ const InsightsTrigger = () => {
5461
source: 'overview'
5562
},
5663
})
64+
65+
dispatch(removeFeatureFromHighlighting('insights'))
5766
}
5867

5968
return (
6069
<div
6170
className={cx(styles.container, { [styles.isOpen]: isInsigtsOpen })}
6271
>
63-
<EuiToolTip
64-
title={isHighlighted ? undefined : 'Insights'}
65-
content={isHighlighted
66-
? 'New tips are available'
67-
: 'Open interactive tutorials to learn more about Redis or Redis Stack capabilities, or use tips to improve your database.'}
72+
<HighlightedFeature
73+
isHighlight={insightsHighlighting && !isHighlighted}
74+
hideFirstChild={!isHighlighted}
75+
{...(BUILD_FEATURES.insights || {})}
6876
>
69-
<EuiButton
70-
fill
71-
size="s"
72-
color="secondary"
73-
className={styles.btn}
74-
role="button"
75-
iconType={TriggerIcon}
76-
onClick={handleClickTrigger}
77-
data-testid="insights-trigger"
77+
<EuiToolTip
78+
title={isHighlighted ? undefined : 'Insights'}
79+
content={isHighlighted
80+
? 'New tips are available'
81+
: 'Open interactive tutorials to learn more about Redis or Redis Stack capabilities, or use tips to improve your database.'}
7882
>
79-
<EuiText className={cx(
80-
styles.triggerText,
81-
)}
83+
<EuiButton
84+
fill
85+
size="s"
86+
color="secondary"
87+
className={styles.btn}
88+
role="button"
89+
iconType={TriggerIcon}
90+
onClick={handleClickTrigger}
91+
data-testid="insights-trigger"
8292
>
83-
Insights
84-
</EuiText>
85-
{isHighlighted && (<span className={styles.highlighting} />)}
86-
</EuiButton>
87-
</EuiToolTip>
93+
<EuiText className={cx(
94+
styles.triggerText,
95+
)}
96+
>
97+
Insights
98+
</EuiText>
99+
{isHighlighted && (<span className={styles.highlighting} />)}
100+
</EuiButton>
101+
</EuiToolTip>
102+
</HighlightedFeature>
88103
</div>
89104
)
90105
}

redisinsight/ui/src/constants/featuresHighlighting.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ interface BuildHighlightingFeature {
1212
}
1313

1414
export const BUILD_FEATURES: Record<string, BuildHighlightingFeature> = {
15-
15+
insights: {
16+
type: 'tooltip',
17+
title: 'Try Redis Tutorials',
18+
content: 'Try our interactive Tutorials to learn how Redis can solve your use cases.',
19+
}
1620
} as const

0 commit comments

Comments
 (0)