Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DT-4910: New texts for infobox #4875

Merged
merged 50 commits into from
Nov 20, 2023
Merged

DT-4910: New texts for infobox #4875

merged 50 commits into from
Nov 20, 2023

Conversation

Dvun
Copy link
Contributor

@Dvun Dvun commented Oct 23, 2023

Proposed Changes

  • New texts for infobox

Pull Request Check List

  • A reasonable set of unit tests is included
  • Console does not show new warnings/errors
  • Changes are documented or they are self explanatory
  • This pull request does not have any merge conflicts
  • All existing tests pass in CI build
  • Code coverage does not decrease (unless measured incorrectly)

Review

  • Read and verify the code changes
  • Test the functionality by running the UI locally with all popular browsers available in your platform
  • Check that the implementation matches the design, when such one is defined in a Jira issue
  • Merge the pull request

@@ -1295,6 +1295,8 @@ const translations = {
'number-of-minutes':
'{number, plural, =0 {0 minutes} one {1 minute} other {{number} minutes}}',
'number-of-spaces': 'Number of spaces:',
'nysse-ticket-limited':
'Nysse tickets are valid on trains in the Nysse area with some limitations. Read more on ',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tekstin tulisi olla geneerinen nimeltään tyyliin 'train-ticket-limited' ja "Nysse"n voisi korvata muuttujalla tyyliin {{agencyName}}. Tai koko teksti tampereen config tiedostoon.

@@ -2431,6 +2433,8 @@ const translations = {
'number-of-minutes':
'{number, plural, =0 {0 minuuttia} one {1 minuutti} other {{number} minuuttia}}',
'number-of-spaces': 'Paikkojen määrä:',
'nysse-ticket-limited':
'Nyssen liput käyvät junaliikenteessä rajoitetusti vain Nysse-alueella. Lue lisää ',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sama kuin ylempänä.

@@ -4347,6 +4351,8 @@ const translations = {
'number-of-minutes':
'{number, plural, =0 {0 minuter} one {1 minut} other {{number} minuter}}',
'number-of-spaces': 'Antalet platser:',
'nysse-ticket-limited':
'Nysse-biljetter är giltiga på tåg i Nysse-området, med vissa begränsningar. Läs mer på ',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sama kuin ylempänä.

{leg.fare &&
leg.fare.isUnknown &&
shouldShowFareInfo(config) &&
(config.showTrainLimitationInfo ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tälle parempi sijainti voisi olla RailLeg, samaan tyyliin kuin CallAgencyLeg pitää oman infoboksinsa sisällään.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tarkemmin katsottuja RailLeg ei ole samantyyppinen kuin callAgencyLeg ja pitääkin sisällään TransitLegin ja määrittelee sille junan parametrejä, eli lokaatio on oikea. Tarkistuksen voisi kuitenkin lisätä että kyseessä on junaliikenne, joka onnistunee mode muuttujan avulla.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mode === 'RAIL' on lisätty, mutta tämä on vain lisä turha koodi lisämine sinne. Koska oli testattu kävelly, bussin, polkupyörä, lentokonen matkat ja vain junan kanssa infoteksti tulee sinne jos tarvitaessa.

);
}

if (config.showTrainLimitationInfo) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tässä olisi hyvä varmistaa, että ehdotukset sisältävät junaliikennettä (esim. samaan tyyliin kuin yllä kutsuliikenteellä itineraryContainsCallLegs).

@@ -34,6 +34,13 @@ export function isCallAgencyPickupType(leg) {
);
}

export function isTrainLimitationPickupType(leg) {
return (
filterLegStops(leg, stoptime => stoptime.pickupType === 'SCHEDULED')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Junia ei voi tarkistaa pickupTypestä, koska muillakin kuin junilla on scheduled pickuptype. Legin modesta tiedon kyllä saa ("rail").

import Icon from './Icon';

const InfoBox = (
{ textId, values, href = null, configData = null },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Component name cannot be generic InfoBox, because it renders very specific fare disclaimer .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FareDisclaimer.js

const itineraryContainsCallLegs = itinerary.legs.some(leg =>
isCallAgencyPickupType(leg),
);
const isTrainLimitation = itinerary.legs.some(leg =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Poor naming:

  • isTrainLimitation -> hasTrainLegs. Actually this could be more generic: configuration could include a map of disclaimers per mode.
  • isShowItineraryContainsCallLegsInfo is totally incomprehensible, change it to 'showCallAgencyDisclaimer'
  • isShowTrainLimitationInfo -> showLegModeDisclaimer

);
}

export function isTrainLimitationPickupType(leg) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad name. This has nothing to do with pickup types.

'Trains in the Nysse area - Nysse, Tampere regional transport',
},
},

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modeDisclaimers: {
train: {
fi: {
showTrainLimitationInfoLink: 'https://www.nysse.fi/junat',
showTrainLimitationInfoLinkText: 'nysse.fi/junat',
},
sv: {
showTrainLimitationInfoLink:
'https://www.nysse.fi/en/ways-to-get-around/train',
showTrainLimitationInfoLinkText:
'Trains in the Nysse area - Nysse, Tampere regional transport',
},
en: {
showTrainLimitationInfoLink:
'https://www.nysse.fi/en/ways-to-get-around/train',
showTrainLimitationInfoLinkText:
'Trains in the Nysse area - Nysse, Tampere regional transport',
},
},
}
}

fi: {
showTrainLimitationInfoLink: 'https://www.nysse.fi/junat',
showTrainLimitationInfoLinkText: 'nysse.fi/junat',
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Muuta showTrainLimitationInfoLink -> link, showTrainLimitationInfoLinkText -> text

leg.fare.isUnknown &&
shouldShowFareInfo(config) &&
(mode === LegMode.Rail && config.modeDisclaimers.rail ? (
<div className="disclaimer-container unknown-fare-disclaimer__leg">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Koeta koodata tämä näin:

(config.modeDisclaimers[mode] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suora käytä mode en pysty, koska tämä tulee kun 'RAIL', mutta tarvitseen configille 'rail'.
Onko sitten parempi käytää tällä mode.toLowerCase() tai sitten sama tiedostossa oli jo aikasemmin kirjoitety
const modeClassName = mode.toLowerCase();
Tämä on hyvä käytä, mutta tuntuu, että muttoja nimi modeClassName ei ole hyvä ???

}

export function hasLegMode(leg) {
return getLegMode(leg) === LegMode.Rail;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tässä funktiossa ei ole järkeä. Poista ja siirrä yhden rivin koodi ItineraryTab.js:lle

isCallAgencyPickupType(leg),
);
const hasTrainLegs = itinerary.legs.some(leg => hasLegMode(leg));

Copy link
Member

@vesameskanen vesameskanen Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seuraava olisi hyvä ratkaisu:
Rakenna taulukko FareDisclaimereja. Taulukoon pusketaan CallAgency yms disclaimerit, ja lisäksi n kpl mode disclaimereja. Eli iteroi kaikki legit ja katso onko käytössä leg.mode disclaimer. Jos on puske taulukkoon.
Tekstit kannattaa siirtää pois translations.txt tiedostosta config .modeDisclaimer objektiin.

Copy link
Member

@vesameskanen vesameskanen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Muutokset menee oikeaan suuntaan, mutta vieläkin voi parantaa.

@vesameskanen vesameskanen merged commit a7d3bd2 into v3 Nov 20, 2023
5 of 6 checks passed
@vesameskanen vesameskanen deleted the DT-4910 branch November 20, 2023 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants