Skip to content

Commit

Permalink
feat(DeploymentViewer): add custom geocoder settings panel
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-grant-ibigroup committed Jul 29, 2021
1 parent 1f91096 commit f697c19
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 7 deletions.
4 changes: 3 additions & 1 deletion __tests__/test-utils/mock-data/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import clone from 'lodash/cloneDeep'

import UserPermissions from '../../../lib/common/user/UserPermissions'
import UserSubscriptions from '../../../lib/common/user/UserSubscriptions'

import type {
Deployment,
FeedVersion,
Expand Down Expand Up @@ -61,6 +60,8 @@ export function makeMockDeployment (
routerId: null,
skipOsmExtract: false,
tripPlannerVersion: 'OTP_1',
peliasUpdate: null,
peliasWebhookUrl: null,
user: null
}
}
Expand All @@ -86,6 +87,7 @@ export const mockProject = {
feedSources: [],
id: 'mock-project-id',
lastUpdated: 1553236399556,
lastUsedPeliasWebhookUrl: null,
name: 'mock-project',
organizationId: null,
otpServers: [],
Expand Down
3 changes: 3 additions & 0 deletions lib/manager/actions/__tests__/__snapshots__/projects.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ Object {
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -175,6 +177,7 @@ Object {
],
"id": "mock-project-with-deployments-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project-with-deployments",
"organizationId": null,
"otpServers": Array [],
Expand Down
16 changes: 11 additions & 5 deletions lib/manager/components/deployment/DeploymentViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ import {formatTimestamp, fromNow} from '../../../common/util/date-time'
import {defaultTileLayerProps} from '../../../common/util/maps'
import { versionsSorter } from '../../../common/util/util'
import {getServerDeployedTo} from '../../util/deployment'
import CurrentDeploymentPanel from './CurrentDeploymentPanel'
import DeploymentConfigurationsPanel from './DeploymentConfigurationsPanel'
import DeploymentConfirmModal from './DeploymentConfirmModal'
import DeploymentVersionsTable from './DeploymentVersionsTable'

import type {Props as ContainerProps} from '../../containers/ActiveDeploymentViewer'
import type {
ServerJob,
SummarizedFeedVersion
} from '../../../types'
import type {ManagerUserState} from '../../../types/reducers'

import CurrentDeploymentPanel from './CurrentDeploymentPanel'
import DeploymentConfigurationsPanel from './DeploymentConfigurationsPanel'
import DeploymentConfirmModal from './DeploymentConfirmModal'
import DeploymentVersionsTable from './DeploymentVersionsTable'
import PeliasPanel from './PeliasPanel'

type Props = ContainerProps & {
addFeedVersion: typeof deploymentActions.addFeedVersion,
deployJobs: Array<ServerJob>,
Expand Down Expand Up @@ -413,6 +414,11 @@ export default class DeploymentViewer extends Component<Props, State> {
deployment={deployment}
updateDeployment={updateDeployment}
/>
{/* Pelias panel */}
<PeliasPanel
deployment={deployment}
updateDeployment={updateDeployment}
/>
</Col>
</Row>
</div>
Expand Down
90 changes: 90 additions & 0 deletions lib/manager/components/deployment/PeliasPanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// @flow

import Icon from '@conveyal/woonerf/components/icon'
import React, { Component } from 'react'
import { Checkbox, FormControl, ListGroup, ListGroupItem, Panel } from 'react-bootstrap'

import * as deploymentActions from '../../actions/deployments'
import type {
Deployment
} from '../../../types'

type Props = {
deployment: Deployment,
updateDeployment: typeof deploymentActions.updateDeployment,
}

type State = {
webhookUrl: string
}

export default class PeliasPanel extends Component<Props, State> {
state = { webhookUrl: '' };

componentDidMount = () => {
const { deployment } = this.props
this.setState({ webhookUrl: (deployment.peliasWebhookUrl || '') })
};

_onChangeUpdatePelias = () =>
this._updateDeployment({
peliasUpdate: !this.props.deployment.peliasUpdate
});

_onBlurWebhookUrl = (event: SyntheticInputEvent<HTMLInputElement>) => {
const { target } = event
const { value } = target
this._updateDeployment({ peliasWebhookUrl: value })
};
_onChangeWebhookUrl = (event: SyntheticInputEvent<HTMLInputElement>) => {
const { target } = event
const { value } = target
this.setState({ webhookUrl: value })
};

_updateDeployment = (props: { [string]: any }) => {
const { deployment, updateDeployment } = this.props
updateDeployment(deployment, props)
};

render () {
const { deployment } = this.props
const { webhookUrl } = this.state

return (
<Panel
header={
<h3>
<Icon type='map-marker' /> Custom Geocoder Settings
</h3>
}
>
<ListGroup fill>
<ListGroupItem>
<h5>Custom Geocoder Webhook URL</h5>
<FormControl
type='url'
placeholder='Update webhook URL'
value={webhookUrl}
onChange={this._onChangeWebhookUrl}
onBlur={this._onBlurWebhookUrl}
/>
</ListGroupItem>
<ListGroupItem>
<h5>Send GTFS feeds to custom geocoder</h5>
<Checkbox
checked={deployment.peliasUpdate}
onChange={this._onChangeUpdatePelias}
>
Update Custom Geocoder
</Checkbox>
</ListGroupItem>
<ListGroupItem>
<h5>Custom POI CSV Upload</h5>
TODO
</ListGroupItem>
</ListGroup>
</Panel>
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr
"feedSources": Array [],
"id": "mock-project-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project",
"organizationId": null,
"otpServers": Array [],
Expand Down Expand Up @@ -1933,6 +1934,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr
"feedSources": Array [],
"id": "mock-project-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project",
"organizationId": null,
"otpServers": Array [],
Expand Down Expand Up @@ -1978,6 +1980,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr
"feedSources": Array [],
"id": "mock-project-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project",
"organizationId": null,
"otpServers": Array [],
Expand Down Expand Up @@ -2096,6 +2099,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr
"feedSources": Array [],
"id": "mock-project-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project",
"organizationId": null,
"otpServers": Array [],
Expand Down Expand Up @@ -2145,6 +2149,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr
"feedSources": Array [],
"id": "mock-project-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project",
"organizationId": null,
"otpServers": Array [],
Expand Down Expand Up @@ -2211,6 +2216,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr
"feedSources": Array [],
"id": "mock-project-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project",
"organizationId": null,
"otpServers": Array [],
Expand Down Expand Up @@ -3891,6 +3897,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr
"feedSources": Array [],
"id": "mock-project-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project",
"organizationId": null,
"otpServers": Array [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -158,6 +160,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -220,6 +224,7 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
],
"id": "mock-project-with-deployments-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project-with-deployments",
"organizationId": null,
"otpServers": Array [],
Expand Down Expand Up @@ -352,6 +357,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -384,6 +391,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -446,6 +455,7 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
],
"id": "mock-project-with-deployments-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project-with-deployments",
"organizationId": null,
"otpServers": Array [],
Expand Down Expand Up @@ -630,6 +640,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -662,6 +674,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -787,6 +801,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -819,6 +835,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -881,6 +899,7 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
],
"id": "mock-project-with-deployments-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project-with-deployments",
"organizationId": null,
"otpServers": Array [],
Expand Down Expand Up @@ -1155,6 +1174,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -1280,6 +1301,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -1312,6 +1335,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -1374,6 +1399,7 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
],
"id": "mock-project-with-deployments-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project-with-deployments",
"organizationId": null,
"otpServers": Array [],
Expand Down Expand Up @@ -1554,6 +1580,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -1679,6 +1707,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -1711,6 +1741,8 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
"osmExtractUrl": null,
"otpCommit": null,
"otpVersion": null,
"peliasUpdate": null,
"peliasWebhookUrl": null,
"pinnedfeedVersionIds": Array [],
"projectBounds": Object {
"east": 0,
Expand Down Expand Up @@ -1773,6 +1805,7 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym
],
"id": "mock-project-with-deployments-id",
"lastUpdated": 1553236399556,
"lastUsedPeliasWebhookUrl": null,
"name": "mock-project-with-deployments",
"organizationId": null,
"otpServers": Array [],
Expand Down
Loading

0 comments on commit f697c19

Please sign in to comment.