forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsageRightsSelectBox.js
More file actions
150 lines (141 loc) · 4.72 KB
/
Copy pathUsageRightsSelectBox.js
File metadata and controls
150 lines (141 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* Copyright (C) 2015 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react'
import I18n from 'i18n!react_files'
import UsageRightsSelectBox from 'compiled/react_files/components/UsageRightsSelectBox'
var CONTENT_OPTIONS = [{
display: I18n.t('Choose usage rights...'),
value: 'choose'
}, {
display: I18n.t('I hold the copyright'),
value: 'own_copyright'
}, {
display: I18n.t('I have obtained permission to use this file.'),
value: 'used_by_permission'
}, {
display: I18n.t('The material is in the public domain'),
value: 'public_domain'
}, {
display: I18n.t('The material is subject to fair use exception'),
value: 'fair_use'
}, {
display: I18n.t('The material is licensed under Creative Commons'),
value: 'creative_commons'
}
];
UsageRightsSelectBox.renderContentOptions = function () {
return CONTENT_OPTIONS.map((contentOption) => {
return (<option key={contentOption.value} value={contentOption.value}>{contentOption.display}</option>);
});
};
UsageRightsSelectBox.renderCreativeCommonsOptions = function () {
var onlyCC = this.state.licenseOptions.filter((license) => {
return license.id.indexOf('cc') === 0;
});
return onlyCC.map((license) => {
return (<option key={license.id} value={license.id}>{license.name}</option>);
});
};
UsageRightsSelectBox.renderShowCreativeCommonsOptions = function () {
var renderShowCreativeCommonsOptions = (
<div className='control-group'>
<label
className='control-label'
htmlFor='creativeCommonsSelection'
>
{I18n.t('Creative Commons License:')}
</label>
<div className='control'>
<select
id='creativeCommonsSelection'
className='UsageRightsSelectBox__creativeCommons'
ref='creativeCommons'
defaultValue={this.props.cc_value}
>
{this.renderCreativeCommonsOptions()}
</select>
</div>
</div>
);
return this.state.showCreativeCommonsOptions ? renderShowCreativeCommonsOptions : null;
};
UsageRightsSelectBox.renderShowMessage = function () {
var renderShowMessage = (
<div
ref='showMessageAlert'
className='alert'
>
<span>
<i className='icon-warning' ></i>
<span style={{paddingLeft: '10px'}}>
{I18n.t("If you do not select usage rights now, this file will be unpublished after it's uploaded.")}
</span>
</span>
</div>
);
return this.state.showMessage ? renderShowMessage : null;
};
UsageRightsSelectBox.render = function () {
return (
<div
className='UsageRightsSelectBox__container'
>
<div className='control-group'>
<label
className='control-label'
htmlFor='usageRightSelector'
>
{I18n.t('Usage Right:')}
</label>
<div className='controls'>
<select
id='usageRightSelector'
className='UsageRightsSelectBox__select'
onChange={this.handleChange}
onKeyUp={this.handleChooseKeyPress}
ref='usageRightSelection'
value={this.state.usageRightSelectionValue}
>
{this.renderContentOptions()}
</select>
</div>
</div>
{this.renderShowCreativeCommonsOptions()}
<div className='control-group'>
<label
className='control-label'
htmlFor='copyrightHolder'
>
{I18n.t('Copyright Holder:')}
</label>
<div className='controls'>
<input
id='copyrightHolder'
type='text'
ref='copyright'
defaultValue={this.props.copyright && this.props.copyright}
placeholder={I18n.t('(c) 2001 Acme Inc.')}
>
</input>
</div>
</div>
{this.renderShowMessage()}
</div>
);
};
export default React.createClass(UsageRightsSelectBox)