TurnstileBlockEdit.js
2 years ago
TurnstileOptions.js
2 years ago
TurnstileProvider.js
2 years ago
main.js
2 years ago
preview.js
2 years ago
variation.js
2 years ago
TurnstileOptions.js
76 lines
| 1 | const { |
| 2 | __, |
| 3 | } = wp.i18n; |
| 4 | const { |
| 5 | ToggleControl, |
| 6 | BaseHelp, |
| 7 | } = JetFBComponents; |
| 8 | const { |
| 9 | useCaptchaProvider, |
| 10 | } = JetFBHooks; |
| 11 | let { |
| 12 | TextControl, |
| 13 | NumberControl, |
| 14 | __experimentalNumberControl, |
| 15 | ExternalLink, |
| 16 | } = wp.components; |
| 17 | |
| 18 | NumberControl = NumberControl || __experimentalNumberControl; |
| 19 | |
| 20 | const currentTab = JetFBActions.globalTab( { |
| 21 | slug: 'captcha-tab', |
| 22 | element: 'turnstile', |
| 23 | empty: {}, |
| 24 | } ); |
| 25 | |
| 26 | function TurnstileOptions() { |
| 27 | const [ providerArgs, setProviderArgs ] = useCaptchaProvider(); |
| 28 | |
| 29 | const currentArgs = providerArgs.use_global |
| 30 | ? currentTab |
| 31 | : providerArgs; |
| 32 | |
| 33 | return <> |
| 34 | <ToggleControl |
| 35 | checked={ providerArgs.use_global } |
| 36 | onChange={ use_global => setProviderArgs( |
| 37 | { use_global } ) } |
| 38 | > |
| 39 | { __( 'Use', 'jet-form-builder' ) + ' ' } |
| 40 | <a href={ JetFormEditorData.global_settings_url + |
| 41 | '#captcha-tab__turnstile' }> |
| 42 | { __( 'Global Settings', 'jet-form-builder' ) } |
| 43 | </a> |
| 44 | </ToggleControl> |
| 45 | <TextControl |
| 46 | label={ __( 'Site Key:', 'jet-form-builder' ) } |
| 47 | value={ currentArgs.key } |
| 48 | help={ __( |
| 49 | 'Read the hint to the Secret Key field', |
| 50 | 'jet-form-builder', |
| 51 | ) } |
| 52 | disabled={ providerArgs.use_global } |
| 53 | onChange={ key => setProviderArgs( { key } ) } |
| 54 | /> |
| 55 | <TextControl |
| 56 | label={ __( 'Secret Key:', 'jet-form-builder' ) } |
| 57 | value={ currentArgs.secret } |
| 58 | help={ __( |
| 59 | 'You can find both keys on your Turnstile Site settings page', |
| 60 | 'jet-form-builder', |
| 61 | ) } |
| 62 | disabled={ providerArgs.use_global } |
| 63 | onChange={ secret => setProviderArgs( { secret } ) } |
| 64 | /> |
| 65 | <BaseHelp> |
| 66 | { __( 'Didn\'t find it? Here is', 'jet-form-builder' ) + ' ' } |
| 67 | <ExternalLink |
| 68 | href={ 'https://developers.cloudflare.com/turnstile/get-started/#get-a-sitekey-and-secret-key' } |
| 69 | > |
| 70 | { __( 'a more detailed description', 'jet-form-builder' ) } |
| 71 | </ExternalLink> |
| 72 | </BaseHelp> |
| 73 | </>; |
| 74 | } |
| 75 | |
| 76 | export default TurnstileOptions; |