Skip to content

Commit dba322b

Browse files
committed
fix IndexSection tests by adding error notifications to default toast container
1 parent 8124c5c commit dba322b

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

redisinsight/ui/src/components/notifications/Notifications.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import { RiToaster } from 'uiSrc/components/base/display/toast'
33
import { useErrorNotifications, useMessageNotifications } from './hooks'
44
import { InfiniteNotifications } from './components/infinite-messages/InfiniteNotifications'
5+
import { defaultContainerId } from './constants'
56

67
const Notifications = () => {
78
useErrorNotifications()
@@ -10,7 +11,7 @@ const Notifications = () => {
1011
return (
1112
<>
1213
<InfiniteNotifications />
13-
<RiToaster containerId={'default'} />
14+
<RiToaster containerId={defaultContainerId} />
1415
</>
1516
)
1617
}

redisinsight/ui/src/components/notifications/components/infinite-messages/InfiniteMessages.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,3 @@ export const INFINITE_MESSAGES: InfiniteMessagesType = {
277277
// }
278278
}),
279279
}
280-
281-
export const IMContainerId = 'InfiniteMessages'
282-
export const ONE_HOUR = 3_600_000

redisinsight/ui/src/components/notifications/components/infinite-messages/InfiniteNotifications.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React, { useEffect, useRef } from 'react'
22

33
import { useInfiniteNotifications } from 'uiSrc/components/notifications/hooks'
44
import { riToast, RiToaster } from 'uiSrc/components/base/display/toast'
5-
import { IMContainerId, ONE_HOUR } from './InfiniteMessages'
65
import { InfiniteMessage } from 'uiSrc/slices/interfaces'
6+
import { IMContainerId, ONE_HOUR } from '../../constants'
77

88
const DISMISS_DELAY = 3000 // 3 seconds interval
99

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const defaultContainerId = 'default'
2+
3+
export const IMContainerId = 'InfiniteMessages'
4+
export const ONE_HOUR = 3_600_000

redisinsight/ui/src/components/notifications/error-messages.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { InfoIcon, ToastDangerIcon } from 'uiSrc/components/base/icons'
66
import RdiDeployErrorContent from './components/rdi-deploy-error-content'
77
import { EncryptionErrorContent, DefaultErrorContent } from './components'
88
import CloudCapiUnAuthorizedErrorContent from './components/cloud-capi-unauthorized'
9+
import { defaultContainerId } from './constants'
910

1011
// TODO: use i18n file for texts
1112
export default {
@@ -29,7 +30,11 @@ export default {
2930
},
3031
},
3132
},
32-
{ variant: riToast.Variant.Danger, toastId },
33+
{
34+
variant: riToast.Variant.Danger,
35+
toastId,
36+
containerId: defaultContainerId,
37+
},
3338
),
3439
ENCRYPTION: (onClose = () => {}, instanceId = '', toastId?: string) =>
3540
riToast(
@@ -42,7 +47,11 @@ export default {
4247
),
4348
showCloseButton: false,
4449
},
45-
{ variant: riToast.Variant.Danger, toastId },
50+
{
51+
variant: riToast.Variant.Danger,
52+
toastId,
53+
containerId: defaultContainerId,
54+
},
4655
),
4756
CLOUD_CAPI_KEY_UNAUTHORIZED: (
4857
{
@@ -70,7 +79,11 @@ export default {
7079
/>
7180
),
7281
},
73-
{ variant: riToast.Variant.Danger, toastId },
82+
{
83+
variant: riToast.Variant.Danger,
84+
toastId,
85+
containerId: defaultContainerId,
86+
},
7487
),
7588
RDI_DEPLOY_PIPELINE: (
7689
{ title, message }: { title?: string; message: string },
@@ -87,6 +100,10 @@ export default {
87100
<RdiDeployErrorContent message={message} onClose={onClose} />
88101
),
89102
},
90-
{ variant: riToast.Variant.Danger, toastId },
103+
{
104+
variant: riToast.Variant.Danger,
105+
toastId,
106+
containerId: defaultContainerId,
107+
},
91108
),
92109
}

redisinsight/ui/src/components/notifications/hooks/useMessageNotifications.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { messagesSelector, removeMessage } from 'uiSrc/slices/app/notifications'
55
import { IMessage } from 'uiSrc/slices/interfaces'
66
import { setReleaseNotesViewed } from 'uiSrc/slices/app/info'
77
import { ColorText } from 'uiSrc/components/base/text'
8+
import { defaultContainerId } from '../constants'
89

910
export const useMessageNotifications = () => {
1011
const messagesData = useSelector(messagesSelector)
@@ -61,7 +62,11 @@ export const useMessageNotifications = () => {
6162
},
6263
showCloseButton,
6364
},
64-
{ variant: riToast.Variant.Success, toastId: id },
65+
{
66+
variant: riToast.Variant.Success,
67+
toastId: id,
68+
containerId: defaultContainerId,
69+
},
6570
)
6671
toastIdsRef.current.set(id, toastId)
6772
},

0 commit comments

Comments
 (0)