Skip to content

Commit 9d78e37

Browse files
fix(FeedTransformRules): Remove version clone trigger, add gtfs+ trigger.
1 parent cb55d3f commit 9d78e37

File tree

5 files changed

+30
-9
lines changed

5 files changed

+30
-9
lines changed

i18n/english.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ components:
253253
fetchedAutomatically: Fetched Automatically
254254
manuallyUploaded: Manually Uploaded
255255
producedInHouse: Produced In-house
256+
producedInHouseGtfsPlus: Produced In-house (GTFS+)
257+
regionalMerge: Regional Merge
258+
servicePeriodMerge: Service Period Merge
259+
versionClone: Version Clone
256260
title: Retrieval Method
257261
snapshot: Editor Snapshot
258262
title: Settings

lib/common/constants/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const RETRIEVAL_METHODS = Object.freeze({
3232
MANUALLY_UPLOADED: 'MANUALLY_UPLOADED',
3333
FETCHED_AUTOMATICALLY: 'FETCHED_AUTOMATICALLY',
3434
PRODUCED_IN_HOUSE: 'PRODUCED_IN_HOUSE',
35+
PRODUCED_IN_HOUSE_GTFS_PLUS: 'PRODUCED_IN_HOUSE_GTFS_PLUS',
3536
SERVICE_PERIOD_MERGE: 'SERVICE_PERIOD_MERGE',
3637
REGIONAL_MERGE: 'REGIONAL_MERGE',
3738
VERSION_CLONE: 'VERSION_CLONE'

lib/common/util/util.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import gravatar from 'gravatar'
44

5+
import {getComponentMessages} from '../../common/util/config'
56
import type {Feed, FeedVersion, Project, SummarizedFeedVersion} from '../../types'
67

78
export function defaultSorter (a: FeedVersion | Project | Feed, b: FeedVersion | Project | Feed): number {
@@ -30,13 +31,25 @@ export function versionsSorter (
3031
}
3132

3233
export function retrievalMethodString (method: string): string {
34+
// Get the retrieval method strings.
35+
const messages = getComponentMessages('FeedSourceViewer')
36+
const retrievalMethod = 'properties.retrievalMethod'
37+
3338
switch (method) {
3439
case 'MANUALLY_UPLOADED':
35-
return 'Manually Uploaded'
40+
return messages(`${retrievalMethod}.manuallyUploaded`)
3641
case 'FETCHED_AUTOMATICALLY':
37-
return 'Fetched Automatically'
42+
return messages(`${retrievalMethod}.fetchedAutomatically`)
3843
case 'PRODUCED_IN_HOUSE':
39-
return 'Produced In-house'
44+
return messages(`${retrievalMethod}.producedInHouse`)
45+
case 'PRODUCED_IN_HOUSE_GTFS_PLUS':
46+
return messages(`${retrievalMethod}.producedInHouseGtfsPlus`)
47+
case 'REGIONAL_MERGE':
48+
return messages(`${retrievalMethod}.regionalMerge`)
49+
case 'SERVICE_PERIOD_MERGE':
50+
return messages(`${retrievalMethod}.servicePeriodMerge`)
51+
case 'VERSION_CLONE':
52+
return messages(`${retrievalMethod}.versionClone`)
4053
default:
4154
throw new Error('Unknown method')
4255
}

lib/manager/components/transform/FeedTransformRules.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ import {
1212
import Select from 'react-select'
1313

1414
import {RETRIEVAL_METHODS} from '../../../common/constants'
15-
import toSentenceCase from '../../../common/util/to-sentence-case'
16-
import FeedTransformation from './FeedTransformation'
15+
import {retrievalMethodString} from '../../../common/util/util'
1716
import {getTransformationName} from '../../util/transform'
1817
import VersionRetrievalBadge from '../version/VersionRetrievalBadge'
19-
2018
import type {
2119
Feed,
2220
FeedTransformRules as FeedTransformRulesType,
2321
ReactSelectOption
2422
} from '../../../types'
2523

24+
import FeedTransformation from './FeedTransformation'
25+
2626
function newFeedTransformation (type: string = 'ReplaceFileFromVersionTransformation', props: any = {}) {
2727
return {
2828
'@type': type,
@@ -95,14 +95,17 @@ export default class FeedTransformRules extends Component<TransformRulesProps> {
9595
if (typeof method === 'string') {
9696
return {
9797
value: method,
98-
label: toSentenceCase(method.toLowerCase().split('_').join(' '))
98+
label: retrievalMethodString(method)
9999
}
100100
}
101101
return null
102102
}
103103

104104
render () {
105105
const {feedSource, ruleSet, index} = this.props
106+
const retrievalOptions = Object.values(RETRIEVAL_METHODS)
107+
.filter(v => v !== RETRIEVAL_METHODS.VERSION_CLONE)
108+
.map(this._retrievalMethodToOption)
106109
const methodBadges = ruleSet.retrievalMethods.map(method =>
107110
<VersionRetrievalBadge key={method} retrievalMethod={method} />)
108111
return (
@@ -135,7 +138,7 @@ export default class FeedTransformRules extends Component<TransformRulesProps> {
135138
clearable={false}
136139
multi
137140
placeholder='Select GTFS retrieval methods'
138-
options={Object.values(RETRIEVAL_METHODS).map(this._retrievalMethodToOption)}
141+
options={retrievalOptions}
139142
value={ruleSet.retrievalMethods.map(this._retrievalMethodToOption)}
140143
onChange={this._onChangeRetrievalMethods} />
141144
{ruleSet.transformations.length > 0

lib/manager/components/version/VersionRetrievalBadge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Icon from '@conveyal/woonerf/components/icon'
44
import React from 'react'
55

66
import toSentenceCase from '../../../common/util/to-sentence-case'
7-
87
import type { FeedVersion, RetrievalMethod } from '../../../types'
98

109
type Props = {
@@ -19,6 +18,7 @@ const iconForRetrievalMethod = (retrievalMethod: RetrievalMethod | 'UNKNOWN') =>
1918
case 'REGIONAL_MERGE':
2019
return 'globe'
2120
case 'PRODUCED_IN_HOUSE':
21+
case 'PRODUCED_IN_HOUSE_GTFS_PLUS':
2222
return 'pencil'
2323
case 'MANUALLY_UPLOADED':
2424
return 'upload'

0 commit comments

Comments
 (0)