Skip to content

Commit 5854f5d

Browse files
authored
Merge pull request #692 from CleanTalk/mod_react_15_av
Mod. Settings. Moving settings to React
2 parents 1105fac + 14aad11 commit 5854f5d

44 files changed

Lines changed: 4180 additions & 767 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

css/spbc-settings.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/src/spbc-settings.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@
7676
.spbc_waf_reason{display: none;}
7777
.spbc_waf_reason_title:hover + .spbc_waf_reason{display: inline;}
7878

79-
/** .spbc_sub* and spbc_affiliate_shortcode used in General settings tab */
80-
.spbc_sub_setting{margin-left: 30px !important;}
81-
.spbc_sub2_setting{margin-left: 60px !important;}
82-
.spbc_affiliate_shortcode{width:inherit !important; min-width: inherit !important}
83-
8479
.spbc_highlighted{
8580
outline-offset: 5px;
8681
outline-color: red;

inc/spbc-settings.php

Lines changed: 6 additions & 554 deletions
Large diffs are not rendered by default.

js/public/spbct-react-bundle.js

Lines changed: 284 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import React from 'react';
1+
import React, {useContext} from 'react';
22
import SettingsGroup from './SettingsGroup';
3+
import VulnerabilityCheckDesc from './Settings/VulnerabilityCheckDesc';
4+
import {DataRootContext} from '../../App';
35
const {__} = wp.i18n;
46

57
export default function Settings(props) {
@@ -23,6 +25,8 @@ export default function Settings(props) {
2325
wlCompanyName,
2426
} = props;
2527

28+
const {wlModeEnabled} = useContext(DataRootContext) || {};
29+
2630
const settingKeys = Object.keys(settings || {});
2731

2832
const SETTINGS_SECTIONS_TITLES = {
@@ -46,61 +50,56 @@ export default function Settings(props) {
4650
title: __('Malware Scanner', 'security-malware-firewall'),
4751
description: '',
4852
},
53+
vulnerability_check: {
54+
title: __('Modules vulnerability detection', 'security-malware-firewall'),
55+
description: <VulnerabilityCheckDesc />,
56+
},
57+
admin_bar: {
58+
title: __('Admin Bar', 'security-malware-firewall'),
59+
description: '',
60+
},
61+
misc: {
62+
title: __('Miscellaneous', 'security-malware-firewall'),
63+
description: '',
64+
},
65+
spbc_trusted_and_affiliate: {
66+
title: __('Trusted and Affiliate', 'security-malware-firewall'),
67+
description: '',
68+
},
4969
};
5070

5171
return <>
5272
{settingKeys.map((sectionGroupId) => {
53-
if (
54-
sectionGroupId === 'apikey'
55-
) {
56-
return <SettingsGroup
57-
key={sectionGroupId}
58-
groupTitle={SETTINGS_SECTIONS_TITLES[sectionGroupId].title}
59-
groupDescription={SETTINGS_SECTIONS_TITLES[sectionGroupId].description}
60-
groupId={sectionGroupId}
61-
settingsSlug={settingsSlug}
62-
settings={settings[sectionGroupId]}
63-
keyIsOk={keyIsOk}
64-
wpUserRolesOptions={wpUserRolesOptions}
65-
verificationEmail={verificationEmail}
66-
authLoginPageUrl={authLoginPageUrl}
67-
techSupportUrlPrefix={techSupportUrlPrefix}
68-
loginRenameNotifyAdminEmail={loginRenameNotifyAdminEmail}
69-
canActivatePlugins={canActivatePlugins}
70-
shuffleSaltsUnlocked={shuffleSaltsUnlocked}
71-
/>;
73+
if (!SETTINGS_SECTIONS_TITLES[sectionGroupId]) {
74+
return null;
7275
}
73-
if (
74-
sectionGroupId === 'auth_and_logging_in' ||
75-
sectionGroupId === 'scanner_settings' ||
76-
sectionGroupId === 'firewall'
77-
) {
78-
// todo: AG needs to be reduced in context
79-
return <SettingsGroup
80-
key={sectionGroupId}
81-
groupTitle={SETTINGS_SECTIONS_TITLES[sectionGroupId].title}
82-
groupDescription={SETTINGS_SECTIONS_TITLES[sectionGroupId].description}
83-
groupId={sectionGroupId}
84-
settingsSlug={settingsSlug}
85-
settings={settings[sectionGroupId]}
86-
keyIsOk={keyIsOk}
87-
wpUserRolesOptions={wpUserRolesOptions}
88-
verificationEmail={verificationEmail}
89-
authLoginPageUrl={authLoginPageUrl}
90-
techSupportUrlPrefix={techSupportUrlPrefix}
91-
loginRenameNotifyAdminEmail={loginRenameNotifyAdminEmail}
92-
canActivatePlugins={canActivatePlugins}
93-
shuffleSaltsUnlocked={shuffleSaltsUnlocked}
94-
visitorIpSources={visitorIpSources}
95-
scannerExclusionsDir={scannerExclusionsDir}
96-
scannerExclusionsURL={scannerExclusionsURL}
97-
visitorCurrentIp={visitorCurrentIp}
98-
nextScheduledScanDescription={nextScheduledScanDescription}
99-
scannerAutoStartManualTimezone={scannerAutoStartManualTimezone}
100-
wlCompanyName={wlCompanyName}
101-
/>;
76+
if (sectionGroupId === 'spbc_trusted_and_affiliate' && wlModeEnabled) {
77+
return null;
10278
}
103-
return null;
79+
80+
return <SettingsGroup
81+
key={sectionGroupId}
82+
groupTitle={SETTINGS_SECTIONS_TITLES[sectionGroupId].title}
83+
groupDescription={SETTINGS_SECTIONS_TITLES[sectionGroupId].description}
84+
groupId={sectionGroupId}
85+
settingsSlug={settingsSlug}
86+
settings={settings[sectionGroupId]}
87+
keyIsOk={keyIsOk}
88+
wpUserRolesOptions={wpUserRolesOptions}
89+
verificationEmail={verificationEmail}
90+
authLoginPageUrl={authLoginPageUrl}
91+
techSupportUrlPrefix={techSupportUrlPrefix}
92+
loginRenameNotifyAdminEmail={loginRenameNotifyAdminEmail}
93+
canActivatePlugins={canActivatePlugins}
94+
shuffleSaltsUnlocked={shuffleSaltsUnlocked}
95+
visitorIpSources={visitorIpSources}
96+
scannerExclusionsDir={scannerExclusionsDir}
97+
scannerExclusionsURL={scannerExclusionsURL}
98+
visitorCurrentIp={visitorCurrentIp}
99+
nextScheduledScanDescription={nextScheduledScanDescription}
100+
scannerAutoStartManualTimezone={scannerAutoStartManualTimezone}
101+
wlCompanyName={wlCompanyName}
102+
/>;
104103
})}
105104
</>;
106105
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
const {__} = wp.i18n;
3+
4+
export default function AdminBarAdminsOnlineCounter(props) {
5+
const {id, name, value, onSettingChange} = props;
6+
7+
return (
8+
<div className="spbc_sub_setting">
9+
<input
10+
type="checkbox"
11+
id={'spbc_setting_' + id}
12+
name={name}
13+
value={value}
14+
checked={value === 1 || value === '1' || value === true}
15+
onChange={(e) => {
16+
const next = e.target.checked ? 1 : 0;
17+
onSettingChange?.(id, next);
18+
}}
19+
/>
20+
<label
21+
htmlFor={'spbc_setting_' + id}
22+
className="spbc_setting-field_title--field"
23+
>
24+
{__('Administrators online counter', 'security-malware-firewall')}
25+
</label>
26+
<i data-setting={id} className="spbc_long_description__show spbc-icon-help-circled"></i>
27+
<div className="spbc_settings_description">{__('Shows the number of administrators online in the admin bar.', 'security-malware-firewall')}</div>
28+
</div>
29+
);
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react';
2+
const {__} = wp.i18n;
3+
4+
export default function AdminBarBruteForceCounter(props) {
5+
const {id, name, value, onSettingChange} = props;
6+
7+
return (
8+
<div className="spbc_sub_setting">
9+
<input
10+
type="checkbox"
11+
id={'spbc_setting_' + id}
12+
name={name}
13+
value={value}
14+
checked={value === 1 || value === '1' || value === true}
15+
onChange={(e) => {
16+
const next = e.target.checked ? 1 : 0;
17+
onSettingChange?.(id, next);
18+
}}
19+
/>
20+
<label
21+
htmlFor={'spbc_setting_' + id}
22+
className="spbc_setting-field_title--field"
23+
>
24+
{__('Allowed/Blocked login attempts counter', 'security-malware-firewall')}
25+
</label>
26+
<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>
27+
</div>
28+
);
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react';
2+
const {__} = wp.i18n;
3+
4+
export default function AdminBarFirewallCounter(props) {
5+
const {id, name, value, onSettingChange} = props;
6+
7+
return (
8+
<div className="spbc_sub_setting">
9+
<input
10+
type="checkbox"
11+
id={'spbc_setting_' + id}
12+
name={name}
13+
value={value}
14+
checked={value === 1 || value === '1' || value === true}
15+
onChange={(e) => {
16+
const next = e.target.checked ? 1 : 0;
17+
onSettingChange?.(id, next);
18+
}}
19+
/>
20+
<label
21+
htmlFor={'spbc_setting_' + id}
22+
className="spbc_setting-field_title--field"
23+
>
24+
{__('Security Firewall counter', 'security-malware-firewall')}
25+
</label>
26+
<div className="spbc_settings_description">{__('Shows the firewall counters in the admin bar. Counts only the local database.', 'security-malware-firewall')}</div>
27+
</div>
28+
);
29+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from 'react';
2+
import useSettingsDependencies from '../../../../hooks/useSettingsDependencies';
3+
4+
const {__, sprintf} = wp.i18n;
5+
6+
export default function AdminBarShow(props) {
7+
const {id, name, value, onSettingChange, wlCompanyName} = props;
8+
const handleSettingsDependencies = useSettingsDependencies();
9+
10+
return (
11+
<>
12+
<input
13+
type="checkbox"
14+
id={'spbc_setting_' + id}
15+
name={name}
16+
value={value}
17+
checked={value === 1 || value === '1' || value === true}
18+
onChange={(e) => {
19+
const next = e.target.checked ? 1 : 0;
20+
onSettingChange?.(id, next);
21+
handleSettingsDependencies(
22+
'admin_bar__admins_online_counter,' +
23+
'admin_bar__brute_force_counter,' +
24+
'admin_bar__firewall_counter',
25+
)(e);
26+
}}
27+
/>
28+
<label
29+
htmlFor={'spbc_setting_' + id}
30+
className="spbc_setting-field_title--field"
31+
>
32+
{__('Show statistics in admin bar', 'security-malware-firewall')}
33+
</label>
34+
<div className="spbc_settings_description">{
35+
sprintf(
36+
__('Show/hide the %s drop-down menu at the top bar of the WordPress backend.', 'security-malware-firewall'),
37+
wlCompanyName ?? __('CleanTalk', 'security-malware-firewall'),
38+
)
39+
}</div>
40+
</>
41+
);
42+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react';
2+
const {__} = wp.i18n;
3+
4+
export default function DataAdditionalHeaders(props) {
5+
const {id, name, value, onSettingChange} = props;
6+
7+
return (
8+
<>
9+
<input
10+
type="checkbox"
11+
id={'spbc_setting_' + id}
12+
name={name}
13+
value={value}
14+
checked={value === 1 || value === '1' || value === true}
15+
onChange={(e) => {
16+
const next = e.target.checked ? 1 : 0;
17+
onSettingChange?.(id, next);
18+
}}
19+
/>
20+
<label
21+
htmlFor={'spbc_setting_' + id}
22+
className="spbc_setting-field_title--field"
23+
>
24+
{__('Send additional HTTP headers', 'security-malware-firewall')}
25+
</label>
26+
<i data-setting={id} className="spbc_long_description__show spbc-icon-help-circled"></i>
27+
<div className="spbc_settings_description">{
28+
__('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')
29+
}</div>
30+
</>
31+
);
32+
}

0 commit comments

Comments
 (0)