mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 20:44:30 +08:00
467955dc2c
commit 64938016f6ffbf366a220e7abd9af6f7a4cb478b Author: Ben Gotow <bengotow@gmail.com> Date: Sun Oct 4 16:42:38 2015 -0700 Don't allow people to double click the token check button, make requests take at least 400msec commit e548f3ee449c676a813c5630f1624963872ed6e6 Merge: 3350b91 e4b4933 Author: Ben Gotow <bengotow@gmail.com> Date: Sun Oct 4 16:39:56 2015 -0700 Merge branch 'token-auth' of github.com:nylas/N1 into token-auth # Conflicts: # internal_packages/onboarding/lib/token-auth-page.cjsx commit 3350b917449c29299fa078d59a4a5a9339fdf29b Author: Ben Gotow <bengotow@gmail.com> Date: Sun Oct 4 16:38:52 2015 -0700 Improve a few error states, adding "checking" state when checking token commit e4b49334cbf59145d9bdd955d35636f16a7c4924 Author: EthanBlackburn <ethan@nylas.com> Date: Sun Oct 4 16:21:39 2015 -0700 Correct retry behavior commit 11cd9a75b2a1ca0f4347160df93815743909ccea Author: EthanBlackburn <ethan@nylas.com> Date: Sat Oct 3 18:06:55 2015 -0700 Removed old auth token variable commit afe451cd70de528def3443d8b373fd24f4aa5cde Author: EthanBlackburn <ethan@nylas.com> Date: Sat Oct 3 16:08:12 2015 -0700 Added token auth page
100 lines
3 KiB
CoffeeScript
100 lines
3 KiB
CoffeeScript
React = require 'react/addons'
|
|
OnboardingActions = require './onboarding-actions'
|
|
ReactCSSTransitionGroup = React.addons.CSSTransitionGroup
|
|
PageRouterStore = require './page-router-store'
|
|
|
|
WelcomePage = require './welcome-page'
|
|
AccountChoosePage = require './account-choose-page'
|
|
AccountSettingsPage = require './account-settings-page'
|
|
InitialPreferencesPage = require './initial-preferences-page'
|
|
InitialPackagesPage = require './initial-packages-page'
|
|
TokenAuthPage = require './token-auth-page'
|
|
|
|
|
|
class PageRouter extends React.Component
|
|
@displayName: 'PageRouter'
|
|
@containerRequired: false
|
|
|
|
constructor: (@props) ->
|
|
@state = @_getStateFromStore()
|
|
window.OnboardingActions = OnboardingActions
|
|
|
|
_getStateFromStore: =>
|
|
page: PageRouterStore.page()
|
|
pageData: PageRouterStore.pageData()
|
|
|
|
componentDidMount: =>
|
|
@unsubscribe = PageRouterStore.listen(@_onStateChanged, @)
|
|
setTimeout(@_initializeWindowSize, 10)
|
|
|
|
componentDidUpdate: =>
|
|
setTimeout(@_updateWindowSize, 10)
|
|
|
|
_initializeWindowSize: =>
|
|
return if @_unmounted
|
|
{width, height} = React.findDOMNode(@refs.activePage).getBoundingClientRect()
|
|
atom.setSize(width, height)
|
|
atom.center()
|
|
atom.show()
|
|
|
|
_updateWindowSize: =>
|
|
return if @_unmounted
|
|
{width, height} = React.findDOMNode(@refs.activePage).getBoundingClientRect()
|
|
atom.setSizeAnimated(width, height)
|
|
|
|
_onStateChanged: =>
|
|
@setState(@_getStateFromStore())
|
|
|
|
componentWillUnmount: =>
|
|
@_unmounted = true
|
|
@unsubscribe?()
|
|
|
|
render: =>
|
|
<div className="page-frame">
|
|
{@_renderDragRegion()}
|
|
<ReactCSSTransitionGroup
|
|
transitionName="alpha-fade"
|
|
leaveTimeout={150}
|
|
enterTimeout={150}>
|
|
{@_renderCurrentPage()}
|
|
{@_renderCurrentPageGradient()}
|
|
</ReactCSSTransitionGroup>
|
|
<div className="page-background" style={background: "#f6f7f8"}/>
|
|
</div>
|
|
|
|
_renderCurrentPageGradient: =>
|
|
gradient = @state.pageData?.provider?.color
|
|
if gradient
|
|
background = "linear-gradient(to top, #f6f7f8, #{gradient})"
|
|
height = 200
|
|
else
|
|
background = "linear-gradient(to top, #f6f7f8 0%, rgba(255,255,255,0) 100%), linear-gradient(to right, #e1e58f 0%, #a8d29e 50%, #8bc9c9 100%)"
|
|
height = 330
|
|
<div className="page-gradient" key={"#{@state.page}-gradient"} style={background: background, height: height}/>
|
|
|
|
_renderCurrentPage: =>
|
|
Component = {
|
|
"welcome": WelcomePage
|
|
"token-auth": TokenAuthPage
|
|
"account-choose": AccountChoosePage
|
|
"account-settings": AccountSettingsPage
|
|
"initial-preferences": InitialPreferencesPage
|
|
"initial-packages": InitialPackagesPage
|
|
}[@state.page]
|
|
|
|
<div key={@state.page} className="page-container">
|
|
<Component pageData={@state.pageData} ref="activePage" onResize={@_updateWindowSize}/>
|
|
</div>
|
|
|
|
_renderDragRegion: ->
|
|
styles =
|
|
top:0
|
|
left: 26
|
|
right:0
|
|
height: 27
|
|
zIndex:100
|
|
position: 'absolute'
|
|
"WebkitAppRegion": "drag"
|
|
<div className="dragRegion" style={styles}></div>
|
|
|
|
module.exports = PageRouter
|