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

Enable list save button when a collection is selected. #27

Merged
merged 1 commit into from
Jun 15, 2022

Conversation

ray-lee
Copy link
Contributor

@ray-lee ray-lee commented Jun 10, 2022

Description

  • Previously, when editing a list, the save button was only enabled when a book was added from a search. Now, the save button is enabled when either a source collection is selected, or a book is added from a search.

  • The logic to determine if the save button should be enabled didn't really make sense to me -- possibly some stuff was left over from older versions, and isn't relevant now -- so I rewrote it to be much simpler.

  • When writing new tests, I ran into some places where there were missing null checks on variables, so I fixed those.

Note: I don't like the implementation of the list editing component. It has a lot of internal state that makes it very hard to test without directly setting the state in tests, which breaks the encapsulation. I don't have time to refactor the component to be stateless now, but I'd like to in the future.

Motivation and Context

The implementation team sometimes needs to create lists that automatically add from collections, and do not specify any additional books from a search. This is a valid way to create a list, but the admin UI doesn't allow the list to be saved without having any books added from a search.

Notion: https://www.notion.so/lyrasis/Cannot-save-a-list-without-an-item-in-it-on-Collection-Manager-665bc3d28d9c451ba778ff0558f81133

How Has This Been Tested?

  • In the admin UI, click on Lists in the header.
  • Click Create New List in the left sidebar.
    The save button should be disabled.
  • Enter a title.
    The save button should be disabled.
  • Expand the Add from collections section.
  • Check any collection.
    The save button should be enabled.
  • Uncheck the collection.
    The save button should be disabled.
  • In the Search for titles section, enter a search term, and click Search.
  • Drag one of the results to the list on the right.
    The save button should be enabled.
  • Try various combinations of title, having/not having selected collections, and having/not having list items.
    The save button should be enabled only when there is a non-blank title, and either a collection is selected, or a book is added.

Unit tests are included.

Checklist:

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

Previously, the save button was only enabled when a book was added. Now, the save button is enabled when either a collection is selected, or a book is added.
@ray-lee ray-lee requested a review from a team June 10, 2022 01:16
Copy link
Contributor

@RishiDiwanTT RishiDiwanTT left a comment

Choose a reason for hiding this comment

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

Looks good!

@tdilauro tdilauro merged commit b430b15 into main Jun 15, 2022
@tdilauro tdilauro deleted the bugfix/save-list-with-collection-only branch June 15, 2022 15:48
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