diff --git a/client/my-sites/comments/comment/comment-author-more-info.jsx b/client/my-sites/comments/comment/comment-author-more-info.jsx index ca12860b8cc7c..7da2a38b97a8b 100644 --- a/client/my-sites/comments/comment/comment-author-more-info.jsx +++ b/client/my-sites/comments/comment/comment-author-more-info.jsx @@ -20,7 +20,7 @@ import { urlToDomainAndPath } from 'lib/url'; import canCurrentUser from 'state/selectors/can-current-user'; import { getSiteComment } from 'state/comments/selectors'; import getSiteSetting from 'state/selectors/get-site-setting'; -import isEmailBlacklisted from 'state/selectors/is-email-blacklisted'; +import isAuthorsEmailBlocked from 'state/selectors/is-authors-email-blocked'; import { bumpStat, composeAnalytics, @@ -52,12 +52,12 @@ export class CommentAuthorMoreInfo extends Component { authorEmail, authorId, commentId, - isAuthorBlacklisted, + isAuthorBlocked, showNotice, - siteBlacklist, + blockedCommentAuthorKeys, siteId, translate, - updateBlacklist, + updateBlockedCommentAuthors, } = this.props; const noticeOptions = { @@ -67,17 +67,17 @@ export class CommentAuthorMoreInfo extends Component { }; const analytics = { - action: isAuthorBlacklisted ? 'unblock_user' : 'block_user', + action: isAuthorBlocked ? 'unblock_user' : 'block_user', user_type: authorId ? 'wpcom' : 'email_only', }; - if ( isAuthorBlacklisted ) { - const newBlacklist = siteBlacklist + if ( isAuthorBlocked ) { + const nextBlockedCommentAuthorKeys = blockedCommentAuthorKeys .split( '\n' ) .filter( ( item ) => item !== authorEmail ) .join( '\n' ); - updateBlacklist( siteId, newBlacklist, analytics ); + updateBlockedCommentAuthors( siteId, nextBlockedCommentAuthorKeys, analytics ); return showNotice( translate( 'User %(email)s unblocked.', { args: { email: authorEmail } } ), @@ -85,9 +85,11 @@ export class CommentAuthorMoreInfo extends Component { ); } - const newBlacklist = siteBlacklist ? siteBlacklist + '\n' + authorEmail : authorEmail; + const nextBlockedCommentAuthorKeys = blockedCommentAuthorKeys + ? blockedCommentAuthorKeys + '\n' + authorEmail + : authorEmail; - updateBlacklist( siteId, newBlacklist, analytics ); + updateBlockedCommentAuthors( siteId, nextBlockedCommentAuthorKeys, analytics ); showNotice( translate( 'User %(email)s is blocked and can no longer comment on your site.', { @@ -104,7 +106,7 @@ export class CommentAuthorMoreInfo extends Component { authorIp, authorUrl, authorUsername, - isAuthorBlacklisted, + isAuthorBlocked, showBlockUser, siteSlug, trackAnonymousModeration, @@ -166,8 +168,8 @@ export class CommentAuthorMoreInfo extends Component { { showBlockUser && (
-
) } @@ -216,9 +218,9 @@ const mapStateToProps = ( state, { commentId } ) => { authorIp: get( comment, 'author.ip_address' ), authorUsername: get( comment, 'author.nice_name' ), authorUrl: get( comment, 'author.URL', '' ), - isAuthorBlacklisted: isEmailBlacklisted( state, siteId, authorEmail ), + isAuthorBlocked: isAuthorsEmailBlocked( state, siteId, authorEmail ), showBlockUser, - siteBlacklist: getSiteSetting( state, siteId, 'blacklist_keys' ), + blockedCommentAuthorKeys: getSiteSetting( state, siteId, 'blacklist_keys' ), siteId, siteSlug: getSelectedSiteSlug( state ), }; @@ -226,7 +228,7 @@ const mapStateToProps = ( state, { commentId } ) => { const mapDispatchToProps = ( dispatch ) => ( { showNotice: ( text, options ) => dispatch( successNotice( text, options ) ), - updateBlacklist: ( siteId, blacklist_keys, analytics ) => + updateBlockedCommentAuthors: ( siteId, blockedCommentAuthorKeys, analytics ) => dispatch( withAnalytics( composeAnalytics( @@ -238,7 +240,7 @@ const mapDispatchToProps = ( dispatch ) => ( { : 'comment_author_unblocked' ) ), - saveSiteSettings( siteId, { blacklist_keys } ) + saveSiteSettings( siteId, { blacklist_keys: blockedCommentAuthorKeys } ) ) ), trackAnonymousModeration: () => diff --git a/client/my-sites/site-settings/disconnect-site/confirm.jsx b/client/my-sites/site-settings/disconnect-site/confirm.jsx index a6c2b5c22fe16..b57a8242e970c 100644 --- a/client/my-sites/site-settings/disconnect-site/confirm.jsx +++ b/client/my-sites/site-settings/disconnect-site/confirm.jsx @@ -33,7 +33,7 @@ class ConfirmDisconnection extends PureComponent { translate: PropTypes.func, }; - static reasonWhitelist = [ + static allowedReasons = [ 'troubleshooting', 'cannot-work', 'slow', @@ -48,7 +48,7 @@ class ConfirmDisconnection extends PureComponent { const surveyData = { 'why-cancel': { - response: find( this.constructor.reasonWhitelist, ( r ) => r === reason ), + response: find( this.constructor.allowedReasons, ( r ) => r === reason ), text: isArray( text ) ? text.join() : text, }, source: { diff --git a/client/my-sites/site-settings/form-discussion.jsx b/client/my-sites/site-settings/form-discussion.jsx index 531cf110caf32..9937ca0c97176 100644 --- a/client/my-sites/site-settings/form-discussion.jsx +++ b/client/my-sites/site-settings/form-discussion.jsx @@ -513,7 +513,7 @@ class SiteSettingsFormDiscussion extends Component { ); } - commentBlacklistSettings() { + disallowedCommentsSettings() { const { eventTracker, fields, @@ -525,22 +525,22 @@ class SiteSettingsFormDiscussion extends Component { } = this.props; return ( - { translate( 'Comment blacklist' ) } - + { translate( 'Disallowed comments' ) } + { translate( 'When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be put in the trash. ' + 'One word or IP per line. It will match inside words, so "press" will match "WordPress".' ) } ); @@ -608,7 +608,7 @@ class SiteSettingsFormDiscussion extends Component {
{ this.commentModerationSettings() }
- { this.commentBlacklistSettings() } + { this.disallowedCommentsSettings() } { isJetpack && ( diff --git a/client/my-sites/site-settings/protect.jsx b/client/my-sites/site-settings/protect.jsx index d58dea33e2c36..2a3732cbc3fe9 100644 --- a/client/my-sites/site-settings/protect.jsx +++ b/client/my-sites/site-settings/protect.jsx @@ -40,15 +40,15 @@ class Protect extends Component { fields: {}, }; - handleAddToWhitelist = () => { + handleAddToAllowedList = () => { const { setFieldValue } = this.props; - let whitelist = trimEnd( this.getProtectWhitelist() ); + let allowedIps = trimEnd( this.getProtectAllowedIps() ); - if ( whitelist.length ) { - whitelist += '\n'; + if ( allowedIps.length ) { + allowedIps += '\n'; } - setFieldValue( 'jetpack_protect_global_whitelist', whitelist + this.getIpAddress() ); + setFieldValue( 'jetpack_protect_global_whitelist', allowedIps + this.getIpAddress() ); }; getIpAddress() { @@ -59,22 +59,22 @@ class Protect extends Component { return null; } - getProtectWhitelist() { + getProtectAllowedIps() { const { jetpack_protect_global_whitelist } = this.props.fields; return jetpack_protect_global_whitelist || ''; } - isIpAddressWhitelisted() { + isIpAddressAllowed() { const ipAddress = this.getIpAddress(); if ( ! ipAddress ) { return false; } - const whitelist = this.getProtectWhitelist().split( '\n' ); + const allowedIps = this.getProtectAllowedIps().split( '\n' ); return ( - includes( whitelist, ipAddress ) || - some( whitelist, ( entry ) => { + includes( allowedIps, ipAddress ) || + some( allowedIps, ( entry ) => { if ( entry.indexOf( '-' ) < 0 ) { return false; } @@ -97,7 +97,7 @@ class Protect extends Component { } = this.props; const ipAddress = this.getIpAddress(); - const isIpWhitelisted = this.isIpAddressWhitelisted(); + const isIpAllowed = this.isIpAddressAllowed(); const disabled = isRequestingSettings || isSavingSettings || protectModuleUnavailable || ! protectModuleActive; const protectToggle = ( @@ -137,31 +137,31 @@ class Protect extends Component { { ipAddress && ( ) }

- { translate( 'Whitelisted IP addresses' ) } + { translate( 'Allowed IP addresses' ) } { translate( - 'You may whitelist an IP address or series of addresses preventing them from ' + + 'You may explicitly allow an IP address or series of addresses preventing them from ' + 'ever being blocked by Jetpack. IPv4 and IPv6 are acceptable. ' + 'To specify a range, enter the low value and high value separated by a dash. ' + 'Example: 12.12.12.1-12.12.12.100' diff --git a/client/my-sites/site-settings/style.scss b/client/my-sites/site-settings/style.scss index 8056352d8c13d..6ae60ed0262e6 100644 --- a/client/my-sites/site-settings/style.scss +++ b/client/my-sites/site-settings/style.scss @@ -461,7 +461,7 @@ margin-top: -21px; } -.site-settings__add-to-whitelist { +.site-settings__add-to-explicitly-allowed-list { margin-top: 3px; } diff --git a/client/state/selectors/is-authors-email-blocked.js b/client/state/selectors/is-authors-email-blocked.js new file mode 100644 index 0000000000000..fad0391d9acb9 --- /dev/null +++ b/client/state/selectors/is-authors-email-blocked.js @@ -0,0 +1,25 @@ +/** + * External dependencies + */ +import { includes } from 'lodash'; + +/** + * Internal dependencies + */ +import getSiteSetting from 'state/selectors/get-site-setting'; + +/** + * Check if an email address is disallowed according to + * the list of blocked addresses for the site. + * + * @param {object} state Global state tree + * @param {number} siteId Site ID + * @param {string} email An email address. + * @returns {boolean} If the email address is disallowed. + */ +export const isAuthorsEmailBlocked = ( state, siteId, email = '' ) => { + const blocklist = getSiteSetting( state, siteId, 'blacklist_keys' ) || ''; + return includes( blocklist.split( '\n' ), email ); +}; + +export default isAuthorsEmailBlocked; diff --git a/client/state/selectors/is-email-blacklisted.js b/client/state/selectors/is-email-blacklisted.js deleted file mode 100644 index c711881794e89..0000000000000 --- a/client/state/selectors/is-email-blacklisted.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * External dependencies - */ -import { includes } from 'lodash'; - -/** - * Internal dependencies - */ -import getSiteSetting from 'state/selectors/get-site-setting'; - -/** - * Check if a site blacklist contains an email address. - * - * @param {object} state Global state tree - * @param {number} siteId Site ID - * @param {string} email An email address. - * @returns {boolean} If the blacklist contains the email address. - */ -export const isEmailBlacklisted = ( state, siteId, email = '' ) => { - const blacklist = getSiteSetting( state, siteId, 'blacklist_keys' ) || ''; - return includes( blacklist.split( '\n' ), email ); -}; - -export default isEmailBlacklisted; diff --git a/client/state/selectors/test/is-authors-email-blocked.js b/client/state/selectors/test/is-authors-email-blocked.js new file mode 100644 index 0000000000000..3989441bba8d1 --- /dev/null +++ b/client/state/selectors/test/is-authors-email-blocked.js @@ -0,0 +1,50 @@ +/** + * External dependencies + */ +import { expect } from 'chai'; + +/** + * Internal dependencies + */ +import isAuthorsEmailBlocked from 'state/selectors/is-authors-email-blocked'; + +const email = 'foo@bar.baz'; + +const state = { + siteSettings: { + items: { + 123: { + blacklist_keys: 'mail@mail.com\ntest@example.com\nfoo@bar.baz\nyadda@yadda.yadda', + }, + 456: { + blacklist_keys: 'mail@mail.com\ntest@example.com\nyadda@yadda.yadda', + }, + 789: { + blacklist_keys: '', + }, + }, + }, +}; + +const noSiteSettingsState = { siteSettings: {} }; + +describe( 'isAuthorsEmailBlocked()', () => { + test( 'should return true if email is blocked', () => { + expect( isAuthorsEmailBlocked( state, 123, email ) ).to.be.true; + } ); + test( 'should return false if email is not blocked', () => { + expect( isAuthorsEmailBlocked( state, 456, email ) ).to.be.false; + } ); + test( 'should return false if blocklist is empty', () => { + expect( isAuthorsEmailBlocked( state, 789, email ) ).to.be.false; + } ); + test( 'should return false if there are no site settings in state', () => { + expect( isAuthorsEmailBlocked( noSiteSettingsState, 123, email ) ).to.be.false; + } ); + test( 'should return false if no email is provided', () => { + expect( isAuthorsEmailBlocked( state, 123 ) ).to.be.false; + } ); + test( 'should return false if email is empty', () => { + expect( isAuthorsEmailBlocked( state, 123, '' ) ).to.be.false; + } ); +} ); diff --git a/client/state/selectors/test/is-email-blacklisted.js b/client/state/selectors/test/is-email-blacklisted.js deleted file mode 100644 index 50d7649fc81be..0000000000000 --- a/client/state/selectors/test/is-email-blacklisted.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * External dependencies - */ -import { expect } from 'chai'; - -/** - * Internal dependencies - */ -import isEmailBlacklisted from 'state/selectors/is-email-blacklisted'; - -const email = 'foo@bar.baz'; - -const state = { - siteSettings: { - items: { - 123: { - blacklist_keys: 'mail@mail.com\ntest@example.com\nfoo@bar.baz\nyadda@yadda.yadda', - }, - 456: { - blacklist_keys: 'mail@mail.com\ntest@example.com\nyadda@yadda.yadda', - }, - 789: { - blacklist_keys: '', - }, - }, - }, -}; - -const noSiteSettingsState = { siteSettings: {} }; - -describe( 'isEmailBlacklisted()', () => { - test( 'should return true if email is blacklisted', () => { - expect( isEmailBlacklisted( state, 123, email ) ).to.be.true; - } ); - test( 'should return false if email is not blacklisted', () => { - expect( isEmailBlacklisted( state, 456, email ) ).to.be.false; - } ); - test( 'should return false if blacklist is empty', () => { - expect( isEmailBlacklisted( state, 789, email ) ).to.be.false; - } ); - test( 'should return false if there are no site settings in state', () => { - expect( isEmailBlacklisted( noSiteSettingsState, 123, email ) ).to.be.false; - } ); - test( 'should return false if no email is provided', () => { - expect( isEmailBlacklisted( state, 123 ) ).to.be.false; - } ); - test( 'should return false if email is empty', () => { - expect( isEmailBlacklisted( state, 123, '' ) ).to.be.false; - } ); -} );