Skip to content

Commit 2bb896f

Browse files
Merge pull request #2932 from RedisInsight/fe/bugfixing
#RI-5311 - Popover appears after Triggers and Functions
2 parents f2ae0a5 + fdf2579 commit 2bb896f

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import {
77
} from 'uiSrc/slices/recommendations/recommendations'
88
import { fireEvent, screen, cleanup, mockedStore, render } from 'uiSrc/utils/test-utils'
99
import { MOCK_RECOMMENDATIONS } from 'uiSrc/constants/mocks/mock-recommendations'
10-
import { changeSelectedTab, insightsPanelSelector, resetExplorePanelSearch, toggleInsightsPanel } from 'uiSrc/slices/panels/insights'
10+
import { changeSelectedTab, insightsPanelSelector, resetExplorePanelSearch, setExplorePanelIsPageOpen, toggleInsightsPanel } from 'uiSrc/slices/panels/insights'
1111
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
1212
import { Pages } from 'uiSrc/constants'
1313
import { connectedInstanceCDSelector } from 'uiSrc/slices/instances/instances'
1414
import { InsightsPanelTabs } from 'uiSrc/slices/interfaces/insights'
1515
import { getTutorialCapability } from 'uiSrc/utils'
16+
import { isShowCapabilityTutorialPopover } from 'uiSrc/services'
1617
import DatabaseSidePanels from './DatabaseSidePanels'
1718

1819
let store: typeof mockedStore
@@ -78,6 +79,11 @@ jest.mock('uiSrc/utils', () => ({
7879
getTutorialCapability: jest.fn().mockReturnValue({ tutorialPage: { id: 'id' }, telemetryName: 'searchAndQuery' }),
7980
}))
8081

82+
jest.mock('uiSrc/services', () => ({
83+
...jest.requireActual('uiSrc/services'),
84+
isShowCapabilityTutorialPopover: jest.fn(),
85+
}))
86+
8187
/**
8288
* DatabaseSidePanels tests
8389
*
@@ -227,7 +233,8 @@ describe('DatabaseSidePanels', () => {
227233

228234
describe('capability', () => {
229235
beforeEach(() => {
230-
(connectedInstanceCDSelector as jest.Mock).mockReturnValueOnce({ free: true })
236+
(connectedInstanceCDSelector as jest.Mock).mockReturnValueOnce({ free: true });
237+
(isShowCapabilityTutorialPopover as jest.Mock).mockImplementation(() => true)
231238
})
232239
it('should call store actions', () => {
233240
(getTutorialCapability as jest.Mock).mockImplementation(() => ({
@@ -250,6 +257,7 @@ describe('DatabaseSidePanels', () => {
250257
const expectedActions = [
251258
getRecommendations(),
252259
resetExplorePanelSearch(),
260+
setExplorePanelIsPageOpen(false),
253261
changeSelectedTab(InsightsPanelTabs.Explore),
254262
toggleInsightsPanel(true),
255263
]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { EuiButtonIcon, EuiTab, EuiTabs, keys } from '@elastic/eui'
44
import { useDispatch, useSelector } from 'react-redux'
55
import { useHistory, useLocation, useParams } from 'react-router-dom'
66

7-
import { changeSelectedTab, insightsPanelSelector, resetExplorePanelSearch, toggleInsightsPanel } from 'uiSrc/slices/panels/insights'
7+
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'
1010
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
@@ -63,19 +63,19 @@ const DatabaseSidePanels = (props: Props) => {
6363
return
6464
}
6565

66-
const search = new URLSearchParams(window.location.search)
6766
const tutorialCapabilityPath = getTutorialCapability(capabilitySource)?.tutorialPage?.args?.path || ''
6867

6968
// set 'guidPath' with the path to capability tutorial
7069
if (tutorialCapabilityPath) {
70+
const search = new URLSearchParams(window.location.search)
7171
search.set('guidePath', tutorialCapabilityPath)
72+
history.push({ search: search.toString() })
7273
} else {
7374
// reset explore if tutorial is not found
7475
dispatch(resetExplorePanelSearch())
76+
dispatch(setExplorePanelIsPageOpen(false))
7577
}
7678

77-
history.push({ search: search.toString() })
78-
7979
dispatch(changeSelectedTab(InsightsPanelTabs.Explore))
8080
dispatch(toggleInsightsPanel(true))
8181
}, [capabilitySource, free])

redisinsight/ui/src/services/capability.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { CapabilityStorageItem } from 'uiSrc/constants/storage'
22
import { getCapabilityStorageField, setCapabilityStorageField } from 'uiSrc/services'
3+
import { getTutorialCapability } from 'uiSrc/utils'
34

45
const TIME_TO_READ_POPOVER_TEXT = 1_000
56

67
export const isShowCapabilityTutorialPopover = (isFree = false) =>
7-
!!isFree && !getCapabilityStorageField(CapabilityStorageItem.tutorialPopoverShown)
8+
!!isFree
9+
&& !getCapabilityStorageField(CapabilityStorageItem.tutorialPopoverShown)
10+
&& getTutorialCapability(getCapabilityStorageField(CapabilityStorageItem.source))?.name
811

912
export const setCapabilityPopoverShown = () => {
1013
setTimeout(() => {

0 commit comments

Comments
 (0)