Skip to content

Commit 2876301

Browse files
committedOct 25, 2021
feat(pelias): move webhook URL to project
1 parent 84f671a commit 2876301

File tree

9 files changed

+137
-150
lines changed

9 files changed

+137
-150
lines changed
 

‎__tests__/test-utils/mock-data/manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export function makeMockDeployment (
6262
tripPlannerVersion: 'OTP_1',
6363
peliasUpdate: null,
6464
peliasResetDb: null,
65-
peliasWebhookUrl: null,
6665
peliasCsvFiles: [],
6766
user: null
6867
}
@@ -94,6 +93,7 @@ export const mockProject = {
9493
organizationId: null,
9594
otpServers: [],
9695
pinnedDeploymentId: null,
96+
peliasWebhookUrl: null,
9797
routerConfig: {
9898
carDropoffTime: null,
9999
numItineraries: null,

‎lib/manager/actions/__tests__/__snapshots__/projects.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ Object {
117117
"peliasCsvFiles": Array [],
118118
"peliasResetDb": null,
119119
"peliasUpdate": null,
120-
"peliasWebhookUrl": null,
121120
"pinnedfeedVersionIds": Array [],
122121
"projectBounds": Object {
123122
"east": 0,
@@ -185,6 +184,7 @@ Object {
185184
"name": "mock-project-with-deployments",
186185
"organizationId": null,
187186
"otpServers": Array [],
187+
"peliasWebhookUrl": null,
188188
"pinnedDeploymentId": null,
189189
"routerConfig": Object {
190190
"carDropoffTime": null,

‎lib/manager/components/ProjectSettingsForm.js

Lines changed: 76 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ type ProjectModel = {
4040
bounds?: Bounds,
4141
defaultTimeZone?: string,
4242
id?: string,
43-
name?: string
43+
name?: string,
44+
peliasWebhookUrl?: string
4445
}
4546

4647
type Props = {
@@ -58,7 +59,8 @@ type State = {
5859
validation: {
5960
bounds: boolean,
6061
defaultLocation: boolean,
61-
name: boolean
62+
name: boolean,
63+
webhookUrl: boolean
6264
}
6365
}
6466

@@ -71,7 +73,8 @@ export default class ProjectSettingsForm extends Component<Props, State> {
7173
validation: {
7274
bounds: true,
7375
defaultLocation: true,
74-
name: true
76+
name: true,
77+
webhookUrl: true
7578
}
7679
}
7780

@@ -181,13 +184,16 @@ export default class ProjectSettingsForm extends Component<Props, State> {
181184
this.setState(update(this.state, {model: {$merge: {defaultTimeZone}}}))
182185
}
183186

184-
_onChangeName = ({target}: {target: HTMLInputElement}) => {
187+
_onChangeTextInput = ({target}: {target: HTMLInputElement}) => {
185188
const {name, value} = target
186189
this.setState(
187-
update(this.state, {
188-
model: { $merge: {[name]: value} },
189-
validation: { [name]: { $set: value && value.length > 0 } }
190-
})
190+
update(
191+
this.state,
192+
{
193+
model: { $merge: { [ name ]: value } },
194+
validation: { [ name ]: { $set: value && value.length > 0 } }
195+
}
196+
)
191197
)
192198
}
193199

@@ -266,20 +272,19 @@ export default class ProjectSettingsForm extends Component<Props, State> {
266272
)
267273
}
268274
return (
269-
<div>
275+
(<div>
270276
<ConfirmModal ref='confirm' />
271277
<Panel header={<h4>{this.messages('title')}</h4>}>
272278
<ListGroup fill>
273279
<ListGroupItem>
274280
<FormGroup
275281
data-test-id='project-name-input-container'
276-
validationState={validationState(validation.name)}
277-
>
282+
validationState={validationState(validation.name)}>
278283
<ControlLabel>{this.messages('fields.name')}</ControlLabel>
279284
<FormControl
280285
value={model.name || ''}
281286
name={'name'}
282-
onChange={this._onChangeName}
287+
onChange={this._onChangeTextInput}
283288
/>
284289
<FormControl.Feedback />
285290
<HelpBlock>Required.</HelpBlock>
@@ -300,19 +305,17 @@ export default class ProjectSettingsForm extends Component<Props, State> {
300305
</Checkbox>
301306
{autoFetchChecked
302307
? <DateTimeField
303-
dateTime={(
304-
typeof autoFetchMinute === 'number' &&
305-
typeof autoFetchHour === 'number'
306-
)
307-
? +moment().startOf('day')
308-
.add(autoFetchHour, 'hours')
309-
.add(autoFetchMinute, 'minutes')
310-
: DEFAULT_FETCH_TIME
311-
}
308+
dateTime={typeof autoFetchMinute === 'number' &&
309+
typeof autoFetchHour === 'number'
310+
? +moment().startOf('day').add(autoFetchHour, 'hours').add(
311+
autoFetchMinute,
312+
'minutes'
313+
)
314+
: DEFAULT_FETCH_TIME}
312315
mode='time'
313-
onChange={this._onChangeDateTime} />
314-
: null
315-
}
316+
onChange={this._onChangeDateTime}
317+
/>
318+
: null}
316319
</FormGroup>
317320
</ListGroupItem>
318321
</ListGroup>
@@ -330,22 +333,18 @@ export default class ProjectSettingsForm extends Component<Props, State> {
330333
type='text'
331334
defaultValue={model.bounds
332335
? `${model.bounds.west},${model.bounds.south},${model.bounds.east},${model.bounds.north}`
333-
: ''
334-
}
336+
: ''}
335337
ref='boundingBox'
336-
placeholder={this.messages('fields.location.boundingBoxPlaceHolder')}
337-
onChange={this._onChangeBounds} />
338-
{
339-
<InputGroup.Button>
340-
<Button
341-
// TODO: wait for react-leaflet-draw to update library
342-
// to re-enable bounds select
343-
disabled
344-
onClick={this._onOpenMapBoundsModal}>
345-
<Glyphicon glyph='fullscreen' />
346-
</Button>
347-
</InputGroup.Button>
348-
}
338+
placeholder={this.messages(
339+
'fields.location.boundingBoxPlaceHolder'
340+
)}
341+
onChange={this._onChangeBounds}
342+
/>
343+
{<InputGroup.Button>
344+
<Button disabled onClick={this._onOpenMapBoundsModal}>
345+
<Glyphicon glyph='fullscreen' />
346+
</Button>
347+
</InputGroup.Button>}
349348
</InputGroup>
350349
</FormGroup>
351350
</ListGroupItem>
@@ -356,53 +355,61 @@ export default class ProjectSettingsForm extends Component<Props, State> {
356355
</ControlLabel>
357356
<TimezoneSelect
358357
value={model.defaultTimeZone}
359-
onChange={this._onChangeTimeZone} />
358+
onChange={this._onChangeTimeZone}
359+
/>
360+
</ListGroupItem>
361+
</ListGroup>
362+
</Panel>
363+
<Panel header={<h4>Local Places Index</h4>}>
364+
<ListGroup fill>
365+
<ListGroupItem>
366+
<FormGroup validationState={validationState(validation.webhookUrl)}>
367+
<ControlLabel>Webhook URL</ControlLabel>
368+
<FormControl
369+
value={model.peliasWebhookUrl || ''}
370+
name={'peliasWebhookUrl'}
371+
onChange={this._onChangeTextInput}
372+
/>
373+
<FormControl.Feedback />
374+
</FormGroup>
360375
</ListGroupItem>
361376
</ListGroup>
362377
</Panel>
363378
{showDangerZone &&
364-
<Panel bsStyle='danger' header={<h3>Danger zone</h3>}>
365-
<ListGroup fill>
366-
<ListGroupItem>
367-
<Button
368-
bsStyle='danger'
369-
className='pull-right'
370-
data-test-id='delete-project-button'
371-
onClick={this._onDeleteProject}
372-
>
373-
<Icon type='trash' /> Delete project
374-
</Button>
375-
<h4>Delete this project.</h4>
376-
<p>Once you delete an project, the project and all feed sources it contains cannot be recovered.</p>
377-
</ListGroupItem>
378-
</ListGroup>
379-
</Panel>
380-
}
379+
<Panel bsStyle='danger' header={<h3>Danger zone</h3>}>
380+
<ListGroup fill>
381+
<ListGroupItem>
382+
<Button
383+
bsStyle='danger'
384+
className='pull-right'
385+
data-test-id='delete-project-button'
386+
onClick={this._onDeleteProject}>
387+
<Icon type='trash' /> Delete project
388+
</Button>
389+
<h4>Delete this project.</h4>
390+
<p>Once you delete an project, the project and all feed sources it contains cannot be recovered.</p>
391+
</ListGroupItem>
392+
</ListGroup>
393+
</Panel>}
381394
<Row>
382395
<Col xs={12}>
383-
{/* Cancel button */}
384-
<Button
385-
onClick={this._onCancel}
386-
style={{marginRight: 10}}
387-
>
396+
{}
397+
<Button onClick={this._onCancel} style={{ marginRight: 10 }}>
388398
{this.messages('cancel')}
389399
</Button>
390-
{/* Save button */}
400+
{}
391401
<Button
392402
bsStyle='primary'
393403
data-test-id='project-settings-form-save-button'
394-
disabled={
395-
editDisabled ||
396-
this._settingsAreUnedited() ||
397-
!this._formIsValid()
398-
}
404+
disabled={editDisabled || this._settingsAreUnedited() ||
405+
!this._formIsValid()}
399406
onClick={this._onSaveSettings}>
400407
{this.messages('save')}
401408
</Button>
402409
</Col>
403410
</Row>
404411
<MapModal ref='mapModal' />
405-
</div>
412+
</div>)
406413
)
407414
}
408415
}

‎lib/manager/components/deployment/DeploymentViewer.js

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -365,39 +365,48 @@ export default class DeploymentViewer extends Component<Props, State> {
365365
return (
366366
<div>
367367
<Title>{title}</Title>
368-
{target &&
368+
{target && (
369369
<DeploymentConfirmModal
370370
deployToTarget={deployToTarget}
371371
deployment={deployment}
372372
oldDeployment={oldDeployment}
373373
onClose={this._onCloseModal}
374374
project={project}
375-
target={target} />
376-
}
375+
target={target}
376+
/>
377+
)}
377378
<Row>
378379
<Col sm={9}>
379380
<Panel header={this.renderHeader()}>
380381
<ListGroup fill>
381-
<ListGroupItem style={{padding: '0px'}}>
382+
<ListGroupItem style={{ padding: '0px' }}>
382383
{this.renderMap()}
383384
</ListGroupItem>
384385
<ListGroupItem>
385386
{this.renderDeployentVersionsTableHeader(versions)}
386387
</ListGroupItem>
387-
{versions.length === 0
388-
? <p className='lead text-center margin-top-15'>
388+
{versions.length === 0 ? (
389+
<p className='lead text-center margin-top-15'>
389390
No feed sources found.
390391
</p>
391-
: (
392-
<DeploymentVersionsTable
393-
deployment={deployment}
394-
project={project}
395-
versions={versions}
396-
/>
397-
)
398-
}
392+
) : (
393+
<DeploymentVersionsTable
394+
deployment={deployment}
395+
project={project}
396+
versions={versions}
397+
/>
398+
)}
399399
</ListGroup>
400400
</Panel>
401+
{/* Pelias panel. Only show if deployment is pinned and webhook URL is set */}
402+
{project.pinnedDeploymentId === deployment.id &&
403+
project.peliasWebhookUrl && (
404+
<PeliasPanel
405+
deployment={deployment}
406+
updateDeployment={updateDeployment}
407+
project={project}
408+
/>
409+
)}
401410
</Col>
402411
<Col sm={3}>
403412
{/* Current deployment panel */}
@@ -408,18 +417,15 @@ export default class DeploymentViewer extends Component<Props, State> {
408417
fetchDeployment={this.props.fetchDeployment}
409418
project={project}
410419
server={serverDeployedTo}
411-
terminateEC2InstanceForDeployment={this.props.terminateEC2InstanceForDeployment} />
420+
terminateEC2InstanceForDeployment={
421+
this.props.terminateEC2InstanceForDeployment
422+
}
423+
/>
412424
{/* Configurations panel */}
413425
<DeploymentConfigurationsPanel
414426
deployment={deployment}
415427
updateDeployment={updateDeployment}
416428
/>
417-
{/* Pelias panel. Only show if deployment is pinned */}
418-
{project.pinnedDeploymentId === deployment.id && <PeliasPanel
419-
deployment={deployment}
420-
updateDeployment={updateDeployment}
421-
project={project}
422-
/>}
423429
</Col>
424430
</Row>
425431
</div>

0 commit comments

Comments
 (0)