-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protect: Add unignore threat capabilities (#38094)
* Add Scan_History class * changelog * Update changelog * Merge trunk, fix versions * Add initial UI for scan history * Add firstDetected and fixedOn details to threat cards * Fix ignored message * Fix console error * Adjust wording and styles * Optimize * Fix firstDetected and fixedOn property retrieval issues, add todos * Remove unneeded ref * Consolidate scan history UI to existing components * Remove todos * Return false for scanHistory when upgrade is missing * Manage ScanPage states when viewing history * Move source data logic to useProtectData hook * Improve Summary component Button logic * ScanPage refactoring * Reapply missing scanIsUnavailable check * Add comments * Hide ignore when viewing threats, and clear history cache when updating or fixing * Add unignore actions and conditional handling to the UI * Add null coalescing to core threat prop assignment * Fix core threat normalization * Optimizations and refactoring * Revert standarization, and use conditionals * Add dummy arg to avoid bad translation minification * Changlog entry * Move viewingScanHistory out of initial state * Use threat status over lack of fixedOn to display unignore button * Add foundation for unignore request * Remove need for signature_id * Add TypeScript support to Jetpack Protect * Downgrade typescript to 5.0.4, to match other monorepo projects * Add TypeScript support to Jetpack Protect * Init feature branch * Protect: Add Scan_History class (#37903) * Protect: Add Scan History UI (#37988) * Init feature branch * Init feature branch * Init feature branch * Use react router for threat history, separate scan and history root components, minor UI adjustments * changelog * Add dummy args to avoid bad minification * Hide scan section navigation when user has no plan * Wrap ScanButton with forwardRef * Add onboarding popover to Scan Now button in empty state * Fix filtering of core threat history * Redirect to /scan from /scan/history when user has no plan * Fix animation glitch in onboarding popover * Remove unnecessary additions * Further removals after failed base merge * More removals * Add todos * Use status to conditional render unignore action button * Move ignore/unignore actions to dedicated modals * Add TypeScript support to Jetpack Protect * Downgrade typescript to 5.0.4, to match other monorepo projects * Add TypeScript support to Jetpack Protect * Init feature branch * Protect: Add Scan_History class (#37903) * Protect: Add Scan History UI (#37988) * changelog * Protect: Separate scanner and history views via React Router and UI adjustments (#38325) * Run ./tools/fixup-project-versions.sh * Restore project versions * Run ./tools/fixup-project-versions.sh * Remove todo comment (#38628) * Remove changelog * Display fix threat button only for current threats * Further unification * Refresh scan history after unignore * Update projects/plugins/protect/src/js/components/unignore-threat-modal/index.jsx Co-authored-by: Nate Weller <[email protected]> * Fix lint errors --------- Co-authored-by: Nate Weller <[email protected]> Co-authored-by: Nate Weller <[email protected]>
- Loading branch information
1 parent
943d66f
commit 22675f3
Showing
9 changed files
with
229 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
66 changes: 66 additions & 0 deletions
66
projects/plugins/protect/src/js/components/unignore-threat-modal/index.jsx
This file contains 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 { Button, Text } from '@automattic/jetpack-components'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { Icon } from '@wordpress/icons'; | ||
import { STORE_ID } from '../../state/store'; | ||
import ThreatSeverityBadge from '../severity'; | ||
import UserConnectionGate from '../user-connection-gate'; | ||
import styles from './styles.module.scss'; | ||
|
||
const UnignoreThreatModal = ( { id, title, label, icon, severity } ) => { | ||
const { setModal, unignoreThreat } = useDispatch( STORE_ID ); | ||
const threatsUpdating = useSelect( select => select( STORE_ID ).getThreatsUpdating() ); | ||
|
||
const handleCancelClick = () => { | ||
return event => { | ||
event.preventDefault(); | ||
setModal( { type: null } ); | ||
}; | ||
}; | ||
|
||
const handleUnignoreClick = () => { | ||
return async event => { | ||
event.preventDefault(); | ||
unignoreThreat( id, () => { | ||
setModal( { type: null } ); | ||
} ); | ||
}; | ||
}; | ||
|
||
return ( | ||
<UserConnectionGate> | ||
<Text variant="title-medium" mb={ 2 }> | ||
{ __( 'Do you really want to unignore this threat?', 'jetpack-protect' ) } | ||
</Text> | ||
<Text mb={ 3 }>{ __( 'Jetpack will unignore the threat:', 'jetpack-protect' ) }</Text> | ||
|
||
<div className={ styles.threat }> | ||
<Icon icon={ icon } className={ styles.threat__icon } /> | ||
<div className={ styles.threat__summary }> | ||
<Text className={ styles.threat__summary__label } mb={ 1 }> | ||
{ label } | ||
</Text> | ||
<Text className={ styles.threat__summary__title }>{ title }</Text> | ||
</div> | ||
<div className={ styles.threat__severity }> | ||
<ThreatSeverityBadge severity={ severity } /> | ||
</div> | ||
</div> | ||
|
||
<div className={ styles.footer }> | ||
<Button variant="secondary" onClick={ handleCancelClick() }> | ||
{ __( 'Cancel', 'jetpack-protect' ) } | ||
</Button> | ||
<Button | ||
isDestructive={ true } | ||
isLoading={ Boolean( threatsUpdating && threatsUpdating[ id ] ) } | ||
onClick={ handleUnignoreClick() } | ||
> | ||
{ __( 'Unignore threat', 'jetpack-protect' ) } | ||
</Button> | ||
</div> | ||
</UserConnectionGate> | ||
); | ||
}; | ||
|
||
export default UnignoreThreatModal; |
40 changes: 40 additions & 0 deletions
40
projects/plugins/protect/src/js/components/unignore-threat-modal/styles.module.scss
This file contains 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,40 @@ | ||
.threat { | ||
border: 1px solid var( --jp-gray ); | ||
border-radius: var( --jp-border-radius ); | ||
padding: calc( var( --spacing-base ) * 2 ); // 16px | ||
display: flex; | ||
margin-bottom: calc( var( --spacing-base ) * 3 ); // 24px | ||
|
||
&__icon { | ||
margin-right: calc( var( --spacing-base ) * 2 ); // 16px | ||
min-width: 24px; | ||
} | ||
|
||
&__summary { | ||
width: 100%; | ||
} | ||
|
||
&__summary__label { | ||
font-size: 18px; | ||
line-height: 24px; | ||
font-weight: 600; | ||
margin-bottom: 0; | ||
} | ||
|
||
&__summary__title { | ||
font-size: 14px; | ||
line-height: 21px; | ||
color: var( --jp-gray-80 ); | ||
} | ||
|
||
&__severity { | ||
align-self: center; | ||
margin-left: calc( var( --spacing-base ) * 2 ); // 16px | ||
margin-right: var( --spacing-base ); // 8px | ||
} | ||
} | ||
|
||
.footer { | ||
display: flex; | ||
justify-content: space-between; | ||
} |
This file contains 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