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

Task/WP-728: Mutation hook: Copy file #1000

Merged
merged 12 commits into from
Nov 21, 2024
Merged

Conversation

jalowe13
Copy link
Collaborator

@jalowe13 jalowe13 commented Nov 6, 2024

Overview

Updating hooks to use React Query mutations with Typescript. This mutation covers copying a file.

Related

Changes

  • useCopy.js to useCopy.ts
  • Identify types of payloads
  • Wraps dispatch actions inside a mutation

Testing

  • Navigate to the folder where the file is that you would like to copy
  • Select the checkbox of the folder
  • Click the copy button
  • Select the destination directory to copy to

UI

image

Copy link

codecov bot commented Nov 6, 2024

Codecov Report

Attention: Patch coverage is 16.79389% with 109 lines in your changes missing coverage. Please review.

Project coverage is 72.88%. Comparing base (b01a86a) to head (71709a7).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
client/src/hooks/datafiles/mutations/useCopy.ts 16.79% 109 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1000       +/-   ##
===========================================
+ Coverage   60.44%   72.88%   +12.44%     
===========================================
  Files         211      534      +323     
  Lines        6285    33456    +27171     
  Branches      730     2981     +2251     
===========================================
+ Hits         3799    24385    +20586     
- Misses       2329     8876     +6547     
- Partials      157      195       +38     
Flag Coverage Δ
javascript 75.76% <16.79%> (?)
unittests 60.44% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
client/src/hooks/datafiles/mutations/useCopy.ts 16.79% <16.79%> (ø)

... and 322 files with indirect coverage changes

---- 🚨 Try these New Features:

@jalowe13 jalowe13 marked this pull request as ready for review November 6, 2024 21:32
@jalowe13 jalowe13 marked this pull request as draft November 7, 2024 19:19
@jalowe13 jalowe13 marked this pull request as ready for review November 7, 2024 20:43
@jalowe13 jalowe13 requested a review from shayanaijaz November 13, 2024 15:05
Copy link
Collaborator

@jmcmillenmusic jmcmillenmusic left a comment

Choose a reason for hiding this comment

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

This works 100% as intended! Looks good to me!

});
// Result
const result = copyCalls;
dispatch({
Copy link
Collaborator

@jarosenb jarosenb Nov 21, 2024

Choose a reason for hiding this comment

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

This dispatch will occur immediately after copyCalls is constructed. You might need to use mutateAsync and await each mutation before dispatching the toast. mutateAsync returns a promise so you could use Promise.all() here.

Copy link
Collaborator

@jarosenb jarosenb left a comment

Choose a reason for hiding this comment

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

LGTM! The final callback now doesn't fire until all operations are complete.

@jarosenb jarosenb merged commit adb9b29 into main Nov 21, 2024
5 of 6 checks passed
@jarosenb jarosenb deleted the task/WP-728--useCopy-mutation-hook branch November 21, 2024 22:02
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