@automattic/jetpack-components 0.70.1 → 0.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/build/components/split-button/index.js +2 -2
  3. package/build/index.d.ts +1 -3
  4. package/build/index.js +1 -3
  5. package/components/split-button/index.tsx +14 -12
  6. package/components/split-button/style.module.scss +5 -0
  7. package/index.ts +1 -3
  8. package/package.json +1 -3
  9. package/build/components/threat-fixer-button/index.d.ts +0 -17
  10. package/build/components/threat-fixer-button/index.js +0 -56
  11. package/build/components/threat-severity-badge/index.d.ts +0 -4
  12. package/build/components/threat-severity-badge/index.js +0 -13
  13. package/build/components/threats-data-views/constants.d.ts +0 -33
  14. package/build/components/threats-data-views/constants.js +0 -37
  15. package/build/components/threats-data-views/index.d.ts +0 -30
  16. package/build/components/threats-data-views/index.js +0 -413
  17. package/build/components/threats-data-views/threats-status-toggle-group-control.d.ts +0 -16
  18. package/build/components/threats-data-views/threats-status-toggle-group-control.js +0 -95
  19. package/components/threat-fixer-button/index.tsx +0 -101
  20. package/components/threat-fixer-button/styles.module.scss +0 -16
  21. package/components/threat-modal/fixer-state-notice.tsx +0 -63
  22. package/components/threat-modal/index.tsx +0 -109
  23. package/components/threat-modal/styles.module.scss +0 -81
  24. package/components/threat-modal/threat-actions.tsx +0 -93
  25. package/components/threat-modal/threat-fix-confirmation.tsx +0 -54
  26. package/components/threat-modal/threat-fix-details.tsx +0 -65
  27. package/components/threat-modal/threat-notice.tsx +0 -84
  28. package/components/threat-modal/threat-summary.tsx +0 -30
  29. package/components/threat-modal/threat-technical-details.tsx +0 -67
  30. package/components/threat-severity-badge/index.tsx +0 -26
  31. package/components/threat-severity-badge/styles.module.scss +0 -27
  32. package/components/threats-data-views/constants.ts +0 -49
  33. package/components/threats-data-views/index.tsx +0 -534
  34. package/components/threats-data-views/styles.module.scss +0 -40
  35. package/components/threats-data-views/threats-status-toggle-group-control.tsx +0 -158
@@ -1,63 +0,0 @@
1
- import { __ } from '@wordpress/i18n';
2
- import { useMemo } from 'react';
3
- import styles from './styles.module.scss';
4
- import ThreatNotice from './threat-notice.js';
5
-
6
- /**
7
- * FixerStateNotice component
8
- *
9
- * @param {object} props - The component props.
10
- * @param {object} props.fixerState - The state of the fixer (inProgress, error, stale).
11
- * @param {boolean} props.fixerState.inProgress - Whether the fixer is in progress.
12
- * @param {boolean} props.fixerState.error - Whether the fixer encountered an error.
13
- * @param {boolean} props.fixerState.stale - Whether the fixer is stale.
14
- *
15
- * @return {JSX.Element | null} The rendered fixer notice or null if no notice is available.
16
- */
17
- const FixerStateNotice = ( {
18
- fixerState,
19
- }: {
20
- fixerState: { inProgress: boolean; error: boolean; stale: boolean };
21
- } ) => {
22
- const { status, title, content } = useMemo( () => {
23
- if ( fixerState.error ) {
24
- return {
25
- status: 'error' as const,
26
- title: __( 'An error occurred auto-fixing this threat', 'jetpack-components' ),
27
- content: __(
28
- 'Jetpack encountered a filesystem error while attempting to auto-fix this threat. Please try again later or contact support.',
29
- 'jetpack-components'
30
- ),
31
- };
32
- }
33
-
34
- if ( fixerState.stale ) {
35
- return {
36
- status: 'error' as const,
37
- title: __( 'The auto-fixer is taking longer than expected', 'jetpack-components' ),
38
- content: __(
39
- 'Jetpack has been attempting to auto-fix this threat for too long, and something may have gone wrong. Please try again later or contact support.',
40
- 'jetpack-components'
41
- ),
42
- };
43
- }
44
-
45
- if ( fixerState.inProgress ) {
46
- return {
47
- status: 'success' as const,
48
- title: __( 'An auto-fixer is in progress', 'jetpack-components' ),
49
- content: __( 'Please wait while Jetpack auto-fixes the threat.', 'jetpack-components' ),
50
- };
51
- }
52
-
53
- return {};
54
- }, [ fixerState ] );
55
-
56
- return title ? (
57
- <div className={ styles[ 'fixer-notice' ] }>
58
- <ThreatNotice status={ status } title={ title } content={ content } />
59
- </div>
60
- ) : null;
61
- };
62
-
63
- export default FixerStateNotice;
@@ -1,109 +0,0 @@
1
- import { type Threat } from '@automattic/jetpack-scan';
2
- import { Modal } from '@wordpress/components';
3
- import { createContext } from 'react';
4
- import Text from '../text/index.js';
5
- import ThreatSeverityBadge from '../threat-severity-badge/index.js';
6
- import styles from './styles.module.scss';
7
- import ThreatFixConfirmation from './threat-fix-confirmation.js';
8
-
9
- interface ThreatModalContextType {
10
- closeModal: () => void;
11
- threat: Threat;
12
- handleUpgradeClick?: () => void;
13
- userConnectionNeeded: boolean;
14
- handleConnectUser: () => void;
15
- userIsConnecting: boolean;
16
- siteCredentialsNeeded: boolean;
17
- credentialsIsFetching: boolean;
18
- credentialsRedirectUrl: string;
19
- handleFixThreatClick?: ( threats: Threat[] ) => void;
20
- handleIgnoreThreatClick?: ( threats: Threat[] ) => void;
21
- handleUnignoreThreatClick?: ( threats: Threat[] ) => void;
22
- }
23
-
24
- export const ThreatModalContext = createContext< ThreatModalContextType | null >( null );
25
-
26
- /**
27
- * ThreatModal component
28
- *
29
- * @param {object} props - The props.
30
- * @param {object} props.threat - The threat.
31
- * @param {boolean} props.isUserConnected - Whether the user is connected.
32
- * @param {boolean} props.hasConnectedOwner - Whether the user has a connected owner.
33
- * @param {boolean} props.userIsConnecting - Whether the user is connecting.
34
- * @param {Function} props.handleConnectUser - The handleConnectUser function.
35
- * @param {object} props.credentials - The credentials.
36
- * @param {boolean} props.credentialsIsFetching - Whether the credentials are fetching.
37
- * @param {string} props.credentialsRedirectUrl - The credentials redirect URL.
38
- * @param {Function} props.handleUpgradeClick - The handleUpgradeClick function.
39
- * @param {Function} props.handleFixThreatClick - The handleFixThreatClick function.
40
- * @param {Function} props.handleIgnoreThreatClick - The handleIgnoreThreatClick function.
41
- * @param {Function} props.handleUnignoreThreatClick - The handleUnignoreThreatClick function.
42
- *
43
- * @return {JSX.Element} The threat modal.
44
- */
45
- export default function ThreatModal( {
46
- threat,
47
- isUserConnected,
48
- hasConnectedOwner,
49
- userIsConnecting,
50
- handleConnectUser,
51
- credentials,
52
- credentialsIsFetching,
53
- credentialsRedirectUrl,
54
- handleUpgradeClick,
55
- handleFixThreatClick,
56
- handleIgnoreThreatClick,
57
- handleUnignoreThreatClick,
58
- ...modalProps
59
- }: {
60
- threat: Threat;
61
- isUserConnected: boolean;
62
- hasConnectedOwner: boolean;
63
- userIsConnecting: boolean;
64
- handleConnectUser: () => void;
65
- credentials: false | Record< string, unknown >[];
66
- credentialsIsFetching: boolean;
67
- credentialsRedirectUrl: string;
68
- handleUpgradeClick?: () => void;
69
- handleFixThreatClick?: ( threats: Threat[] ) => void;
70
- handleIgnoreThreatClick?: ( threats: Threat[] ) => void;
71
- handleUnignoreThreatClick?: ( threats: Threat[] ) => void;
72
- } & React.ComponentProps< typeof Modal > ): JSX.Element {
73
- const userConnectionNeeded = ! isUserConnected || ! hasConnectedOwner;
74
- const siteCredentialsNeeded = ! credentials || credentials.length === 0;
75
-
76
- return (
77
- <Modal
78
- title={
79
- <div className={ styles.title }>
80
- <Text variant="title-small">{ threat.title }</Text>
81
- { !! threat.severity && <ThreatSeverityBadge severity={ threat.severity } /> }
82
- </div>
83
- }
84
- size="large"
85
- { ...modalProps }
86
- >
87
- <div className={ styles[ 'threat-details' ] }>
88
- <ThreatModalContext.Provider
89
- value={ {
90
- closeModal: modalProps.onRequestClose,
91
- threat,
92
- handleUpgradeClick,
93
- userConnectionNeeded,
94
- handleConnectUser,
95
- userIsConnecting,
96
- siteCredentialsNeeded,
97
- credentialsIsFetching,
98
- credentialsRedirectUrl,
99
- handleFixThreatClick,
100
- handleIgnoreThreatClick,
101
- handleUnignoreThreatClick,
102
- } }
103
- >
104
- <ThreatFixConfirmation />
105
- </ThreatModalContext.Provider>
106
- </div>
107
- </Modal>
108
- );
109
- }
@@ -1,81 +0,0 @@
1
- .threat-details {
2
- display: flex;
3
- flex-direction: column;
4
- gap: calc( var( --spacing-base ) * 3 ); // 24px
5
- }
6
-
7
- .section {
8
- display: flex;
9
- flex-direction: column;
10
- gap: calc( var( --spacing-base ) * 2 ); // 16px
11
- }
12
-
13
- .section .section__toggle {
14
- text-decoration: none;
15
-
16
- &:hover {
17
- text-decoration: underline;
18
- }
19
-
20
- &__content {
21
- display: flex;
22
- gap: calc( var( --spacing-base ) / 2 ); // 4px
23
- align-items: center;
24
- }
25
- }
26
-
27
- .title {
28
- display: flex;
29
- align-items: center;
30
- gap: calc( var( --spacing-base ) * 1.5 ); // 12px
31
- }
32
-
33
- .filename {
34
- background-color: var( --jp-gray-0 );
35
- padding: calc( var( --spacing-base ) * 3 ); // 24px
36
- overflow-x: auto;
37
- }
38
-
39
- .modal-footer {
40
- padding-top: calc( var( --spacing-base ) * 3 ); // 24px
41
- border-top: 1px solid var( --jp-gray-5 );
42
-
43
- .threat-actions {
44
- display: flex;
45
- justify-content: flex-end;
46
- gap: calc( var( --spacing-base ) * 2 ); // 16px;
47
- }
48
- }
49
-
50
- .fixer-notice {
51
- padding-bottom: calc( var( --spacing-base ) * 3 ); // 24px
52
- }
53
-
54
- .notice {
55
- &__title {
56
- display: flex;
57
- gap: calc( var( --spacing-base ) / 2 ); // 4px
58
-
59
- p {
60
- font-weight: bold;
61
- }
62
- }
63
-
64
- &__actions {
65
- display: flex;
66
- gap: calc( var( --spacing-base ) * 2 ); // 16px;
67
- }
68
-
69
- &__action {
70
- margin-top: calc( var( --spacing-base ) * 2 ); // 16px;
71
- }
72
- }
73
-
74
- svg.spinner {
75
- color: var( --jp-black );
76
- height: 20px;
77
- width: 20px;
78
- margin-left: calc( var( --spacing-base ) / 2 ); // 4px;
79
- margin-right: 6px;
80
-
81
- }
@@ -1,93 +0,0 @@
1
- import { getFixerState, getDetailedFixerAction } from '@automattic/jetpack-scan';
2
- import { __ } from '@wordpress/i18n';
3
- import { useCallback, useContext, useMemo } from 'react';
4
- import { Button } from '@automattic/jetpack-components';
5
- import FixerStateNotice from './fixer-state-notice.js';
6
- import styles from './styles.module.scss';
7
- import { ThreatModalContext } from './index.js';
8
-
9
- /**
10
- * ThreatActions component
11
- *
12
- * @return {JSX.Element | null} The rendered action buttons or null if no actions are available.
13
- */
14
- const ThreatActions = (): JSX.Element => {
15
- const {
16
- closeModal,
17
- threat,
18
- handleFixThreatClick,
19
- handleIgnoreThreatClick,
20
- handleUnignoreThreatClick,
21
- userConnectionNeeded,
22
- siteCredentialsNeeded,
23
- } = useContext( ThreatModalContext );
24
- const disabled = userConnectionNeeded || siteCredentialsNeeded;
25
-
26
- const fixerState = useMemo( () => {
27
- return getFixerState( threat.fixer );
28
- }, [ threat.fixer ] );
29
-
30
- const detailedFixerAction = useMemo( () => getDetailedFixerAction( threat ), [ threat ] );
31
-
32
- const onFixClick = useCallback( () => {
33
- handleFixThreatClick?.( [ threat ] );
34
- closeModal();
35
- }, [ threat, handleFixThreatClick, closeModal ] );
36
-
37
- const onIgnoreClick = useCallback( () => {
38
- handleIgnoreThreatClick?.( [ threat ] );
39
- closeModal();
40
- }, [ threat, handleIgnoreThreatClick, closeModal ] );
41
-
42
- const onUnignoreClick = useCallback( () => {
43
- handleUnignoreThreatClick?.( [ threat ] );
44
- closeModal();
45
- }, [ threat, handleUnignoreThreatClick, closeModal ] );
46
-
47
- if ( ! threat?.status || threat.status === 'fixed' ) {
48
- return null;
49
- }
50
-
51
- return (
52
- <div className={ styles[ 'modal-footer' ] }>
53
- <FixerStateNotice fixerState={ fixerState } />
54
- <div className={ styles[ 'threat-actions' ] }>
55
- { threat.status === 'ignored' && (
56
- <Button
57
- disabled={ disabled }
58
- isDestructive={ true }
59
- variant="secondary"
60
- onClick={ onUnignoreClick }
61
- >
62
- { __( 'Un-ignore threat', 'jetpack-components' ) }
63
- </Button>
64
- ) }
65
- { threat.status === 'current' && (
66
- <>
67
- <Button
68
- isDestructive={ true }
69
- variant="secondary"
70
- onClick={ onIgnoreClick }
71
- disabled={ disabled || ( fixerState.inProgress && ! fixerState.stale ) }
72
- >
73
- { __( 'Ignore threat', 'jetpack-components' ) }
74
- </Button>
75
- { threat.fixable && (
76
- <Button
77
- isPrimary
78
- disabled={ disabled || ( fixerState.inProgress && ! fixerState.stale ) }
79
- onClick={ onFixClick }
80
- >
81
- { fixerState.error || fixerState.stale
82
- ? __( 'Retry fixer', 'jetpack-components' )
83
- : detailedFixerAction }
84
- </Button>
85
- ) }
86
- </>
87
- ) }
88
- </div>
89
- </div>
90
- );
91
- };
92
-
93
- export default ThreatActions;
@@ -1,54 +0,0 @@
1
- import { __ } from '@wordpress/i18n';
2
- import { useContext } from 'react';
3
- import ThreatActions from './threat-actions.js';
4
- import ThreatFixDetails from './threat-fix-details.js';
5
- import ThreatNotice from './threat-notice.js';
6
- import ThreatSummary from './threat-summary.js';
7
- import ThreatTechnicalDetails from './threat-technical-details.js';
8
- import { ThreatModalContext } from './index.js';
9
-
10
- /**
11
- * ThreatFixConfirmation component
12
- *
13
- * @return {JSX.Element} The rendered fix confirmation.
14
- */
15
- const ThreatFixConfirmation = () => {
16
- const { userConnectionNeeded, siteCredentialsNeeded } = useContext( ThreatModalContext );
17
- return (
18
- <>
19
- <ThreatSummary />
20
- <ThreatTechnicalDetails />
21
- <ThreatFixDetails />
22
- { siteCredentialsNeeded && userConnectionNeeded && (
23
- <ThreatNotice
24
- title={ 'Additional connections needed' }
25
- content={ __(
26
- 'A user connection and server credentials provide Jetpack the access necessary to ignore and auto-fix threats on your site.',
27
- 'jetpack-components'
28
- ) }
29
- />
30
- ) }
31
- { ! siteCredentialsNeeded && userConnectionNeeded && (
32
- <ThreatNotice
33
- title={ __( 'User connection needed', 'jetpack-components' ) }
34
- content={ __(
35
- 'A user connection provides Jetpack the access necessary to ignore and auto-fix threats on your site.',
36
- 'jetpack-components'
37
- ) }
38
- />
39
- ) }
40
- { siteCredentialsNeeded && ! userConnectionNeeded && (
41
- <ThreatNotice
42
- title={ __( 'Site credentials needed', 'jetpack-components' ) }
43
- content={ __(
44
- 'Your server credentials allow Jetpack to access the server that’s powering your website. This information is securely saved and only used to ignore and auto-fix threats detected on your site.',
45
- 'jetpack-components'
46
- ) }
47
- />
48
- ) }
49
- <ThreatActions />
50
- </>
51
- );
52
- };
53
-
54
- export default ThreatFixConfirmation;
@@ -1,65 +0,0 @@
1
- import { getFixerDescription } from '@automattic/jetpack-scan';
2
- import { __, sprintf } from '@wordpress/i18n';
3
- import React, { useMemo, useContext } from 'react';
4
- import ContextualUpgradeTrigger from '../contextual-upgrade-trigger/index.js';
5
- import Text from '../text/index.js';
6
- import styles from './styles.module.scss';
7
- import { ThreatModalContext } from './index.js';
8
-
9
- /**
10
- * ThreatFixDetails component
11
- *
12
- * @return {JSX.Element | null} The rendered fix details or null if no fixable details are available.
13
- */
14
- const ThreatFixDetails = (): JSX.Element => {
15
- const { threat, handleUpgradeClick } = useContext( ThreatModalContext );
16
-
17
- const title = useMemo( () => {
18
- if ( threat.status === 'fixed' ) {
19
- return __( 'How did Jetpack fix it?', 'jetpack-components' );
20
- }
21
- if ( threat.status === 'current' && threat.fixable ) {
22
- return __( 'How can Jetpack auto-fix this threat?', 'jetpack-components' );
23
- }
24
- return __( 'How to fix it?', 'jetpack-components' );
25
- }, [ threat ] );
26
-
27
- const fix = useMemo( () => {
28
- // The threat has a fixed version available, but no auto-fix is available.
29
- // The user needs to update the extension to the fixed version.
30
- if ( ! threat.fixable && threat.fixedIn ) {
31
- return sprintf(
32
- /* translators: Translates to Updates to version. %1$s: Name. %2$s: Fixed version */
33
- __( 'Update %1$s to version %2$s.', 'jetpack-components' ),
34
- threat.extension.name,
35
- threat.fixedIn
36
- );
37
- }
38
-
39
- // The threat has an auto-fix available.
40
- return getFixerDescription( threat );
41
- }, [ threat ] );
42
-
43
- if ( ! threat.fixable && ! threat.fixedIn ) {
44
- return null;
45
- }
46
-
47
- return (
48
- <div className={ styles.section }>
49
- <Text variant="title-small">{ title }</Text>
50
- <Text>{ fix }</Text>
51
- { handleUpgradeClick && (
52
- <ContextualUpgradeTrigger
53
- description={ __(
54
- 'Looking for advanced scan results and one-click fixes?',
55
- 'jetpack-components'
56
- ) }
57
- cta={ __( 'Upgrade Jetpack now', 'jetpack-components' ) }
58
- onClick={ handleUpgradeClick }
59
- />
60
- ) }
61
- </div>
62
- );
63
- };
64
-
65
- export default ThreatFixDetails;
@@ -1,84 +0,0 @@
1
- import { Notice, Spinner } from '@wordpress/components';
2
- import { __ } from '@wordpress/i18n';
3
- import { Icon, warning } from '@wordpress/icons';
4
- import { useContext } from 'react';
5
- import { Text, Button } from '@automattic/jetpack-components';
6
- import styles from './styles.module.scss';
7
- import { ThreatModalContext } from './index.js';
8
-
9
- /**
10
- * ThreatNotice component
11
- *
12
- * @param {object} props - The component props.
13
- * @param {string} props.status - The status of the notice.
14
- * @param {string} props.title - The title of the notice.
15
- * @param {string} props.content - The content of the notice.
16
- *
17
- * @return {JSX.Element} The rendered ThreatNotice component.
18
- */
19
- const ThreatNotice = ( {
20
- status = 'warning',
21
- title,
22
- content,
23
- }: {
24
- status?: 'warning' | 'error' | 'success' | undefined;
25
- title: string;
26
- content: string;
27
- } ): JSX.Element => {
28
- const {
29
- userConnectionNeeded,
30
- userIsConnecting,
31
- handleConnectUser,
32
- siteCredentialsNeeded,
33
- credentialsRedirectUrl,
34
- credentialsIsFetching,
35
- } = useContext( ThreatModalContext );
36
-
37
- return (
38
- <Notice
39
- status={ status }
40
- isDismissible={ false }
41
- children={
42
- <div className={ styles.notice }>
43
- <div className={ styles.notice__title }>
44
- { status === 'success' ? (
45
- <Spinner className={ styles.spinner } />
46
- ) : (
47
- <Icon icon={ warning } size={ 30 } />
48
- ) }
49
- <Text variant="title-small" mb={ 2 }>
50
- { title }
51
- </Text>
52
- </div>
53
- <Text>{ content }</Text>
54
- <div className={ styles.notice__actions }>
55
- { userConnectionNeeded && (
56
- <Button
57
- className={ styles.notice__action }
58
- isExternalLink={ true }
59
- weight="regular"
60
- isLoading={ userIsConnecting }
61
- onClick={ handleConnectUser }
62
- >
63
- { __( 'Connect your user account', 'jetpack-components' ) }
64
- </Button>
65
- ) }
66
- { siteCredentialsNeeded && (
67
- <Button
68
- className={ styles.notice__action }
69
- isExternalLink={ true }
70
- weight="regular"
71
- href={ credentialsRedirectUrl }
72
- isLoading={ credentialsIsFetching }
73
- >
74
- { __( 'Enter server credentials', 'jetpack-components' ) }
75
- </Button>
76
- ) }
77
- </div>
78
- </div>
79
- }
80
- />
81
- );
82
- };
83
-
84
- export default ThreatNotice;
@@ -1,30 +0,0 @@
1
- import { __ } from '@wordpress/i18n';
2
- import { useContext } from 'react';
3
- import { Button } from '@automattic/jetpack-components';
4
- import Text from '../text/index.js';
5
- import styles from './styles.module.scss';
6
- import { ThreatModalContext } from './index.js';
7
-
8
- /**
9
- * ThreatSummary component
10
- *
11
- * @return {JSX.Element} The rendered threat summary.
12
- */
13
- const ThreatSummary = (): JSX.Element => {
14
- const { threat } = useContext( ThreatModalContext );
15
-
16
- return (
17
- <div className={ styles.section }>
18
- { !! threat.description && <Text>{ threat.description }</Text> }
19
- { !! threat.source && (
20
- <div>
21
- <Button variant="link" isExternalLink={ true } weight="regular" href={ threat.source }>
22
- { __( 'See more technical details of this threat', 'jetpack-components' ) }
23
- </Button>
24
- </div>
25
- ) }
26
- </div>
27
- );
28
- };
29
-
30
- export default ThreatSummary;
@@ -1,67 +0,0 @@
1
- import { __ } from '@wordpress/i18n';
2
- import { chevronDown, chevronUp, Icon } from '@wordpress/icons';
3
- import { useState, useCallback, useContext } from 'react';
4
- import { Text, Button } from '@automattic/jetpack-components';
5
- import DiffViewer from '../diff-viewer/index.js';
6
- import MarkedLines from '../marked-lines/index.js';
7
- import styles from './styles.module.scss';
8
- import { ThreatModalContext } from './index.js';
9
-
10
- /**
11
- * ThreatTechnicalDetails component
12
- *
13
- * @return {JSX.Element | null} The rendered technical details or null if no details are available.
14
- */
15
- const ThreatTechnicalDetails = (): JSX.Element => {
16
- const { threat } = useContext( ThreatModalContext );
17
-
18
- const [ open, setOpen ] = useState( false );
19
-
20
- const toggleOpen = useCallback( () => {
21
- setOpen( ! open );
22
- }, [ open ] );
23
-
24
- if ( ! threat.filename && ! threat.context && ! threat.diff ) {
25
- return null;
26
- }
27
-
28
- return (
29
- <div className={ styles.section }>
30
- <div className={ styles.section__title }>
31
- <Button
32
- variant="link"
33
- className={ styles.section__toggle }
34
- aria-expanded={ open }
35
- aria-controls={ `threat-details-${ threat.id }` }
36
- onClick={ toggleOpen }
37
- >
38
- <div className={ styles.section__toggle__content }>
39
- <Text variant="title-small" mb={ 0 }>
40
- { open
41
- ? __( 'Hide the technical details', 'jetpack-components' )
42
- : __( 'Show the technical details', 'jetpack-components' ) }
43
- </Text>
44
- <Icon icon={ open ? chevronUp : chevronDown } size={ 24 } />
45
- </div>
46
- </Button>
47
- </div>
48
- { open && (
49
- <div
50
- className={ open ? styles.section__open : styles.section__closed }
51
- id={ `threat-details-${ threat.id }` }
52
- >
53
- { threat.filename && (
54
- <>
55
- <Text>{ __( 'Threat found in file:', 'jetpack-components' ) }</Text>
56
- <pre className={ styles.filename }>{ threat.filename }</pre>
57
- </>
58
- ) }
59
- { threat.context && <MarkedLines context={ threat.context } /> }
60
- { threat.diff && <DiffViewer diff={ threat.diff } /> }
61
- </div>
62
- ) }
63
- </div>
64
- );
65
- };
66
-
67
- export default ThreatTechnicalDetails;
@@ -1,26 +0,0 @@
1
- import { _x } from '@wordpress/i18n';
2
- import Badge from '../badge/index.js';
3
-
4
- const ThreatSeverityBadge = ( { severity } ) => {
5
- if ( severity >= 5 ) {
6
- return (
7
- <Badge variant="danger">
8
- { _x( 'Critical', 'Severity label for issues rated 5 or higher.', 'jetpack-components' ) }
9
- </Badge>
10
- );
11
- }
12
-
13
- if ( severity >= 3 && severity < 5 ) {
14
- return (
15
- <Badge variant="warning">
16
- { _x( 'High', 'Severity label for issues rated between 3 and 5.', 'jetpack-components' ) }
17
- </Badge>
18
- );
19
- }
20
-
21
- return (
22
- <Badge>{ _x( 'Low', 'Severity label for issues rated below 3.', 'jetpack-components' ) }</Badge>
23
- );
24
- };
25
-
26
- export default ThreatSeverityBadge;