-
Notifications
You must be signed in to change notification settings - Fork 4
Mod. Settings. Moving settings to React #692
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
013529e
Mod. Settings. Moving Vulnerability Check settings to React
AntonV1211 dd468f4
Mod. Settings. Moving Admin Bar settings to React
AntonV1211 96adca6
Fix jest config, add test for settings
AntonV1211 f3fbe87
Jest test for firewall and scanner
AntonV1211 17c1ee7
Mod. Settings. Moving Miscellaneous settings to React
AntonV1211 f7ef648
fix php, js test errors
AntonV1211 ec7fb54
fix php, js test errors
AntonV1211 318ad40
merge dev
AntonV1211 d1775fe
Mod. Settings. Transferring settings to React
AntonV1211 b9871cf
Merge branch 'dev' of https://github.com/CleanTalk/security-malware-f…
AntonV1211 9024aa1
Fix errors
AntonV1211 11e4131
Jest test
AntonV1211 50410d3
Potential fix for pull request finding
AntonV1211 38cd5e2
Fix copilot review
AntonV1211 5570946
Merge branch 'mod_react_15_av' of https://github.com/CleanTalk/securi…
AntonV1211 d08a731
Sync branch
AntonV1211 4776572
Fix eslint
AntonV1211 14aad11
Fix. Settings. Refactoring and deleting old code
AntonV1211 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...rc/react/components/TabContent/TabSettingsGeneral/Settings/AdminBarAdminsOnlineCounter.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import React from 'react'; | ||
| const {__} = wp.i18n; | ||
|
|
||
| export default function AdminBarAdminsOnlineCounter(props) { | ||
| const {id, name, value, onSettingChange} = props; | ||
|
|
||
| return ( | ||
| <div className="spbc_sub_setting"> | ||
| <input | ||
| type="checkbox" | ||
| id={'spbc_setting_' + id} | ||
| name={name} | ||
| value={value} | ||
| checked={value === 1 || value === '1' || value === true} | ||
| onChange={(e) => { | ||
| const next = e.target.checked ? 1 : 0; | ||
| onSettingChange?.(id, next); | ||
| }} | ||
| /> | ||
| <label | ||
| htmlFor={'spbc_setting_' + id} | ||
| className="spbc_setting-field_title--field" | ||
| > | ||
| {__('Administrators online counter', 'security-malware-firewall')} | ||
| </label> | ||
| <i data-setting={id} className="spbc_long_description__show spbc-icon-help-circled"></i> | ||
| <div className="spbc_settings_description">{__('Shows the number of administrators online in the admin bar.', 'security-malware-firewall')}</div> | ||
| </div> | ||
| ); | ||
| } |
29 changes: 29 additions & 0 deletions
29
js/src/react/components/TabContent/TabSettingsGeneral/Settings/AdminBarBruteForceCounter.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import React from 'react'; | ||
| const {__} = wp.i18n; | ||
|
|
||
| export default function AdminBarBruteForceCounter(props) { | ||
| const {id, name, value, onSettingChange} = props; | ||
|
|
||
| return ( | ||
| <div className="spbc_sub_setting"> | ||
| <input | ||
| type="checkbox" | ||
| id={'spbc_setting_' + id} | ||
| name={name} | ||
| value={value} | ||
| checked={value === 1 || value === '1' || value === true} | ||
| onChange={(e) => { | ||
| const next = e.target.checked ? 1 : 0; | ||
| onSettingChange?.(id, next); | ||
| }} | ||
| /> | ||
| <label | ||
| htmlFor={'spbc_setting_' + id} | ||
| className="spbc_setting-field_title--field" | ||
| > | ||
| {__('Allowed/Blocked login attempts counter', 'security-malware-firewall')} | ||
| </label> | ||
| <div className="spbc_settings_description">{__('Shows the number of blocked login attempts in the admin bar. Counts only the local database.', 'security-malware-firewall')}</div> | ||
| </div> | ||
| ); | ||
| } |
29 changes: 29 additions & 0 deletions
29
js/src/react/components/TabContent/TabSettingsGeneral/Settings/AdminBarFirewallCounter.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import React from 'react'; | ||
| const {__} = wp.i18n; | ||
|
|
||
| export default function AdminBarFirewallCounter(props) { | ||
| const {id, name, value, onSettingChange} = props; | ||
|
|
||
| return ( | ||
| <div className="spbc_sub_setting"> | ||
| <input | ||
| type="checkbox" | ||
| id={'spbc_setting_' + id} | ||
| name={name} | ||
| value={value} | ||
| checked={value === 1 || value === '1' || value === true} | ||
| onChange={(e) => { | ||
| const next = e.target.checked ? 1 : 0; | ||
| onSettingChange?.(id, next); | ||
| }} | ||
| /> | ||
| <label | ||
| htmlFor={'spbc_setting_' + id} | ||
| className="spbc_setting-field_title--field" | ||
| > | ||
| {__('Security Firewall counter', 'security-malware-firewall')} | ||
| </label> | ||
| <div className="spbc_settings_description">{__('Shows the firewall counters in the admin bar. Counts only the local database.', 'security-malware-firewall')}</div> | ||
| </div> | ||
| ); | ||
| } |
42 changes: 42 additions & 0 deletions
42
js/src/react/components/TabContent/TabSettingsGeneral/Settings/AdminBarShow.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import React from 'react'; | ||
| import useSettingsDependencies from '../../../../hooks/useSettingsDependencies'; | ||
|
|
||
| const {__, sprintf} = wp.i18n; | ||
|
|
||
| export default function AdminBarShow(props) { | ||
| const {id, name, value, onSettingChange, wlCompanyName} = props; | ||
| const handleSettingsDependencies = useSettingsDependencies(); | ||
|
|
||
| return ( | ||
| <> | ||
| <input | ||
| type="checkbox" | ||
| id={'spbc_setting_' + id} | ||
| name={name} | ||
| value={value} | ||
| checked={value === 1 || value === '1' || value === true} | ||
| onChange={(e) => { | ||
| const next = e.target.checked ? 1 : 0; | ||
| onSettingChange?.(id, next); | ||
| handleSettingsDependencies( | ||
| 'admin_bar__admins_online_counter,' + | ||
| 'admin_bar__brute_force_counter,' + | ||
| 'admin_bar__firewall_counter', | ||
| )(e); | ||
| }} | ||
| /> | ||
| <label | ||
| htmlFor={'spbc_setting_' + id} | ||
| className="spbc_setting-field_title--field" | ||
| > | ||
| {__('Show statistics in admin bar', 'security-malware-firewall')} | ||
| </label> | ||
| <div className="spbc_settings_description">{ | ||
| sprintf( | ||
| __('Show/hide the %s drop-down menu at the top bar of the WordPress backend.', 'security-malware-firewall'), | ||
| wlCompanyName ?? __('CleanTalk', 'security-malware-firewall'), | ||
| ) | ||
| }</div> | ||
| </> | ||
| ); | ||
| } |
32 changes: 32 additions & 0 deletions
32
js/src/react/components/TabContent/TabSettingsGeneral/Settings/DataAdditionalHeaders.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import React from 'react'; | ||
| const {__} = wp.i18n; | ||
|
|
||
| export default function DataAdditionalHeaders(props) { | ||
| const {id, name, value, onSettingChange} = props; | ||
|
|
||
| return ( | ||
| <> | ||
| <input | ||
| type="checkbox" | ||
| id={'spbc_setting_' + id} | ||
| name={name} | ||
| value={value} | ||
| checked={value === 1 || value === '1' || value === true} | ||
| onChange={(e) => { | ||
| const next = e.target.checked ? 1 : 0; | ||
| onSettingChange?.(id, next); | ||
| }} | ||
| /> | ||
| <label | ||
| htmlFor={'spbc_setting_' + id} | ||
| className="spbc_setting-field_title--field" | ||
| > | ||
| {__('Send additional HTTP headers', 'security-malware-firewall')} | ||
| </label> | ||
| <i data-setting={id} className="spbc_long_description__show spbc-icon-help-circled"></i> | ||
| <div className="spbc_settings_description">{ | ||
| __('Add these headers to the HTTP responses on the public pages: X-Content-Type-Options, X-XSS-Protection to get protection from XSS and drive-by download attacks.', 'security-malware-firewall') | ||
| }</div> | ||
| </> | ||
| ); | ||
| } |
52 changes: 52 additions & 0 deletions
52
js/src/react/components/TabContent/TabSettingsGeneral/Settings/DataSetCookies.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import ReactZ from 'react'; | ||
| import InputRadioGroup from '../../../FormElements/InputRadioGroup'; | ||
|
|
||
| const {__} = wp.i18n; | ||
|
|
||
| /** | ||
| * @param {object} props | ||
| * @param {string} props.id | ||
| * @param {string} props.name | ||
| * @param {string|number} props.value | ||
| * @param {function(string, *): void} [props.onSettingChange] | ||
| * @return {JSX.Element} | ||
| */ | ||
| export default function DataSetCookies(props) { | ||
| const {id, name, value, onSettingChange} = props; | ||
|
|
||
| const options = [ | ||
| {value: '1', label: __('On', 'security-malware-firewall')}, | ||
| {value: '0', label: __('Off', 'security-malware-firewall')}, | ||
| {value: '2', label: __('Alternative mechanism', 'security-malware-firewall')}, | ||
| ]; | ||
|
|
||
| return ( | ||
| <> | ||
| <span className="spbc_settings-field_title spbc_settings-field_title--field"> | ||
| {__('Set cookies', 'security-malware-firewall')} | ||
| </span> | ||
| <i data-setting="data_set_cookies" className="spbc_long_description__show spbc-icon-help-circled"></i> | ||
|
AntonV1211 marked this conversation as resolved.
Outdated
|
||
| <div style={{marginBottom: 10}} className="spbc_settings_description"> | ||
| <span> | ||
| <> | ||
| {__('Turn this option off or use the alternative mechanism for cookies to forbid the plugin generate any cookies on the website\'s front-end.', 'security-malware-firewall')} | ||
| <br/> | ||
| {__('Alternative mechanism will store data in the website database and will not set cookies in browsers, so any cache solution will work just fine.', 'security-malware-firewall')} | ||
| </> | ||
| </span> | ||
| <br/> | ||
| </div> | ||
| <InputRadioGroup | ||
| id={id} | ||
| name={name} | ||
| value={value ?? '0'} | ||
| options={options} | ||
| onChange={(e) => { | ||
| const next = e.target.value; | ||
| onSettingChange?.(id, next); | ||
| }} | ||
| disabled={false} | ||
| /> | ||
| </> | ||
| ); | ||
| } | ||
66 changes: 66 additions & 0 deletions
66
js/src/react/components/TabContent/TabSettingsGeneral/Settings/MiscBackendLogsEnable.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import React, {useContext} from 'react'; | ||
| import {DataRootContext} from '../../../App'; | ||
| const {__, sprintf} = wp.i18n; | ||
| const {createInterpolateElement} = wp.element; | ||
|
|
||
| export default function MiscBackendLogsEnable(props) { | ||
| const {id, name, value, onSettingChange, wlCompanyName} = props; | ||
| const {myBillingLink, backendLogsEnabled, backendLogsLink, wlModeEnabled} = useContext(DataRootContext) || {}; | ||
|
|
||
| if (!backendLogsEnabled) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| <input | ||
| type="checkbox" | ||
| id={'spbc_setting_' + id} | ||
| name={name} | ||
| value={value} | ||
| checked={value === 1 || value === '1' || value === true} | ||
| onChange={(e) => { | ||
| const next = e.target.checked ? 1 : 0; | ||
| onSettingChange?.(id, next); | ||
| }} | ||
| /> | ||
|
AntonV1211 marked this conversation as resolved.
Outdated
|
||
| <label | ||
| htmlFor={'spbc_setting_' + id} | ||
| className="spbc_setting-field_title--field" | ||
| > | ||
| {__('Collect and send PHP logs', 'security-malware-firewall')} | ||
| </label> | ||
| <i data-setting={id} className="spbc_long_description__show spbc-icon-help-circled"></i> | ||
|
|
||
| {(backendLogsEnabled || wlModeEnabled) ? ( | ||
| <div className="spbc_settings_description">{ | ||
| sprintf( | ||
| __('Collect and send PHP error logs to your %s Dashboard where you can list them.', 'security-malware-firewall'), | ||
| wlModeEnabled && wlCompanyName ? wlCompanyName : __('CleanTalk', 'security-malware-firewall'), | ||
| ) | ||
| }</div> | ||
| ) : ( | ||
| <div className="spbc_settings_description"> | ||
| {createInterpolateElement( | ||
| __( | ||
| 'To see the collected logs please use the <a1>Backend PHP log</a1>. The <a2>extra package</a2> is required to start the collection, please click "Synchronize with the Cloud" in the plugin settings after purchasing the Extra package.', | ||
| 'security-malware-firewall', | ||
| ), | ||
| { | ||
| a1: <a | ||
| href={backendLogsLink} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| />, | ||
| a2: <a | ||
| href={myBillingLink} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| />, | ||
| }, | ||
| )} | ||
| </div> | ||
| )} | ||
| </> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.