Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import {
} from '@elastic/eui'
import { find } from 'lodash'
import cx from 'classnames'
import { CloudJobStep } from 'uiSrc/electron/constants'
import { CloudJobName, CloudJobStep } from 'uiSrc/electron/constants'
import ExternalLink from 'uiSrc/components/base/external-link'
import ChampagneIcon from 'uiSrc/assets/img/icons/champagne.svg'
import Divider from 'uiSrc/components/divider/Divider'
import { OAuthProviders } from 'uiSrc/components/oauth/oauth-select-plan/constants'

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

import { Maybe } from 'uiSrc/utils'
import styles from './styles.module.scss'

export enum InfiniteMessagesIds {
Expand Down Expand Up @@ -91,8 +92,11 @@ export const INFINITE_MESSAGES = {
</div>
)
}),
SUCCESS_CREATE_DB: (details: Omit<CloudSuccessResult, 'resourceId'>, onSuccess: () => void) => {
SUCCESS_CREATE_DB: (details: Omit<CloudSuccessResult, 'resourceId'>, onSuccess: () => void, jobName: Maybe<CloudJobName>) => {
const vendor = find(OAuthProviders, ({ id }) => id === details.provider)
const withFeed = jobName
&& [CloudJobName.CreateFreeDatabase, CloudJobName.CreateFreeSubscriptionAndDatabase].includes(jobName)
const text = `You can now use your Redis Stack database in Redis Cloud${withFeed ? ' with pre-loaded sample data' : ''}.`
return ({
id: InfiniteMessagesIds.oAuthSuccess,
className: 'wide',
Expand All @@ -110,7 +114,7 @@ export const INFINITE_MESSAGES = {
<EuiFlexItem grow>
<EuiTitle className="infiniteMessage__title"><span>Congratulations!</span></EuiTitle>
<EuiText size="xs">
You can now use your Redis Stack database in Redis Cloud with pre-loaded sample data.
{text}
<EuiSpacer size="s" />
<b>Notice:</b> the database will be deleted after 15 days of inactivity.
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { setSSOFlow } from 'uiSrc/slices/instances/cloud'
const OAuthJobs = () => {
const {
status,
name: jobName,
error,
step,
result,
Expand All @@ -44,7 +45,7 @@ const OAuthJobs = () => {
break

case CloudJobStatus.Finished:
dispatch(fetchInstancesAction(() => dispatch(createFreeDbSuccess(result, history))))
dispatch(fetchInstancesAction(() => dispatch(createFreeDbSuccess(result, history, jobName))))
dispatch(setJob({ id: '', name: CloudJobName.CreateFreeSubscriptionAndDatabase, status: '' }))
localStorageService.remove(BrowserStorageItem.OAuthJobId)
break
Expand Down
8 changes: 4 additions & 4 deletions redisinsight/ui/src/slices/oauth/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AxiosError } from 'axios'
import { remove } from 'lodash'
import { apiService, localStorageService } from 'uiSrc/services'
import { ApiEndpoints, BrowserStorageItem, Pages } from 'uiSrc/constants'
import { getApiErrorCode, getApiErrorMessage, getAxiosError, isStatusSuccessful, Nullable } from 'uiSrc/utils'
import { getApiErrorCode, getApiErrorMessage, getAxiosError, isStatusSuccessful, Maybe, Nullable } from 'uiSrc/utils'

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

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

history.push(Pages.workbench(id))
history.push(Pages.browser(id))
}

dispatch(showOAuthProgress(true))
dispatch(removeInfiniteNotification(InfiniteMessagesIds.oAuthProgress))
dispatch(addInfiniteNotification(INFINITE_MESSAGES.SUCCESS_CREATE_DB(details, onConnect)))
dispatch(addInfiniteNotification(INFINITE_MESSAGES.SUCCESS_CREATE_DB(details, onConnect, jobName)))
dispatch(setSelectAccountDialogState(false))
} catch (_err) {
const error = _err as AxiosError
Expand Down
4 changes: 2 additions & 2 deletions redisinsight/ui/src/slices/tests/oauth/cloud.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1024,13 +1024,13 @@ describe('oauth cloud slice', () => {
const onConnect = () => {}

// Act
await store.dispatch<any>(createFreeDbSuccess(result, {}))
await store.dispatch<any>(createFreeDbSuccess(result, {}, CloudJobName.CreateFreeDatabase))

// Assert
const expectedActions = [
showOAuthProgress(true),
removeInfiniteNotification(InfiniteMessagesIds.oAuthProgress),
addInfiniteNotification(INFINITE_MESSAGES.SUCCESS_CREATE_DB({}, onConnect)),
addInfiniteNotification(INFINITE_MESSAGES.SUCCESS_CREATE_DB({}, onConnect, CloudJobName.CreateFreeDatabase)),
setSelectAccountDialogState(false),
]
expect(clearStoreActions(store.getActions())).toEqual(clearStoreActions(expectedActions))
Expand Down