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

debug client: support stop ids in from / to inputs #6133

Open
wants to merge 2 commits into
base: dev-2.x
Choose a base branch
from

Conversation

richardkoszegi
Copy link
Contributor

Summary

Added support for location ids in from/to fields in debug client.

Implementation Details:

  • Added locationConverter: converts strings to Location objects and back based on LocationStringParser class.
  • LocationInputField: a value state introduced for the input field. The new useEffect hook updates this state when location parameter changes. On the onBlur event, this component fires the new onLocationChange event if a valid location can be parsed from the input.
  • SearchBar: updates tripQueryVariables based on the changed location.

@richardkoszegi richardkoszegi requested a review from a team as a code owner October 9, 2024 13:55
Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (dev-2.x@f9ea044). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             dev-2.x    #6133   +/-   ##
==========================================
  Coverage           ?   69.93%           
  Complexity         ?    17727           
==========================================
  Files              ?     1996           
  Lines              ?    75402           
  Branches           ?     7717           
==========================================
  Hits               ?    52730           
  Misses             ?    19995           
  Partials           ?     2677           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leonardehrenfried
Copy link
Member

We talked about it and @t2gran has requested that you look up the coordinate of the stop and place the flag icon on the map. Would that be too much to ask?

I personally like this change but @testower is the React expert and needs to review it.

@t2gran t2gran added this to the 2.7 (next release) milestone Oct 16, 2024
@richardkoszegi
Copy link
Contributor Author

We talked about it and @t2gran has requested that you look up the coordinate of the stop and place the flag icon on the map. Would that be too much to ask?

I personally like this change but @testower is the React expert and needs to review it.

I hope it won't be a big change, so it can be implemented in this pr. 🙂

I think I just need to write a stopId -> coordinates resolver using the quay query and call it in the NavigationMarkers component to set the flags.

@@ -29,6 +29,26 @@ export function SearchBar({ onRoute, tripQueryVariables, setTripQueryVariables,
const [showServerInfo, setShowServerInfo] = useState(false);
const target = useRef(null);

const setFromLocation = useCallback(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is perfectly fine pattern, but we have done it slightly differently - passing tripQueryVariables and setTripQueryVariables into the input components, and calling them there. I suggest keeping to this for consistency.

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 moved these functions to the LocationInputField component.


const NAME_SEPARATOR = '::';

export function parseLocation(value: string): Location | null {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand what this function does. In particular, there seems to be something going on with "name" which seems out of scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These function is the typescript version of the LocationStringParser.java class.

I removed the "name" parsing part.

@richardkoszegi
Copy link
Contributor Author

I implemented the stopId -> coordinate resolver with the quay query, and it works fine with stops, but not with stop places / stop-areas or any other nodes that have id (eg. vehicle rental stations).

I think it's not the frontend's job to decide, which query has to be called to resolve the coordinates, so it would be nice, if the graphql api has a generic place query, that resolves the coordinates for any id. What do you think about it?

Comment on lines +17 to +18
longitude,
latitude,
Copy link
Member

@t2gran t2gran Oct 22, 2024

Choose a reason for hiding this comment

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

My knowledge of JS is limited - but it looks like the arguments order is swapped according to the interface definition above. As a practice to avoid errors I like to always do lat, long never long, lat (doc, params, args, execution order and so on).

@testower
Copy link
Contributor

There are still unresolved issues in this PR imho. Maybe need to discuss in developer meeting? Although I'm unable to join until week after next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants