-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-components): add pagination support for styling hook allow…
…ing styling more than 1000 nodes (#3544) * Working pagination for styling hook * Refactored styling hook * Refactored styling and assetMappings hooks
- Loading branch information
Showing
10 changed files
with
372 additions
and
84 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
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
37 changes: 37 additions & 0 deletions
37
react-components/src/hooks/useMappedEquipmentBy3DModelsList.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/*! | ||
* Copyright 2023 Cognite AS | ||
*/ | ||
import { type UseQueryResult, useQuery } from '@tanstack/react-query'; | ||
import { type FdmAssetMappingsConfig } from '..'; | ||
import { useFdmSdk } from '../components/RevealContainer/SDKProvider'; | ||
|
||
export const useMappedEquipmentBy3DModelsList = ( | ||
Default3DFdmConfig: FdmAssetMappingsConfig, | ||
modelsList: Array<{ modelId: number; revisionId: number }> = [] | ||
): UseQueryResult<string[]> => { | ||
const fdmClient = useFdmSdk(); | ||
|
||
return useQuery( | ||
['reveal', 'react-components', ...modelsList.map(({ modelId }) => modelId.toString()).sort()], | ||
async () => { | ||
const filter = { | ||
in: { | ||
property: ['edge', 'endNode'], | ||
values: modelsList.map(({ modelId }) => ({ | ||
space: Default3DFdmConfig.global3dSpace, | ||
externalId: `model_3d_${modelId}` | ||
})) | ||
} | ||
}; | ||
|
||
const mappings = await fdmClient.filterAllInstances( | ||
filter, | ||
'edge', | ||
Default3DFdmConfig.source | ||
); | ||
|
||
return mappings.edges.map((edge) => edge.startNode.externalId); | ||
}, | ||
{ staleTime: Infinity } | ||
); | ||
}; |
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.