Skip to content

Commit 921a8c0

Browse files
Merge pull request #3661 from RedisInsight/fe/bugfix/RI-5967-remove-new-message-from-imported-databases
RI-5967 Show new message only on freedb create, redirect to browser o…
2 parents 9c6ca56 + cf264e7 commit 921a8c0

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import {
1111
} from '@elastic/eui'
1212
import { find } from 'lodash'
1313
import cx from 'classnames'
14-
import { CloudJobStep } from 'uiSrc/electron/constants'
14+
import { CloudJobName, CloudJobStep } from 'uiSrc/electron/constants'
1515
import ExternalLink from 'uiSrc/components/base/external-link'
1616
import ChampagneIcon from 'uiSrc/assets/img/icons/champagne.svg'
1717
import Divider from 'uiSrc/components/divider/Divider'
1818
import { OAuthProviders } from 'uiSrc/components/oauth/oauth-select-plan/constants'
1919

2020
import { CloudSuccessResult } from 'uiSrc/slices/interfaces'
2121

22+
import { Maybe } from 'uiSrc/utils'
2223
import styles from './styles.module.scss'
2324

2425
export enum InfiniteMessagesIds {
@@ -91,8 +92,11 @@ export const INFINITE_MESSAGES = {
9192
</div>
9293
)
9394
}),
94-
SUCCESS_CREATE_DB: (details: Omit<CloudSuccessResult, 'resourceId'>, onSuccess: () => void) => {
95+
SUCCESS_CREATE_DB: (details: Omit<CloudSuccessResult, 'resourceId'>, onSuccess: () => void, jobName: Maybe<CloudJobName>) => {
9596
const vendor = find(OAuthProviders, ({ id }) => id === details.provider)
97+
const withFeed = jobName
98+
&& [CloudJobName.CreateFreeDatabase, CloudJobName.CreateFreeSubscriptionAndDatabase].includes(jobName)
99+
const text = `You can now use your Redis Stack database in Redis Cloud${withFeed ? ' with pre-loaded sample data' : ''}.`
96100
return ({
97101
id: InfiniteMessagesIds.oAuthSuccess,
98102
className: 'wide',
@@ -110,7 +114,7 @@ export const INFINITE_MESSAGES = {
110114
<EuiFlexItem grow>
111115
<EuiTitle className="infiniteMessage__title"><span>Congratulations!</span></EuiTitle>
112116
<EuiText size="xs">
113-
You can now use your Redis Stack database in Redis Cloud with pre-loaded sample data.
117+
{text}
114118
<EuiSpacer size="s" />
115119
<b>Notice:</b> the database will be deleted after 15 days of inactivity.
116120
</EuiText>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { setSSOFlow } from 'uiSrc/slices/instances/cloud'
2626
const OAuthJobs = () => {
2727
const {
2828
status,
29+
name: jobName,
2930
error,
3031
step,
3132
result,
@@ -44,7 +45,7 @@ const OAuthJobs = () => {
4445
break
4546

4647
case CloudJobStatus.Finished:
47-
dispatch(fetchInstancesAction(() => dispatch(createFreeDbSuccess(result, history))))
48+
dispatch(fetchInstancesAction(() => dispatch(createFreeDbSuccess(result, history, jobName))))
4849
dispatch(setJob({ id: '', name: CloudJobName.CreateFreeSubscriptionAndDatabase, status: '' }))
4950
localStorageService.remove(BrowserStorageItem.OAuthJobId)
5051
break

redisinsight/ui/src/slices/oauth/cloud.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { AxiosError } from 'axios'
33
import { remove } from 'lodash'
44
import { apiService, localStorageService } from 'uiSrc/services'
55
import { ApiEndpoints, BrowserStorageItem, Pages } from 'uiSrc/constants'
6-
import { getApiErrorCode, getApiErrorMessage, getAxiosError, isStatusSuccessful, Nullable } from 'uiSrc/utils'
6+
import { getApiErrorCode, getApiErrorMessage, getAxiosError, isStatusSuccessful, Maybe, Nullable } from 'uiSrc/utils'
77

88
import { CloudJobName, CloudJobStatus } from 'uiSrc/electron/constants'
99
import {
@@ -242,7 +242,7 @@ export const oauthCapiKeysSelector = (state: RootState) => state.oauth.cloud.cap
242242
// The reducer
243243
export default oauthCloudSlice.reducer
244244

245-
export function createFreeDbSuccess(result: CloudSuccessResult, history: any) {
245+
export function createFreeDbSuccess(result: CloudSuccessResult, history: any, jobName: Maybe<CloudJobName>) {
246246
return async (dispatch: AppDispatch, stateInit: () => RootState) => {
247247
const { resourceId: id, ...details } = result
248248
try {
@@ -257,12 +257,12 @@ export function createFreeDbSuccess(result: CloudSuccessResult, history: any) {
257257
dispatch(checkConnectToInstanceAction(id))
258258
}
259259

260-
history.push(Pages.workbench(id))
260+
history.push(Pages.browser(id))
261261
}
262262

263263
dispatch(showOAuthProgress(true))
264264
dispatch(removeInfiniteNotification(InfiniteMessagesIds.oAuthProgress))
265-
dispatch(addInfiniteNotification(INFINITE_MESSAGES.SUCCESS_CREATE_DB(details, onConnect)))
265+
dispatch(addInfiniteNotification(INFINITE_MESSAGES.SUCCESS_CREATE_DB(details, onConnect, jobName)))
266266
dispatch(setSelectAccountDialogState(false))
267267
} catch (_err) {
268268
const error = _err as AxiosError

redisinsight/ui/src/slices/tests/oauth/cloud.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,13 +1024,13 @@ describe('oauth cloud slice', () => {
10241024
const onConnect = () => {}
10251025

10261026
// Act
1027-
await store.dispatch<any>(createFreeDbSuccess(result, {}))
1027+
await store.dispatch<any>(createFreeDbSuccess(result, {}, CloudJobName.CreateFreeDatabase))
10281028

10291029
// Assert
10301030
const expectedActions = [
10311031
showOAuthProgress(true),
10321032
removeInfiniteNotification(InfiniteMessagesIds.oAuthProgress),
1033-
addInfiniteNotification(INFINITE_MESSAGES.SUCCESS_CREATE_DB({}, onConnect)),
1033+
addInfiniteNotification(INFINITE_MESSAGES.SUCCESS_CREATE_DB({}, onConnect, CloudJobName.CreateFreeDatabase)),
10341034
setSelectAccountDialogState(false),
10351035
]
10361036
expect(clearStoreActions(store.getActions())).toEqual(clearStoreActions(expectedActions))

0 commit comments

Comments
 (0)