Skip to content
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

feat(core): add useGetNavigationUrl in shell client #14964

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, all the app information is available in Shell-context. So, no need to make it async but it can be made synchronous.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take a look 👍

Copy link
Contributor

@tibs245 tibs245 Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seen by curiosity.

getURL return string in the basic inplementation : packages/components/ovh-shell/src/plugin/navigation/index.ts

But the problem it's we provide : invokePluginMethod in packages/components/ovh-shell/src/client/shell-client.ts

I don't known if it's possible to remove it

Copy link
Contributor Author

@aboungnaseng-ovhcloud aboungnaseng-ovhcloud Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tibs245 you mean you want to return a string, more easy to use ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure to understand how do you want to make it synchronous. @anooparveti how do you make it synchronous ? as @tibs245 said, getUrl use 'invokePluginMethod' we need to wait this promise

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,
});
};
Loading