Skip to content

Commit 4141026

Browse files
Merge pull request #3027 from RedisInsight/fe/bugfix/RI-5378
#RI-5378 - fix telemetry events
2 parents b2594a0 + 3bb117e commit 4141026

File tree

13 files changed

+56
-50
lines changed

13 files changed

+56
-50
lines changed

redisinsight/ui/src/pages/browser/modules/key-details/components/hash-details/HashDetails.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ const HashDetails = (props: Props) => {
3131
onOpenAddItemPanel()
3232
}
3333

34-
const closeAddItemPanel = () => {
34+
const closeAddItemPanel = (isCancelled?: boolean) => {
3535
setIsAddItemPanelOpen(false)
36-
onCloseAddItemPanel()
36+
if (isCancelled) {
37+
onCloseAddItemPanel()
38+
}
3739
}
3840

3941
const Actions = ({ width }: { width: number }) => (
@@ -56,7 +58,7 @@ const HashDetails = (props: Props) => {
5658
)}
5759
{isAddItemPanelOpen && (
5860
<div className={cx('formFooterBar', 'contentActive')}>
59-
<AddHashFields onCancel={closeAddItemPanel} />
61+
<AddHashFields closePanel={closeAddItemPanel} />
6062
</div>
6163
)}
6264
</div>

redisinsight/ui/src/pages/browser/modules/key-details/components/hash-details/add-hash-fields/AddHashFields.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
2-
import { fireEvent, render, screen } from 'uiSrc/utils/test-utils'
32
import { instance, mock } from 'ts-mockito'
3+
import { fireEvent, render, screen } from 'uiSrc/utils/test-utils'
44
import AddHashFields, { Props } from './AddHashFields'
55

66
const HASH_FIELD = 'hash-field'

redisinsight/ui/src/pages/browser/modules/key-details/components/hash-details/add-hash-fields/AddHashFields.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ import AddItemsActions from 'uiSrc/pages/browser/components/add-items-actions/Ad
2323

2424
import { stringToBuffer } from 'uiSrc/utils'
2525
import { AddFieldsToHashDto } from 'apiSrc/modules/browser/dto/hash.dto'
26-
import styles from '../styles.module.scss'
2726

2827
export interface Props {
29-
onCancel: (isCancelled?: boolean) => void;
28+
closePanel: (isCancelled?: boolean) => void
3029
}
3130

3231
export interface IHashFieldState {
@@ -42,7 +41,7 @@ export const INITIAL_HASH_FIELD_STATE: IHashFieldState = {
4241
}
4342

4443
const AddHashFields = (props: Props) => {
45-
const { onCancel } = props
44+
const { closePanel } = props
4645
const dispatch = useDispatch()
4746
const [fields, setFields] = useState<IHashFieldState[]>([{ ...INITIAL_HASH_FIELD_STATE }])
4847
const { loading } = useSelector(updateHashValueStateSelector)
@@ -91,7 +90,7 @@ const AddHashFields = (props: Props) => {
9190
}
9291

9392
const onSuccessAdded = () => {
94-
onCancel()
93+
closePanel()
9594
sendEventTelemetry({
9695
event: getBasedOnViewTypeEvent(
9796
viewType,
@@ -203,7 +202,7 @@ const AddHashFields = (props: Props) => {
203202
<EuiFlexGroup justifyContent="flexEnd" gutterSize="l">
204203
<EuiFlexItem grow={false}>
205204
<div>
206-
<EuiButton color="secondary" onClick={() => onCancel(true)} data-testid="cancel-fields-btn">
205+
<EuiButton color="secondary" onClick={() => closePanel(true)} data-testid="cancel-fields-btn">
207206
<EuiTextColor color="default">Cancel</EuiTextColor>
208207
</EuiButton>
209208
</div>

redisinsight/ui/src/pages/browser/modules/key-details/components/list-details/ListDetails.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ const ListDetails = (props: Props) => {
3636
onOpenAddItemPanel()
3737
}
3838

39-
const closeAddItemPanel = () => {
39+
const closeAddItemPanel = (isCancelled?: boolean) => {
4040
setIsAddItemPanelOpen(false)
41-
onCloseAddItemPanel()
41+
if (isCancelled) {
42+
onCloseAddItemPanel()
43+
}
4244
}
4345

4446
const closeRemoveItemPanel = () => {
@@ -73,12 +75,12 @@ const ListDetails = (props: Props) => {
7375
)}
7476
{isAddItemPanelOpen && (
7577
<div className={cx('formFooterBar', 'contentActive')}>
76-
<AddListElements onCancel={closeAddItemPanel} />
78+
<AddListElements closePanel={closeAddItemPanel} />
7779
</div>
7880
)}
7981
{isRemoveItemPanelOpen && (
8082
<div className={cx('formFooterBar', styles.contentActive)}>
81-
<RemoveListElements onCancel={closeRemoveItemPanel} onRemoveKey={onRemoveKey} />
83+
<RemoveListElements closePanel={closeRemoveItemPanel} onRemoveKey={onRemoveKey} />
8284
</div>
8385
)}
8486
</div>

redisinsight/ui/src/pages/browser/modules/key-details/components/list-details/add-list-elements/AddListElements.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { PushElementToListDto } from 'apiSrc/modules/browser/dto'
2525
import styles from '../styles.module.scss'
2626

2727
export interface Props {
28-
onCancel: (isCancelled?: boolean) => void;
28+
closePanel: (isCancelled?: boolean) => void
2929
}
3030

3131
export enum ListElementDestination {
@@ -48,7 +48,7 @@ const optionsDestinations: EuiSuperSelectOption<string>[] = [
4848
]
4949

5050
const AddListElements = (props: Props) => {
51-
const { onCancel } = props
51+
const { closePanel } = props
5252

5353
const [element, setElement] = useState<string>('')
5454
const [destination, setDestination] = useState<ListElementDestination>(TAIL_DESTINATION)
@@ -66,7 +66,7 @@ const AddListElements = (props: Props) => {
6666
}, [])
6767

6868
const onSuccessAdded = () => {
69-
onCancel()
69+
closePanel()
7070
sendEventTelemetry({
7171
event: getBasedOnViewTypeEvent(
7272
viewType,
@@ -138,7 +138,7 @@ const AddListElements = (props: Props) => {
138138
<EuiFlexGroup justifyContent="flexEnd" gutterSize="l">
139139
<EuiFlexItem grow={false}>
140140
<div>
141-
<EuiButton color="secondary" onClick={() => onCancel(true)} data-testid="cancel-members-btn">
141+
<EuiButton color="secondary" onClick={() => closePanel(true)} data-testid="cancel-members-btn">
142142
<EuiTextColor color="default">Cancel</EuiTextColor>
143143
</EuiButton>
144144
</div>

redisinsight/ui/src/pages/browser/modules/key-details/components/list-details/remove-list-elements/RemoveListElements.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
import styles from './styles.module.scss'
4141

4242
export interface Props {
43-
onCancel: () => void
43+
closePanel: (isCancelled?: boolean) => void
4444
onRemoveKey: () => void
4545
}
4646

@@ -56,7 +56,7 @@ const optionsDestinations: EuiSuperSelectOption<string>[] = [
5656
]
5757

5858
const RemoveListElements = (props: Props) => {
59-
const { onCancel, onRemoveKey } = props
59+
const { closePanel, onRemoveKey } = props
6060

6161
const [count, setCount] = useState<string>('')
6262
const [destination, setDestination] = useState<ListElementDestination>(TAIL_DESTINATION)
@@ -122,7 +122,7 @@ const RemoveListElements = (props: Props) => {
122122

123123
const onSuccessRemoved = (newTotal: number) => {
124124
if (newTotal <= 0) onRemoveKey()
125-
onCancel()
125+
closePanel()
126126
sendEventTelemetry({
127127
event: getBasedOnViewTypeEvent(
128128
viewType,
@@ -278,7 +278,7 @@ const RemoveListElements = (props: Props) => {
278278
<EuiFlexGroup justifyContent="flexEnd" gutterSize="l">
279279
<EuiFlexItem grow={false}>
280280
<div>
281-
<EuiButton color="secondary" onClick={() => onCancel()} data-testid="cancel-elements-btn">
281+
<EuiButton color="secondary" onClick={() => closePanel(true)} data-testid="cancel-elements-btn">
282282
<EuiTextColor color="default">Cancel</EuiTextColor>
283283
</EuiButton>
284284
</div>

redisinsight/ui/src/pages/browser/modules/key-details/components/set-details/SetDetails.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ const SetDetails = (props: Props) => {
3131
onOpenAddItemPanel()
3232
}
3333

34-
const closeAddItemPanel = () => {
34+
const closeAddItemPanel = (isCancelled?: boolean) => {
3535
setIsAddItemPanelOpen(false)
36-
onCloseAddItemPanel()
36+
if (isCancelled) {
37+
onCloseAddItemPanel()
38+
}
3739
}
3840

3941
const Actions = ({ width }: { width: number }) => (
@@ -56,7 +58,7 @@ const SetDetails = (props: Props) => {
5658
)}
5759
{isAddItemPanelOpen && (
5860
<div className={cx('formFooterBar', 'contentActive')}>
59-
<AddSetMembers onCancel={closeAddItemPanel} />
61+
<AddSetMembers closePanel={closeAddItemPanel} />
6062
</div>
6163
)}
6264
</div>

redisinsight/ui/src/pages/browser/modules/key-details/components/set-details/add-set-members/AddSetMembers.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import AddItemsActions from 'uiSrc/pages/browser/components/add-items-actions/Ad
2222
import { AddZsetFormConfig as config } from 'uiSrc/pages/browser/components/add-key/constants/fields-config'
2323

2424
export interface Props {
25-
onCancel: (isCancelled?: boolean) => void;
25+
closePanel: (isCancelled?: boolean) => void
2626
}
2727

2828
export interface ISetMemberState {
@@ -36,7 +36,7 @@ export const INITIAL_SET_MEMBER_STATE: ISetMemberState = {
3636
}
3737

3838
const AddSetMembers = (props: Props) => {
39-
const { onCancel } = props
39+
const { closePanel } = props
4040
const dispatch = useDispatch()
4141
const [members, setMembers] = useState<ISetMemberState[]>([{ ...INITIAL_SET_MEMBER_STATE }])
4242
const { loading } = useSelector(setSelector)
@@ -50,7 +50,7 @@ const AddSetMembers = (props: Props) => {
5050
}, [members.length])
5151

5252
const onSuccessAdded = () => {
53-
onCancel()
53+
closePanel()
5454
sendEventTelemetry({
5555
event: getBasedOnViewTypeEvent(
5656
viewType,
@@ -154,7 +154,6 @@ const AddSetMembers = (props: Props) => {
154154
length={members.length}
155155
addItem={addMember}
156156
removeItem={removeMember}
157-
removeCanClear
158157
clearIsDisabled={isClearDisabled(item)}
159158
clearItemValues={clearMemberValues}
160159
loading={loading}
@@ -171,7 +170,7 @@ const AddSetMembers = (props: Props) => {
171170
>
172171
<EuiFlexGroup justifyContent="flexEnd" gutterSize="l">
173172
<EuiFlexItem grow={false}>
174-
<EuiButton color="secondary" onClick={() => onCancel(true)} data-testid="cancel-members-btn">
173+
<EuiButton color="secondary" onClick={() => closePanel(true)} data-testid="cancel-members-btn">
175174
<EuiTextColor color="default">Cancel</EuiTextColor>
176175
</EuiButton>
177176
</EuiFlexItem>

redisinsight/ui/src/pages/browser/modules/key-details/components/stream-details/StreamDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ const StreamDetails = (props: Props) => {
7070
{isAddItemPanelOpen && (
7171
<div className={cx('formFooterBar', 'contentActive')}>
7272
{streamViewType === StreamViewType.Data && (
73-
<AddStreamEntries onCancel={closeAddItemPanel} />
73+
<AddStreamEntries closePanel={closeAddItemPanel} />
7474
)}
7575
{STREAM_ADD_GROUP_VIEW_TYPES.includes(streamViewType!) && (
76-
<AddStreamGroup onCancel={closeAddItemPanel} />
76+
<AddStreamGroup closePanel={closeAddItemPanel} />
7777
)}
7878
</div>
7979
)}

redisinsight/ui/src/pages/browser/modules/key-details/components/stream-details/add-stream-entity/AddStreamEntries.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import StreamEntryFields from './StreamEntryFields/StreamEntryFields'
1717
import styles from './styles.module.scss'
1818

1919
export interface Props {
20-
onCancel: (isCancelled?: boolean) => void
20+
closePanel: (isCancelled?: boolean) => void
2121
}
2222

2323
const AddStreamEntries = (props: Props) => {
24-
const { onCancel } = props
24+
const { closePanel } = props
2525
const { lastEntry } = useSelector(streamDataSelector)
2626
const { name: keyName = '' } = useSelector(selectedKeyDataSelector) ?? { name: undefined }
2727
const { viewType } = useSelector(keysSelector)
@@ -75,7 +75,7 @@ const AddStreamEntries = (props: Props) => {
7575
}
7676

7777
const onSuccessAdded = () => {
78-
onCancel()
78+
closePanel()
7979
sendEventTelemetry({
8080
event: getBasedOnViewTypeEvent(
8181
viewType,
@@ -130,7 +130,7 @@ const AddStreamEntries = (props: Props) => {
130130
<EuiFlexGroup justifyContent="flexEnd" gutterSize="l">
131131
<EuiFlexItem grow={false}>
132132
<div>
133-
<EuiButton color="secondary" onClick={() => onCancel(true)} data-testid="cancel-members-btn">
133+
<EuiButton color="secondary" onClick={() => closePanel(true)} data-testid="cancel-members-btn">
134134
<EuiTextColor color="default">Cancel</EuiTextColor>
135135
</EuiButton>
136136
</div>

0 commit comments

Comments
 (0)