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

Closed source UI #22

Closed
wants to merge 1 commit into from
Closed

Closed source UI #22

wants to merge 1 commit into from

Conversation

CWestICL
Copy link

@CWestICL CWestICL commented Aug 8, 2023

Changes made to /frontend/components/software/edit/information/SoftwareInformationForm.tsx to hide the Repository URL, Citation and Licenses fields when the Closed Source switch is on.

Closes #20.

@CWestICL CWestICL requested a review from cc-a August 8, 2023 13:57
@CWestICL CWestICL self-assigned this Aug 8, 2023
@CWestICL
Copy link
Author

CWestICL commented Aug 8, 2023

PR opened in draft as I haven't implemented the changes for the Licenses field yet. I'm still working on creating a hidden field that submits a value of "Proprietary" when the Licenses field is hidden.

@cc-a
Copy link

cc-a commented Aug 9, 2023

Thanks for this @CWestICL. Looks like a good start. One question, and bear with me here, but how does it work? The logic in the AutosaveSoftwareLicenses function makes sense to me and I guess the form is being re-rendered when the switch is toggled but what's the mechanism behind this?

For any further changes could you create PR's against the closed-source-ui branch, same as we did with the imperial-home-page branch. We'll need to shut this one as we shouldn't be putting things into main of this fork.

@CWestICL
Copy link
Author

CWestICL commented Aug 9, 2023

Ah my bad, I'll reopen this PR with a new branch.

As for the mechanism behind what I've done so far, I think the SoftwareInformationForm component is using some react-hook-form functionality to watch for any changes made to the form and re-render accordingly. Each time the switch is toggled it updates the formData.closed_source value which I've then used an if statement to hide/show the relevant fields.

I haven't actually implemented the AutosaveSoftwareLicenses logic yet as I haven't wrapped my head around how exactly the License values are saved to the Software item in the database. I'm thinking that I can use the if statement to hide the Licenses field like I've done the others but I also need to find a way to inject the "Proprietary" value into the form itself.

@CWestICL CWestICL closed this Aug 9, 2023
@CWestICL CWestICL mentioned this pull request Aug 9, 2023
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.

Modify software edit form based on Closed Source toggle
2 participants