Skip to content

Commit 290551b

Browse files
authored
Merge pull request #3441 from RedisInsight/release/2.50.0
Release/2.50.0
2 parents 7248095 + 9a34660 commit 290551b

File tree

9 files changed

+62
-11
lines changed

9 files changed

+62
-11
lines changed

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

Lines changed: 3 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

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

Lines changed: 4 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,7 @@ const CommonAppSubscription = () => {
5555

5656
socketRef.current.on(CloudJobEvents.Monitor, (data: CloudJobInfo) => {
5757
const jobName = data.name as unknown
58+
5859
if (
5960
jobName === CloudJobName.CreateFreeDatabase
6061
|| 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-jobs/OAuthJobs.spec.tsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { cloneDeep } from 'lodash'
33
import { useSelector } from 'react-redux'
44
import { AxiosError } from 'axios'
55
import { cleanup, clearStoreActions, mockedStore, render } from 'uiSrc/utils/test-utils'
6-
import { oauthCloudJobSelector, setJob, setSocialDialogState } from 'uiSrc/slices/oauth/cloud'
6+
import { logoutUser, oauthCloudJobSelector, setJob, setSocialDialogState } from 'uiSrc/slices/oauth/cloud'
77
import { CloudJobStatus, CloudJobName, CloudJobStep } from 'uiSrc/electron/constants'
88
import { addErrorNotification, addInfiniteNotification, removeInfiniteNotification } from 'uiSrc/slices/app/notifications'
99
import { RootState } from 'uiSrc/slices/store'
@@ -203,4 +203,38 @@ describe('OAuthJobs', () => {
203203
clearStoreActions(expectedActions)
204204
)
205205
})
206+
207+
it('should call logoutUser when statusCode is 401', async () => {
208+
const mockDatabaseId = '123'
209+
const error = {
210+
statusCode: 401,
211+
errorCode: CustomErrorCodes.CloudSubscriptionAlreadyExistsFree,
212+
resource: {
213+
databaseId: mockDatabaseId
214+
}
215+
};
216+
(oauthCloudJobSelector as jest.Mock).mockImplementation(() => ({
217+
status: ''
218+
}))
219+
220+
const { rerender } = render(<OAuthJobs />);
221+
222+
(oauthCloudJobSelector as jest.Mock).mockImplementation(() => ({
223+
status: CloudJobStatus.Failed,
224+
error,
225+
}))
226+
227+
rerender(<OAuthJobs />)
228+
229+
const expectedActions = [
230+
logoutUser(),
231+
addInfiniteNotification(INFINITE_MESSAGES.DATABASE_EXISTS()),
232+
setSSOFlow(),
233+
setSocialDialogState(null),
234+
removeInfiniteNotification(InfiniteMessagesIds.oAuthProgress),
235+
]
236+
expect(clearStoreActions(store.getActions())).toEqual(
237+
clearStoreActions(expectedActions)
238+
)
239+
})
206240
})

redisinsight/ui/src/components/oauth/oauth-jobs/OAuthJobs.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { fetchInstancesAction } from 'uiSrc/slices/instances/instances'
88
import {
99
createFreeDbJob,
1010
createFreeDbSuccess,
11+
logoutUser,
1112
oauthCloudJobSelector,
1213
oauthCloudSelector,
1314
setJob,
@@ -18,7 +19,7 @@ import { addErrorNotification, addInfiniteNotification, removeInfiniteNotificati
1819
import { parseCloudOAuthError } from 'uiSrc/utils'
1920
import { INFINITE_MESSAGES, InfiniteMessagesIds } from 'uiSrc/components/notifications/components'
2021
import { TelemetryEvent, sendEventTelemetry } from 'uiSrc/telemetry'
21-
import { BrowserStorageItem, CustomErrorCodes } from 'uiSrc/constants'
22+
import { ApiStatusCode, BrowserStorageItem, CustomErrorCodes } from 'uiSrc/constants'
2223
import { localStorageService } from 'uiSrc/services'
2324
import { setSSOFlow } from 'uiSrc/slices/instances/cloud'
2425

@@ -49,10 +50,15 @@ const OAuthJobs = () => {
4950
break
5051

5152
case CloudJobStatus.Failed:
52-
5353
const errorCode = get(error, 'errorCode', 0) as CustomErrorCodes
5454
const subscriptionId = get(error, 'resource.subscriptionId', 0)
5555
const resources = get(error, 'resource', {}) as CloudImportDatabaseResources
56+
const statusCode = get(error, 'statusCode', 0) as number
57+
58+
if (statusCode === ApiStatusCode.Unauthorized) {
59+
dispatch(logoutUser())
60+
}
61+
5662
// eslint-disable-next-line sonarjs/no-nested-switch
5763
switch (errorCode) {
5864
case CustomErrorCodes.CloudDatabaseAlreadyExistsFree:

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)