-
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 41 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
1 change: 1 addition & 0 deletions
1
packages/twenty-front/src/modules/object-record/constants/DefaultMutationBatchSize.ts
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export const DEFAULT_MUTATION_BATCH_SIZE = 30; |
1 change: 1 addition & 0 deletions
1
packages/twenty-front/src/modules/object-record/constants/DeleteMaxCount.ts
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export const DELETE_MAX_COUNT = 10000; |
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
2 changes: 1 addition & 1 deletion
2
packages/twenty-front/src/modules/object-record/hooks/__tests__/useFindManyRecords.test.tsx
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
76 changes: 76 additions & 0 deletions
76
packages/twenty-front/src/modules/object-record/hooks/useFetchAllRecordIds.ts
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; | ||
import { UseFindManyRecordsParams } from '@/object-record/hooks/useFetchMoreRecordsWithPagination'; | ||
import { useLazyFindManyRecords } from '@/object-record/hooks/useLazyFindManyRecords'; | ||
import { useCallback } from 'react'; | ||
import { isDefined } from '~/utils/isDefined'; | ||
|
||
type UseLazyFetchAllRecordIdsParams<T> = Omit< | ||
UseFindManyRecordsParams<T>, | ||
'skip' | ||
>; | ||
|
||
export const useFetchAllRecordIds = <T>({ | ||
objectNameSingular, | ||
filter, | ||
orderBy, | ||
}: UseLazyFetchAllRecordIdsParams<T>) => { | ||
const { fetchMore, findManyRecords } = useLazyFindManyRecords({ | ||
objectNameSingular, | ||
filter, | ||
orderBy, | ||
recordGqlFields: { id: true }, | ||
}); | ||
|
||
const { objectMetadataItem } = useObjectMetadataItem({ | ||
objectNameSingular, | ||
}); | ||
|
||
const fetchAllRecordIds = useCallback(async () => { | ||
if (!isDefined(findManyRecords)) { | ||
return []; | ||
} | ||
|
||
const findManyRecordsDataResult = await findManyRecords(); | ||
|
||
const firstQueryResult = | ||
findManyRecordsDataResult?.data?.[objectMetadataItem.namePlural]; | ||
|
||
const totalCount = firstQueryResult?.totalCount ?? 1; | ||
|
||
const recordsCount = firstQueryResult?.edges.length ?? 0; | ||
|
||
const recordIdSet = new Set( | ||
firstQueryResult?.edges?.map((edge) => edge.node.id) ?? [], | ||
); | ||
|
||
const remainingCount = totalCount - recordsCount; | ||
|
||
const remainingPages = Math.ceil(remainingCount / 30); | ||
|
||
let lastCursor = firstQueryResult?.pageInfo.endCursor ?? ''; | ||
|
||
for (let i = 0; i < remainingPages; i++) { | ||
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. pageIndex rather than i |
||
const rawResult = await fetchMore?.({ | ||
variables: { | ||
lastCursor: lastCursor, | ||
}, | ||
}); | ||
|
||
const fetchMoreResult = rawResult?.data?.[objectMetadataItem.namePlural]; | ||
|
||
for (const edge of fetchMoreResult.edges) { | ||
recordIdSet.add(edge.node.id); | ||
} | ||
|
||
lastCursor = fetchMoreResult.pageInfo.endCursor ?? ''; | ||
} | ||
|
||
const recordIds = Array.from(recordIdSet); | ||
|
||
return recordIds; | ||
}, [fetchMore, findManyRecords, objectMetadataItem.namePlural]); | ||
|
||
return { | ||
fetchAllRecordIds, | ||
}; | ||
}; |
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.
why 1 as default and not 0?