Skip to content

Commit 8ccbec8

Browse files
authored
Merge pull request #1989 from RedisInsight/fe/bugfix/RI-4428_RI-4417
bugfix #RI-4428 #RI-4417
2 parents 5e382b4 + 2d84bdc commit 8ccbec8

File tree

7 files changed

+80
-19
lines changed

7 files changed

+80
-19
lines changed

redisinsight/ui/src/pages/browser/components/bulk-actions/BulkActions.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ describe('BulkActions', () => {
153153
eventData: {
154154
databaseId: 'instanceId',
155155
action: BulkActionsType.Delete,
156-
search: '',
156+
match: '*',
157157
filterType: 'hash'
158158
}
159159
})

redisinsight/ui/src/pages/browser/components/bulk-actions/BulkActions.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import { BulkActionsType } from 'uiSrc/constants'
1919
import { keysSelector } from 'uiSrc/slices/browser/keys'
2020
import { getMatchType, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
21+
import { DEFAULT_SEARCH_MATCH } from 'uiSrc/constants/api'
2122

2223
import BulkUpload from './BulkUpload'
2324
import BulkDelete from './BulkDelete'
@@ -41,16 +42,12 @@ const BulkActions = (props: Props) => {
4142
const dispatch = useDispatch()
4243

4344
useEffect(() => {
44-
let matchValue = '*'
45-
if (search !== '*' && !!search) {
46-
matchValue = getMatchType(search)
47-
}
4845
sendEventTelemetry({
4946
event: TelemetryEvent.BULK_ACTIONS_OPENED,
5047
eventData: {
5148
databaseId: instanceId,
5249
filterType: filter,
53-
match: matchValue,
50+
match: (search && search !== DEFAULT_SEARCH_MATCH) ? getMatchType(search) : DEFAULT_SEARCH_MATCH,
5451
}
5552
})
5653
}, [])
@@ -71,7 +68,7 @@ const BulkActions = (props: Props) => {
7168
}
7269

7370
if (type === BulkActionsType.Delete) {
74-
eventData.search = search
71+
eventData.match = (search && search !== DEFAULT_SEARCH_MATCH) ? getMatchType(search) : DEFAULT_SEARCH_MATCH
7572
eventData.filterType = filter
7673
}
7774

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,70 @@
11
import React from 'react'
22
import { mock } from 'ts-mockito'
3-
import { render } from 'uiSrc/utils/test-utils'
43

4+
import { fireEvent, render, screen } from 'uiSrc/utils/test-utils'
5+
import { BulkActionsType } from 'uiSrc/constants'
6+
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
57
import BulkActionsTabs, { Props } from './BulkActionsTabs'
68

79
const mockedProps = {
810
...mock<Props>(),
911
}
1012

13+
jest.mock('uiSrc/telemetry', () => ({
14+
...jest.requireActual('uiSrc/telemetry'),
15+
sendEventTelemetry: jest.fn(),
16+
}))
17+
18+
jest.mock('uiSrc/slices/browser/bulkActions', () => ({
19+
...jest.requireActual('uiSrc/slices/browser/bulkActions'),
20+
selectedBulkActionsSelector: jest.fn().mockReturnValue({
21+
type: 'delete'
22+
}),
23+
}))
24+
25+
jest.mock('uiSrc/slices/browser/keys', () => ({
26+
...jest.requireActual('uiSrc/slices/browser/keys'),
27+
keysSelector: jest.fn().mockReturnValue({
28+
filter: 'set',
29+
search: 'dawkmdk*'
30+
}),
31+
}))
32+
1133
describe('BulkActionsTabs', () => {
1234
it('should render', () => {
1335
expect(render(<BulkActionsTabs {...mockedProps} />)).toBeTruthy()
1436
})
37+
38+
it('should call proper telemetry events', async () => {
39+
const sendEventTelemetryMock = jest.fn();
40+
(sendEventTelemetry as jest.Mock).mockImplementation(() => sendEventTelemetryMock)
41+
42+
render(<BulkActionsTabs {...mockedProps} onChangeType={jest.fn()} />)
43+
44+
fireEvent.click(screen.getByTestId('bulk-action-tab-upload'))
45+
46+
expect(sendEventTelemetry).toBeCalledWith({
47+
event: TelemetryEvent.BULK_ACTIONS_OPENED,
48+
eventData: {
49+
databaseId: '',
50+
action: BulkActionsType.Upload,
51+
}
52+
});
53+
54+
(sendEventTelemetry as jest.Mock).mockRestore()
55+
56+
fireEvent.click(screen.getByTestId('bulk-action-tab-delete'))
57+
58+
expect(sendEventTelemetry).toBeCalledWith({
59+
event: TelemetryEvent.BULK_ACTIONS_OPENED,
60+
eventData: {
61+
databaseId: '',
62+
action: BulkActionsType.Delete,
63+
match: 'PATTERN',
64+
filterType: 'set'
65+
}
66+
});
67+
68+
(sendEventTelemetry as jest.Mock).mockRestore()
69+
})
1570
})

redisinsight/ui/src/pages/browser/components/bulk-actions/BulkActionsTabs/BulkActionsTabs.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ import { useSelector } from 'react-redux'
55
import { BulkActionsType } from 'uiSrc/constants'
66
import { selectedBulkActionsSelector } from 'uiSrc/slices/browser/bulkActions'
77

8-
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
8+
import { getMatchType, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
99
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
10+
import { DEFAULT_SEARCH_MATCH } from 'uiSrc/constants/api'
11+
import { keysSelector } from 'uiSrc/slices/browser/keys'
12+
1013
import { bulkActionsTypeTabs } from '../constants/bulk-type-options'
1114
import styles from './styles.module.scss'
1215

@@ -17,16 +20,23 @@ export interface Props {
1720
const BulkActionsTabs = (props: Props) => {
1821
const { onChangeType } = props
1922
const { id: instanceId } = useSelector(connectedInstanceSelector)
23+
const { filter, search } = useSelector(keysSelector)
2024
const { type } = useSelector(selectedBulkActionsSelector)
2125

2226
const onSelectedTabChanged = (id: BulkActionsType) => {
27+
const eventData: Record<string, any> = {
28+
databaseId: instanceId,
29+
action: id
30+
}
31+
32+
if (id === BulkActionsType.Delete) {
33+
eventData.match = (search && search !== DEFAULT_SEARCH_MATCH) ? getMatchType(search) : DEFAULT_SEARCH_MATCH
34+
eventData.filterType = filter
35+
}
36+
2337
sendEventTelemetry({
24-
event: TelemetryEvent.BULK_ACTIONS_SWITCHED,
25-
eventData: {
26-
databaseId: instanceId,
27-
prevValue: type,
28-
currentValue: id
29-
}
38+
event: TelemetryEvent.BULK_ACTIONS_OPENED,
39+
eventData
3040
})
3141
onChangeType(id)
3242
}

redisinsight/ui/src/pages/browser/components/bulk-actions/BulkUpload/BulkUpload.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const BulkUpload = (props: Props) => {
5656
const onStartAgain = () => {
5757
dispatch(setBulkUploadStartAgain())
5858
setFiles(null)
59+
setIsSubmitDisabled(true)
5960
}
6061

6162
const handleUploadWarning = () => {

redisinsight/ui/src/pages/browser/components/key-list/KeyList.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { cloneDeep } from 'lodash'
33
import { fireEvent } from '@testing-library/react'
44
import { cleanup, mockedStore, render, waitFor, screen, clearStoreActions } from 'uiSrc/utils/test-utils'
55
import { KeysStoreData, KeyViewType, SearchMode } from 'uiSrc/slices/interfaces/keys'
6-
import { deleteSelectedKey, keysSelector, setLastBatchKeys } from 'uiSrc/slices/browser/keys'
6+
import { deleteKey, keysSelector, setLastBatchKeys } from 'uiSrc/slices/browser/keys'
77
import { apiService } from 'uiSrc/services'
88
import KeyList from './KeyList'
99

@@ -196,7 +196,7 @@ describe('KeyList', () => {
196196
fireEvent.click(screen.getByTestId('submit-delete-key'))
197197

198198
const expectedActions = [
199-
deleteSelectedKey()
199+
deleteKey()
200200
]
201201
expect(clearStoreActions(store.getActions().slice(-1))).toEqual(clearStoreActions(expectedActions))
202202
})

redisinsight/ui/src/telemetry/events.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ export enum TelemetryEvent {
198198
BULK_ACTIONS_WARNING = 'BULK_ACTIONS_WARNING',
199199
BULK_ACTIONS_CANCELLED = 'BULK_ACTIONS_CANCELLED',
200200
BULK_ACTIONS_STARTED = 'BULK_ACTIONS_STARTED',
201-
BULK_ACTIONS_STOPPED = 'BULK_ACTIONS_STOPPED',
202-
BULK_ACTIONS_SWITCHED = 'BULK_ACTIONS_SWITCHED',
203201

204202
DATABASE_ANALYSIS_STARTED = 'DATABASE_ANALYSIS_STARTED',
205203
DATABASE_ANALYSIS_HISTORY_VIEWED = 'DATABASE_ANALYSIS_HISTORY_VIEWED',

0 commit comments

Comments
 (0)