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

Lf 4742 link ensemble sensor list to map #3702

Open
wants to merge 18 commits into
base: integration
Choose a base branch
from

Conversation

Duncan-Brain
Copy link
Collaborator

@Duncan-Brain Duncan-Brain commented Feb 28, 2025

Description

This creates a LocationViewer component -- it includes a header bar with close button and selected locations.

The full width effect is on the route and not on the component.

Jira link: LF-4742

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have added "MISSING" for all new language tags to languages I don't speak
  • I have added the GNU General Public License to all new files

@Duncan-Brain Duncan-Brain requested review from a team as code owners February 28, 2025 01:38
@Duncan-Brain Duncan-Brain requested review from SayakaOno and kathyavini and removed request for a team February 28, 2025 01:38
Copy link
Collaborator

@SayakaOno SayakaOno left a comment

Choose a reason for hiding this comment

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

It's really tough to understand how the map works 😢 Thank you for figuring it out!!!
I left a few comments, but this is great!

style: PropTypes.object,
farmName: PropTypes.string,
showVideo: PropTypes.func,
showClose: PropTypes.func,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be onClose or handleClose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I kept the existing style of the component 'showVideo', but could update both?

Copy link
Collaborator

@SayakaOno SayakaOno Feb 28, 2025

Choose a reason for hiding this comment

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

"showVideo" is a function to show videos (not the icon), but isn't "showClose" used to close the map?
I might have misunderstood something 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

showVideo should have been named "onClickVideo" or "handleVideoClick" in my opinion because yes it is a function to show the videos. I didn't look how hard it would be to rename it.

Once I used it as a boolean to render the icon the name makes sense in that situation as a boolean. Then I kept that convention.

I will just change them both! I have no clue why but the video icon is an <input/> too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So they are both named with 'handle' now -- it was easy there was only one other component using it. I also moved the icon away from being an input element and converted the file to TS.

<DetectedFields t={t} fields={fields} />
<TextButton
className={styles.seeOnMapButton}
onClick={() => handleSeeOnMap(location)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Location duplicates data already available in GroupedSensors. Could we instead extract the necessary info from GroupedSensors and pass:

{
  id,
  location_id: id,
  point,
  type: isSensorArray ? 'sensor_array' : 'sensor',
}

instead of adding Location to useGroupedSensors?

If adding a fake location_id here doesn't feel right, we could add the fake one returned by the backend in useGroupedSensors...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question -- I know I duplicated data and I do not want to do it, but it was purposeful. I struggled with what the nicest way to do it was since we have two systems for using locations now -- selectors and queries. And the old components use the selectors.

I was tempted to just use the selectors and I think I thought if I matched the selectors... since the components were all built to use them .. I could avoid overthinking and "explicitly selecting" the desired data as you suggest. I wanted to just pass it and forget it even it it meant duplicating a little bit of data.

I am worried about eventually dealing with fake location_ids.. but it probably doesnt matter right now. Looking at it again I can probably explicitly choose the parameters as you are suggesting and add all the conditionals to deal with the structure differences... let me try that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay I used you code here -- the location type needed a name propert, that is the only reason I added it.

}}
locations={locations}
// Choose the active state as the way to view-only locations
selectedLocationIds={locations.map((l) => l.id)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be l.location_id?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! Not sure why it worked before

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