Skip to content

Commit

Permalink
Protect: UI Adjustments (#38899)
Browse files Browse the repository at this point in the history
  • Loading branch information
nateweller authored Aug 19, 2024
1 parent 6920fe8 commit bc742ee
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 50 deletions.
1 change: 0 additions & 1 deletion projects/plugins/protect/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
'jetpack-protect.php' => ['PhanNoopNew'],
'src/class-credentials.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturnProbablyReal'],
'src/class-rest-controller.php' => ['PhanParamTooMany'],
'src/class-threats.php' => ['PhanParamTooMany'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
// (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Protect Threat History: remove auto-fix column as it is not applicable to history.


2 changes: 1 addition & 1 deletion projects/plugins/protect/src/class-threats.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static function get_api_base() {
* @return bool
*/
public static function update_threat( $threat_id, $updates ) {
$api_base = self::get_api_base( $threat_id );
$api_base = self::get_api_base();
if ( is_wp_error( $api_base ) ) {
return false;
}
Expand Down
27 changes: 15 additions & 12 deletions projects/plugins/protect/src/js/components/paid-accordion/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const PaidAccordionItem = ( {
fixedOn,
onOpen,
status,
hideAutoFixColumn = false,
} ) => {
const accordionData = useContext( PaidAccordionContext );
const open = accordionData?.open === id;
Expand Down Expand Up @@ -117,18 +118,20 @@ export const PaidAccordionItem = ( {
<div>
<ThreatSeverityBadge severity={ severity } />
</div>
<div>
{ fixable && (
<>
{ threatsAreFixing.indexOf( id ) >= 0 ? (
<Spinner color="black" />
) : (
<Icon icon={ check } className={ styles[ 'icon-check' ] } size={ 28 } />
) }
{ isSmall && <span>{ __( 'Auto-fix', 'jetpack-protect' ) }</span> }
</>
) }
</div>
{ ! hideAutoFixColumn && (
<div>
{ fixable && (
<>
{ threatsAreFixing.indexOf( id ) >= 0 ? (
<Spinner color="black" />
) : (
<Icon icon={ check } className={ styles[ 'icon-check' ] } size={ 28 } />
) }
{ isSmall && <span>{ __( 'Auto-fix', 'jetpack-protect' ) }</span> }
</>
) }
</div>
) }
<div className={ styles[ 'accordion-header-button' ] }>
<Icon icon={ open ? chevronUp : chevronDown } size={ 38 } />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const ThreatAccordionItem = ( {
type,
severity,
status,
hideAutoFixColumn = false,
} ) => {
const threatsAreFixing = useSelect( select => select( STORE_ID ).getThreatsAreFixing() );
const { setModal } = useDispatch( STORE_ID );
Expand Down Expand Up @@ -87,6 +88,7 @@ const ThreatAccordionItem = ( {
}
recordEvent( `jetpack_protect_${ type }_threat_open` );
}, [ recordEvent, type ] ) }
hideAutoFixColumn={ hideAutoFixColumn }
>
{ description && (
<div className={ styles[ 'threat-section' ] }>
Expand Down Expand Up @@ -135,39 +137,41 @@ const ThreatAccordionItem = ( {
</div>
) }
{ ! description && <div className={ styles[ 'threat-section' ] }>{ learnMoreButton }</div> }
<div className={ styles[ 'threat-footer' ] }>
{ 'ignored' === status && (
<Button
isDestructive={ true }
variant="secondary"
onClick={ handleUnignoreThreatClick() }
>
{ __( 'Unignore threat', 'jetpack-protect' ) }
</Button>
) }
{ 'current' === status && (
<>
{ [ 'ignored', 'current' ].includes( status ) && (
<div className={ styles[ 'threat-footer' ] }>
{ 'ignored' === status && (
<Button
isDestructive={ true }
variant="secondary"
onClick={ handleIgnoreThreatClick() }
onClick={ handleUnignoreThreatClick() }
disabled={ fixerInProgress }
>
{ __( 'Ignore threat', 'jetpack-protect' ) }
{ __( 'Unignore threat', 'jetpack-protect' ) }
</Button>
{ fixable && (
<Button disabled={ fixerInProgress } onClick={ handleFixThreatClick() }>
{ __( 'Fix threat', 'jetpack-protect' ) }
) }
{ 'current' === status && (
<>
<Button
isDestructive={ true }
variant="secondary"
onClick={ handleIgnoreThreatClick() }
>
{ __( 'Ignore threat', 'jetpack-protect' ) }
</Button>
) }
</>
) }
</div>
{ fixable && (
<Button disabled={ fixerInProgress } onClick={ handleFixThreatClick() }>
{ __( 'Fix threat', 'jetpack-protect' ) }
</Button>
) }
</>
) }
</div>
) }
</PaidAccordionItem>
);
};

const PaidList = ( { list } ) => {
const PaidList = ( { list, hideAutoFixColumn = false } ) => {
const [ isSmall ] = useBreakpointMatch( [ 'sm', 'lg' ], [ null, '<' ] );

return (
Expand All @@ -176,7 +180,7 @@ const PaidList = ( { list } ) => {
<div className={ styles[ 'accordion-heading' ] }>
<span>{ __( 'Details', 'jetpack-protect' ) }</span>
<span>{ __( 'Severity', 'jetpack-protect' ) }</span>
<span>{ __( 'Auto-fix', 'jetpack-protect' ) }</span>
{ ! hideAutoFixColumn && <span>{ __( 'Auto-fix', 'jetpack-protect' ) }</span> }
<span></span>
</div>
) }
Expand Down Expand Up @@ -224,6 +228,7 @@ const PaidList = ( { list } ) => {
type={ type }
version={ version }
status={ status }
hideAutoFixColumn={ hideAutoFixColumn }
/>
)
) }
Expand Down
12 changes: 2 additions & 10 deletions projects/plugins/protect/src/js/routes/firewall/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -708,19 +708,12 @@ const FirewallPage = () => {
onChange={ handleChange }
disabled={ ! canEditFirewallSettings || ! ipBlockListEnabled }
/>
<Text variant="body-extra-small" mt={ 1 }>
{ __(
'By adding their IP addresses, you ensure they will never access your site.',
'jetpack-protect'
) }
</Text>
</div>
) }
{ ipBlockListEnabled && (
<div className={ styles[ 'block-list-button-container' ] }>
<Button
onClick={ saveIpBlockListChanges }
size={ 'small' }
isLoading={ ipBlockListIsUpdating }
disabled={ ! canEditFirewallSettings || ! ipBlockListHasChanges }
>
Expand Down Expand Up @@ -765,7 +758,7 @@ const FirewallPage = () => {
/>
<Text variant="body-extra-small" mt={ 1 }>
{ __(
"Add IP addresses here to ensure they always have access your site, regardless of Jetpack's security features.",
"Add IP addresses here to ensure they always have access to your site, regardless of Jetpack's security features.",
'jetpack-protect'
) }
</Text>
Expand All @@ -774,7 +767,7 @@ const FirewallPage = () => {
{ formState.jetpack_waf_ip_allow_list_enabled && (
<div className={ styles[ 'allow-list-button-container' ] }>
<div>
<Text variant="body-small" mb={ 1 }>
<Text variant="body-small" className={ styles[ 'allow-list-current-ip' ] }>
{ createInterpolateElement(
sprintf(
// translators: placeholder is the user's current IP address.
Expand All @@ -797,7 +790,6 @@ const FirewallPage = () => {
</div>
<Button
onClick={ saveIpAllowListChanges }
size={ 'small' }
isLoading={ ipAllowListIsUpdating }
disabled={ formIsSubmitting || ! ipAllowListHasChanges }
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,20 @@
}
}

.allow-list-current-ip {
line-height: 1;
margin-bottom: calc( var( --spacing-base ) * 1.5 ); // 12px
}

.allow-list-button-container {
margin-top: calc( var( --spacing-base ) * 3 );
margin-top: calc( var( --spacing-base ) * 2 );
display: flex;
justify-content: space-between;
align-items: flex-start;
}

.block-list-button-container {
margin-top: calc( var( --spacing-base ) * 3 );
margin-top: calc( var( --spacing-base ) * 2 );
display: flex;
justify-content: right;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ const ScanHistoryRoute = () => {
<StatusFilters numFixed={ numFixed } numIgnored={ numIgnored } />
</div>
</div>
<PaidList list={ list } />
<PaidList list={ list } hideAutoFixColumn={ true } />
</div>
) : (
<>
Expand Down

0 comments on commit bc742ee

Please sign in to comment.