Skip to content

Commit

Permalink
Merge branch 'dev' into remove-user-setting-save-btn
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup authored Oct 19, 2023
2 parents 64f98db + 9a8f7f1 commit c9407f7
Show file tree
Hide file tree
Showing 28 changed files with 941 additions and 119 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ jobs:
auto-approve-and-automerge:
# sources:
# https://github.com/hmarr/auto-approve-action
# https://github.com/marketplace/actions/enable-github-automerge
# https://github.com/marketplace/actions/enable-pull-request-automerge#dependabot-example
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: github.actor == 'dependabot[bot]'
steps:
- uses: actions/checkout@v2
- name: Auto-approve PR
uses: hmarr/auto-approve-action@v3
- name: Enable auto-merge
run: gh pr merge --merge --auto ${{ github.event.pull_request.number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: alexwilson/enable-github-automerge-action@main
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 1 addition & 1 deletion .github/workflows/percy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Download OTP2 config file
run: curl $PERCY_OTP2_CONFIG_URL --output /tmp/otp2config.yml
env:
PERCY_OTP2_CONFIG_URL: ${{ secrets.PERCY_MOCK_OTP2_GEOCODER_CONFIG }}
PERCY_OTP2_CONFIG_URL: ${{ secrets.PERCY_MOCK_OTP2_GEOCODER_CALLTAKER_CONFIG }}
- name: Build OTP-RR Calltaker
# Calltaker has a separate config file, so another build should be produced.
run: yarn build
Expand Down
467 changes: 467 additions & 0 deletions __tests__/components/viewers/__snapshots__/stop-viewer.js.snap

Large diffs are not rendered by default.

46 changes: 33 additions & 13 deletions __tests__/util/ui.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { getItineraryView, ItineraryView } from '../../lib/util/ui'
import {
getItineraryView,
getMapToggleNewItineraryView,
ItineraryView
} from '../../lib/util/ui'

describe('util > ui', () => {
describe('getItineraryView', () => {
Expand All @@ -17,18 +21,21 @@ describe('util > ui', () => {
)
})
it('returns an itinerary list view if URL contains ui_activeItinerary=-1 regardless of ui_itineraryView', () => {
expect(
getItineraryView({
ui_activeItinerary: -1,
ui_itineraryView: ItineraryView.FULL
})
).toBe(ItineraryView.LIST)
expect(
getItineraryView({
ui_activeItinerary: -1,
ui_itineraryView: ItineraryView.LEG
})
).toBe(ItineraryView.LIST)
const expectedValues = {
[ItineraryView.FULL]: ItineraryView.LIST,
[ItineraryView.LEG]: ItineraryView.LIST,
[ItineraryView.LEG_HIDDEN]: ItineraryView.LIST,
[ItineraryView.LIST]: ItineraryView.LIST,
[ItineraryView.LIST_HIDDEN]: ItineraryView.LIST_HIDDEN
}
Object.entries(expectedValues).forEach(([k, v]) => {
expect(
getItineraryView({
ui_activeItinerary: -1,
ui_itineraryView: k
})
).toBe(v)
})
})
it('returns the specified view mode when set in URL', () => {
expect(
Expand All @@ -39,4 +46,17 @@ describe('util > ui', () => {
).toBe(ItineraryView.LEG)
})
})
describe('getMapToggleNewItineraryView', () => {
it('should obtain the new itinerary view value', () => {
const expectedValues = {
[ItineraryView.LEG]: ItineraryView.LEG_HIDDEN,
[ItineraryView.LEG_HIDDEN]: ItineraryView.LEG,
[ItineraryView.LIST]: ItineraryView.LIST_HIDDEN,
[ItineraryView.LIST_HIDDEN]: ItineraryView.LIST
}
Object.entries(expectedValues).forEach(([k, v]) => {
expect(getMapToggleNewItineraryView(k)).toBe(v)
})
})
})
})
3 changes: 3 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ itinerary:
# Whether the plan first/previous/next/last buttons should be shown along with
# plan trip itineraries.
showPlanFirstLastButtons: false
# Filters out trips returned by OTP by default, unless specifically requested.
# e.g. filters out walk-only itineraries if user has not explicitly asked for them.
strictItineraryFiltering: false
# Whether to render route names and colors in the blocks inside
# the batch ui rows
renderRouteNamesInBlocks: true
Expand Down
3 changes: 3 additions & 0 deletions i18n/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ actions:
smsVerificationFailed: >-
Su teléfono no ha podido ser verificado. Quizás el código que has
introducido ha caducado. Solicita un nuevo código e inténtalo de nuevo.
mustBeLoggedInToSavePlace: Por favor, inicia la sesión para guardar las ubicaciones.
placeRemembered: La configuración de este lugar se ha guardado.
common:
coordinates: "{lat}; {lon}"
dateExpressions:
Expand Down Expand Up @@ -489,6 +491,7 @@ components:
operatedBy: Servicio operado por {agencyName}
selectADirection: Seleccione una dirección…
stopsTo: Hacia
headsignTo: '{headsign} ({lastStop})'
RouteViewer:
agencyFilter: Filtro de agencia
allAgencies: Todas las agencias
Expand Down
135 changes: 135 additions & 0 deletions i18n/tr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
_id: en-US
actions:
fieldTrip:
saveItinerariesError: 'Seyahat planları kaydedilemedi: {err}'
setDateError: 'Tarih ayarlanırken hata oluştu:'
fetchFieldTripError: ''
setGroupSizeError: 'Grup boyutu ayarlanırken hata oluştu:'
maxTripRequestsExceeded: Geçerli sonuçlar olmadan yolculuk isteklerinin sayısı
aşıldı
setPaymentError: 'Ödeme bilgileri ayarlanırken hata oluştu:'
setRequestStatusError: 'İstek durumu ayarlanırken hata oluştu:'
editSubmitterNotesError: 'Gönderenin notları düzenlenirken hata oluştu:'
user:
emailVerificationResent: E-posta doğrulama mesajı yeniden gönderildi.
genericError: 'Bir hata ile karşılaşıldı: {err}'
smsVerificationFailed: Telefonunuz doğrulanamadı. Girdiğiniz kodun süresi dolmuş
olabilir. Lütfen yeni bir kod isteyin ve tekrar deneyin.
authTokenError: Yetkilendirme anahtarı alınırken hata oluştu.
mustBeLoggedInToSavePlace: Konumları kaydetmek için lütfen giriş yapın.
itineraryExistenceCheckFailed: Seçtiğiniz seyahatin mümkün olup olmadığı kontrol
edilirken hata oluştu.
smsInvalidCode: Girdiğiniz kod geçersiz. Lütfen tekrar deneyin.
accountDeleted: Kullanıcı hesabınız ({email}) silindi.
preferencesSaved: Tercihleriniz kaydedilmiştir.
placeRemembered: Bu yerin ayarları kaydedildi.
confirmDeletePlace: Bu yeri kaldırmak ister misiniz?
smsResendThrottled: Belirtilen telefon numarasına bir dakikadan kısa süre önce
bir doğrulama SMS'i gönderildi. Lütfen birkaç dakika sonra tekrar deneyin.
location:
userDeniedPermission: Kullanıcı izni reddetti
deniedAccessAlert: "Konumunuza erişim engellendi.\nMevcut konumunuzu kullanmak
için tarayıcınızdan konum izinlerini etkinleştirin ve sayfayı yeniden yükleyin.
\n"
unknownPositionError: Konum alınırken bilinmeyen hata
geolocationNotSupportedError: Coğrafi konum tarayıcınız tarafından desteklenmiyor
callTaker:
fetchCallsError: 'Çağrılar alınırken hata oluştu: {err}'
queryFetchError: 'Sorgular alınırken hata oluştu: {err}'
map:
currentLocation: (Mevcut Konum)
common:
daysOfWeekPlural:
thursday: Perşembeler
tuesday: Salılar
saturday: Cumartesileri
friday: Cumalar
monday: Pazartesileri
wednesday: Çarşambalar
sunday: Pazarları
modes:
car: Araba
micromobility_rent: E-Skutır
subway: Metro
micromobility: E-Skutır
rent: Kiralama seçenekleri
walk: Yürümek
funicular: Füniküler
car_park: Park Et Devam Et
flex: Esnek Rotalar
ferry: Feribot
bike: Bisiklet
tram: Tramvay
gondola: Gondol
drive: Sürücü
cable_car: Teleferik
rail: Demiryolu
bus: Otobüs
bicycle_rent: Bisiklet paylaşımı
notifications:
email: eposta
push: bildirimler
sms: SMS
daysOfWeekCompact:
wednesday: Çar
thursday: Per
sunday: Paz
tuesday: Sal
saturday: Cmt
friday: Cum
monday: Pzt
itineraryDescriptions:
fareUnknown: Ücret bilgisi yok
forms:
"yes": Evet
print: Yazdır
"no": Hayır
finish: Bitiş
submitting: Gönderiliyor…
startOver: Baştan Başla
close: Kapat
edit: Düzenle
delete: Sil
save: Kaydet
cancel: İptal
back: Geri
error: hata!
next: Sonraki
defaultValue: '{value} (varsayılan)'
daysOfWeek:
sunday: Pazar
wednesday: Çarşamba
saturday: Cumartesi
friday: Cuma
monday: Pazartesi
tuesday: Salı
thursday: Perşembe
dateExpressions:
tomorrow: Yarın
yesterday: Dün
today: Bugün
coordinates: '{lat}, {lon}'
linkOpensNewWindow: (Yeni pencere açar)
places:
home: ev
dining: yemek
work:
searchForms:
click: tıkla
time:
duration:
aFewSeconds: birkaç saniye
components:
AddPlaceButton:
addPlace: Yer ekle
tooManyPlaces: Maksimum ara yerlere ulaşıldı
needOriginDestination: Ara yerler eklemek için başlangıç/bitiş noktasını tanımlayın
AfterSignInScreen:
mainTitle: Yönlendiriliyor...
A11yPrefs:
accessibilityRoutingByDefault: Varsayılan olarak erişilebilir seyahatleri tercih
et
AdvancedOptions:
preferredRoutes: Tercih edilen rotaları seçin...
bannedRoutes: Yasaklanan rotaları seç…
_name: İngilizce
60 changes: 54 additions & 6 deletions lib/actions/apiV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
aggregateModes,
populateSettingWithValue
} from '@opentripplanner/trip-form'
import { createAction } from 'redux-actions'
import { decodeQueryParams, DelimitedArrayParam } from 'use-query-params'
import clone from 'clone'
import coreUtils from '@opentripplanner/core-utils'
Expand Down Expand Up @@ -45,7 +46,8 @@ import { RoutingQueryCallResult } from './api-constants'
import { setItineraryView } from './ui'
import { zoomToPlace } from './map'

const { generateCombinations, generateOtp2Query } = coreUtils.queryGen
const { generateCombinations, generateOtp2Query, SIMPLIFICATIONS } =
coreUtils.queryGen
const { getTripOptionsFromQuery, getUrlParams } = coreUtils.query
const { convertGraphQLResponseToLegacy } = coreUtils.itinerary
const { randId } = coreUtils.storage
Expand Down Expand Up @@ -824,6 +826,8 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
config?.modes?.initialState?.enabledModeButtons ||
{}

const strictModes = config?.itinerary?.strictItineraryFiltering

// Filter mode definitions based on active mode keys
const activeModeButtons = config.modes?.modeButtons.filter((mb) =>
activeModeKeys.includes(mb.key)
Expand Down Expand Up @@ -878,8 +882,6 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
})
)

dispatch(setItineraryView(ItineraryView.LIST))

combinations.forEach((combo, index) => {
const query = generateOtp2Query(combo)
dispatch(
Expand Down Expand Up @@ -920,11 +922,31 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
routingError,
{
rewritePayload: (response, dispatch, getState) => {
const withCollapsedShortNames =
response.data?.plan?.itineraries?.map((itin) => ({
const itineraries = response.data?.plan?.itineraries

// Convert user-selected transit modes from mode selector into modes recognized by OTP.
const activeModeStrings = activeModes.map(
(am) => SIMPLIFICATIONS[am.mode]
)

let filteredItineraries = itineraries
// If "strictItineraryFiltering" is enabled, only return itineraries that contain at least one explicitly requested mode...
if (strictModes) {
filteredItineraries = itineraries.filter((itin) =>
itin.legs.some((leg) =>
activeModeStrings.includes(SIMPLIFICATIONS[leg.mode])
)
)
// ... Otherwise return all itineraries.
}

// Filter itineraries to collapse short names and hide unnecessary errors.
const withCollapsedShortNames = filteredItineraries.map(
(itin) => ({
...itin,
legs: itin.legs?.map(convertGraphQLResponseToLegacy)
}))
})
)

/* It is possible for a NO_TRANSIT_CONNECTION error to be
returned even if trips were returned, since it is on a mode-by-mode basis.
Expand Down Expand Up @@ -976,13 +998,39 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
}
}

const requestingServiceTimeRange = createAction('SERVICE_TIME_RANGE_REQUEST')
const receivedServiceTimeRange = createAction('SERVICE_TIME_RANGE_RESPONSE')
const receivedServiceTimeRangeError = createAction('SERVICE_TIME_RANGE_ERROR')

/** Queries for service time range. */
const retrieveServiceTimeRangeIfNeeded = () =>
function (dispatch, getState) {
if (getState().otp.serviceTimeRange) return
dispatch(requestingServiceTimeRange)
return dispatch(
createGraphQLQueryAction(
`{
serviceTimeRange {
start
end
}
}`,
{},
receivedServiceTimeRange,
receivedServiceTimeRangeError,
{}
)
)
}

export default {
fetchStopInfo,
findPatternsForRoute,
findRoute,
findRoutes,
findTrip,
getVehiclePositionsForRoute,
retrieveServiceTimeRangeIfNeeded,
routingQuery,
vehicleRentalQuery
}
Loading

0 comments on commit c9407f7

Please sign in to comment.