@@ -65,15 +65,29 @@ export default class FeedSourceSettings extends Component {
65
65
project,
66
66
user
67
67
} = this . props
68
+ const {
69
+ name,
70
+ url
71
+ } = this . state
68
72
// const messages = getComponentMessages('FeedSourceSettings')
69
73
const disabled = ! user . permissions . hasFeedPermission ( project . organizationId , project . id , feedSource . id , 'manage-feed' )
70
74
const isProjectAdmin = user . permissions . isProjectAdmin ( project . id , project . organizationId )
71
75
// const editGtfsDisabled = !user.permissions.hasFeedPermission(project.organizationId, project.id, feedSource.id, 'edit-gtfs')
72
76
const autoFetchFeed = feedSource . retrievalMethod === 'FETCHED_AUTOMATICALLY'
73
77
const resourceType = activeComponent === 'settings' && activeSubComponent && activeSubComponent . toUpperCase ( )
78
+ if ( disabled ) {
79
+ return (
80
+ < Row >
81
+ < Col xs = { 6 } mdOffset = { 3 } >
82
+ < p className = 'lead text-center' > < strong > Warning!</ strong > You do not have permission to edit details for this feed source.</ p >
83
+ </ Col >
84
+ </ Row >
85
+ )
86
+ }
74
87
return (
75
88
< Row >
76
89
< Col xs = { 3 } >
90
+ { /* Side panel */ }
77
91
< Panel >
78
92
< ListGroup fill >
79
93
< LinkContainer
@@ -98,19 +112,21 @@ export default class FeedSourceSettings extends Component {
98
112
< Col xs = { 6 } />
99
113
{ ! resourceType
100
114
? < Col xs = { 7 } >
115
+ { /* Settings */ }
101
116
< Panel header = { < h3 > Settings</ h3 > } >
102
117
< ListGroup fill >
103
118
< ListGroupItem >
104
119
< FormGroup >
105
120
< ControlLabel > Feed source name</ ControlLabel >
106
121
< InputGroup >
107
122
< FormControl
108
- value = { typeof this . state . name !== 'undefined' ? this . state . name : feedSource . name }
123
+ value = { name || feedSource . name }
109
124
name = { 'name' }
125
+ disabled = { disabled }
110
126
onChange = { this . _onChange } />
111
127
< InputGroup . Button >
112
128
< Button
113
- disabled = { ! this . state . name || this . state . name === feedSource . name } // disable if no change or no value.
129
+ disabled = { disabled || ! name || name === feedSource . name } // disable if no change or no value.
114
130
onClick = { this . _onNameSaved } >
115
131
Rename
116
132
</ Button >
@@ -137,12 +153,13 @@ export default class FeedSourceSettings extends Component {
137
153
< ControlLabel > Feed source fetch URL</ ControlLabel >
138
154
< InputGroup >
139
155
< FormControl
140
- value = { typeof this . state . url !== 'undefined' ? this . state . url : feedSource . url || '' }
156
+ value = { url || feedSource . url }
141
157
name = { 'url' }
158
+ disabled = { disabled }
142
159
onChange = { this . _onChange } />
143
160
< InputGroup . Button >
144
161
< Button
145
- disabled = { this . state . url === feedSource . url } // disable if no change.
162
+ disabled = { disabled || url === feedSource . url } // disable if no change.
146
163
onClick = { this . _onSaveUrl } >
147
164
Change URL
148
165
</ Button >
@@ -154,6 +171,7 @@ export default class FeedSourceSettings extends Component {
154
171
< FormGroup >
155
172
< Checkbox
156
173
checked = { autoFetchFeed }
174
+ disabled = { disabled }
157
175
onChange = { this . _onToggleAutoFetch }
158
176
bsStyle = 'danger' >
159
177
< strong > Auto fetch feed source</ strong >
@@ -168,6 +186,7 @@ export default class FeedSourceSettings extends Component {
168
186
< ListGroupItem >
169
187
< Button
170
188
onClick = { this . _onTogglePublic }
189
+ disabled = { disabled }
171
190
className = 'pull-right' >
172
191
Make { feedSource . isPublic ? 'private' : 'public' }
173
192
</ Button >
@@ -178,6 +197,7 @@ export default class FeedSourceSettings extends Component {
178
197
< Button
179
198
onClick = { confirmDeleteFeedSource }
180
199
className = 'pull-right'
200
+ disabled = { disabled }
181
201
bsStyle = 'danger' >
182
202
< Icon type = 'trash' /> Delete feed source
183
203
</ Button >
0 commit comments