Refactor CustomListEditor and related components. #31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This refactors the
CustomListEditor
,CustomListEntriesEditor
, andCustomListSearch
components to:The state that was being kept by these components is now lifted up into the Redux store. Several new action creators have been added to represent the actions users can perform on the custom list editor form. A new
customListEditor
reducer handles these actions, and updates the state accordingly. The view components are now pure functions that accept props (pulled from the Redux state), and return a rendered DOM.† There is still one tiny bit of state in
CustomListEntriesEditor
, the source of a drag while a drag-and-drop is in progress. This can be moved later, if we ever need to generalize drag-and-drop.This presentation contains an overview of the refactoring: https://docs.google.com/presentation/d/1v-0KdPXHT_fe6suydnUhTeY_NrVFt_lYqFLbPEH9JZc
Motivation and Context
This greatly simplifies the view components, makes them more testable, and reduces the chance of introducing bugs. It was originally motivated by trying to fix the Save and Cancel buttons being enabled before any changes to a list had been made (https://www.notion.so/lyrasis/Custom-List-Manager-has-active-Save-Cancel-buttons-before-anything-has-been-changed-06ae75f1e064469da0e70bd662396059). This was caused by a confusing interaction between the props and state of
CustomListEditor
. Refactoring these components to remove state allows us to fix this issue, and makes it easier to add new features.Notion: https://www.notion.so/lyrasis/Refactor-list-editing-components-to-be-stateless-1e9dbc5af08643b99867d4bdabdcb536
How Has This Been Tested?
Checklist: