Skip to content

Commit 7e29ccf

Browse files
Merge pull request #2965 from RedisInsight/fe/feature/RI-4950_tutorials-home-page
#RI-4950 - add tutorials for home page, refactoring
2 parents be24d29 + 2abbe95 commit 7e29ccf

File tree

79 files changed

+1545
-623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1545
-623
lines changed
Lines changed: 37 additions & 0 deletions
Loading

redisinsight/ui/src/components/database-side-panels/DatabaseSidePanels.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ beforeEach(() => {
9797
})
9898

9999
describe('DatabaseSidePanels', () => {
100+
beforeEach(() => {
101+
reactRouterDom.useParams = jest.fn().mockReturnValue({ instanceId: 'instanceId' })
102+
})
100103
it('should render', () => {
101104
expect(render(<DatabaseSidePanels />)).toBeTruthy()
102105
})
@@ -135,6 +138,25 @@ describe('DatabaseSidePanels', () => {
135138
expect(screen.queryByTestId('recommendations-unread-count')).not.toBeInTheDocument()
136139
})
137140

141+
it('should not render recommendations count without instanceId', () => {
142+
reactRouterDom.useParams = jest.fn().mockReturnValue({ instanceId: undefined });
143+
(insightsPanelSelector as jest.Mock).mockReturnValue({
144+
isOpen: true,
145+
tabSelected: 'tips'
146+
});
147+
148+
(recommendationsSelector as jest.Mock).mockImplementationOnce(() => ({
149+
...mockRecommendationsSelector,
150+
data: {
151+
recommendations: [],
152+
totalUnread: 7,
153+
},
154+
}))
155+
156+
render(<DatabaseSidePanels />)
157+
expect(screen.queryByTestId('recommendations-unread-count')).not.toBeInTheDocument()
158+
})
159+
138160
it('should render recommendations count with totalUnread > 0', () => {
139161
(insightsPanelSelector as jest.Mock).mockReturnValue({
140162
isOpen: true,

redisinsight/ui/src/components/database-side-panels/DatabaseSidePanels.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useHistory, useLocation, useParams } from 'react-router-dom'
77
import { changeSelectedTab, insightsPanelSelector, resetExplorePanelSearch, setExplorePanelIsPageOpen, toggleInsightsPanel } from 'uiSrc/slices/panels/insights'
88
import { InsightsPanelTabs } from 'uiSrc/slices/interfaces/insights'
99
import { recommendationsSelector } from 'uiSrc/slices/recommendations/recommendations'
10-
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
10+
import { sendEventTelemetry, TELEMETRY_EMPTY_VALUE, TelemetryEvent } from 'uiSrc/telemetry'
1111
import { connectedInstanceCDSelector, connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
1212
import { ONBOARDING_FEATURES } from 'uiSrc/components/onboarding-features'
1313
import { FullScreen, OnboardingTour } from 'uiSrc/components'
@@ -93,7 +93,7 @@ const DatabaseSidePanels = (props: Props) => {
9393
sendEventTelemetry({
9494
event: TelemetryEvent.INSIGHTS_PANEL_CLOSED,
9595
eventData: {
96-
databaseId: instanceId,
96+
databaseId: instanceId || TELEMETRY_EMPTY_VALUE,
9797
provider,
9898
page,
9999
tab: tabSelected
@@ -109,7 +109,7 @@ const DatabaseSidePanels = (props: Props) => {
109109
sendEventTelemetry({
110110
event: TelemetryEvent.INSIGHTS_PANEL_TAB_CHANGED,
111111
eventData: {
112-
databaseId: instanceId,
112+
databaseId: instanceId || TELEMETRY_EMPTY_VALUE,
113113
prevTab: tabSelected,
114114
currentTab: name,
115115
},
@@ -121,7 +121,7 @@ const DatabaseSidePanels = (props: Props) => {
121121
sendEventTelemetry({
122122
event: TelemetryEvent.INSIGHTS_PANEL_FULL_SCREEN_CLICKED,
123123
eventData: {
124-
databaseId: instanceId,
124+
databaseId: instanceId || TELEMETRY_EMPTY_VALUE,
125125
state: value ? 'exit' : 'open'
126126
},
127127
})
@@ -155,7 +155,7 @@ const DatabaseSidePanels = (props: Props) => {
155155
>
156156
<>
157157
<span className={styles.tabName}>Tips</span>
158-
{!!totalUnread && (
158+
{(!!totalUnread && instanceId) && (
159159
<div
160160
className={styles.tabTotalUnread}
161161
data-testid="recommendations-unread-count"

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/Code/Code.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useSelector } from 'react-redux'
55
import EnablementAreaContext from 'uiSrc/pages/workbench/contexts/enablementAreaContext'
66
import { CodeButtonParams } from 'uiSrc/constants'
77
import { parseParams } from 'uiSrc/utils'
8-
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
8+
import { sendEventTelemetry, TELEMETRY_EMPTY_VALUE, TelemetryEvent } from 'uiSrc/telemetry'
99
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
1010
import { getFileInfo, getTutorialSection, } from '../../utils'
1111

@@ -64,7 +64,7 @@ const Code = ({ children, params = '', label, path, ...rest }: Props) => {
6464
sendEventTelemetry({
6565
event: TelemetryEvent.EXPLORE_PANEL_COMMAND_COPIED,
6666
eventData: {
67-
databaseId: instanceId,
67+
databaseId: instanceId || TELEMETRY_EMPTY_VALUE,
6868
buttonName: label,
6969
path,
7070
provider,

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/CodeButtonBlock/CodeButtonBlock.spec.tsx

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,32 +149,48 @@ describe('CodeButtonBlock', () => {
149149

150150
expect(sendEventTelemetry).toBeCalledWith({
151151
event: TelemetryEvent.EXPLORE_PANEL_DATABASE_CHANGE_CLICKED,
152-
eventData:
153-
{
154-
databaseId: 'instanceId'
155-
}
152+
eventData: {
153+
databaseId: 'instanceId'
154+
}
156155
})
157156
})
158157

159158
it('should call popover with no module loaded', async () => {
160-
const sendEventTelemetryMock = jest.fn();
161-
(sendEventTelemetry as jest.Mock).mockImplementation(() => sendEventTelemetryMock)
162159
const onApply = jest.fn()
163160

164161
render(
165162
<CodeButtonBlock
166163
{...instance(mockedProps)}
167164
label={label}
168165
onApply={onApply}
169-
params={{ run_confirmation: 'true' }}
166+
params={{ run_confirmation: 'false' }}
170167
content="ft.info"
171168
/>
172169
)
173170
await act(() => {
174171
fireEvent.click(screen.getByTestId(`run-btn-${label}`))
175172
})
176173

177-
expect(screen.getByTestId('tutorials-docker-link')).toBeInTheDocument()
178-
expect(screen.getByTestId('tutorials-get-started-link')).toBeInTheDocument()
174+
expect(screen.getByTestId('module-not-loaded-popover')).toBeInTheDocument()
175+
})
176+
177+
it('should call not opened db popover without instanceId', async () => {
178+
reactRouterDom.useParams = jest.fn().mockReturnValue({ instanceId: undefined })
179+
const onApply = jest.fn()
180+
181+
render(
182+
<CodeButtonBlock
183+
{...instance(mockedProps)}
184+
label={label}
185+
onApply={onApply}
186+
params={{ run_confirmation: 'false' }}
187+
content={simpleContent}
188+
/>
189+
)
190+
await act(() => {
191+
fireEvent.click(screen.getByTestId(`run-btn-${label}`))
192+
})
193+
194+
expect(screen.getByTestId('database-not-opened-popover')).toBeInTheDocument()
179195
})
180196
})

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/CodeButtonBlock/CodeButtonBlock.tsx

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { BooleanParams, CodeButtonParams, MonacoLanguage } from 'uiSrc/constants
1010
import { CodeBlock } from 'uiSrc/components'
1111
import { getDBConfigStorageField } from 'uiSrc/services'
1212
import { ConfigDBStorageItem } from 'uiSrc/constants/storage'
13-
import ModuleNotLoadedMinimalized
14-
from 'uiSrc/components/messages/module-not-loaded-minimalized/ModuleNotLoadedMinimalized'
13+
import { ModuleNotLoadedMinimalized, DatabaseNotOpened } from 'uiSrc/components/messages'
1514
import { OAuthSocialSource } from 'uiSrc/slices/interfaces'
1615
import { AdditionalRedisModule } from 'apiSrc/modules/database/models/additional.redis.module'
1716

@@ -82,12 +81,7 @@ const CodeButtonBlock = (props: Props) => {
8281
}
8382

8483
const handleRunClicked = () => {
85-
if (notLoadedModule) {
86-
setIsPopoverOpen(true)
87-
return
88-
}
89-
90-
if (!isNotShowConfirmation && isButtonHasConfirmation) {
84+
if (!instanceId || notLoadedModule || (!isNotShowConfirmation && isButtonHasConfirmation)) {
9185
setIsPopoverOpen(true)
9286
return
9387
}
@@ -104,6 +98,24 @@ const CodeButtonBlock = (props: Props) => {
10498
setIsPopoverOpen(false)
10599
}
106100

101+
const getPopoverMessage = (): React.ReactNode => {
102+
if (!instanceId) {
103+
return (<DatabaseNotOpened />)
104+
}
105+
106+
if (notLoadedModule) {
107+
return (
108+
<ModuleNotLoadedMinimalized
109+
moduleName={notLoadedModule}
110+
source={OAuthSocialSource.Tutorials}
111+
onClose={() => setIsPopoverOpen(false)}
112+
/>
113+
)
114+
}
115+
116+
return (<RunConfirmationPopover onApply={handleApplyRun} />)
117+
}
118+
107119
return (
108120
<div className={styles.wrapper}>
109121
<EuiFlexGroup gutterSize="none">
@@ -158,14 +170,7 @@ const CodeButtonBlock = (props: Props) => {
158170
</EuiToolTip>
159171
)}
160172
>
161-
{!!notLoadedModule && (
162-
<ModuleNotLoadedMinimalized
163-
moduleName={notLoadedModule}
164-
source={OAuthSocialSource.Tutorials}
165-
onClose={() => setIsPopoverOpen(false)}
166-
/>
167-
)}
168-
{!notLoadedModule && <RunConfirmationPopover onApply={handleApplyRun} />}
173+
{getPopoverMessage()}
169174
</EuiPopover>
170175
</EuiFlexItem>
171176
</EuiFlexGroup>

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/Group/Group.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useSelector } from 'react-redux'
44
import { useParams } from 'react-router-dom'
55
import cx from 'classnames'
66

7-
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
7+
import { sendEventTelemetry, TELEMETRY_EMPTY_VALUE, TelemetryEvent } from 'uiSrc/telemetry'
88
import { workbenchCustomTutorialsSelector } from 'uiSrc/slices/workbench/wb-custom-tutorials'
99
import { EAItemActions } from 'uiSrc/constants'
1010
import { ONBOARDING_FEATURES } from 'uiSrc/components/onboarding-features'
@@ -60,7 +60,7 @@ const Group = (props: Props) => {
6060
sendEventTelemetry({
6161
event: TelemetryEvent.EXPLORE_PANEL_IMPORT_CLICKED,
6262
eventData: {
63-
databaseId: instanceId,
63+
databaseId: instanceId || TELEMETRY_EMPTY_VALUE,
6464
}
6565
})
6666
}

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/InternalPage/InternalPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useSelector } from 'react-redux'
1515

1616
import { ExternalLink } from 'uiSrc/components'
1717
import { IEnablementAreaItem } from 'uiSrc/slices/interfaces'
18-
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
18+
import { sendEventTelemetry, TELEMETRY_EMPTY_VALUE, TelemetryEvent } from 'uiSrc/telemetry'
1919
import { getTutorialCapability, Nullable } from 'uiSrc/utils'
2020

2121
import { ReactComponent as RocketIcon } from 'uiSrc/assets/img/icons/rocket.svg'
@@ -88,7 +88,7 @@ const InternalPage = (props: Props) => {
8888
path,
8989
link,
9090
section: getTutorialSection(manifestPath),
91-
databaseId: instanceId,
91+
databaseId: instanceId || TELEMETRY_EMPTY_VALUE,
9292
}
9393
})
9494
}

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/InternalPage/styles/main.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@
2727
margin: ($margin-size-pace * 3 + px) 0;
2828
}
2929

30+
img {
31+
max-width: 100%;
32+
}
3033
}

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/Navigation/Navigation.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useDispatch } from 'react-redux'
77
import { EnablementAreaComponent, IEnablementAreaItem } from 'uiSrc/slices/interfaces'
88

99
import { ApiEndpoints, EAItemActions, EAManifestFirstKey } from 'uiSrc/constants'
10-
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
10+
import { sendEventTelemetry, TELEMETRY_EMPTY_VALUE, TelemetryEvent } from 'uiSrc/telemetry'
1111
import { deleteCustomTutorial, uploadCustomTutorial } from 'uiSrc/slices/workbench/wb-custom-tutorials'
1212

1313
import {
@@ -58,7 +58,7 @@ const Navigation = (props: Props) => {
5858
sendEventTelemetry({
5959
event: TelemetryEvent.EXPLORE_PANEL_IMPORT_SUBMITTED,
6060
eventData: {
61-
databaseId: instanceId,
61+
databaseId: instanceId || TELEMETRY_EMPTY_VALUE,
6262
source: file ? 'Upload' : 'URL'
6363
}
6464
})
@@ -74,7 +74,7 @@ const Navigation = (props: Props) => {
7474
sendEventTelemetry({
7575
event: TelemetryEvent.EXPLORE_PANEL_TUTORIAL_DELETED,
7676
eventData: {
77-
databaseId: instanceId,
77+
databaseId: instanceId || TELEMETRY_EMPTY_VALUE,
7878
}
7979
})
8080
}))

0 commit comments

Comments
 (0)