-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add useNavigationGetUrl in shell client
ref: MANAGER-15760 Signed-off-by: Alex Boungnaseng <[email protected]> Co-authored-by: Thibault Barske <[email protected]>
- Loading branch information
1 parent
a209044
commit b224a51
Showing
2 changed files
with
23 additions
and
0 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
21 changes: 21 additions & 0 deletions
21
packages/manager/core/shell-client/src/hooks/useNavigationGetUrl.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,21 @@ | ||
import { useContext } from 'react'; | ||
import { DefinedInitialDataOptions, useQuery } from '@tanstack/react-query'; | ||
import { ParamValueType } from '@ovh-ux/url-builder'; | ||
import { ShellContext } from '../ShellContext'; | ||
|
||
export const useNavigationGetUrl = ( | ||
linkParams: [string, string, Record<string, ParamValueType>], | ||
options: Partial<DefinedInitialDataOptions<unknown>> = {}, | ||
) => { | ||
const { | ||
shell: { navigation }, | ||
} = useContext(ShellContext); | ||
|
||
return useQuery({ | ||
queryKey: ['shell', 'getUrl', linkParams], | ||
queryFn: () => navigation.getURL(...linkParams), | ||
refetchOnReconnect: false, | ||
refetchOnWindowFocus: false, | ||
...options, | ||
}); | ||
}; |