Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 39550
1
###############################################################################
2
#
3
# CoCalc: Collaborative Calculation in the Cloud
4
#
5
# Copyright (C) 2016, Sagemath Inc.
6
#
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#
20
###############################################################################
21
22
misc = require('smc-util/misc')
23
immutable = require('immutable')
24
25
# Import redux_account, so the account store is initialized.
26
require('./redux_account')
27
28
{React, ReactDOM, rclass, rtypes, redux} = require('./smc-react')
29
{Tab, Tabs, Grid, Col, Row} = require('react-bootstrap')
30
{LandingPage} = require('./landing_page')
31
{AccountSettingsTop} = require('./r_account')
32
{BillingPageRedux} = require('./billing')
33
{UpgradesPage} = require('./r_upgrades')
34
{SupportPage} = require('./support')
35
{SSHKeysPage} = require('./account_ssh_keys')
36
{Icon} = require('./r_misc')
37
{set_url} = require('./history')
38
39
exports.AccountPage = rclass
40
displayName : 'AccountPage'
41
42
reduxProps :
43
projects :
44
project_map : rtypes.immutable.Map
45
users :
46
user_map : rtypes.immutable.Map
47
customize :
48
kucalc : rtypes.string
49
account :
50
account_id : rtypes.string
51
active_page : rtypes.string
52
strategies : rtypes.array
53
sign_up_error : rtypes.object
54
sign_in_error : rtypes.string
55
signing_in : rtypes.bool
56
signing_up : rtypes.bool
57
forgot_password_error : rtypes.string
58
forgot_password_success : rtypes.string # is this needed?
59
show_forgot_password : rtypes.bool
60
token : rtypes.bool
61
reset_key : rtypes.string
62
reset_password_error : rtypes.string
63
remember_me : rtypes.bool
64
has_remember_me : rtypes.bool
65
first_name : rtypes.string
66
last_name : rtypes.string
67
email_address : rtypes.string
68
passports : rtypes.object
69
show_sign_out : rtypes.bool
70
sign_out_error : rtypes.string
71
everywhere : rtypes.bool
72
terminal : rtypes.object
73
evaluate_key : rtypes.string
74
autosave : rtypes.number
75
font_size : rtypes.number
76
editor_settings : rtypes.object
77
other_settings : rtypes.immutable.Map
78
profile : rtypes.object
79
groups : rtypes.array
80
stripe_customer : rtypes.object
81
ssh_keys : rtypes.immutable.Map
82
83
propTypes :
84
actions : rtypes.object.isRequired
85
redux : rtypes.object.isRequired
86
87
getDefaultProps: ->
88
actions : redux.getActions('account')
89
redux : redux
90
91
handle_select: (key) ->
92
switch key
93
when 'billing'
94
@props.redux.getActions('billing')?.update_customer()
95
when 'support'
96
@props.redux.getActions('support')?.load_support_tickets()
97
@props.redux.getActions('account').set_active_tab(key)
98
@props.redux.getActions('account').push_state("/#{key}")
99
100
render_upgrades: ->
101
<UpgradesPage
102
redux = {@props.redux}
103
stripe_customer = {@props.stripe_customer}
104
project_map = {@props.project_map} />
105
106
render_ssh_keys_page: ->
107
<SSHKeysPage
108
account_id = {@props.account_id}
109
ssh_keys = {@props.ssh_keys}
110
/>
111
112
render_account_settings: ->
113
<AccountSettingsTop
114
redux = {@props.redux}
115
first_name = {@props.first_name}
116
last_name = {@props.last_name}
117
email_address = {@props.email_address}
118
passports = {@props.passports}
119
show_sign_out = {@props.show_sign_out}
120
sign_out_error = {@props.sign_out_error}
121
everywhere = {@props.everywhere}
122
terminal = {@props.terminal}
123
evaluate_key = {@props.evaluate_key}
124
autosave = {@props.autosave}
125
font_size = {@props.font_size}
126
editor_settings = {@props.editor_settings}
127
other_settings = {@props.other_settings.toJS()}
128
groups = {@props.groups} />
129
130
render_landing_page: ->
131
<LandingPage
132
redux = {redux}
133
strategies = {@props.strategies}
134
sign_up_error = {@props.sign_up_error}
135
sign_in_error = {@props.sign_in_error}
136
signing_in = {@props.signing_in}
137
signing_up = {@props.signing_up}
138
forgot_password_error = {@props.forgot_password_error}
139
forgot_password_success = {@props.forgot_password_success}
140
show_forgot_password = {@props.show_forgot_password}
141
token = {@props.token}
142
reset_key = {@props.reset_key}
143
reset_password_error = {@props.reset_password_error}
144
remember_me = {@props.remember_me}
145
has_remember_me = {@props.has_remember_me}
146
has_account = {misc.local_storage_length() > 0} />
147
148
render_commercial_tabs: ->
149
if not require('./customize').commercial
150
return null
151
v = []
152
v.push <Tab key='billing' eventKey="billing" title={<span><Icon name='money'/> Subscriptions</span>}>
153
{<BillingPageRedux /> if @props.active_page == 'billing'}
154
</Tab>
155
v.push <Tab key='upgrades' eventKey="upgrades" title={<span><Icon name='arrow-circle-up'/> Upgrades</span>}>
156
{@render_upgrades() if @props.active_page == 'upgrades'}
157
</Tab>
158
if @props.kucalc is 'yes'
159
v.push <Tab key='ssh-keys' eventKey="ssh-keys" title={<span><Icon name='key'/> SSH Keys</span>}>
160
{@render_ssh_keys_page() if @props.active_page == 'ssh-keys'}
161
</Tab>
162
v.push <Tab key='support' eventKey="support" title={<span><Icon name='medkit'/> Support</span>}>
163
{<SupportPage/> if @props.active_page == 'support'}
164
</Tab>
165
return v
166
167
render: ->
168
logged_in = @props.redux.getStore('account')?.is_logged_in()
169
<div style={overflow:'auto'}>
170
<Grid className='constrained'>
171
{@render_landing_page() if not logged_in}
172
{<Row>
173
<Col md={12}>
174
<Tabs activeKey={@props.active_page} onSelect={@handle_select} animation={false} style={paddingTop: "1em"} id="account-page-tabs">
175
<Tab key='account' eventKey="account" title={<span><Icon name='wrench'/> Account Settings</span>}>
176
{@render_account_settings() if not @props.active_page? or @props.active_page == 'account'}
177
</Tab>
178
{@render_commercial_tabs()}
179
</Tabs>
180
</Col>
181
</Row> if logged_in}
182
</Grid>
183
</div>
184
185