@@ -12,14 +12,15 @@ import { shell } from '../../lib/dispatcher/app-shell'
1212import { CouponInput } from './coupon-input'
1313import { LinkButton } from '../lib/link-button'
1414import { CallToAction } from '../lib/call-to-action'
15+ import { PremiumType } from '../../lib/app-state'
1516
1617interface IPremiumUpsellProps {
1718 /** A function called when the dialog is dismissed. */
1819 readonly onDismissed : ( ) => void
1920 readonly dispatcher : Dispatcher
2021 readonly user ?: Account
2122 readonly isUnlockingKactusFullAccess : boolean
22- readonly enterprise : boolean
23+ readonly kind : PremiumType | 'choice'
2324 readonly retryAction ?: RetryAction
2425}
2526
@@ -28,10 +29,42 @@ interface IPremiumUpsellState {
2829 readonly showingCheckout : boolean
2930 readonly loadingCheckout : boolean
3031 readonly coupon : string
31- readonly plan : string
3232 readonly couponState : IAPICoupon | 'loading' | null
33+ readonly choice : PremiumType
3334}
3435
36+ const EnterpriseCopy = ( ) =>
37+ < ul >
38+ < li > Unlimited public repositories</ li >
39+ < li >
40+ No locked-in commitment: you can always generate the sketch files to
41+ switch back
42+ </ li >
43+ < li >
44+ < strong > Unlimited private repositories</ strong >
45+ </ li >
46+ < li >
47+ < strong > Support single sign-on and on-premises deployment</ strong >
48+ </ li >
49+ < li >
50+ < strong >
51+ Support any git server (BitBucket, Gitlab, self-hosted, etc.)
52+ </ strong >
53+ </ li >
54+ </ ul >
55+
56+ const PremiumCopy = ( ) =>
57+ < ul >
58+ < li > Unlimited public repositories</ li >
59+ < li >
60+ No locked-in commitment: you can always generate the sketch files to
61+ switch back
62+ </ li >
63+ < li >
64+ < strong > Unlimited private repositories</ strong >
65+ </ li >
66+ </ ul >
67+
3568export class PremiumUpsell extends React . Component <
3669 IPremiumUpsellProps ,
3770 IPremiumUpsellState
@@ -45,8 +78,8 @@ export class PremiumUpsell extends React.Component<
4578 this . state = {
4679 showingCheckout : false ,
4780 loadingCheckout : false ,
81+ choice : this . props . kind !== 'choice' ? this . props . kind : 'premium' ,
4882 coupon : '' ,
49- plan : 'kactus-1-month' ,
5083 couponState : null ,
5184 }
5285 }
@@ -83,7 +116,7 @@ export class PremiumUpsell extends React.Component<
83116 }
84117 await this . props . dispatcher . unlockKactus ( this . props . user , token . id , {
85118 email : token . email ,
86- enterprise : this . props . enterprise ,
119+ enterprise : this . state . choice === ' enterprise' ,
87120 coupon : this . state . coupon !== '' ? this . state . coupon : undefined ,
88121 } )
89122
@@ -152,8 +185,10 @@ export class PremiumUpsell extends React.Component<
152185 < div >
153186 < p >
154187 Hey! This feature is only available in the{ ' ' }
155- { this . props . enterprise ? 'enterprise' : 'full access' } version
156- of Kactus.
188+ { this . state . choice === 'enterprise'
189+ ? 'enterprise'
190+ : 'full access' } { ' ' }
191+ version of Kactus.
157192 </ p >
158193 < p >
159194 You need to login to Kactus using GitHub before unlocking it.
@@ -172,8 +207,9 @@ export class PremiumUpsell extends React.Component<
172207 }
173208
174209 if (
175- ( ! this . props . enterprise && this . props . user . unlockedKactus ) ||
176- ( this . props . enterprise && this . props . user . unlockedEnterpriseKactus )
210+ ( this . state . choice === 'premium' && this . props . user . unlockedKactus ) ||
211+ ( this . state . choice === 'enterprise' &&
212+ this . props . user . unlockedEnterpriseKactus )
177213 ) {
178214 return (
179215 < Dialog
@@ -186,67 +222,37 @@ export class PremiumUpsell extends React.Component<
186222 )
187223 }
188224
189- const copy = this . props . enterprise
190- ? < div >
191- < p >
192- Hey! This feature is only available in the enterprise version of
193- Kactus.
194- </ p >
195- < ul >
196- < li > Unlimited public repositories</ li >
197- < li >
198- No locked-in commitment: you can always generate the sketch files
199- to switch back
200- </ li >
201- < li >
202- < strong > Unlimited private repositories</ strong >
203- </ li >
204- < li >
205- < strong > Support single sign-on and on-premises deployment</ strong >
206- </ li >
207- < li >
208- < strong >
209- Support any git server (BitBucket, Gitlab, self-hosted, etc.)
210- </ strong >
211- </ li >
212- </ ul >
213- < p >
214- More information available{ ' ' }
215- < LinkButton onClick = { this . onExternalLink } > here</ LinkButton > .
216- </ p >
217- < CouponInput
218- couponState = { couponState }
219- coupon = { coupon }
220- onValueChanged = { this . onCouponChange }
221- />
222- </ div >
223- : < div >
224- < p >
225- Hey! This feature is only available in the full access version of
226- Kactus.
227- </ p >
228- < ul >
229- < li > Unlimited public repositories</ li >
230- < li >
231- No locked-in commitment: you can always generate the sketch files
232- to switch back
233- </ li >
234- < li >
235- < strong > Unlimited private repositories</ strong >
236- </ li >
237- </ ul >
238- < p >
239- More information available{ ' ' }
240- < LinkButton onClick = { this . onExternalLink } > here</ LinkButton > .
241- </ p >
242- < CouponInput
243- couponState = { couponState }
244- coupon = { coupon }
245- onValueChanged = { this . onCouponChange }
246- />
247- </ div >
225+ const copy =
226+ this . props . kind === 'choice'
227+ ? < div className = "choices" >
228+ < div
229+ className = {
230+ 'plan' + ( this . state . choice === 'premium' ? ' selected' : '' )
231+ }
232+ onClick = { this . selectPremiumPlan }
233+ >
234+ < h2 > Premium</ h2 >
235+ < h3 > $4.99</ h3 >
236+ < h4 > per month</ h4 >
237+ < PremiumCopy />
238+ </ div >
239+ < div
240+ className = {
241+ 'plan' + ( this . state . choice === 'enterprise' ? ' selected' : '' )
242+ }
243+ onClick = { this . selectEnterprisePlan }
244+ >
245+ < h2 > Enterprise</ h2 >
246+ < h3 > $11.99</ h3 >
247+ < h4 > per month</ h4 >
248+ < EnterpriseCopy />
249+ </ div >
250+ </ div >
251+ : this . state . choice === 'enterprise'
252+ ? < EnterpriseCopy />
253+ : < PremiumCopy />
248254
249- let price = this . props . enterprise ? 11.99 : 4.99
255+ let price = this . state . choice === ' enterprise' ? 11.99 : 4.99
250256 if ( couponState && couponState !== 'loading' ) {
251257 if ( couponState . percent_off ) {
252258 price = price * ( 100 - couponState . percent_off ) / 100
@@ -263,7 +269,7 @@ export class PremiumUpsell extends React.Component<
263269 onLoaded = { this . finishedLoadingCheckout }
264270 onToken = { this . onToken }
265271 user = { this . props . user }
266- enterprise = { this . props . enterprise }
272+ enterprise = { this . state . choice === ' enterprise' }
267273 price = { price }
268274 /> }
269275 { ! showingCheckout &&
@@ -276,6 +282,16 @@ export class PremiumUpsell extends React.Component<
276282 >
277283 < DialogContent >
278284 { copy }
285+ < p >
286+ More information available{ ' ' }
287+ < LinkButton onClick = { this . onExternalLink } > here</ LinkButton > .
288+ </ p >
289+ { this . props . kind === 'choice' &&
290+ < CouponInput
291+ couponState = { couponState }
292+ coupon = { coupon }
293+ onValueChanged = { this . onCouponChange }
294+ /> }
279295 </ DialogContent >
280296
281297 < DialogFooter >
@@ -331,4 +347,16 @@ export class PremiumUpsell extends React.Component<
331347 private signInEnterprise = ( ) => {
332348 this . props . dispatcher . showEnterpriseSignInDialog ( this . props . retryAction )
333349 }
350+
351+ private selectPremiumPlan = ( ) => {
352+ this . setState ( {
353+ choice : 'premium' ,
354+ } )
355+ }
356+
357+ private selectEnterprisePlan = ( ) => {
358+ this . setState ( {
359+ choice : 'enterprise' ,
360+ } )
361+ }
334362}
0 commit comments