mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Hide webhook elements when sandbox state is not matching the server
This commit is contained in:
parent
8188faeec4
commit
9adcfe4b7d
3 changed files with 41 additions and 6 deletions
|
@ -1,3 +1,5 @@
|
|||
import {setVisibleByClass} from "../../../ppcp-button/resources/js/modules/Helper/Hiding"
|
||||
|
||||
document.addEventListener(
|
||||
'DOMContentLoaded',
|
||||
() => {
|
||||
|
@ -147,5 +149,25 @@ document.addEventListener(
|
|||
simulateBtn.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
const sandboxCheckbox = document.querySelector('#ppcp-sandbox_on');
|
||||
if (sandboxCheckbox) {
|
||||
const setWebhooksVisibility = (show) => {
|
||||
[
|
||||
'#field-webhook_status_heading',
|
||||
'#field-webhooks_list',
|
||||
'#field-webhooks_resubscribe',
|
||||
'#field-webhooks_simulate',
|
||||
].forEach(selector => {
|
||||
setVisibleByClass(selector, show, 'hide');
|
||||
});
|
||||
};
|
||||
|
||||
const serverSandboxState = PayPalCommerceGatewayWebhooksStatus.environment === 'sandbox';
|
||||
setWebhooksVisibility(serverSandboxState === sandboxCheckbox.checked);
|
||||
sandboxCheckbox.addEventListener('click', () => {
|
||||
setWebhooksVisibility(serverSandboxState === sandboxCheckbox.checked);
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue