@automattic/jetpack-components 0.70.1 → 0.72.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.
- package/CHANGELOG.md +20 -1
- package/build/components/dot-pager/index.d.ts +14 -0
- package/build/components/dot-pager/index.js +52 -0
- package/build/components/number-control/index.js +1 -1
- package/build/components/split-button/index.js +2 -2
- package/build/components/swipeable/index.d.ts +12 -0
- package/build/components/swipeable/index.js +293 -0
- package/build/index.d.ts +2 -3
- package/build/index.js +2 -3
- package/components/dot-pager/README.md +20 -0
- package/components/dot-pager/index.tsx +147 -0
- package/components/dot-pager/style.scss +80 -0
- package/components/number-control/index.jsx +3 -1
- package/components/split-button/index.tsx +14 -12
- package/components/split-button/style.module.scss +5 -0
- package/components/swipeable/README.md +34 -0
- package/components/swipeable/index.tsx +425 -0
- package/components/swipeable/style.scss +34 -0
- package/index.ts +2 -3
- package/package.json +1 -3
- package/build/components/threat-fixer-button/index.d.ts +0 -17
- package/build/components/threat-fixer-button/index.js +0 -56
- package/build/components/threat-severity-badge/index.d.ts +0 -4
- package/build/components/threat-severity-badge/index.js +0 -13
- package/build/components/threats-data-views/constants.d.ts +0 -33
- package/build/components/threats-data-views/constants.js +0 -37
- package/build/components/threats-data-views/index.d.ts +0 -30
- package/build/components/threats-data-views/index.js +0 -413
- package/build/components/threats-data-views/threats-status-toggle-group-control.d.ts +0 -16
- package/build/components/threats-data-views/threats-status-toggle-group-control.js +0 -95
- package/components/threat-fixer-button/index.tsx +0 -101
- package/components/threat-fixer-button/styles.module.scss +0 -16
- package/components/threat-modal/fixer-state-notice.tsx +0 -63
- package/components/threat-modal/index.tsx +0 -109
- package/components/threat-modal/styles.module.scss +0 -81
- package/components/threat-modal/threat-actions.tsx +0 -93
- package/components/threat-modal/threat-fix-confirmation.tsx +0 -54
- package/components/threat-modal/threat-fix-details.tsx +0 -65
- package/components/threat-modal/threat-notice.tsx +0 -84
- package/components/threat-modal/threat-summary.tsx +0 -30
- package/components/threat-modal/threat-technical-details.tsx +0 -67
- package/components/threat-severity-badge/index.tsx +0 -26
- package/components/threat-severity-badge/styles.module.scss +0 -27
- package/components/threats-data-views/constants.ts +0 -49
- package/components/threats-data-views/index.tsx +0 -534
- package/components/threats-data-views/styles.module.scss +0 -40
- package/components/threats-data-views/threats-status-toggle-group-control.tsx +0 -158
|
@@ -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;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
.threat-severity-badge {
|
|
2
|
-
border-radius: 32px;
|
|
3
|
-
flex-shrink: 0;
|
|
4
|
-
font-size: 12px;
|
|
5
|
-
font-style: normal;
|
|
6
|
-
font-weight: 600;
|
|
7
|
-
line-height: 16px;
|
|
8
|
-
padding: calc( var( --spacing-base ) / 2 ); // 4px
|
|
9
|
-
position: relative;
|
|
10
|
-
text-align: center;
|
|
11
|
-
width: 60px;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.is-critical {
|
|
15
|
-
background: var( --jp-red-5 );
|
|
16
|
-
color: var( --jp-red-60 );
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.is-high {
|
|
20
|
-
background: var( --jp-yellow-5 );
|
|
21
|
-
color: var( --jp-yellow-60 );
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.is-low {
|
|
25
|
-
background: var( --jp-gray-0 );
|
|
26
|
-
color: var( --jp-gray-50 );
|
|
27
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { __ } from '@wordpress/i18n';
|
|
2
|
-
import {
|
|
3
|
-
code as fileIcon,
|
|
4
|
-
color as themeIcon,
|
|
5
|
-
plugins as pluginIcon,
|
|
6
|
-
shield as shieldIcon,
|
|
7
|
-
wordpress as coreIcon,
|
|
8
|
-
} from '@wordpress/icons';
|
|
9
|
-
|
|
10
|
-
export const THREAT_STATUSES: { value: string; label: string; variant?: 'success' | 'warning' }[] =
|
|
11
|
-
[
|
|
12
|
-
{ value: 'current', label: __( 'Active', 'jetpack-components' ), variant: 'warning' },
|
|
13
|
-
{ value: 'fixed', label: __( 'Fixed', 'jetpack-components' ), variant: 'success' },
|
|
14
|
-
{ value: 'ignored', label: __( 'Ignored', 'jetpack-components' ) },
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
export const THREAT_TYPES = [
|
|
18
|
-
{ value: 'plugins', label: __( 'Plugin', 'jetpack-components' ) },
|
|
19
|
-
{ value: 'themes', label: __( 'Theme', 'jetpack-components' ) },
|
|
20
|
-
{ value: 'core', label: __( 'WordPress', 'jetpack-components' ) },
|
|
21
|
-
{ value: 'file', label: __( 'File', 'jetpack-components' ) },
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
export const THREAT_ICONS = {
|
|
25
|
-
plugins: pluginIcon,
|
|
26
|
-
themes: themeIcon,
|
|
27
|
-
core: coreIcon,
|
|
28
|
-
file: fileIcon,
|
|
29
|
-
default: shieldIcon,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const THREAT_FIELD_THREAT = 'threat';
|
|
33
|
-
export const THREAT_FIELD_TITLE = 'title';
|
|
34
|
-
export const THREAT_FIELD_DESCRIPTION = 'description';
|
|
35
|
-
export const THREAT_FIELD_ICON = 'icon';
|
|
36
|
-
export const THREAT_FIELD_STATUS = 'status';
|
|
37
|
-
export const THREAT_FIELD_TYPE = 'type';
|
|
38
|
-
export const THREAT_FIELD_EXTENSION = 'extension';
|
|
39
|
-
export const THREAT_FIELD_PLUGIN = 'plugin';
|
|
40
|
-
export const THREAT_FIELD_THEME = 'theme';
|
|
41
|
-
export const THREAT_FIELD_SEVERITY = 'severity';
|
|
42
|
-
export const THREAT_FIELD_SIGNATURE = 'signature';
|
|
43
|
-
export const THREAT_FIELD_FIRST_DETECTED = 'first-detected';
|
|
44
|
-
export const THREAT_FIELD_FIXED_ON = 'fixed-on';
|
|
45
|
-
export const THREAT_FIELD_AUTO_FIX = 'auto-fix';
|
|
46
|
-
|
|
47
|
-
export const THREAT_ACTION_FIX = 'fix';
|
|
48
|
-
export const THREAT_ACTION_IGNORE = 'ignore';
|
|
49
|
-
export const THREAT_ACTION_UNIGNORE = 'unignore';
|