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-4691: UI to connect to ensemble #3675

Merged
merged 42 commits into from
Feb 7, 2025

Conversation

SayakaOno
Copy link
Collaborator

@SayakaOno SayakaOno commented Jan 31, 2025

Description

Implement the first screen of the add sensor flow.

  • Add Partners component (to be renamed to Addons or something similar later)
    • The position of the cross icon for clearing error is off - this will be fixed in another ticket.
  • Update PostSensor container
    • API integration (POST farmAddon, GET sensors)
    • Remove white background colour from the form (Loïc confirmed!)
  • Add translations and colours (Includes translations and colours for LF-4693 and 4696 🙏)
  • Make Loading component fixed relative to viewport (The file is currently nested within ContextForm, but I plan to extract it in a future PR. Keeping it for now to avoid a bigger diff)
  • Implement ability to hide Previous button in WithStepperProgressBar
  • Add isCompactSideMenu prop to POST_SENSOR_URL route
  • Update Map component
    • Navigate to the Add sensors form when "Sensor" is selected
    • Remove sensor upload related code
  • Update ContextForm to accept formMode prop ("onBlur", "onChange" etc.)
  • Delete unused files and code for bulk sensor upload

Jira link: https://lite-farm.atlassian.net/browse/LF-4691

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?

  • 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

@SayakaOno SayakaOno added enhancement New feature or request new translations New translations to be sent to CrowdIn are present labels Jan 31, 2025
@SayakaOno SayakaOno self-assigned this Jan 31, 2025
* send showPreviousButton prop to ContextForm
@SayakaOno SayakaOno requested review from antsgar and Duncan-Brain and removed request for a team February 3, 2025 18:09
@SayakaOno SayakaOno force-pushed the LF-4691/UI_to_connect_to_Ensemble branch from 607cb74 to c53bdf2 Compare February 3, 2025 18:11
Duncan-Brain
Duncan-Brain previously approved these changes Feb 5, 2025
Copy link
Collaborator

@Duncan-Brain Duncan-Brain left a comment

Choose a reason for hiding this comment

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

Looking good!

Left a couple of inline questions ..nothing too important I don't think.

Empty scrollbar is present:
Screenshot 2025-02-04 at 12 49 25 PM

I am not sure if Loading should be under /ContextForm -- it seems like it should be for all of app or replace existing Loading animation if we are redesigning a new one.

Could consider creating a /Addon directory and placing Partners cards under it since may be shared between farm settings, add sensors and probably other addons like layers and pivots.

return uuidValidate(value) || errorMessage;
};

const PARTNERS = [{ name: 'Ensemble scientific', url: 'www.esci.io', logoPath: EsciLogo }];
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 go in new constants file with the partner id in this object? in addon_partner table "scientific" is capitalized : 'Ensemble Scientific'

@@ -277,4 +288,6 @@ export const {
useAddSoilAmendmentProductMutation,
useUpdateSoilAmendmentProductMutation,
useGetSensorsQuery,
useLazyGetSensorsQuery,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool ! Is this to start requesting data faster than loading of next component?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Exactly! I'm not sure if I keep it with the updated design though...


// Proceed to sensors view
onSuccess();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the form data be cleared here?

Currently when I press save, successfully reach next page, then press back button >>> entered data is still present in input. I think in the future when GET endpoint is ready it will check for existing addon -- so maybe that will handle the need to clear form or not.

styles.loadingScreen,
isCompactSideMenu ? styles.withCompactSideMenu : styles.withExpandedSideMenu,
)}
style={style}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is inline styles temporary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, it's permanent. This is the only way I know to use dynamic px values via props in CSS, but if you know a better way, please let me know!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, I didn't see the props being used by any parents yet so thought maybe it was just for testing. Would a className not be able to override variables 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.

Ah I see! It should be possible, but we'd have to do isCompactSideMenu ? styles.withCompactSideMenu : styles.withExpandedSideMenu in the parent component and write this much of CSS for a className, so using style seems more intuitive and simpler.

.className {
  height: calc(100vh - var(--global-navbar-height) - var(--vertical-margin) * 2);

  &.withCompactSideMenu {
    width: calc(100vw - var(--global-compact-side-menu-width) - var(--horizontal-margin) * 2);
  }
  &.withExpandedSideMenu {
    width: calc(100vw - var(--global-side-menu-width) - var(--horizontal-margin) * 2);
  }

  @include xs-breakpoint {
    &.withCompactSideMenu,
    &.withExpandedSideMenu {
      width: calc(100vw - var(--mobile-margin) * 2);
      height: calc(100vh - var(--global-navbar-height) - var(--mobile-margin) * 2);
      margin: var(--mobile-margin);
    }
  }
}

FormContent: () => <div>Partner selection view</div>,
onContinueAction: linkOrganizationId,
FormContent: () => <Partners />,
onContinueAction: linkEsci,
},
{ FormContent: () => <div>ESCI devices view</div> },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this temporary? I don't think ESCI devices view should be a step in the form. I see it looks that way in figma... but I am not sure its appropriate. If we are making a pattern similar to AnimalsSummary we should maybe reuse that instead and redirect to this page.

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 believe it should've been implemented this way with the old header and the back button, and I was going to create another container for the sensor list page. It makes sense to redirect the user to the sensor list page with the updated design!

@SayakaOno SayakaOno marked this pull request as draft February 5, 2025 17:53
Copy link
Collaborator Author

@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.

Thank you @Duncan-Brain !
I'll try to fix the scrollbar. As for the file structure, I'll reorganize it later in a separate PR!

I'll re-open the PR once I apply the updated design. Thank you 🙏

FormContent: () => <div>Partner selection view</div>,
onContinueAction: linkOrganizationId,
FormContent: () => <Partners />,
onContinueAction: linkEsci,
},
{ FormContent: () => <div>ESCI devices view</div> },
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 believe it should've been implemented this way with the old header and the back button, and I was going to create another container for the sensor list page. It makes sense to redirect the user to the sensor list page with the updated design!

styles.loadingScreen,
isCompactSideMenu ? styles.withCompactSideMenu : styles.withExpandedSideMenu,
)}
style={style}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, it's permanent. This is the only way I know to use dynamic px values via props in CSS, but if you know a better way, please let me know!

@@ -277,4 +288,6 @@ export const {
useAddSoilAmendmentProductMutation,
useUpdateSoilAmendmentProductMutation,
useGetSensorsQuery,
useLazyGetSensorsQuery,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Exactly! I'm not sure if I keep it with the updated design though...

* accept showLoading instead of onContinueAction in steps
* accept onAfterSave prop
* avoid page transition blocking after form is saved
* adjust stories
@SayakaOno
Copy link
Collaborator Author

Updates:

  • The sensors list is not part of the form anymore.
  • Update WithStepperProgressBar to:
    • accept showLoading instead of onContinueAction in steps
    • accept onAfterSave prop
    • avoid page transition blocking after form is saved
    • adjust stories
  • Fix capitalization in 'Ensemble Scientific'
  • Fix padding styling (it was weirdly scrollable)
  • Hide unnecessary scrollbar
  • PARTNERS constant cleanup

Thank you for re-reviewing! 🙏

@SayakaOno SayakaOno marked this pull request as ready for review February 6, 2025 00:45
@@ -92,3 +92,6 @@ export const createCompleteTaskUrl = (id: string | number, hasAnimals: boolean):
// Maps
export const MAP_URL = '/map';
export const POST_SENSOR_URL = '/create_location/sensor';

// Sensors
export const SENSORS = '/sensors';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. /sensors?partner_id=1
  2. /addon/1/sensors

I initially presented the first option to the team, but if we prioritize the addon over sensors as Duncan mentioned, we could probably go with something like the second one? Any thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Both would be good! The first one also adds flexibility if we ever decide we want to have a screen showing all sensors for all manufacturers, which would be /sensors, but Loïc said we wouldn't want to do that so maybe irrelevant.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah this is tough, I agree both are good. You could choose either. I just want to keep /map out of it I think. It might make sense to eventually reach these multiple ways so I think you can choose!

So many thoughts -- but are they useful? haha

Just trying to think about how a farmer might set up an addon. Especially if that addon does multiple things like ESCI -- they provide us with both irrigation prescriptions and sensors. So I can see how navigating from /farm_setting to /addon makes sense. (option 2)

But I also understand that eventually (in the distant future) might be need for a /farm_equipment/ module where we would move access to /sensors or /irrigation_equipment and then configuring or viewing there. (option 1)

Same with /Insights/irrigation_prescriptions etc.

Since for some reason we are adding an esci addon (with both prescriptions and sensors) with the "add sensors" button it might make sense either way 🤷

Copy link
Collaborator

@antsgar antsgar left a comment

Choose a reason for hiding this comment

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

Sorry it took a while for me to review this! This looks soooo good, the loading screen with the animation is on point 🔥 it's so clean! Loving it ❤️

@@ -92,3 +92,6 @@ export const createCompleteTaskUrl = (id: string | number, hasAnimals: boolean):
// Maps
export const MAP_URL = '/map';
export const POST_SENSOR_URL = '/create_location/sensor';

// Sensors
export const SENSORS = '/sensors';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Both would be good! The first one also adds flexibility if we ever decide we want to have a screen showing all sensors for all manufacturers, which would be /sensors, but Loïc said we wouldn't want to do that so maybe irrelevant.

Copy link
Collaborator

@Duncan-Brain Duncan-Brain left a comment

Choose a reason for hiding this comment

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

Looking great I love how ContextForm is improving over time!

@Duncan-Brain Duncan-Brain added this pull request to the merge queue Feb 7, 2025
Merged via the queue into integration with commit 312f57c Feb 7, 2025
4 of 5 checks passed
@Duncan-Brain Duncan-Brain deleted the LF-4691/UI_to_connect_to_Ensemble branch February 7, 2025 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new translations New translations to be sent to CrowdIn are present
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants