Skip to content

Commit 5bcf20b

Browse files
authored
Merge pull request #3439 from RedisInsight/fe/bugfix/release/2.50.0
#RI-5793, #RI-5794, #RI-5798, #RI-5799
2 parents 9e5baca + c60d7ca commit 5bcf20b

File tree

7 files changed

+55
-8
lines changed

7 files changed

+55
-8
lines changed

redisinsight/ui/src/components/global-subscriptions/CommonAppSubscription/CommonAppSubscription.spec.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { setNewNotificationReceived, setLastReceivedNotification } from 'uiSrc/s
88
import { setIsConnected } from 'uiSrc/slices/app/socket-connection'
99
import { NotificationType } from 'uiSrc/slices/interfaces'
1010
import { cleanup, mockedStore, render } from 'uiSrc/utils/test-utils'
11-
import { SocketEvent } from 'uiSrc/constants'
11+
import { CloudJobEvents, SocketEvent } from 'uiSrc/constants'
1212
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
1313
import { RecommendationsSocketEvents } from 'uiSrc/constants/recommendations'
1414
import { addUnreadRecommendations } from 'uiSrc/slices/recommendations/recommendations'
15+
import { logoutUser } from 'uiSrc/slices/oauth/cloud'
1516
import { NotificationsDto } from 'apiSrc/modules/notification/dto'
1617

18+
import { CloudJobInfo } from 'apiSrc/modules/cloud/job/models'
1719
import CommonAppSubscription from './CommonAppSubscription'
1820

1921
let store: typeof mockedStore
@@ -108,4 +110,34 @@ describe('CommonAppSubscription', () => {
108110

109111
unmount()
110112
})
113+
114+
it('should logout if cloud:job:monitor return statusCode=401', () => {
115+
const { unmount } = render(<CommonAppSubscription />)
116+
117+
const mockData: CloudJobInfo = {
118+
id: '4d76ba0c-71d3-4c9c-ada5-a6e5f4102af5',
119+
name: 'CREATE_FREE_SUBSCRIPTION_AND_DATABASE',
120+
status: 'failed',
121+
error: {
122+
message: 'Authorization failed',
123+
statusCode: 401,
124+
error: 'CloudApiUnauthorized',
125+
errorCode: 11001
126+
},
127+
step: 'subscription'
128+
}
129+
130+
socket.on(CloudJobEvents.Monitor, (data: CloudJobInfo) => {
131+
expect(data).toEqual(mockData)
132+
})
133+
134+
socket.socketClient.emit(CloudJobEvents.Monitor, mockData)
135+
136+
const afterRenderActions = [
137+
logoutUser(),
138+
]
139+
expect(store.getActions()).toEqual([...afterRenderActions])
140+
141+
unmount()
142+
})
111143
})

redisinsight/ui/src/components/global-subscriptions/CommonAppSubscription/CommonAppSubscription.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { useEffect, useRef, useState } from 'react'
22
import { useDispatch, useSelector } from 'react-redux'
33
import { io, Socket } from 'socket.io-client'
44

5-
import { remove } from 'lodash'
6-
import { CloudJobEvents, SocketEvent, SocketFeaturesEvent } from 'uiSrc/constants'
5+
import { get, remove } from 'lodash'
6+
import { ApiStatusCode, CloudJobEvents, SocketEvent, SocketFeaturesEvent } from 'uiSrc/constants'
77
import { NotificationEvent } from 'uiSrc/constants/notifications'
88
import { setNewNotificationAction } from 'uiSrc/slices/app/notifications'
99
import { setIsConnected } from 'uiSrc/slices/app/socket-connection'
@@ -13,7 +13,7 @@ import { addUnreadRecommendations } from 'uiSrc/slices/recommendations/recommend
1313
import { RecommendationsSocketEvents } from 'uiSrc/constants/recommendations'
1414
import { getFeatureFlagsSuccess } from 'uiSrc/slices/app/features'
1515
import { CustomHeaders } from 'uiSrc/constants/api'
16-
import { oauthCloudJobSelector, setJob } from 'uiSrc/slices/oauth/cloud'
16+
import { logoutUser, oauthCloudJobSelector, setJob } from 'uiSrc/slices/oauth/cloud'
1717
import { CloudJobName } from 'uiSrc/electron/constants'
1818
import { CloudJobInfo } from 'apiSrc/modules/cloud/job/models'
1919

@@ -55,6 +55,13 @@ const CommonAppSubscription = () => {
5555

5656
socketRef.current.on(CloudJobEvents.Monitor, (data: CloudJobInfo) => {
5757
const jobName = data.name as unknown
58+
const statusCode = get(data, 'error.statusCode')
59+
60+
if (statusCode === ApiStatusCode.Unauthorized) {
61+
dispatch(logoutUser())
62+
return
63+
}
64+
5865
if (
5966
jobName === CloudJobName.CreateFreeDatabase
6067
|| jobName === CloudJobName.CreateFreeSubscriptionAndDatabase

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
EuiTitle
1111
} from '@elastic/eui'
1212
import { find } from 'lodash'
13+
import cx from 'classnames'
1314
import { CloudJobStep } from 'uiSrc/electron/constants'
1415
import ExternalLink from 'uiSrc/components/base/external-link'
1516
import ChampagneIcon from 'uiSrc/assets/img/icons/champagne.svg'
@@ -42,7 +43,7 @@ export const INFINITE_MESSAGES = {
4243
>
4344
<EuiFlexGroup justifyContent="flexEnd" direction="row" gutterSize="none">
4445
<EuiFlexItem grow={false}>
45-
<EuiLoadingSpinner className="infiniteMessage__icon" />
46+
<EuiLoadingSpinner className={cx('infiniteMessage__icon', styles.loading)} />
4647
</EuiFlexItem>
4748
<EuiFlexItem grow>
4849
<EuiTitle className="infiniteMessage__title">
@@ -67,7 +68,7 @@ export const INFINITE_MESSAGES = {
6768
>
6869
<EuiFlexGroup justifyContent="flexEnd" direction="row" gutterSize="none">
6970
<EuiFlexItem grow={false}>
70-
<EuiLoadingSpinner className="infiniteMessage__icon" />
71+
<EuiLoadingSpinner className={cx('infiniteMessage__icon', styles.loading)} />
7172
</EuiFlexItem>
7273
<EuiFlexItem grow>
7374
<EuiTitle className="infiniteMessage__title">
@@ -259,7 +260,7 @@ export const INFINITE_MESSAGES = {
259260
>
260261
<EuiFlexGroup justifyContent="flexEnd" direction="row" gutterSize="none">
261262
<EuiFlexItem grow={false}>
262-
<EuiLoadingSpinner className="infiniteMessage__icon" />
263+
<EuiLoadingSpinner className={cx('infiniteMessage__icon', styles.loading)} />
263264
</EuiFlexItem>
264265
<EuiFlexItem grow>
265266
<EuiTitle className="infiniteMessage__title">

redisinsight/ui/src/components/notifications/components/infinite-messages/styles.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99
margin-right: 4px;
1010
}
1111
}
12+
13+
.loading {
14+
border-top-color: var(--euiColorGhost) !important;
15+
}

redisinsight/ui/src/components/oauth/oauth-sso/oauth-create-db/OAuthCreateDb.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ describe('OAuthCreateDb', () => {
109109
setSSOFlow(OAuthSocialAction.Create),
110110
showOAuthProgress(true),
111111
addInfiniteNotification(INFINITE_MESSAGES.PENDING_CREATE_DB(CloudJobStep.Credentials)),
112+
setSocialDialogState(null),
112113
addFreeDb()
113114
]
114115
expect(store.getActions()).toEqual(expectedActions)

redisinsight/ui/src/components/oauth/oauth-sso/oauth-create-db/OAuthCreateDb.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
createFreeDbJob,
66
fetchPlans,
77
oauthCloudUserSelector,
8+
setSocialDialogState,
89
showOAuthProgress
910
} from 'uiSrc/slices/oauth/cloud'
1011

@@ -62,6 +63,7 @@ const OAuthCreateDb = (props: Props) => {
6263
dispatch(addInfiniteNotification(INFINITE_MESSAGES.PENDING_CREATE_DB(CloudJobStep.Credentials)))
6364

6465
if (isRecommended) {
66+
dispatch(setSocialDialogState(null))
6567
dispatch(createFreeDbJob({
6668
name: CloudJobName.CreateFreeSubscriptionAndDatabase,
6769
resources: {

redisinsight/ui/src/components/side-panels/panels/ai-assistant/components/texts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const EXPERT_CHAT_AGREEMENTS = (
8282

8383
export const EXPERT_CHAT_INITIAL_MESSAGE = (
8484
<>
85-
<EuiText size="xs">Welcome!</EuiText>
85+
<EuiText size="xs">Hi!</EuiText>
8686
<EuiText size="xs">I am here to help you get started with data querying.</EuiText>
8787
<EuiText size="xs">Type <b>/help</b> to get more info on what questions I can answer.</EuiText>
8888
<EuiSpacer />

0 commit comments

Comments
 (0)