Skip to content

Media/refactor hooks #715

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

Merged
merged 5 commits into from
Feb 4, 2022
Merged

Media/refactor hooks #715

merged 5 commits into from
Feb 4, 2022

Conversation

gweiying
Copy link
Contributor

@gweiying gweiying commented Dec 17, 2021

This PR adds custom React query hooks for the media CRUD operations, and updates the existing directory hooks with media directory invalidation and caching logic.

Implementation

The media CRUD React query hooks differ from previous hooks.

As the media retrieval is slower and more resource-heavy, we use React Query's setQueryData details to immediately create cached copies of the media content. We use this caching for the following scenarios:

  • creating a media file
  • updating the name of a media file
  • deleting a media file
  • retrieving the directory of media files (from the media directory list, caching the content of each individual media file)

We can also consider in the future extending this to the renaming of media directories as that is also fairly slow, however this is not currently supported on the backend as the backend does not return the new directory name. As this is unlikely to be a common issue, we can consider this in the future.

Others

This PR does not provide any standalone functionality and is meant to be reviewed with #716, #717, #718, and #719. However this PR is backward compatible and does not break existing functionality.

Copy link
Contributor

@alexanderleegs alexanderleegs left a comment

Choose a reason for hiding this comment

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

lgtm!

@gweiying gweiying merged commit 219aa98 into media/refactor Feb 4, 2022
@gweiying gweiying deleted the media/refactor-hooks branch February 4, 2022 07:53
@gweiying gweiying mentioned this pull request Feb 4, 2022
gweiying added a commit that referenced this pull request Feb 4, 2022
* Media/refactor hooks (#715)

* feat(hooks): add media CRUD hooks

* fix(hooks): update query invalidation logic for media CRUD directories

* fix(hooks): update query invalidation logic for media move

* nit: clean up unused variables and copy

* fix: update with correct query key params

* Media/refactor components (#716)

* refactor(Breadcrumb): update Breadcrumb to parse mediaDirectoryName

* refactor(Breadcrumb): update BreadcrumbItem to accept onClick argument

* fix(Breadcrumb): update CSS and fix typo in resource links

* refactor(move): create move components

* refactor(move): update page move modal with new components

* refactor(media): remove inline queries & upload handler from media select modal

* refactor(media): create parent component for media upload input html component

* refactor(media): add modal and yep schema validation for media settings

* refactor(media): add parent media component for media actions (upload, select, alt-text)

* refactor(media): update EditorModals and FormFieldMedia to use parent media component for actions

* refactor(media): add media move modal

* refactor(media): update FolderCard and MediaCard

* refactor(media): update DirectoryCreation and DirectorySettings for media directories support

* nit: fix extra ~ in copy for special characters error

* chore: update sidebar links for media directories

* chore: clean up unused components

* chore: add media utils and validators

* refactor(media): add medial modal for alt-text input

* fix: allow # in media directory names

* fix: update handling for retrieved mediaDatas

* Media/refactor tests (#717)

* chore: update button copy and button ids in tests

* chore: add alt text copy for EditPage insert media test

* chore: update resource tests for refactored FormFieldMedia component

* chore: update images and files tests for refactored Media flows

* chore: add waits for flaky test timeouts

* chore: fix flaky tests

* Media/refactor layouts (#719)

* refactor(screens): generalize PageMoveScreen to handle both pages and media

* fix: update references to MoveScreen

* feat(screens): add MediaCreation and MediaSettings screens

* refactor(screens): update DirectoryCreation and DirectorySettings to support media directories

* refactor(screens): update DeleteWarning to support media

* refactor(Media): update Media layout:
- remove inline react query
- remove inline upload handler
- replace inline states with url params

* chore: update frontend routes

* fix: add missing variable for ResourceCategory layout

* refactor(media): add medial modal for alt-text input

* chore: encode media directory link in FolderCard

* Media/refactor services (#743)

* feat: add media CRUD services

* fix(services): update directory services with media endpoints and handlers

* fix(services): update mover services with media endpoints

* chore: add mediaServices to servicesContext

* chore: update documentation of endpoints
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.

2 participants