-
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.
Merge branch 'add/protect-threat-history' into add/protect-threat-his…
…tory-hooks-refactor
- Loading branch information
Showing
16 changed files
with
372 additions
and
41 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
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
Oops, something went wrong.