Skip to content

Conversation

@gracienl
Copy link

Purpose

This pull request updates the CropSelector component so that the green “+” button for adding a new crop can be optionally disabled.
In particular, the Harvest form should not allow adding a new crop from the CropSelector, since a crop must already exist in order to be harvested. This PR adds a prop to CropSelector to control that behavior and sets it so that the “+” is hidden on the Harvest form while remaining available in other contexts.

Verification steps

Navigate to: FarmData2 → Harvest. Locate the Crop input on the Harvest form.
Confirm that:

  • There is no green “+” button on the right side of the Crop selector.
  • You can still select an existing crop and submit the form as usual.

Approach

  1. A new optional prop named allowAdd was introduced to the CropSelector component. This prop determines whether the "+" button for creating a new crop should appear. The default behavior remains unchanged, since allowAdd defaults to true, meaning all existing forms continue to show the button unless they explicitly choose not to.
  2. Inside the component, the logic that enables the "+" button was updated so that it only activates when two conditions are met: the user has permission to create new crop types, and allowAdd is set to true. If either condition is not met, the button is not shown.
  3. On the Harvest form, allowAdd is now set to false. This removes the "+" button from that specific form, reflecting the fact that new crops should not be added during a harvest operation. All other forms that rely on the existing behavior continue to function normally.

Testing

  • Manual testing: Verified that the Harvest form no longer shows the green “+” button next to the Crop selector.
  • Automated testing: Ran:
    test.bash --fd2 --live --e2e --glob=modules/farm_fd2/**/harvest/*.e2e.cy.js --gui
    All existing Harvest E2E tests passed.

Related issues

Close #279

Additional Information

H12 - OSS2 Submission. Gracie and Rohan

Licensing Certification

FarmData2 is a Free Cultural Work and all accepted contributions are licensed as described in the LICENSE.md file. This requires that the contributor holds the rights to do so. By submitting this pull request I certify that I satisfy the terms of the Developer Certificate of Origin for its contents.

rohanpiya and others added 2 commits December 10, 2025 12:02
* Commit for draft pull request

* Removed + from the crop selector
* add allowAdd prop

* add allowAdd prop

* allowAdd prob done

* no new crop can be added

---------

Signed-off-by: rohanpiya <piyar@dickinson.edu>
Co-authored-by: rohanpiya <piyar@dickinson.edu>
Copy link

@braughtg braughtg left a comment

Choose a reason for hiding this comment

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

Overall this is looking pretty good. There are some changes that have been requested.

In addition, the E2E tests for the Harvest form should confirm that the "+" button is not visible when the CropSelector is used on the Harvest form. The component test requested checks that the new prop works, this test will check that that prop has actually been set by the Harvest form.

Please make the requested changes and push them to this PR. When you have made the changes change the PR back to "Ready for review".

@braughtg braughtg marked this pull request as draft December 10, 2025 17:51
@gracienl gracienl marked this pull request as ready for review December 10, 2025 19:45
Copy link

@braughtg braughtg left a comment

Choose a reason for hiding this comment

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

This is getting close! I have one suggestion in the code for a change in phrasing. Also, the prior review asked for an E2E test. See the comment on the harvest.e2e.cy.js file.

When you have made the changes, respond briefly to each comment and then change this PR back to ready for review.

default: false,
},
/**
* Whether the "+" should appear on the crop dropdown menu.

Choose a reason for hiding this comment

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

I think a better phrasing here would be "Whether the user is allowed to add a new crop or not."

Choose a reason for hiding this comment

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

As indicated in the prior review, a test should be added to this file that checks that the CropSelector is displayed in the Harvest form without the "+" allowing the user to add a new crop.

@braughtg braughtg marked this pull request as draft December 11, 2025 18:46
@gracienl gracienl marked this pull request as ready for review December 20, 2025 02:55
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.

Harvest form should not allow a new crop to be added.

3 participants