-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue-5772] Add sort feature on settings tables (#5787)
## Proposed Changes - Introduce a new custom hook - useTableSort to sort table content - Add test cases for the new custom hook - Integrate useTableSort hook on to the table in settings object and settings object field pages ## Related Issue #5772 ## Evidence https://github.com/twentyhq/twenty/assets/87609792/8be456ce-2fa5-44ec-8bbd-70fb6c8fdb30 ## Evidence after addressing review comments https://github.com/twentyhq/twenty/assets/87609792/c267e3da-72f9-4c0e-8c94-a38122d6395e ## Further comments Apologies for the large PR. Looking forward for the review --------- Co-authored-by: Félix Malfait <[email protected]> Co-authored-by: Lucas Bordeau <[email protected]>
- Loading branch information
1 parent
0f75e14
commit 59e14fa
Showing
40 changed files
with
1,221 additions
and
437 deletions.
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
2 changes: 1 addition & 1 deletion
2
packages/twenty-front/src/modules/apollo/optimistic-effect/utils/sortCachedObjectEdges.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
3 changes: 2 additions & 1 deletion
3
packages/twenty-front/src/modules/object-metadata/hooks/useGetObjectOrderByField.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
3 changes: 2 additions & 1 deletion
3
packages/twenty-front/src/modules/object-metadata/utils/getObjectOrderByField.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
3 changes: 2 additions & 1 deletion
3
packages/twenty-front/src/modules/object-metadata/utils/getOrderByForFieldMetadataType.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
2 changes: 1 addition & 1 deletion
2
packages/twenty-front/src/modules/object-record/graphql/types/RecordGqlOperationOrderBy.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
48 changes: 48 additions & 0 deletions
48
...twenty-front/src/modules/object-record/multiple-objects/hooks/useCombinedGetTotalCount.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,48 @@ | ||
import { useQuery } from '@apollo/client'; | ||
|
||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem'; | ||
import { EMPTY_QUERY } from '@/object-record/constants/EmptyQuery'; | ||
import { RecordGqlOperationSignature } from '@/object-record/graphql/types/RecordGqlOperationSignature'; | ||
import { useGenerateCombinedFindManyRecordsQuery } from '@/object-record/multiple-objects/hooks/useGenerateCombinedFindManyRecordsQuery'; | ||
import { MultiObjectRecordQueryResult } from '@/object-record/relation-picker/hooks/useMultiObjectRecordsQueryResultFormattedAsObjectRecordForSelectArray'; | ||
|
||
export const useCombinedGetTotalCount = ({ | ||
objectMetadataItems, | ||
skip = false, | ||
}: { | ||
objectMetadataItems: ObjectMetadataItem[]; | ||
skip?: boolean; | ||
}) => { | ||
const operationSignatures = objectMetadataItems.map( | ||
(objectMetadataItem) => | ||
({ | ||
objectNameSingular: objectMetadataItem.nameSingular, | ||
variables: {}, | ||
fields: { | ||
id: true, | ||
}, | ||
}) satisfies RecordGqlOperationSignature, | ||
); | ||
|
||
const findManyQuery = useGenerateCombinedFindManyRecordsQuery({ | ||
operationSignatures, | ||
}); | ||
|
||
const { data } = useQuery<MultiObjectRecordQueryResult>( | ||
findManyQuery ?? EMPTY_QUERY, | ||
{ | ||
skip, | ||
}, | ||
); | ||
|
||
const totalCountByObjectMetadataItemNamePlural = Object.fromEntries( | ||
Object.entries(data ?? {}).map(([namePlural, objectRecordConnection]) => [ | ||
namePlural, | ||
objectRecordConnection.totalCount, | ||
]), | ||
); | ||
|
||
return { | ||
totalCountByObjectMetadataItemNamePlural, | ||
}; | ||
}; |
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
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.