mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
✨ Add new settings-page navigation helper
This commit is contained in:
parent
4534167dae
commit
5472ca580f
1 changed files with 22 additions and 2 deletions
|
@ -5,6 +5,26 @@ const goToWooCommercePaymentsTab = () => {
|
|||
window.location.href = window.ppcpSettings.wcPaymentsTabUrl;
|
||||
};
|
||||
|
||||
export const useNavigation = () => {
|
||||
return { goToWooCommercePaymentsTab };
|
||||
/**
|
||||
* Navigate to the main settings page, or to a defined tab (panel).
|
||||
* Always initiates a browser navigation - if the user already is on the defined settings page,
|
||||
* this function acts as a page-reload.
|
||||
*
|
||||
* @param {?string} [panel=null] Which settings tab to display.
|
||||
*/
|
||||
const goToPluginSettings = ( panel = null ) => {
|
||||
let url = window.ppcpSettings.pluginSettingsUrl;
|
||||
|
||||
if ( panel ) {
|
||||
url += '&panel=' + panel;
|
||||
}
|
||||
|
||||
window.location.href = url;
|
||||
};
|
||||
|
||||
export const useNavigation = () => {
|
||||
return {
|
||||
goToWooCommercePaymentsTab,
|
||||
goToPluginSettings,
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue