@@ -28,7 +28,7 @@ import { INFINITE_MESSAGES } from 'uiSrc/components/notifications/components'
28
28
import { CloudJobStep } from 'uiSrc/electron/constants'
29
29
import { appFeatureFlagsFeaturesSelector } from 'uiSrc/slices/app/features'
30
30
import { FeatureFlags , Theme } from 'uiSrc/constants'
31
- import { OAuthSocialSource , TFRegion } from 'uiSrc/slices/interfaces'
31
+ import { OAuthSocialSource , Region } from 'uiSrc/slices/interfaces'
32
32
import { ThemeContext } from 'uiSrc/contexts/themeContext'
33
33
import TriggeredFunctionsDarkSVG from 'uiSrc/assets/img/sidebar/gears.svg'
34
34
import TriggeredFunctionsLightSVG from 'uiSrc/assets/img/sidebar/gears_active.svg'
@@ -37,9 +37,10 @@ import { CloudSubscriptionPlanResponse } from 'apiSrc/modules/cloud/subscription
37
37
import { OAuthProvider , OAuthProviders } from './constants'
38
38
import styles from './styles.module.scss'
39
39
40
- export const DEFAULT_REGION = 'us-east-1'
40
+ export const DEFAULT_REGIONS = [ 'us-east-2' , 'asia-northeast-1' ]
41
41
export const DEFAULT_PROVIDER = OAuthProvider . AWS
42
- const getTFProviderRegions = ( regions : TFRegion [ ] , provider : OAuthProvider ) =>
42
+
43
+ const getProviderRegions = ( regions : Region [ ] , provider : OAuthProvider ) =>
43
44
( find ( regions , { provider } ) || { } ) . regions || [ ]
44
45
45
46
const OAuthSelectPlan = ( ) => {
@@ -48,38 +49,43 @@ const OAuthSelectPlan = () => {
48
49
const { source } = useSelector ( oauthCloudSelector )
49
50
const { [ FeatureFlags . cloudSso ] : cloudSsoFeature = { } } = useSelector ( appFeatureFlagsFeaturesSelector )
50
51
51
- const tfRegions : TFRegion [ ] = get ( cloudSsoFeature , 'data.selectPlan.components.triggersAndFunctions' , [ ] )
52
+ const tfRegions : Region [ ] = get ( cloudSsoFeature , 'data.selectPlan.components.triggersAndFunctions' , [ ] )
53
+ const rsRegions : Region [ ] = get ( cloudSsoFeature , 'data.selectPlan.components.redisStackPreview' , [ ] )
52
54
53
55
const [ plans , setPlans ] = useState ( plansInit || [ ] )
54
56
const [ planIdSelected , setPlanIdSelected ] = useState ( '' )
55
57
const [ providerSelected , setProviderSelected ] = useState < OAuthProvider > ( DEFAULT_PROVIDER )
56
- const [ tfProviderRegions , setTfProviderRegions ] = useState ( getTFProviderRegions ( tfRegions , providerSelected ) )
58
+ const [ tfProviderRegions , setTfProviderRegions ] = useState ( getProviderRegions ( tfRegions , providerSelected ) )
59
+ const [ rsProviderRegions , setRsProviderRegions ] = useState ( getProviderRegions ( rsRegions , providerSelected ) )
57
60
58
61
const dispatch = useDispatch ( )
59
62
60
63
const isTFSource = source ?. endsWith ( OAuthSocialSource . TriggersAndFunctions )
61
64
62
65
useEffect ( ( ) => {
63
- setTfProviderRegions ( getTFProviderRegions ( tfRegions , providerSelected ) )
64
- } , [ providerSelected ] )
66
+ setTfProviderRegions ( getProviderRegions ( tfRegions , providerSelected ) )
67
+ setRsProviderRegions ( getProviderRegions ( rsRegions , providerSelected ) )
68
+ } , [ providerSelected , plansInit ] )
65
69
66
70
useEffect ( ( ) => {
67
71
if ( ! plansInit . length ) {
68
72
return
69
73
}
70
74
71
- const defaultRegions = isTFSource ? tfProviderRegions || [ DEFAULT_REGION ] : [ DEFAULT_REGION ]
75
+ const defaultRegions = isTFSource
76
+ ? [ tfProviderRegions , DEFAULT_REGIONS ] . find ( ( arr ) => arr ?. length )
77
+ : DEFAULT_REGIONS
72
78
73
79
const filteredPlans = filter ( plansInit , { provider : providerSelected } )
74
80
. sort ( ( a , b ) => ( a ?. details ?. displayOrder || 0 ) - ( b ?. details ?. displayOrder || 0 ) )
75
81
76
82
const defaultPlan = filteredPlans . find ( ( { region = '' } ) => defaultRegions ?. includes ( region ) )
77
-
78
- const planId = ( defaultPlan || first ( filteredPlans ) || { } ) . id ?. toString ( ) || ''
83
+ const rsPreviewPlan = filteredPlans . find ( ( { region = '' } ) => rsProviderRegions ?. includes ( region ) )
84
+ const planId = ( defaultPlan || rsPreviewPlan || first ( filteredPlans ) || { } ) . id ?. toString ( ) || ''
79
85
80
86
setPlans ( filteredPlans )
81
87
setPlanIdSelected ( planId )
82
- } , [ isTFSource , plansInit , providerSelected , tfProviderRegions ] )
88
+ } , [ isTFSource , plansInit , providerSelected , tfProviderRegions , rsProviderRegions ] )
83
89
84
90
const handleOnClose = useCallback ( ( ) => {
85
91
sendEventTelemetry ( {
@@ -96,11 +102,15 @@ const OAuthSelectPlan = () => {
96
102
const getOptionDisplay = ( item : CloudSubscriptionPlanResponse ) => {
97
103
const { region = '' , details : { countryName = '' , cityName = '' } , provider } = item
98
104
const tfProviderRegions : string [ ] = find ( tfRegions , { provider } ) ?. regions || [ ]
105
+ const rsProviderRegions : string [ ] = find ( rsRegions , { provider } ) ?. regions || [ ]
99
106
100
107
return (
101
- < EuiText color = "subdued" size = "s" >
108
+ < EuiText color = "subdued" size = "s" data-testid = { `option- ${ region } ` } >
102
109
{ `${ countryName } (${ cityName } )` }
103
110
< EuiTextColor className = { styles . regionName } > { region } </ EuiTextColor >
111
+ { rsProviderRegions ?. includes ( region ) && (
112
+ < EuiTextColor className = { styles . rspreview } data-testid = { `rs-text-${ region } ` } > (Redis 7.2)</ EuiTextColor >
113
+ ) }
104
114
{ tfProviderRegions ?. includes ( region ) && (
105
115
< EuiToolTip
106
116
content = "Triggers and functions are available in this region"
@@ -156,7 +166,7 @@ const OAuthSelectPlan = () => {
156
166
</ EuiTitle >
157
167
< section className = { styles . providers } >
158
168
{ OAuthProviders . map ( ( { icon, id, label } ) => (
159
- < div className = { styles . provider } >
169
+ < div className = { styles . provider } key = { id } >
160
170
{ id === providerSelected
161
171
&& < div className = { cx ( styles . providerActiveIcon ) } > < EuiIcon type = "check" /> </ div > }
162
172
< EuiButton
0 commit comments