From 1d850c29e4d99823ec8418d8758d3b3486dcb67e Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Fri, 22 Sep 2023 15:28:35 -0400 Subject: [PATCH 1/9] perf(state): Don't include calltaker state or reducer if not config-enabled. --- lib/reducers/call-taker.js | 14 ++++++++++---- lib/util/state.js | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/reducers/call-taker.js b/lib/reducers/call-taker.js index 202bc22c0..9953484ef 100644 --- a/lib/reducers/call-taker.js +++ b/lib/reducers/call-taker.js @@ -6,11 +6,17 @@ import { FETCH_STATUS } from '../util/constants' import { getISOLikeTimestamp } from '../util/state' import { getModuleConfig, Modules } from '../util/config' +function getCalltakerConfig(config) { + return getModuleConfig({ otp: { config } }, Modules.CALL_TAKER) +} + function createCallTakerReducer(config) { - const calltakerConfig = getModuleConfig( - { otp: { config } }, - Modules.CALL_TAKER - ) + const calltakerConfig = getCalltakerConfig(config) + if (!calltakerConfig) { + // Don't include the calltaker reducer at all if calltaker is not enabled in config. + return undefined + } + const initialState = { activeCall: null, callHistory: { diff --git a/lib/util/state.js b/lib/util/state.js index c25b0b615..dee8fd604 100644 --- a/lib/util/state.js +++ b/lib/util/state.js @@ -245,8 +245,8 @@ function getActiveSearchRealtimeResponse(state) { * https://decembersoft.com/posts/error-selector-creators-expect-all-input-selectors-to-be-functions/ */ export const getActiveFieldTripRequest = createSelector( - (state) => state.callTaker?.fieldTrip.activeId, - (state) => state.callTaker?.fieldTrip.requests, + (state) => state.callTaker?.fieldTrip?.activeId, + (state) => state.callTaker?.fieldTrip?.requests, (activeId, requests) => { if (!activeId || !requests) return return requests.data.find((req) => req.id === activeId) From a20d0d24bc69685eb27be1462cee31bec4066623 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Fri, 22 Sep 2023 16:03:30 -0400 Subject: [PATCH 2/9] refactor(app): Remove unneeded calltaker config. --- lib/app.js | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/lib/app.js b/lib/app.js index 4ea733227..b56facafa 100644 --- a/lib/app.js +++ b/lib/app.js @@ -21,12 +21,7 @@ import { BatchResultsScreen, BatchRoutingPanel, BatchSearchScreen, - CallHistoryWindow, - CallTakerControls, - CallTakerPanel, DefaultItinerary, - FieldTripWindows, - MailablesWindow, ResponsiveWebapp } from './index' @@ -178,17 +173,7 @@ const components = { ItineraryBody: DefaultItinerary, - MainControls: isCallTakerModuleEnabled ? CallTakerControls : null, - - MainPanel: isCallTakerModuleEnabled ? CallTakerPanel : BatchRoutingPanel, - - MapWindows: isCallTakerModuleEnabled ? ( - <> - - - - - ) : null, + MainPanel: BatchRoutingPanel, MobileResultsScreen: BatchResultsScreen, From 932d8354b2379b3d6b7cde847f376e3cfef19580 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Fri, 22 Sep 2023 16:32:03 -0400 Subject: [PATCH 3/9] perf(index): Remove calltaker components from index --- lib/index.js | 12 ------------ percy/har-mock-config-call-taker.js | 10 ++++++---- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/lib/index.js b/lib/index.js index 9b8180f8a..f7d142a80 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,9 +1,5 @@ /* eslint-disable prettier/prettier */ /* eslint-disable sort-imports-es6-autofix/sort-imports-es6 */ -import CallTakerControls from './components/admin/call-taker-controls' -import CallHistoryWindow from './components/admin/call-history-window' -import FieldTripWindows from './components/admin/field-trip-windows' -import MailablesWindow from './components/admin/mailables-window' import DateTimeModal from './components/form/date-time-modal' import DateTimePreview from './components/form/date-time-preview' import ErrorMessage from './components/form/error-message' @@ -29,7 +25,6 @@ import ViewStopButton from './components/viewers/view-stop-button' import ViewerContainer from './components/viewers/viewer-container' import ResponsiveWebapp from './components/app/responsive-webapp' import AppMenu from './components/app/app-menu' -import CallTakerPanel from './components/app/call-taker-panel' import DesktopNav from './components/app/desktop-nav' import BatchRoutingPanel from './components/app/batch-routing-panel' import BatchResultsScreen from './components/mobile/batch-results-screen' @@ -50,12 +45,6 @@ const MobileResultsScreen = BatchResultsScreen const MobileSearchScreen = BatchSearchScreen export { - // module components - CallHistoryWindow, - CallTakerControls, - FieldTripWindows, - MailablesWindow, - // form components DateTimeModal, DateTimePreview, @@ -96,7 +85,6 @@ export { // app components, ResponsiveWebapp, AppMenu, - CallTakerPanel, DesktopNav, // batch routing components diff --git a/percy/har-mock-config-call-taker.js b/percy/har-mock-config-call-taker.js index f1e892114..31cd154f1 100644 --- a/percy/har-mock-config-call-taker.js +++ b/percy/har-mock-config-call-taker.js @@ -14,14 +14,16 @@ import React from 'react' import { BatchResultsScreen, BatchSearchScreen, - CallHistoryWindow, - CallTakerPanel, - FieldTripWindows, - MailablesWindow, MetroItinerary // Webpack sets this file to run from a subdirectory within otp-react-redux // ../lib points to the index file of otp-react-redux's source code } from '../lib' +import { + CallHistoryWindow, + FieldTripWindows, + MailablesWindow +} from '../lib/components/admin' +import { CallTakerPanel } from '../lib/components/app' /** * Custom itinerary footer for this deployment. From 2c111bb294b4347558ff2fc35073dca61e23e81f Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Fri, 22 Sep 2023 16:46:16 -0400 Subject: [PATCH 4/9] ci(percy): Update paths for percy calltaker config. --- percy/har-mock-config-call-taker.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/percy/har-mock-config-call-taker.js b/percy/har-mock-config-call-taker.js index 31cd154f1..418f5f6c9 100644 --- a/percy/har-mock-config-call-taker.js +++ b/percy/har-mock-config-call-taker.js @@ -18,12 +18,10 @@ import { // Webpack sets this file to run from a subdirectory within otp-react-redux // ../lib points to the index file of otp-react-redux's source code } from '../lib' -import { - CallHistoryWindow, - FieldTripWindows, - MailablesWindow -} from '../lib/components/admin' -import { CallTakerPanel } from '../lib/components/app' +import CallHistoryWindow from '../lib/components/admin/call-history-window' +import CallTakerPanel from '../lib/components/app/call-taker-panel' +import FieldTripWindows from '../lib/components/admin/field-trip-windows' +import MailablesWindow from '../lib/components/admin/mailables-window' /** * Custom itinerary footer for this deployment. From 42b52eccfd5a38c4f826d14dade11aa867bf9760 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Mon, 25 Sep 2023 16:52:39 -0400 Subject: [PATCH 5/9] ci(percy): Use separate YML config for calltaker. --- .github/workflows/percy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/percy.yml b/.github/workflows/percy.yml index c5e878b72..9684cb875 100644 --- a/.github/workflows/percy.yml +++ b/.github/workflows/percy.yml @@ -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 From 21306af043212b639927efcbce09a1443123a3e8 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:39:30 -0400 Subject: [PATCH 6/9] fix: Remove unneeded word wrap for itin times. --- .../narrative/line-itin/connected-itinerary-body.js | 6 +++++- lib/components/narrative/metro/metro-itinerary.tsx | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/components/narrative/line-itin/connected-itinerary-body.js b/lib/components/narrative/line-itin/connected-itinerary-body.js index 81cdb475a..12c51897a 100644 --- a/lib/components/narrative/line-itin/connected-itinerary-body.js +++ b/lib/components/narrative/line-itin/connected-itinerary-body.js @@ -5,7 +5,8 @@ import { LegDescriptionHeadsignPrefix, PlaceName as PlaceNameWrapper, PlaceRowWrapper, - PlaceSubheader + PlaceSubheader, + TimeColumn } from '@opentripplanner/itinerary-body/lib/styled' import { PlaceName } from '@opentripplanner/itinerary-body/lib/otp-react-redux' import clone from 'clone' @@ -53,6 +54,9 @@ const StyledItineraryBody = styled(ItineraryBody)` ${PlaceRowWrapper} { max-width: inherit; } + ${TimeColumn} { + white-space: nowrap; + } ` class ConnectedItineraryBody extends Component { diff --git a/lib/components/narrative/metro/metro-itinerary.tsx b/lib/components/narrative/metro/metro-itinerary.tsx index cbd0f7194..6eff07f40 100644 --- a/lib/components/narrative/metro/metro-itinerary.tsx +++ b/lib/components/narrative/metro/metro-itinerary.tsx @@ -75,7 +75,6 @@ const ItineraryDetails = styled.ul` margin: 0; overflow: hidden; padding: 0; - width: 90%; ` const PrimaryInfo = styled.li` color: #000000cc; From b3d1313325fefa5bcf3d690df2eb15d1560800ab Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:19:23 -0400 Subject: [PATCH 7/9] fix(i18n): Correctly load OTP-UI's Chinese (simplified) files. --- lib/util/i18n.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/util/i18n.js b/lib/util/i18n.js index 9dfe53126..deb7c88e6 100644 --- a/lib/util/i18n.js +++ b/lib/util/i18n.js @@ -117,6 +117,7 @@ async function loadOtpUiLocaleData(matchedLocale) { */ export async function loadLocaleData(matchedLocale, customMessages) { let messages + let otpUiLocale = matchedLocale switch (matchedLocale) { case 'es': // Spanish translation is not specific to a region messages = await import('../../i18n/es.yml') @@ -130,15 +131,18 @@ export async function loadLocaleData(matchedLocale, customMessages) { case 'vi': // Vietnamese translation is not specific to a region messages = await import('../../i18n/vi.yml') break - case 'zh': // Chinese translation is not specific to a region + case 'zh': // Chinese (Simplified) translation is not specific to a region messages = await import('../../i18n/zh.yml') + // The OTP-UI files for Chinese (Simplified) are (correclty) named `zh_Hans`. + // TODO: Rename this repo's zh files to zh_Hans + otpUiLocale = 'zh_Hans' break default: messages = await import('../../i18n/en-US.yml') break } - const otpUiMessages = await loadOtpUiLocaleData(matchedLocale) + const otpUiMessages = await loadOtpUiLocaleData(otpUiLocale) // Merge custom strings into the standard language strings. const mergedMessages = { From bae420f9851c321948f7c4b01a6f7dbeaefaf311 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:23:55 -0400 Subject: [PATCH 8/9] docs(i18n): Fix comment typo. --- lib/util/i18n.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/i18n.js b/lib/util/i18n.js index deb7c88e6..2674a781e 100644 --- a/lib/util/i18n.js +++ b/lib/util/i18n.js @@ -133,7 +133,7 @@ export async function loadLocaleData(matchedLocale, customMessages) { break case 'zh': // Chinese (Simplified) translation is not specific to a region messages = await import('../../i18n/zh.yml') - // The OTP-UI files for Chinese (Simplified) are (correclty) named `zh_Hans`. + // The OTP-UI files for Chinese (Simplified) are (correctly) named `zh_Hans`. // TODO: Rename this repo's zh files to zh_Hans otpUiLocale = 'zh_Hans' break From 64b4c72e4cf52c68bf3cfbf7fa95d1379169e516 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Thu, 19 Oct 2023 13:59:15 -0400 Subject: [PATCH 9/9] refactor(app): Prevent call history from appearing if datastore is not configured. --- lib/app.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/app.js b/lib/app.js index b56facafa..fda84a81f 100644 --- a/lib/app.js +++ b/lib/app.js @@ -175,6 +175,8 @@ const components = { MainPanel: BatchRoutingPanel, + MapWindows: isCallTakerModuleEnabled ? jsConfig.MapWindows : null, + MobileResultsScreen: BatchResultsScreen, MobileSearchScreen: BatchSearchScreen,