Skip to content

Commit fee9dde

Browse files
authored
Merge pull request #1843 from RedisInsight/fe/feature/RI-4105_highlight-my-tutorials
#RI-4105 - highlight my tutorials
2 parents 12f3f0b + 32faacd commit fee9dde

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed

redisinsight/ui/src/constants/featuresHighlighting.tsx

Lines changed: 7 additions & 1 deletion
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,5 +10,10 @@ interface BuildHighlightingFeature {
910
page?: string
1011
}
1112
export const BUILD_FEATURES: { [key: string]: BuildHighlightingFeature } = {
12-
13+
myTutorials: {
14+
type: 'tooltip',
15+
title: 'Upload your own tutorials',
16+
content: 'Upload tutorials to work in Workbench and share them with others.',
17+
page: PageNames.workbench
18+
}
1319
}

redisinsight/ui/src/pages/workbench/components/enablement-area/EnablementArea/EnablementArea.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515
FormValues
1616
} from 'uiSrc/pages/workbench/components/enablement-area/EnablementArea/components/UploadTutorialForm/UploadTutorialForm'
1717
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
18+
import { appFeatureHighlightingSelector, removeFeatureFromHighlighting } from 'uiSrc/slices/app/features'
19+
import { getHighlightingFeatures } from 'uiSrc/utils/highlighting'
1820
import {
1921
getMarkdownPathByManifest,
2022
getWBSourcePath
@@ -67,6 +69,9 @@ const EnablementArea = (props: Props) => {
6769
const history = useHistory()
6870
const dispatch = useDispatch()
6971
const { search: searchEAContext } = useSelector(appContextWorkbenchEA)
72+
const { features } = useSelector(appFeatureHighlightingSelector)
73+
const { myTutorials: myTutorialsHighlighting } = getHighlightingFeatures(features)
74+
7075
const [isInternalPageVisible, setIsInternalPageVisible] = useState(false)
7176
const [isCreateOpen, setIsCreateOpen] = useState(false)
7277
const [internalPage, setInternalPage] = useState<IInternalPage>({ path: '' })
@@ -75,6 +80,18 @@ const EnablementArea = (props: Props) => {
7580
const searchRef = useRef<string>('')
7681
const { instanceId = '' } = useParams<{ instanceId: string }>()
7782

83+
useEffect(() => {
84+
if (isCreateOpen && myTutorialsHighlighting) {
85+
dispatch(removeFeatureFromHighlighting('myTutorials'))
86+
}
87+
88+
return () => {
89+
if (myTutorialsHighlighting) {
90+
dispatch(removeFeatureFromHighlighting('myTutorials'))
91+
}
92+
}
93+
}, [isCreateOpen, myTutorialsHighlighting])
94+
7895
useEffect(() => {
7996
searchRef.current = search
8097
const pagePath = new URLSearchParams(search).get('item')
@@ -216,6 +233,9 @@ const EnablementArea = (props: Props) => {
216233
const currentSourcePath = sourcePath + (uriPath ? `${uriPath}` : (args?.path ?? ''))
217234
const currentManifestPath = `${manifestPath}/${key}`
218235

236+
const isMyTutorialsGroup = level === 0 && currentSourcePath.startsWith(ApiEndpoints.CUSTOM_TUTORIALS_PATH)
237+
const isHighlightGroup = isMyTutorialsGroup && myTutorialsHighlighting
238+
219239
switch (type) {
220240
case EnablementAreaComponent.Group:
221241
return (
@@ -227,6 +247,7 @@ const EnablementArea = (props: Props) => {
227247
isShowActions={currentSourcePath.startsWith(ApiEndpoints.CUSTOM_TUTORIALS_PATH)}
228248
onCreate={() => setIsCreateOpen((v) => !v)}
229249
onDelete={onDeleteCustomTutorial}
250+
highlightGroup={isHighlightGroup}
230251
{...args}
231252
>
232253
<>

redisinsight/ui/src/pages/workbench/components/enablement-area/EnablementArea/components/Group/Group.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { useParams } from 'react-router-dom'
55

66
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
77
import { workbenchCustomTutorialsSelector } from 'uiSrc/slices/workbench/wb-custom-tutorials'
8+
import { BUILD_FEATURES } from 'uiSrc/constants/featuresHighlighting'
9+
import HighlightedFeature from 'uiSrc/components/hightlighted-feature/HighlightedFeature'
810
import DeleteTutorialButton from '../DeleteTutorialButton'
911
import { EAItemActions } from '../../constants'
1012

@@ -25,6 +27,7 @@ export interface Props {
2527
onToggle?: (isOpen: boolean) => void
2628
triggerStyle?: any
2729
isCustomTutorialsLoading?: boolean
30+
highlightGroup?: boolean
2831
}
2932

3033
const Group = (props: Props) => {
@@ -42,6 +45,7 @@ const Group = (props: Props) => {
4245
onCreate,
4346
onDelete,
4447
triggerStyle,
48+
highlightGroup
4549
} = props
4650
const { deleting: deletingCustomTutorials } = useSelector(workbenchCustomTutorialsSelector)
4751
const { instanceId = '' } = useParams<{ instanceId: string }>()
@@ -86,9 +90,18 @@ const Group = (props: Props) => {
8690

8791
const buttonContent = (
8892
<div className="group-header-wrapper">
89-
<EuiText className="group-header" size="m">
90-
{label}
91-
</EuiText>
93+
<HighlightedFeature
94+
title={BUILD_FEATURES.myTutorials?.title}
95+
content={BUILD_FEATURES.myTutorials?.content}
96+
type={BUILD_FEATURES.myTutorials?.type}
97+
isHighlight={highlightGroup}
98+
dotClassName="dotHighlighting"
99+
wrapperClassName="wrapperHighlighting"
100+
>
101+
<EuiText className="group-header" size="m">
102+
{label}
103+
</EuiText>
104+
</HighlightedFeature>
92105
{isShowActions && actionsContent}
93106
</div>
94107
)

redisinsight/ui/src/pages/workbench/components/enablement-area/EnablementArea/components/Group/styles.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,15 @@
112112
background-color: var(--hoverInListColorDarken);
113113
}
114114
}
115+
116+
.dotHighlighting {
117+
width: 8px;
118+
height: 8px;
119+
top: 0;
120+
right: -8px;
121+
}
122+
123+
.wrapperHighlighting {
124+
display: flex;
125+
}
115126
}

0 commit comments

Comments
 (0)