Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download
Views: 39598
1
##############################################################################
2
#
3
# CoCalc: Collaborative Calculation in the Cloud
4
#
5
# Copyright (C) 2016 -- 2017, 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
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#
19
##############################################################################
20
21
{defaults, required} = require('smc-util/misc')
22
{React, rclass, rtypes} = require('../smc-react')
23
{Alert, Button, ButtonToolbar, ButtonGroup, Input, Row, Col, Panel} = require('react-bootstrap')
24
{Icon, Tip} = require('../r_misc')
25
26
exports.SharedProjectPanel = rclass
27
displayName : "CourseEditor-SharedProject"
28
29
propTypes :
30
shared_project_id : rtypes.string
31
redux : rtypes.object.isRequired
32
name : rtypes.string.isRequired
33
34
getInitialState: ->
35
confirm_create : false
36
37
panel_header_text: ->
38
if @props.shared_project_id
39
"Shared project that everybody can fully use"
40
else
41
"Optionally create a shared project for everybody"
42
43
render: ->
44
<Row>
45
<Col md=6>
46
<Panel header={<h4><Icon name='users' /> {@panel_header_text()} </h4>}>
47
{@render_content()}
48
</Panel>
49
</Col>
50
</Row>
51
52
render_content: ->
53
if @props.shared_project_id
54
@render_has_shared_project()
55
else
56
@render_no_shared_project()
57
58
render_has_shared_project: ->
59
<div>
60
<div style={color:'#444'}>
61
<p>
62
You created a common shared project, which everybody -- students and all collaborators
63
on this project (your TAs and other instructors) -- have <b>write</b> access to. Use
64
this project for collaborative in-class labs, course-wide chat rooms, and making
65
miscellaneous materials available for
66
students to experiment with together.
67
</p>
68
<p>
69
When you created the shared project, everybody who has already created an account
70
is added as a collaborator to the project. Whenever you re-open this course,
71
any students or collaborators on the project that contains this course will be
72
added to the shared project.
73
</p>
74
</div>
75
<br/>
76
<Button onClick={@open_project}>
77
<Icon name="edit" /> Open shared project
78
</Button>
79
</div>
80
81
open_project: ->
82
@props.redux.getActions('projects').open_project(project_id:@props.shared_project_id)
83
84
render_no_shared_project: ->
85
<div>
86
<div style={color:'#444'}>
87
<p>
88
<i>Optionally</i> create a single common shared project, which everybody -- students and all collaborators
89
on this project (your TAs and other instructors) -- will have <b>write</b> access to. This can be useful
90
for collaborative in-class labs, course-wide chat rooms, and making miscellanous materials available for
91
students to experiment with together.
92
</p>
93
<p>
94
When you create the shared project, everybody who has already created an account
95
is added as a collaborator to the project. Whenever you re-open this course,
96
any students or collaborators on the project that contains this course will be
97
added to the shared project.
98
</p>
99
<p>
100
After you create the shared project, you should move the shared project to a members only server
101
or upgrade it in other ways if you want it to be more stable.
102
</p>
103
104
</div>
105
<br/>
106
<Button onClick={=>@setState(confirm_create:true)} disabled={@state.confirm_create}>
107
<Icon name="plus"/> Create shared project...
108
</Button>
109
{@render_confirm_create()}
110
</div>
111
112
render_confirm_create: ->
113
if @state.confirm_create
114
<Alert bsStyle='warning' style={marginTop:'15px'}>
115
<ButtonToolbar>
116
<Button bsStyle='warning' onClick={=>@setState(confirm_create:false);@create_shared_project()}>
117
Create shared project for everybody involved in this class
118
</Button>
119
<Button onClick={=>@setState(confirm_create:false)}>
120
Cancel
121
</Button>
122
</ButtonToolbar>
123
</Alert>
124
125
create_shared_project: ->
126
@props.redux.getActions(@props.name).create_shared_project()
127
128
exports.SharedProjectPanel.Header = rclass
129
propTypes :
130
project_exists : rtypes.bool
131
132
render: ->
133
if @props.project_exists
134
tip = "Shared project that everybody involved in this course may use."
135
else
136
tip = "Create a shared project that everybody in this course may use."
137
<Tip delayShow=1300 title="Shared Project"
138
tip={tip}>
139
<span>
140
<Icon name="users"/> Shared Project
141
</span>
142
</Tip>
143