-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
☑️ Refacto "Select All/Unselect all" on indexes #5320
Merged
Merged
Changes from 21 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
0655efd
☑️ Refacto "Select All/Unselect all" on indexes
gitstart-twenty e056193
Merge commit '005045c596d8b080539ec180c83aa75d301bf770' of https://gi…
gitstart-twenty 40faff3
Fix jest
gitstart-twenty 1cf0db6
Refactor according to self review
gitstart-twenty d6f0675
Merge commit 'fdf10f17e2fa91da60336140fb859ae56e8acfb9' of https://gi…
gitstart-twenty 29dd4f6
Refactor according to review
gitstart-twenty 7de431d
Merge main
gitstart-twenty c0ca3bd
Merge main
gitstart-twenty 5a52f64
Merge main
gitstart-twenty bd8c53e
Merge main
gitstart-twenty fb13ca2
Merge branch 'main' into TWNTY-4397
FelixMalfait 7acce56
Merge branch 'main' into TWNTY-4397
lucasbordeau 2477b14
Fixed typing problem
lucasbordeau 856fa81
Fix
lucasbordeau cb51287
Merge branch 'main' into TWNTY-4397
lucasbordeau 9d7d570
Change download predicate
gitstart-twenty de563bf
Merge main
gitstart-twenty 52a64c7
Merge commit 'd126b148a19bc32a7cb52e7ed04d2470bf8be6b5' of https://gi…
gitstart-twenty a43bf6b
Fix Select All checkbox
gitstart-twenty dfe033d
Merge branch 'main' into TWNTY-4397
lucasbordeau fe9c465
Fixed bug
lucasbordeau 72a4e70
Refactor according to review
gitstart-twenty 922942d
Revert temporary changes
gitstart-twenty db93173
Fix linter issues
gitstart-twenty 72aa58c
Fix records count
gitstart-twenty cf1ac0e
Fix linter
gitstart-twenty 079a412
Merge branch 'main' into TWNTY-4397
lucasbordeau d91482d
Merge commit '5df0ea6466be885ce85dcb2bb849b8493698ce52' of https://gi…
gitstart-twenty d5011b3
Fix click outside table
gitstart-twenty e1343a3
Merge branch 'main' into TWNTY-4397
lucasbordeau 7c7edaa
WIP
lucasbordeau 0c76416
Fix
lucasbordeau 4cefd9c
Fix
lucasbordeau 1bb1d27
removed refetch queries
lucasbordeau 968046d
WIP
lucasbordeau d5f863a
WIP
lucasbordeau 6e6c7f6
WIP
lucasbordeau ec1b8be
Merge branch 'main' into TWNTY-4397
lucasbordeau b676c8b
WIP
lucasbordeau 1ae7a4f
Fixed bug
lucasbordeau 5cf6444
Cleaned
lucasbordeau c04d308
Fixed favorites
lucasbordeau e4bd470
Naming fix
lucasbordeau 9714cd6
Fixed typo
lucasbordeau 1156e08
Fxed naming
lucasbordeau 8ffbbdf
Fix
lucasbordeau 0cc7e64
Fixed test
lucasbordeau 2521676
Fixed coverage with test on new useFetchAllRecordIds and other utils
lucasbordeau 80621c6
Fix lint
lucasbordeau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,16 @@ type DeleteManyRecordsOptions = { | |
skipOptimisticEffect?: boolean; | ||
}; | ||
|
||
const chunkArray = <T>(array: T[], chunkSize: number): T[][] => | ||
array.reduce<T[][]>((acc, item, index) => { | ||
const chunkIndex = Math.floor(index / chunkSize); | ||
if (!acc[chunkIndex]) { | ||
acc[chunkIndex] = []; | ||
} | ||
acc[chunkIndex].push(item); | ||
return acc; | ||
}, []); | ||
|
||
export const useDeleteManyRecords = ({ | ||
objectNameSingular, | ||
}: useDeleteOneRecordProps) => { | ||
|
@@ -41,7 +51,7 @@ export const useDeleteManyRecords = ({ | |
objectMetadataItem.namePlural, | ||
); | ||
|
||
const deleteManyRecords = async ( | ||
const deleteRecordsWithIds = async ( | ||
idsToDelete: string[], | ||
options?: DeleteManyRecordsOptions, | ||
) => { | ||
|
@@ -81,5 +91,16 @@ export const useDeleteManyRecords = ({ | |
return deletedRecords.data?.[mutationResponseField] ?? null; | ||
}; | ||
|
||
const deleteManyRecords = async ( | ||
idsToDelete: string[], | ||
options?: DeleteManyRecordsOptions, | ||
chunkSize = 30, | ||
) => { | ||
const chunkedIds = chunkArray(idsToDelete, chunkSize); | ||
return Promise.all( | ||
chunkedIds.map((ids) => deleteRecordsWithIds(ids, options)), | ||
); | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're now deleting records in chunks of 30 |
||
return { deleteManyRecords }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract in a util