Skip to content

Commit

Permalink
feat(core): add useNavigationGetUrl in shell client
Browse files Browse the repository at this point in the history
ref: MANAGER-15760

Signed-off-by: Alex Boungnaseng <[email protected]>
Co-authored-by: Thibault Barske <[email protected]>
  • Loading branch information
aboungnaseng-ovhcloud and tibs245 committed Jan 17, 2025
1 parent a209044 commit b224a51
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/manager/core/shell-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"@ovh-ux/ovh-at-internet": "^0.18.1",
"@ovh-ux/request-tagger": "^0.4.0",
"@ovh-ux/shell": "^4.1.0",
"@ovh-ux/url-builder": "^2.0.0",
"@tanstack/react-query": "^5.64.1",
"i18next": "^23.8.2",
"i18next-http-backend": "^2.4.2"
},
Expand Down
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,
});
};

0 comments on commit b224a51

Please sign in to comment.