Skip to content

Commit cdd74a9

Browse files
committed
#RI-3927 - add recommendations tab highlighting
1 parent b89f8a0 commit cdd74a9

File tree

8 files changed

+102
-65
lines changed

8 files changed

+102
-65
lines changed

redisinsight/ui/src/components/analytics-tabs/constants.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React, { ReactNode } from 'react'
2+
import { AnalyticsViewTab } from 'uiSrc/slices/interfaces/analytics'
3+
import { useSelector } from 'react-redux'
4+
import { appFeaturesToHighlightSelector } from 'uiSrc/slices/app/features-highlighting'
5+
import HighlightedFeature from 'uiSrc/components/hightlighted-feature/HighlightedFeature'
6+
import { BUILD_FEATURES } from 'uiSrc/constants/featuresHighlighting'
7+
8+
interface AnalyticsTabs {
9+
id: AnalyticsViewTab
10+
label: string | ReactNode
11+
}
12+
13+
const DatabaseAnalyticsTab = () => {
14+
const { recommendations: recommendationsHighlighting } = useSelector(appFeaturesToHighlightSelector) ?? {}
15+
16+
return (
17+
<>
18+
<HighlightedFeature
19+
title={BUILD_FEATURES.recommendations?.title}
20+
content={BUILD_FEATURES.recommendations?.content}
21+
type={BUILD_FEATURES.recommendations?.type}
22+
isHighlight={BUILD_FEATURES.recommendations && recommendationsHighlighting}
23+
dotClassName="tab-highlighting-dot"
24+
>
25+
Database Analysis
26+
</HighlightedFeature>
27+
</>
28+
)
29+
}
30+
31+
export const analyticsViewTabs: AnalyticsTabs[] = [
32+
{
33+
id: AnalyticsViewTab.ClusterDetails,
34+
label: 'Overview',
35+
},
36+
{
37+
id: AnalyticsViewTab.DatabaseAnalysis,
38+
label: <DatabaseAnalyticsTab />,
39+
},
40+
{
41+
id: AnalyticsViewTab.SlowLog,
42+
label: 'Slow Log',
43+
},
44+
]

redisinsight/ui/src/components/hightlighted-feature/HighlightedFeature.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isString } from 'lodash'
12
import { EuiToolTip } from '@elastic/eui'
23
import { ToolTipPositions } from '@elastic/eui/src/components/tool_tip/tool_tip'
34
import cx from 'classnames'
@@ -8,7 +9,7 @@ import styles from './styles.modules.scss'
89

910
export interface Props {
1011
isHighlight?: boolean
11-
children: React.ReactElement<any, any>
12+
children: React.ReactElement<any, any> | string
1213
title?: string | React.ReactElement
1314
content?: string | React.ReactElement
1415
type?: FeaturesHighlightingType
@@ -36,7 +37,7 @@ const HighlightedFeature = (props: Props) => {
3637
dataTestPostfix = ''
3738
} = props
3839

39-
const innerContent = hideFirstChild ? children.props.children : children
40+
const innerContent = hideFirstChild && !isString(children) ? children.props.children : children
4041

4142
const DotHighlighting = () => (
4243
<>

redisinsight/ui/src/components/navigation-menu/styles.module.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ $sideBarWidth: 60px;
207207
}
208208

209209
.highlightDot {
210-
top: 12px !important;
211-
right: 12px !important;
210+
top: 11px !important;
211+
right: 11px !important;
212212

213213
&.activePage {
214214
background-color: #465282 !important;
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react'
2+
import { PageNames } from 'uiSrc/constants/pages'
23

34
export type FeaturesHighlightingType = 'plain' | 'tooltip' | 'popover'
45

@@ -9,9 +10,10 @@ interface BuildHighlightingFeature {
910
page?: string
1011
}
1112
export const BUILD_FEATURES: { [key: string]: BuildHighlightingFeature } = {
12-
importDatabases: {
13+
recommendations: {
1314
type: 'tooltip',
14-
title: 'Import Database Connections',
15-
content: 'Import your database connections from other Redis UIs'
15+
title: 'Database Recommendations',
16+
content: 'Run database analysis to get recommendations for optimizing your database.',
17+
page: PageNames.analytics
1618
}
1719
}
Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,39 @@
11
import React, { ReactNode } from 'react'
2+
import { useDispatch, useSelector } from 'react-redux'
3+
24
import { DatabaseAnalysisViewTab } from 'uiSrc/slices/interfaces/analytics'
3-
import AnalysisDataView from '../analysis-data-view'
5+
import { appFeaturesToHighlightSelector, removeFeatureFromHighlighting } from 'uiSrc/slices/app/features-highlighting'
6+
import { BUILD_FEATURES } from 'uiSrc/constants/featuresHighlighting'
7+
import HighlightedFeature from 'uiSrc/components/hightlighted-feature/HighlightedFeature'
8+
49
import Recommendations from '../recommendations-view'
10+
import AnalysisDataView from '../analysis-data-view'
511

612
interface DatabaseAnalysisTabs {
713
id: DatabaseAnalysisViewTab,
8-
name: (count?: number) => string,
14+
name: (count?: number) => string | ReactNode,
915
content: ReactNode
1016
}
1117

18+
const RecommendationsTab = ({ count }: { count?: number }) => {
19+
const { recommendations: recommendationsHighlighting } = useSelector(appFeaturesToHighlightSelector) ?? {}
20+
21+
const dispatch = useDispatch()
22+
23+
return count ? (
24+
<>
25+
<HighlightedFeature
26+
type="plain"
27+
isHighlight={BUILD_FEATURES.recommendations && recommendationsHighlighting}
28+
onClick={() => dispatch(removeFeatureFromHighlighting('recommendations'))}
29+
dotClassName="tab-highlighting-dot"
30+
>
31+
<>Recommendations ({count})</>
32+
</HighlightedFeature>
33+
</>
34+
) : (<>Recommendations</>)
35+
}
36+
1237
export const databaseAnalysisTabs: DatabaseAnalysisTabs[] = [
1338
{
1439
id: DatabaseAnalysisViewTab.DataSummary,
@@ -17,7 +42,7 @@ export const databaseAnalysisTabs: DatabaseAnalysisTabs[] = [
1742
},
1843
{
1944
id: DatabaseAnalysisViewTab.Recommendations,
20-
name: (count?: number) => (count ? `Recommendations (${count})` : 'Recommendations'),
45+
name: (count) => <RecommendationsTab count={count} />,
2146
content: <Recommendations />
2247
},
2348
]

redisinsight/ui/src/pages/home/components/HomeHeader/HomeHeader.tsx

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,9 @@ import {
99
EuiToolTip,
1010
} from '@elastic/eui'
1111
import { isEmpty } from 'lodash'
12-
import { useDispatch, useSelector } from 'react-redux'
12+
import { useSelector } from 'react-redux'
1313
import cx from 'classnames'
1414
import { ImportDatabasesDialog } from 'uiSrc/components'
15-
import HighlightedFeature from 'uiSrc/components/hightlighted-feature/HighlightedFeature'
16-
import { BUILD_FEATURES } from 'uiSrc/constants/featuresHighlighting'
17-
import {
18-
appFeaturesToHighlightSelector,
19-
removeFeatureFromHighlighting
20-
} from 'uiSrc/slices/app/features-highlighting'
2115
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
2216
import HelpLinksMenu from 'uiSrc/pages/home/components/HelpLinksMenu'
2317
import PromoLink from 'uiSrc/components/promo-link/PromoLink'
@@ -48,10 +42,6 @@ const HomeHeader = ({ onAddInstance, direction, welcomePage = false }: Props) =>
4842
const [guides, setGuides] = useState<IHelpGuide[]>([])
4943
const [isImportDialogOpen, setIsImportDialogOpen] = useState<boolean>(false)
5044

51-
const { importDatabases: importDatabasesHighlighting } = useSelector(appFeaturesToHighlightSelector) ?? {}
52-
53-
const dispatch = useDispatch()
54-
5545
useEffect(() => {
5646
if (loading || !data || isEmpty(data)) {
5747
return
@@ -126,30 +116,20 @@ const HomeHeader = ({ onAddInstance, direction, welcomePage = false }: Props) =>
126116
)
127117

128118
const ImportDatabasesBtn = () => (
129-
<HighlightedFeature
130-
title={BUILD_FEATURES.importDatabases?.title}
131-
content={BUILD_FEATURES.importDatabases?.content}
132-
type={BUILD_FEATURES.importDatabases?.type}
133-
isHighlight={BUILD_FEATURES.importDatabases && importDatabasesHighlighting}
134-
onClick={() => dispatch(removeFeatureFromHighlighting('importDatabases'))}
135-
transformOnHover
136-
hideFirstChild
119+
<EuiToolTip
120+
content="Import Database Connections"
137121
>
138-
<EuiToolTip
139-
content="Import Database Connections"
122+
<EuiButton
123+
fill
124+
color="secondary"
125+
onClick={handleClickImportDbBtn}
126+
className={styles.importDatabasesBtn}
127+
size="m"
128+
data-testid="import-dbs-btn"
140129
>
141-
<EuiButton
142-
fill
143-
color="secondary"
144-
onClick={handleClickImportDbBtn}
145-
className={styles.importDatabasesBtn}
146-
size="m"
147-
data-testid="import-dbs-btn"
148-
>
149-
<EuiIcon type="importAction" />
150-
</EuiButton>
151-
</EuiToolTip>
152-
</HighlightedFeature>
130+
<EuiIcon type="importAction" />
131+
</EuiButton>
132+
</EuiToolTip>
153133
)
154134

155135
const Guides = () => (

redisinsight/ui/src/styles/components/_tabs.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
.tabs-active-borders {
5050
.euiTab {
5151
border-radius: 0;
52-
padding: 8px 12px !important;
52+
padding: 0 !important;
5353
border-bottom: 1px solid var(--separatorColor);
5454
color: var(--euiTextSubduedColor) !important;
5555

@@ -63,9 +63,15 @@
6363
font-size: 13px !important;
6464
line-height: 18px !important;
6565
font-weight: 500 !important;
66+
padding: 8px 12px;
6667
}
6768
}
6869

70+
.tab-highlighting-dot {
71+
top: -6px;
72+
right: -12px;
73+
}
74+
6975
.euiTab + .euiTab {
7076
margin-left: 0 !important;
7177

0 commit comments

Comments
 (0)