React = require 'react'
{shell} = require 'electron'
classnames = require 'classnames'
{Actions} = require 'nylas-exports'
{RetinaImg} = require 'nylas-component-kit'
PageRouterStore = require './page-router-store'
OnboardingActions = require './onboarding-actions'
class WelcomePage extends React.Component
@displayName: "WelcomePage"
constructor: (@props) ->
@state =
step: 0
lastStep: 0
render: ->
OnboardingActions.closeWindow() }>
{@_renderSteps()}
{@_renderButtons()}
_renderButtons: ->
buttons = []
btnText = ""
if @state.step is 0
btnText = "Let’s get started"
else if @state.step is 1
btnText = "Continue"
else if @state.step is 2
btnText = "Get started"
buttons.push {btnText}
return buttons
_renderSteps: -> [
@_renderStep0()
@_renderStep1()
@_renderStep2()
]
_stepClass: (n) ->
obj =
"step-wrap": true
"active": @state.step is n
obj["step-#{n}-wrap"] = true
className = classnames(obj)
return className
_renderStep0: ->
Welcome to Nylas N1
{@_renderNavBubble(0)}
_renderStep1: ->
_gears: ->
gears = []
gear = "gear-large@2x.png"
for i in [0..3]
if i isnt 0 then gear = "gear-large-outer@2x.png"
gears.push
return gears
_renderStep2: ->
_open: (link) ->
shell.openExternal(link)
return
_renderNavBubble: (step=0) ->
bubbles = [0..2].map (n) =>
active = if n is step then "active" else ""
@setState step: n }>
{bubbles}
_onBack: =>
@setState(step: @state.step - 1)
_onContinue: =>
if @state.step < 2
@setState(step: @state.step + 1)
else
Actions.recordUserEvent('Welcome Page Finished', {
tokenAuthEnabled: PageRouterStore.tokenAuthEnabled(0)
})
if PageRouterStore.tokenAuthEnabled() is "no"
OnboardingActions.moveToPage("account-choose")
else
OnboardingActions.moveToPage("token-auth")
module.exports = WelcomePage