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

fix get language locale from map provider #891

Merged
merged 5 commits into from Jul 20, 2021

Conversation

yen-tt
Copy link
Contributor

@yen-tt yen-tt commented Jul 20, 2021

  • getLanguageForProvider was using an undefined variable supportedLocalesforProvider. Updated function to
    get provider instance based on given provider name, and check if the given locale is within the list of provider's supported locales.

J=TECHOPS-1288
TEST=manual

used client experience that uses locale en_GB and see that map is loaded on page
added jest test for getLanguageForProvider()

@coveralls
Copy link

coveralls commented Jul 20, 2021

Coverage Status

Coverage increased (+0.9%) to 6.79% when pulling ff7b5da on dev/full-map-page-locale-fix into 7d6fcaa on hotfix/v1.22.2.

@cea2aj
Copy link
Member

cea2aj commented Jul 20, 2021

Looks good. I think we should probably add a little unit test coverage as well

if (supportedLocalesForProvider.includes(localeStr)) {
return localeStr;
}
const provider = (mapProvider === 'google') ? GoogleMaps : MapboxMaps;
Copy link
Contributor

@oshi97 oshi97 Jul 20, 2021

Choose a reason for hiding this comment

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

should we display an error if mapprovider is not google or mapbox? maybe we want to extract this logic to a separate helper since it's also used in ThemeMap.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, that would help if something is not configure right. I will update this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you think it would be better to default to google/mapbox, or just log error and return null?

Copy link
Contributor

@oshi97 oshi97 Jul 20, 2021

Choose a reason for hiding this comment

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

maybe log an error and return 'en'? I think returning null would make it blow up later down the road. If we want it to blow up I think we should just throw an error, though I imagine logging an error is good enough to not hide bugs but still handle things gracefully

Copy link
Contributor

Choose a reason for hiding this comment

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

ooo sorry you mean for the helper, yeah I think that's fine!

Copy link
Contributor

Choose a reason for hiding this comment

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

we probably don't want to default, I think the provider already defaults to mapbox somewhere else in the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you are referring to the loadAndInitializeMap() in ThemeMap for defaulting to mapbox? which we would replace with our helper call. So I guess to keep the functionality the same, I would default to Mapbox.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah yeah that's my bad

@yen-tt yen-tt requested a review from oshi97 July 20, 2021 21:03
@yen-tt yen-tt merged commit 786ad90 into hotfix/v1.22.2 Jul 20, 2021
@yen-tt yen-tt deleted the dev/full-map-page-locale-fix branch July 20, 2021 22:01
@tmeyer2115 tmeyer2115 mentioned this pull request Jul 26, 2021
tmeyer2115 added a commit that referenced this pull request Jul 26, 2021
### Bug Fixes
- Fixed the logic of the `getLanguageForProvider` utility method. This method maps the `locale` specified by the user to one that is understood by the chosen map provider. (#891)
- Corrected a styling issue with the `SpellCheck` query suggestion. This issue made it difficult to click the query suggestion and fire off a new query. (#892)
@tmeyer2115 tmeyer2115 mentioned this pull request Aug 10, 2021
tmeyer2115 added a commit that referenced this pull request Aug 10, 2021
### Bug Fixes
- Fixed the logic of the `getLanguageForProvider` utility method. This method maps the `locale` specified by the user to one that is understood by the chosen map provider. (#891)
- Corrected a styling issue with the `SpellCheck` query suggestion. This issue made it difficult to click the query suggestion and fire off a new query. (#892)
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.

None yet

4 participants