@automattic/jetpack-components 0.59.0 → 0.61.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 CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ### This is a list detailing changes for the Jetpack RNA Components package releases.
4
4
 
5
+ ## [0.61.0] - 2024-11-18
6
+ ### Added
7
+ - Gridicon Component: Add support for help-outline icon. [#39867]
8
+
9
+ ## [0.60.0] - 2024-11-14
10
+ ### Added
11
+ - Adds tooltips for each ThreatFixerButton state [#40111]
12
+
13
+ ### Fixed
14
+ - Fixes the loading placeholder that didn't disappear when the price loads. [#40157]
15
+
5
16
  ## [0.59.0] - 2024-11-11
6
17
  ### Added
7
18
  - Add ThreatsDataViews component [#39754]
@@ -10,9 +21,7 @@
10
21
 
11
22
  ### Changed
12
23
  - Add ToggleGroupControl to ThreatsDataViews for easily toggling between Active and Historical threats [#39901]
13
- - Updated package dependencies. [#39999]
14
- - Updated package dependencies. [#40000]
15
- - Updated package dependencies. [#40060]
24
+ - Updated package dependencies. [#39999] [#40000] [#40060]
16
25
 
17
26
  ## [0.58.1] - 2024-11-04
18
27
  ### Added
@@ -182,9 +191,7 @@
182
191
  - Social | Wired up confirmation UI with connect button [#37295]
183
192
 
184
193
  ### Changed
185
- - Updated package dependencies. [#37379]
186
- - Updated package dependencies. [#37380]
187
- - Updated package dependencies. [#37382]
194
+ - Updated package dependencies. [#37379] [#37380] [#37382]
188
195
 
189
196
  ## [0.53.2] - 2024-05-13
190
197
  ### Added
@@ -409,8 +416,7 @@
409
416
 
410
417
  ## [0.42.1] - 2023-09-04
411
418
  ### Changed
412
- - Updated package dependencies. [#32803]
413
- - Updated package dependencies. [#32804]
419
+ - Updated package dependencies. [#32803] [#32804]
414
420
 
415
421
  ## [0.42.0] - 2023-09-01
416
422
  ### Added
@@ -460,8 +466,7 @@
460
466
  ## [0.40.1] - 2023-07-05
461
467
  ### Changed
462
468
  - Adjust component pricing slider border and box-shadow styling. [#31593]
463
- - Updated package dependencies. [#31659]
464
- - Updated package dependencies. [#31661]
469
+ - Updated package dependencies. [#31659] [#31661]
465
470
  - Update storybook mdx to use `@storybook/blocks` directly rather than `@storybook/addon-docs`. [#31607]
466
471
 
467
472
  ### Fixed
@@ -739,8 +744,7 @@
739
744
  - Fix ProductPrice layout for long prices [#26595]
740
745
  - IconTooltip: Use click instead of mouseover for summoning [#26457]
741
746
  - Refactor props for structure consistency with JetpackLogo component. [#26510]
742
- - Updated package dependencies. [#26568]
743
- - Updated package dependencies. [#26583]
747
+ - Updated package dependencies. [#26568] [#26583]
744
748
 
745
749
  ### Fixed
746
750
  - Components: fix the positio of TOS component of the PricingTable cmp [#26509]
@@ -1214,6 +1218,8 @@
1214
1218
  ### Changed
1215
1219
  - Update node version requirement to 14.16.1
1216
1220
 
1221
+ [0.61.0]: https://github.com/Automattic/jetpack-components/compare/0.60.0...0.61.0
1222
+ [0.60.0]: https://github.com/Automattic/jetpack-components/compare/0.59.0...0.60.0
1217
1223
  [0.59.0]: https://github.com/Automattic/jetpack-components/compare/0.58.1...0.59.0
1218
1224
  [0.58.1]: https://github.com/Automattic/jetpack-components/compare/0.58.0...0.58.1
1219
1225
  [0.58.0]: https://github.com/Automattic/jetpack-components/compare/0.57.0...0.58.0
@@ -24,6 +24,7 @@ class Gridicon extends Component< GridiconProps > {
24
24
  'gridicons-calendar',
25
25
  'gridicons-cart',
26
26
  'gridicons-folder',
27
+ 'gridicons-help-outline',
27
28
  'gridicons-info',
28
29
  'gridicons-info-outline',
29
30
  'gridicons-posts',
@@ -66,6 +67,8 @@ class Gridicon extends Component< GridiconProps > {
66
67
  return __( 'Toggle search filters.', 'jetpack' );
67
68
  case 'gridicons-folder':
68
69
  return __( 'Category', 'jetpack' );
70
+ case 'gridicons-help-outline':
71
+ return __( 'Help', 'jetpack' );
69
72
  case 'gridicons-info':
70
73
  case 'gridicons-info-outline':
71
74
  return __( 'Information.', 'jetpack' );
@@ -181,6 +184,12 @@ class Gridicon extends Component< GridiconProps > {
181
184
  <path d="M18 19H6c-1.1 0-2-.9-2-2V7c0-1.1.9-2 2-2h3c1.1 0 2 .9 2 2h7c1.1 0 2 .9 2 2v8c0 1.1-.9 2-2 2z" />
182
185
  </g>
183
186
  );
187
+ case 'gridicons-help-outline':
188
+ return (
189
+ <g>
190
+ <path d="M12 4c4.41 0 8 3.59 8 8s-3.59 8-8 8-8-3.59-8-8 3.59-8 8-8m0-2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 13h-2v2h2v-2zm-1.962-2v-.528c0-.4.082-.74.246-1.017.163-.276.454-.546.87-.808.333-.21.572-.397.717-.565.146-.168.22-.36.22-.577 0-.172-.078-.308-.234-.41-.156-.1-.358-.15-.608-.15-.62 0-1.34.22-2.168.658l-.854-1.67c1.02-.58 2.084-.872 3.194-.872.913 0 1.63.202 2.15.603.52.4.78.948.78 1.64 0 .495-.116.924-.347 1.287-.23.362-.6.705-1.11 1.03-.43.278-.7.48-.807.61-.108.13-.163.282-.163.458V13h-1.885z" />
191
+ </g>
192
+ );
184
193
  case 'gridicons-image':
185
194
  return (
186
195
  <g>
@@ -55,7 +55,8 @@ const PricingCard: React.FC< PricingCardProps > = ( {
55
55
  ) }
56
56
  <h1 className="jp-components__pricing-card__title">{ props.title }</h1>
57
57
  <div className="jp-components__pricing-card__pricing">
58
- { props.priceBefore !== props.priceAfter && props.priceAfter > 0 ? (
58
+ { props.priceAfter === 0 && <LoadingPlaceholder width="100%" height={ 48 } /> }
59
+ { props.priceBefore !== props.priceAfter && props.priceAfter > 0 && (
59
60
  <div className="jp-components__pricing-card__price-before">
60
61
  <span className="jp-components__pricing-card__currency">
61
62
  { currencyObjectBefore.symbol }
@@ -71,8 +72,6 @@ const PricingCard: React.FC< PricingCardProps > = ( {
71
72
  ) }
72
73
  <div className="jp-components__pricing-card__price-strikethrough"></div>
73
74
  </div>
74
- ) : (
75
- <LoadingPlaceholder width="100%" height={ 48 } />
76
75
  ) }
77
76
  { props.priceAfter > 0 && (
78
77
  <>
@@ -1,8 +1,13 @@
1
- import { Button, Text, ActionPopover } from '@automattic/jetpack-components';
2
- import { CONTACT_SUPPORT_URL, type Threat, fixerStatusIsStale } from '@automattic/jetpack-scan';
3
- import { ExternalLink } from '@wordpress/components';
4
- import { createInterpolateElement, useCallback, useMemo, useState } from '@wordpress/element';
5
- import { __, sprintf } from '@wordpress/i18n';
1
+ import { Button } from '@automattic/jetpack-components';
2
+ import {
3
+ type Threat,
4
+ fixerIsInError,
5
+ fixerIsInProgress,
6
+ fixerStatusIsStale,
7
+ } from '@automattic/jetpack-scan';
8
+ import { Tooltip } from '@wordpress/components';
9
+ import { useCallback, useMemo } from '@wordpress/element';
10
+ import { __ } from '@wordpress/i18n';
6
11
  import styles from './styles.module.scss';
7
12
 
8
13
  /**
@@ -24,119 +29,133 @@ export default function ThreatFixerButton( {
24
29
  onClick: ( items: Threat[] ) => void;
25
30
  className?: string;
26
31
  } ): JSX.Element {
27
- const [ isPopoverVisible, setIsPopoverVisible ] = useState( false );
28
-
29
- const [ anchor, setAnchor ] = useState( null );
32
+ const fixerState = useMemo( () => {
33
+ const inProgress = threat.fixer && fixerIsInProgress( threat.fixer );
34
+ const error = threat.fixer && fixerIsInError( threat.fixer );
35
+ const stale = threat.fixer && fixerStatusIsStale( threat.fixer );
36
+ return { inProgress, error, stale };
37
+ }, [ threat.fixer ] );
30
38
 
31
- const children = useMemo( () => {
39
+ const tooltipText = useMemo( () => {
32
40
  if ( ! threat.fixable ) {
33
41
  return null;
34
42
  }
35
- if ( threat.fixer && 'error' in threat.fixer && threat.fixer.error ) {
36
- return __( 'Error', 'jetpack' );
43
+
44
+ if ( fixerState.error ) {
45
+ return __( 'An error occurred auto-fixing this threat.', 'jetpack' );
37
46
  }
38
- if ( threat.fixer && 'status' in threat.fixer && threat.fixer.status === 'in_progress' ) {
39
- return __( 'Fixing…', 'jetpack' );
47
+
48
+ if ( fixerState.stale ) {
49
+ return __( 'The auto-fixer is taking longer than expected.', 'jetpack' );
40
50
  }
41
- if ( threat.fixable.fixer === 'delete' ) {
42
- return __( 'Delete', 'jetpack' );
51
+
52
+ if ( fixerState.inProgress ) {
53
+ return __( 'An auto-fixer is in progress.', 'jetpack' );
43
54
  }
44
- if ( threat.fixable.fixer === 'update' ) {
45
- return __( 'Update', 'jetpack' );
55
+
56
+ switch ( threat.fixable.fixer ) {
57
+ case 'delete':
58
+ if ( threat.filename ) {
59
+ if ( threat.filename.endsWith( '/' ) ) {
60
+ return __( 'Deletes the directory that the infected file is in.', 'jetpack' );
61
+ }
62
+
63
+ if ( threat.signature === 'Core.File.Modification' ) {
64
+ return __( 'Deletes the unexpected file in a core WordPress directory.', 'jetpack' );
65
+ }
66
+
67
+ return __( 'Deletes the infected file.', 'jetpack' );
68
+ }
69
+
70
+ if ( threat.extension?.type === 'plugin' ) {
71
+ return __( 'Deletes the plugin directory to fix the threat.', 'jetpack' );
72
+ }
73
+
74
+ if ( threat.extension?.type === 'theme' ) {
75
+ return __( 'Deletes the theme directory to fix the threat.', 'jetpack' );
76
+ }
77
+ break;
78
+ case 'update':
79
+ return __( 'Upgrades the plugin or theme to a newer version.', 'jetpack' );
80
+ case 'replace':
81
+ case 'rollback':
82
+ if ( threat.filename ) {
83
+ return threat.signature === 'Core.File.Modification'
84
+ ? __(
85
+ 'Replaces the modified core WordPress file with the original clean version from the WordPress source code.',
86
+ 'jetpack'
87
+ )
88
+ : __(
89
+ 'Replaces the infected file with a previously backed up version that is clean.',
90
+ 'jetpack'
91
+ );
92
+ }
93
+
94
+ if ( threat.signature === 'php_hardening_WP_Config_NoSalts_001' ) {
95
+ return __(
96
+ 'Replaces the default salt keys in wp-config.php with unique ones.',
97
+ 'jetpack'
98
+ );
99
+ }
100
+ break;
101
+ default:
102
+ return __( 'An auto-fixer is available.', 'jetpack' );
46
103
  }
47
- return __( 'Fix', 'jetpack' );
48
- }, [ threat.fixable, threat.fixer ] );
104
+ }, [ threat, fixerState ] );
49
105
 
50
- const errorMessage = useMemo( () => {
51
- if ( threat.fixer && fixerStatusIsStale( threat.fixer ) ) {
52
- return __( 'The fixer is taking longer than expected.', 'jetpack' );
106
+ const buttonText = useMemo( () => {
107
+ if ( ! threat.fixable ) {
108
+ return null;
53
109
  }
54
110
 
55
- if ( threat.fixer && 'error' in threat.fixer && threat.fixer.error ) {
56
- return __( 'An error occurred auto-fixing this threat.', 'jetpack' );
111
+ if ( fixerState.error ) {
112
+ return __( 'Error', 'jetpack' );
57
113
  }
58
114
 
59
- return null;
60
- }, [ threat.fixer ] );
115
+ switch ( threat.fixable.fixer ) {
116
+ case 'delete':
117
+ return __( 'Delete', 'jetpack' );
118
+ case 'update':
119
+ return __( 'Update', 'jetpack' );
120
+ case 'replace':
121
+ case 'rollback':
122
+ return __( 'Replace', 'jetpack' );
123
+ default:
124
+ return __( 'Fix', 'jetpack' );
125
+ }
126
+ }, [ threat.fixable, fixerState.error ] );
61
127
 
62
128
  const handleClick = useCallback(
63
129
  ( event: React.MouseEvent ) => {
64
130
  event.stopPropagation();
65
- if ( errorMessage && ! isPopoverVisible ) {
66
- setIsPopoverVisible( true );
67
- return;
68
- }
69
131
  onClick( [ threat ] );
70
132
  },
71
- [ onClick, errorMessage, isPopoverVisible, threat ]
133
+ [ onClick, threat ]
72
134
  );
73
135
 
74
- const closePopover = useCallback( () => {
75
- setIsPopoverVisible( false );
76
- }, [] );
77
-
78
136
  if ( ! threat.fixable ) {
79
137
  return null;
80
138
  }
81
139
 
82
140
  return (
83
141
  <div>
84
- <Button
85
- size="small"
86
- weight="regular"
87
- variant="secondary"
88
- onClick={ handleClick }
89
- children={ children }
90
- className={ className }
91
- disabled={
92
- threat.fixer &&
93
- 'status' in threat.fixer &&
94
- threat.fixer.status === 'in_progress' &&
95
- ! errorMessage
96
- }
97
- isLoading={
98
- threat.fixer && 'status' in threat.fixer && threat.fixer.status === 'in_progress'
99
- }
100
- isDestructive={
101
- ( threat.fixable && threat.fixable.fixer === 'delete' ) ||
102
- ( threat.fixer && 'error' in threat.fixer && threat.fixer.error ) ||
103
- ( threat.fixer && fixerStatusIsStale( threat.fixer ) )
104
- }
105
- style={ { minWidth: '72px' } }
106
- ref={ setAnchor }
107
- />
108
- { isPopoverVisible && (
109
- <ActionPopover
110
- anchor={ anchor }
111
- buttonContent={ __( 'Retry Fix', 'jetpack' ) }
112
- hideCloseButton={ true }
113
- noArrow={ false }
142
+ <Tooltip className={ styles.tooltip } text={ tooltipText }>
143
+ <Button
144
+ size="small"
145
+ weight="regular"
146
+ variant="secondary"
114
147
  onClick={ handleClick }
115
- onClose={ closePopover }
116
- title={ __( 'Auto-fix error', 'jetpack' ) }
117
- >
118
- <Text>
119
- { createInterpolateElement(
120
- sprintf(
121
- /* translators: placeholder is an error message. */
122
- __(
123
- '%s Please try again or <supportLink>contact support</supportLink>.',
124
- 'jetpack'
125
- ),
126
- errorMessage
127
- ),
128
- {
129
- supportLink: (
130
- <ExternalLink
131
- href={ CONTACT_SUPPORT_URL }
132
- className={ styles[ 'support-link' ] }
133
- />
134
- ),
135
- }
136
- ) }
137
- </Text>
138
- </ActionPopover>
139
- ) }
148
+ children={ buttonText }
149
+ className={ className }
150
+ isLoading={ fixerState.inProgress }
151
+ isDestructive={
152
+ ( threat.fixable && threat.fixable.fixer === 'delete' ) ||
153
+ fixerState.error ||
154
+ fixerState.stale
155
+ }
156
+ style={ { minWidth: '72px' } }
157
+ />
158
+ </Tooltip>
140
159
  </div>
141
160
  );
142
161
  }
@@ -7,3 +7,10 @@
7
7
  box-shadow: none;
8
8
  }
9
9
  }
10
+
11
+ .tooltip {
12
+ margin-top: var( --spacing-base ) ;
13
+ max-width: 240px;
14
+ border-radius: 4px;
15
+ text-align: left;
16
+ }
@@ -385,7 +385,7 @@ export default function ThreatsDataViews( {
385
385
  ? [
386
386
  {
387
387
  id: THREAT_FIELD_AUTO_FIX,
388
- label: __( 'Auto-Fix', 'jetpack' ),
388
+ label: __( 'Auto-fix', 'jetpack' ),
389
389
  enableHiding: false,
390
390
  elements: [
391
391
  {
@@ -426,7 +426,7 @@ export default function ThreatsDataViews( {
426
426
  if ( dataFields.includes( 'fixable' ) ) {
427
427
  result.push( {
428
428
  id: THREAT_ACTION_FIX,
429
- label: __( 'Auto-Fix', 'jetpack' ),
429
+ label: __( 'Auto-fix', 'jetpack' ),
430
430
  isPrimary: true,
431
431
  supportsBulk: true,
432
432
  callback: onFixThreats,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/jetpack-components",
3
- "version": "0.59.0",
3
+ "version": "0.61.0",
4
4
  "description": "Jetpack Components Package",
5
5
  "author": "Automattic",
6
6
  "license": "GPL-2.0-or-later",
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@automattic/format-currency": "1.0.1",
18
- "@automattic/jetpack-boost-score-api": "^0.1.45",
19
- "@automattic/jetpack-scan": "^0.1.0",
18
+ "@automattic/jetpack-boost-score-api": "^0.1.46",
19
+ "@automattic/jetpack-scan": "^0.2.0",
20
20
  "@babel/runtime": "^7",
21
21
  "@wordpress/browserslist-config": "6.11.0",
22
22
  "@wordpress/components": "28.11.0",
@@ -32,12 +32,12 @@
32
32
  "prop-types": "^15.7.2",
33
33
  "qrcode.react": "3.1.0",
34
34
  "react-slider": "2.0.5",
35
- "social-logos": "^3.1.11",
35
+ "social-logos": "^3.1.12",
36
36
  "uplot": "1.6.31",
37
37
  "uplot-react": "1.1.4"
38
38
  },
39
39
  "devDependencies": {
40
- "@automattic/jetpack-base-styles": "^0.6.35",
40
+ "@automattic/jetpack-base-styles": "^0.6.36",
41
41
  "@babel/core": "7.26.0",
42
42
  "@babel/preset-react": "7.25.9",
43
43
  "@jest/globals": "29.4.3",