Skip to content

Commit

Permalink
fix(FeedTransformRules): Remove version clone trigger, add gtfs+ trig…
Browse files Browse the repository at this point in the history
…ger.
  • Loading branch information
binh-dam-ibigroup committed Jul 15, 2021
1 parent cb55d3f commit 9d78e37
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
4 changes: 4 additions & 0 deletions i18n/english.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ components:
fetchedAutomatically: Fetched Automatically
manuallyUploaded: Manually Uploaded
producedInHouse: Produced In-house
producedInHouseGtfsPlus: Produced In-house (GTFS+)
regionalMerge: Regional Merge
servicePeriodMerge: Service Period Merge
versionClone: Version Clone
title: Retrieval Method
snapshot: Editor Snapshot
title: Settings
Expand Down
1 change: 1 addition & 0 deletions lib/common/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const RETRIEVAL_METHODS = Object.freeze({
MANUALLY_UPLOADED: 'MANUALLY_UPLOADED',
FETCHED_AUTOMATICALLY: 'FETCHED_AUTOMATICALLY',
PRODUCED_IN_HOUSE: 'PRODUCED_IN_HOUSE',
PRODUCED_IN_HOUSE_GTFS_PLUS: 'PRODUCED_IN_HOUSE_GTFS_PLUS',
SERVICE_PERIOD_MERGE: 'SERVICE_PERIOD_MERGE',
REGIONAL_MERGE: 'REGIONAL_MERGE',
VERSION_CLONE: 'VERSION_CLONE'
Expand Down
19 changes: 16 additions & 3 deletions lib/common/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import gravatar from 'gravatar'

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

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

export function retrievalMethodString (method: string): string {
// Get the retrieval method strings.
const messages = getComponentMessages('FeedSourceViewer')
const retrievalMethod = 'properties.retrievalMethod'

switch (method) {
case 'MANUALLY_UPLOADED':
return 'Manually Uploaded'
return messages(`${retrievalMethod}.manuallyUploaded`)
case 'FETCHED_AUTOMATICALLY':
return 'Fetched Automatically'
return messages(`${retrievalMethod}.fetchedAutomatically`)
case 'PRODUCED_IN_HOUSE':
return 'Produced In-house'
return messages(`${retrievalMethod}.producedInHouse`)
case 'PRODUCED_IN_HOUSE_GTFS_PLUS':
return messages(`${retrievalMethod}.producedInHouseGtfsPlus`)
case 'REGIONAL_MERGE':
return messages(`${retrievalMethod}.regionalMerge`)
case 'SERVICE_PERIOD_MERGE':
return messages(`${retrievalMethod}.servicePeriodMerge`)
case 'VERSION_CLONE':
return messages(`${retrievalMethod}.versionClone`)
default:
throw new Error('Unknown method')
}
Expand Down
13 changes: 8 additions & 5 deletions lib/manager/components/transform/FeedTransformRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import {
import Select from 'react-select'

import {RETRIEVAL_METHODS} from '../../../common/constants'
import toSentenceCase from '../../../common/util/to-sentence-case'
import FeedTransformation from './FeedTransformation'
import {retrievalMethodString} from '../../../common/util/util'
import {getTransformationName} from '../../util/transform'
import VersionRetrievalBadge from '../version/VersionRetrievalBadge'

import type {
Feed,
FeedTransformRules as FeedTransformRulesType,
ReactSelectOption
} from '../../../types'

import FeedTransformation from './FeedTransformation'

function newFeedTransformation (type: string = 'ReplaceFileFromVersionTransformation', props: any = {}) {
return {
'@type': type,
Expand Down Expand Up @@ -95,14 +95,17 @@ export default class FeedTransformRules extends Component<TransformRulesProps> {
if (typeof method === 'string') {
return {
value: method,
label: toSentenceCase(method.toLowerCase().split('_').join(' '))
label: retrievalMethodString(method)
}
}
return null
}

render () {
const {feedSource, ruleSet, index} = this.props
const retrievalOptions = Object.values(RETRIEVAL_METHODS)
.filter(v => v !== RETRIEVAL_METHODS.VERSION_CLONE)
.map(this._retrievalMethodToOption)
const methodBadges = ruleSet.retrievalMethods.map(method =>
<VersionRetrievalBadge key={method} retrievalMethod={method} />)
return (
Expand Down Expand Up @@ -135,7 +138,7 @@ export default class FeedTransformRules extends Component<TransformRulesProps> {
clearable={false}
multi
placeholder='Select GTFS retrieval methods'
options={Object.values(RETRIEVAL_METHODS).map(this._retrievalMethodToOption)}
options={retrievalOptions}
value={ruleSet.retrievalMethods.map(this._retrievalMethodToOption)}
onChange={this._onChangeRetrievalMethods} />
{ruleSet.transformations.length > 0
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/components/version/VersionRetrievalBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Icon from '@conveyal/woonerf/components/icon'
import React from 'react'

import toSentenceCase from '../../../common/util/to-sentence-case'

import type { FeedVersion, RetrievalMethod } from '../../../types'

type Props = {
Expand All @@ -19,6 +18,7 @@ const iconForRetrievalMethod = (retrievalMethod: RetrievalMethod | 'UNKNOWN') =>
case 'REGIONAL_MERGE':
return 'globe'
case 'PRODUCED_IN_HOUSE':
case 'PRODUCED_IN_HOUSE_GTFS_PLUS':
return 'pencil'
case 'MANUALLY_UPLOADED':
return 'upload'
Expand Down

0 comments on commit 9d78e37

Please sign in to comment.