Skip to content
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

Update allow list settings access #38886

Merged
merged 11 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions projects/plugins/jetpack/_inc/client/security/allowList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,9 @@ const AllowList = class extends Component {
};

render() {
const isWafActive = this.props.getOptionValue( 'waf' );
const isProtectActive = this.props.getOptionValue( 'protect' );
const wafUnavailableInOfflineMode = this.props.isUnavailableInOfflineMode( 'waf' );
const protectUnavailableInOfflineMode = this.props.isUnavailableInOfflineMode( 'protect' );
const baseInputDisabledCase =
( ! isWafActive && ! isProtectActive ) ||
( wafUnavailableInOfflineMode && protectUnavailableInOfflineMode ) ||
this.props.isFetchingWafSettings ||
this.props.isSavingAnyOption( [ 'waf' ] );
Expand All @@ -137,7 +134,7 @@ const AllowList = class extends Component {
onSubmit={ this.onSubmit }
hideButton={ true }
>
{ ( isWafActive || isProtectActive ) && <QueryWafSettings /> }
<QueryWafSettings />
<SettingsGroup
disableInOfflineMode
support={ {
Expand All @@ -148,9 +145,7 @@ const AllowList = class extends Component {
<FormFieldset>
<div className="waf__settings__toggle-setting">
<ToggleControl
checked={
( isWafActive || isProtectActive ) && this.props.settings?.ipAllowListEnabled
}
checked={ this.props.settings?.ipAllowListEnabled }
toggling={
this.props.isUpdatingWafSettings &&
this.state.ipAllowListEnabled !== this.props.settings?.ipAllowListEnabled
Expand All @@ -166,8 +161,9 @@ const AllowList = class extends Component {
</span>
}
/>
<div className="waf__settings__ips">
{ ( this.state.ipAllowListEnabled || !! this.state.ipAllowList ) && (
<Textarea
className="waf__settings__ips"
disabled={
baseInputDisabledCase ||
this.props.isUpdatingWafSettings ||
Expand All @@ -178,7 +174,9 @@ const AllowList = class extends Component {
value={ this.state.ipAllowList }
onChange={ this.handleIpAllowListChange }
/>
<div className="allow-list-button-container">
) }
{ this.state.ipAllowListEnabled && (
<div className="waf__settings__ips__button-container">
{ this.props.currentIp && (
<div className="current-ip">
<div className="jp-form-label-wide">
Expand Down Expand Up @@ -221,7 +219,7 @@ const AllowList = class extends Component {
{ __( 'Save allow list', 'jetpack' ) }
</Button>
</div>
</div>
) }
</div>
</FormFieldset>
</SettingsGroup>
Expand Down
144 changes: 73 additions & 71 deletions projects/plugins/jetpack/_inc/client/security/style.scss
Original file line number Diff line number Diff line change
@@ -1,83 +1,91 @@
.brute-force__current-ip {
margin-bottom: 16px;
margin-bottom: 16px;
}

.waf__header {
align-items: center;
display: flex;
align-items: center;
display: flex;

.waf__standalone__mode {
margin-left: auto;
}
.waf__standalone__mode {
margin-left: auto;
}

}

.waf__settings {
margin-top: 24px;
margin-left: 64px;
margin-top: 24px;
margin-left: 64px;
margin-bottom: 24px;

&__toggle-setting {
flex-wrap: wrap;
display: flex;
margin-bottom: 16px;

&__label {
display: flex;
align-items: center;
}

&:last-child {
margin-bottom: 0;
}
}

.form-toggle__label {
margin-top: 0;
margin-bottom: 0;
}

&__ips {
width: 100%;
margin-left: 64px;
}

&__ips__save-button {
margin-top: 6px;
float: right;
}

&__share-data-popover {
margin-left: 8px;
}

&__upgrade-popover {
vertical-align: middle;
margin-left: 8px;
}
&__toggle-setting {
flex-wrap: wrap;
display: flex;
margin-bottom: 16px;

&__label {
display: flex;
align-items: center;
}

&:last-child {
margin-bottom: 0;
}
}

.form-toggle__label {
margin-top: 0;
margin-bottom: 0;
}

&__ips {
width: 100%;
margin-left: 64px;

&__button-container {
margin-left: 64px;
width: 100%;
display: flex;
justify-content: space-between;
align-items: flex-start;
}

&__save-button {
margin-top: 0.5rem;
float: right;
}
}

&__share-data-popover {
margin-left: 8px;
}

&__upgrade-popover {
vertical-align: middle;
margin-left: 8px;
}

}

.waf__enhanced-protection {
&, &.dops-card.is-expanded {
margin-bottom: 0;
}

&.dops-foldable-card.is-expanded .dops-foldable-card__content {
border-top: none;
padding-top: 0;
}

ul {
list-style: disc;
margin-top: 0;
margin-bottom: 0;
padding-left: 32px;
}

code {
white-space: nowrap;
}
&, &.dops-card.is-expanded {
margin-bottom: 0;
}

&.dops-foldable-card.is-expanded .dops-foldable-card__content {
border-top: none;
padding-top: 0;
}

ul {
list-style: disc;
margin-top: 0;
margin-bottom: 0;
padding-left: 32px;
}

code {
white-space: nowrap;
}
}


Expand Down Expand Up @@ -179,12 +187,6 @@
}
}

.allow-list-button-container {
display: flex;
justify-content: space-between;
align-items: flex-start;
}

.jp-form-settings-group p {
margin-bottom: 0.5rem;
}
68 changes: 36 additions & 32 deletions projects/plugins/jetpack/_inc/client/security/waf.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -422,39 +422,43 @@ export const Waf = class extends Component {
</span>
}
/>
<div className="waf__settings__ips">
<Textarea
disabled={
baseInputDisabledCase ||
this.props.isUpdatingWafSettings ||
! this.props.settings?.ipBlockListEnabled
}
name="ipBlockList"
placeholder={ sprintf(
/* translators: Placeholder is a list of example IP addresses. */
__( 'Example: %s', 'jetpack' ),
'\n12.12.12.1\n12.12.12.2'
{ ( this.state.ipBlockListEnabled || !! this.state.ipBlockList ) && (
<div className="waf__settings__ips">
<Textarea
disabled={
baseInputDisabledCase ||
this.props.isUpdatingWafSettings ||
! this.props.settings?.ipBlockListEnabled
}
name="ipBlockList"
placeholder={ sprintf(
/* translators: Placeholder is a list of example IP addresses. */
__( 'Example: %s', 'jetpack' ),
'\n12.12.12.1\n12.12.12.2'
) }
value={ this.state.ipBlockList }
onChange={ this.handleIpBlockListChange }
/>
{ this.state.ipBlockListEnabled && (
<Button
primary
rna
compact
type="button"
className="waf__settings__ips__save-button"
disabled={
baseInputDisabledCase ||
this.state.ipBlockList === this.props.settings?.ipBlockList ||
( this.props.isUpdatingWafSettings &&
this.state.ipBlockList !== this.props.settings?.ipBlockList )
}
onClick={ this.onSubmit }
>
{ __( 'Save block list', 'jetpack' ) }
</Button>
) }
value={ this.state.ipBlockList }
onChange={ this.handleIpBlockListChange }
/>
<Button
primary
rna
compact
type="button"
className="waf__settings__ips__save-button"
disabled={
baseInputDisabledCase ||
this.state.ipBlockList === this.props.settings?.ipBlockList ||
( this.props.isUpdatingWafSettings &&
this.state.ipBlockList !== this.props.settings?.ipBlockList )
}
onClick={ this.onSubmit }
>
{ __( 'Save block list', 'jetpack' ) }
</Button>
</div>
</div>
) }
</div>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Makes allow list settings always accessible
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Makes allow list settings always accessible
Loading
Loading