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

Nearby view support #655

Merged

Conversation

daniel-heppner-ibigroup
Copy link
Contributor

@daniel-heppner-ibigroup daniel-heppner-ibigroup commented Sep 13, 2023

This PR adjusts all the places where the stop viewer is called to pass in the whole stop object rather than just the stop ID string. This allows support for the nearby view in OTP-RR, which relies on the lat/lon of the stop rather than its ID.

@daniel-heppner-ibigroup daniel-heppner-ibigroup marked this pull request as ready for review September 28, 2023 18:00
Copy link
Collaborator

@miles-grant-ibigroup miles-grant-ibigroup left a comment

Choose a reason for hiding this comment

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

Could use some improvement in the future but it's good enough for now!

@binh-dam-ibigroup
Copy link
Collaborator

@miles-grant-ibigroup @daniel-heppner-ibigroup Is this one of these PRs that need to be split, especially for the types package, so that a version number is available for other packages to use as reference?

import { FormattedMessage } from "react-intl";

import * as S from "../styled";
import { defaultMessages } from "../util";

interface Props {
onStopClick: ({ stopId: string }) => void;
stopId: string;
onStopClick: (stop: Stop) => void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a breaking change. Either:

  1. Add breaking change commits to all packages that use this new method signature, or,
  2. If maintaining compatibility, change the signature of onStopClick to (stop: Stop | { stopId: string }) (You could create an alias type StopEventHanlder = (stop: Stop | { stopId: string }) => void in the types package to avoid repetition.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great idea! I'll add it. Thank you for the suggestion

@daniel-heppner-ibigroup
Copy link
Contributor Author

Merge conflicts resolved, ready for another look @binh-dam-ibigroup

Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

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

Could you address the tsc error during yarn build?

@daniel-heppner-ibigroup
Copy link
Contributor Author

That's embarrassing. I assigned it back to you before I finished my commits.

Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

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

Update references to the types package to 6.2.0, keep the stopId prop in ViewStopButton, and probably take the tile overlay and stops overlay changes out of this PR (you will need another PR anyway to resolve references to non-alpha versions).

packages/building-blocks/package.json Outdated Show resolved Hide resolved
packages/endpoints-overlay/package.json Outdated Show resolved Hide resolved
import { FormattedMessage } from "react-intl";

import * as S from "../styled";
import { defaultMessages } from "../util";

interface Props {
onStopClick: ({ stopId: string }) => void;
stopId: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Keep this prop (as a fallback) otherwise it is a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made it an either or type, let me know if that's good

@@ -16,10 +16,10 @@
"react-map-gl": "^7.0.15"
},
"dependencies": {
"@opentripplanner/map-popup": "^2.0.5"
"@opentripplanner/map-popup": "^2.0.7-alpha.1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

The tile overlay package should probably be released from a separate PR after the map popup package is released.

"@opentripplanner/map-popup": "^2.0.5",
"@opentripplanner/base-map": "^3.0.15",
"@opentripplanner/from-to-location-picker": "^2.1.10",
"@opentripplanner/map-popup": "^2.0.7-alpha.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The stops overlay package should probably be released from a separate PR after the map popup package is released.

packages/stops-overlay/src/StopsOverlay.story.tsx Outdated Show resolved Hide resolved
packages/stops-overlay/src/StopsOverlay.story.tsx Outdated Show resolved Hide resolved
packages/stops-overlay/src/index.tsx Show resolved Hide resolved
@daniel-heppner-ibigroup
Copy link
Contributor Author

I can't update the Map Overlay package first because it breaks the types in other packages, since the callback can now return a Stop. I think that means a breaking change is unavoidable in Map Overlay and they have to be released with alpha packages.

Sidenote, this is why upgrading to a more modern package manager such as yarn 3 or pnpm would be advantageous, since you can put workspace: as the package version in your monorepo packages.

Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

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

I think it is good to go with one tiny type tweak.

@binh-dam-ibigroup
Copy link
Collaborator

I think that means a breaking change is unavoidable in Map Overlay and they have to be released with alpha packages.

That's fine, but then upgrade to the non-alpha versions soon after they are released.

BREAKING CHANGE: Callback handler for setViewedStop needs to handle a Stop object
Copy link
Collaborator

@miles-grant-ibigroup miles-grant-ibigroup left a comment

Choose a reason for hiding this comment

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

Off to the races 🫡

packages/itinerary-body/package.json Outdated Show resolved Hide resolved
@daniel-heppner-ibigroup daniel-heppner-ibigroup merged commit d76d949 into opentripplanner:master Nov 29, 2023
2 checks passed
@daniel-heppner-ibigroup daniel-heppner-ibigroup deleted the nearby-view-support branch November 29, 2023 20:34
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