Skip to content

Commit f22039b

Browse files
Merge pull request #4171 from RedisInsight/fe/feature/RI-6338
#RI-6338 - update add database form
2 parents 6fc015e + b8ad2e2 commit f22039b

File tree

29 files changed

+817
-222
lines changed

29 files changed

+817
-222
lines changed

redisinsight/ui/src/components/oauth/oauth-sso/oauth-autodiscovery/OAuthAutodiscovery.tsx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,22 @@ import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
1414

1515
import { Pages } from 'uiSrc/constants'
1616
import OAuthForm from 'uiSrc/components/oauth/shared/oauth-form'
17+
18+
import CloudIcon from 'uiSrc/assets/img/oauth/cloud_centered.svg?react'
19+
20+
import { OAuthSsoHandlerDialog } from 'uiSrc/components'
21+
import { getUtmExternalLink } from 'uiSrc/utils/links'
22+
import { EXTERNAL_LINKS } from 'uiSrc/constants/links'
1723
import styles from './styles.module.scss'
1824

1925
export interface Props {
2026
inline?: boolean
2127
source?: OAuthSocialSource
28+
onClose?: () => void
2229
}
2330

2431
const OAuthAutodiscovery = (props: Props) => {
25-
const { inline, source = OAuthSocialSource.Autodiscovery } = props
32+
const { inline, source = OAuthSocialSource.Autodiscovery, onClose } = props
2633
const { data } = useSelector(oauthCloudUserSelector)
2734

2835
const [isDiscoverDisabled, setIsDiscoverDisabled] = useState(false)
@@ -94,6 +101,32 @@ const OAuthAutodiscovery = (props: Props) => {
94101
})
95102
}
96103

104+
const CreateFreeDb = () => (
105+
<div className={styles.createDbSection}>
106+
<div className={styles.createDbTitle}><CloudIcon /><span>Start FREE with Redis Cloud</span></div>
107+
<OAuthSsoHandlerDialog>
108+
{(ssoCloudHandlerClick) => (
109+
<EuiButton
110+
fill
111+
color="secondary"
112+
size="s"
113+
href={getUtmExternalLink(EXTERNAL_LINKS.tryFree, { campaign: '' })}
114+
target="_blank"
115+
onClick={(e: React.MouseEvent) => {
116+
ssoCloudHandlerClick(e, {
117+
source: OAuthSocialSource.DiscoveryForm,
118+
action: OAuthSocialAction.Create
119+
})
120+
onClose?.()
121+
}}
122+
>
123+
Quick start
124+
</EuiButton>
125+
)}
126+
</OAuthSsoHandlerDialog>
127+
</div>
128+
)
129+
97130
return (
98131
<div
99132
className={styles.container}
@@ -111,6 +144,8 @@ const OAuthAutodiscovery = (props: Props) => {
111144
Discover subscriptions and add your databases.
112145
A new Redis Cloud account will be created for you if you don’t have one.
113146
</EuiText>
147+
<EuiSpacer size="m" />
148+
<CreateFreeDb />
114149
<EuiSpacer size="xl" />
115150
<EuiText>Get started with</EuiText>
116151
<EuiTitle className={styles.title} size="l"><h3>Redis Cloud account</h3></EuiTitle>

redisinsight/ui/src/components/oauth/oauth-sso/oauth-autodiscovery/styles.module.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@
5555
font-size: 12px !important;
5656
}
5757
}
58+
59+
.createDbSection {
60+
display: flex;
61+
align-items: center;
62+
justify-content: space-between;
63+
width: 100%;
64+
65+
border: 1px solid var(--controlsBorderColor);
66+
border-radius: 8px;
67+
padding: 8px 16px;
68+
69+
.createDbTitle {
70+
display: flex;
71+
align-items: center;
72+
73+
> svg {
74+
margin-right: 8px;
75+
}
76+
}
77+
}
5878
}
5979

6080
.withAdvantagesWrapper {

redisinsight/ui/src/constants/links.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const UTM_CAMPAINGS: Record<any, string> = {
2424
[OAuthSocialSource.Workbench]: 'redisinsight_workbench',
2525
[CloudSsoUtmCampaign.BrowserFilter]: 'browser_filter',
2626
[OAuthSocialSource.EmptyDatabasesList]: 'empty_db_list',
27+
[OAuthSocialSource.AddDbForm]: 'add_db_form',
2728
PubSub: 'pub_sub',
2829
Main: 'main',
2930
}

redisinsight/ui/src/contexts/ModalTitleProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Nullable } from 'uiSrc/utils'
33

44
interface ModalHeaderContextType {
55
modalHeader: Nullable<React.ReactNode>
6-
setModalHeader: (content: Nullable<React.ReactNode>) => void
6+
setModalHeader: (content: Nullable<React.ReactNode>, withBack?: boolean) => void
77
}
88

99
// Create a context

redisinsight/ui/src/pages/home/HomePage.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ enum OpenDialogName {
5050

5151
const HomePage = () => {
5252
const [openDialog, setOpenDialog] = useState<Nullable<OpenDialogName>>(null)
53-
const initialDbTypeRef = useRef<AddDbType>(AddDbType.cloud)
5453

5554
const dispatch = useDispatch()
5655

@@ -176,7 +175,6 @@ const HomePage = () => {
176175
}
177176

178177
const handleAddInstance = (addDbType = AddDbType.manual) => {
179-
initialDbTypeRef.current = addDbType
180178
setOpenDialog(OpenDialogName.AddDatabase)
181179
dispatch(setEditedInstance(null))
182180
}
@@ -226,7 +224,6 @@ const HomePage = () => {
226224
: handleClose
227225
}
228226
onDbEdited={onDbEdited}
229-
initConnectionType={initialDbTypeRef.current}
230227
/>
231228
<div key="homePage" className="homePage">
232229
{(!isInstanceExists && !loading && !loadingChanging ? (

redisinsight/ui/src/pages/home/components/add-database-flow-tabs/AddDatabaseFlowTabs.spec.tsx

Lines changed: 0 additions & 20 deletions
This file was deleted.

redisinsight/ui/src/pages/home/components/add-database-flow-tabs/AddDatabaseFlowTabs.tsx

Lines changed: 0 additions & 46 deletions
This file was deleted.

redisinsight/ui/src/pages/home/components/add-database-flow-tabs/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

redisinsight/ui/src/pages/home/components/add-database-flow-tabs/styles.module.scss

Lines changed: 0 additions & 10 deletions
This file was deleted.

redisinsight/ui/src/pages/home/components/cloud-connection/CloudConnectionFormWrapper.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import React, { useEffect } from 'react'
22
import { useDispatch, useSelector } from 'react-redux'
33
import { useHistory } from 'react-router-dom'
44

5+
import { EuiTitle } from '@elastic/eui'
56
import { Pages } from 'uiSrc/constants'
67
import { cloudSelector, fetchSubscriptionsRedisCloud, setSSOFlow } from 'uiSrc/slices/instances/cloud'
78
import { resetErrors } from 'uiSrc/slices/app/notifications'
89
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
910

11+
import { useModalHeader } from 'uiSrc/contexts/ModalTitleProvider'
1012
import CloudConnectionForm from './cloud-connection-form'
1113

1214
export interface Props {
@@ -24,12 +26,19 @@ const CloudConnectionFormWrapper = ({ onClose }: Props) => {
2426
const history = useHistory()
2527
const { loading, credentials } = useSelector(cloudSelector)
2628

27-
useEffect(
28-
() => () => {
29+
const { setModalHeader } = useModalHeader()
30+
31+
useEffect(() => {
32+
setModalHeader(
33+
<EuiTitle size="s"><h4>Discover Cloud databases</h4></EuiTitle>,
34+
true
35+
)
36+
37+
return () => {
38+
setModalHeader(null)
2939
dispatch(resetErrors())
30-
},
31-
[]
32-
)
40+
}
41+
}, [])
3342

3443
const formSubmit = (credentials: ICloudConnectionSubmit) => {
3544
sendEventTelemetry({

0 commit comments

Comments
 (0)