Skip to content

Commit 6d8d3be

Browse files
committed
fix(deployment-settings): add updater file, gbfs, and sort sourceTypes
1 parent 2e50fef commit 6d8d3be

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

lib/manager/components/Updater.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import React, {PropTypes, Component} from 'react'
2+
import {Button, Col, Panel, Glyphicon, Form, FormGroup, ControlLabel, FormControl} from 'react-bootstrap'
3+
4+
import {getMessage, getComponentMessages} from '../../common/util/config'
5+
import {UPDATER_FIELDS} from '../util/deployment'
6+
7+
export default class Updater extends Component {
8+
static propTypes = {
9+
onChange: PropTypes.func,
10+
onRemove: PropTypes.func,
11+
updater: PropTypes.object
12+
}
13+
14+
_onChange = (evt) => this.props.onChange(evt, this.props.index)
15+
16+
// _onChangeNumber = (evt) => this.props.onChange(this.props.index, {[evt.target.name]: evt.target.value})
17+
18+
_onRemove = () => this.props.onRemove(this.props.index)
19+
20+
render () {
21+
const messages = getComponentMessages('ProjectSettings')
22+
const {updater} = this.props
23+
return (
24+
<Panel
25+
header={`${updater.type || '[type]'} - ${updater.url || '[url]'}`}
26+
defaultExpanded={!updater.type}
27+
collapsible>
28+
<Form>
29+
<Button
30+
bsSize='xsmall'
31+
bsStyle='danger'
32+
className='pull-right'
33+
onClick={this._onRemove}>
34+
Remove <Glyphicon glyph='remove' />
35+
</Button>
36+
{UPDATER_FIELDS.map((f, i) => {
37+
const fieldName = f.name.split('.').slice(-1)[0]
38+
return (
39+
<Col key={i} xs={f.width || 6}>
40+
<FormGroup>
41+
<ControlLabel>{getMessage(messages, `deployment.${f.name}`)}</ControlLabel>
42+
<FormControl
43+
value={updater[fieldName]}
44+
{...f}
45+
name={f.name}
46+
children={f.children
47+
? f.children.sort((a, b) => {
48+
if (a.value < b.value) return -1
49+
if (a.value > b.value) return 1
50+
return 0
51+
}).map((o, i) => (
52+
<option key={i} {...o} />
53+
))
54+
: undefined
55+
}
56+
onChange={this._onChange} />
57+
</FormGroup>
58+
</Col>
59+
)
60+
})}
61+
</Form>
62+
</Panel>
63+
)
64+
}
65+
}

lib/manager/util/deployment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export const UPDATER_FIELDS = [
129129
{value: 'sf-bay-area', children: 'sf-bay-area'},
130130
{value: 'share-bike', children: 'share-bike'},
131131
{value: 'kml-placemarks', children: 'kml-placemarks'},
132+
{value: 'gbfs', children: 'gbfs'},
132133
{value: 'gtfs-file', children: 'gtfs-file'},
133134
{value: 'gtfs-http', children: 'gtfs-http'}
134135
]

0 commit comments

Comments
 (0)