[feat] Allow rename before image upload in EditPage, refactor ImageModal #117
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.
Overview
This PR achieves a couple of things:
EditPage
component (previously implemented for theImages
tab in [Feat] Allow image upload in EditPage #105).ImageModal
component to be a ReactPureComponent
. This provides performance benefits when rendering newly uploaded images. We can usePureComponent
because the shallow comparison performed byPureComponent
(which only compares references for objects/nested state) is sufficient because we do not and will not allow users to replace the content of an image while retaining the file name.Renaming before upload
This functionality is facilitated by storing
images
in the parentEditPage
instead of insideImageModal
. Ifimages
were stored insideImageModal
, we would need to define a modal inside a modal, which would prevent us from taking advantage of the performance benefits afforded by usingPureComponent
. The flow for uploading an image inEditPage
thus becomes:ImageModal
appearsImageModal
. This allows the user to select an image to upload.ImageSettingsModal
to rename the image. Upon clicking save,EditPage
retrieves the images again so that the newly uploaded image is reflected inImageModal
and theImageSettingsModal
is closed.