@automattic/newspack-blocks 1.53.0 → 1.53.1

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.
@@ -7,7 +7,7 @@
7
7
  * Author URI: https://newspack.blog/
8
8
  * Text Domain: newspack-blocks
9
9
  * Domain Path: /languages
10
- * Version: 1.53.0
10
+ * Version: 1.53.1
11
11
  *
12
12
  * @package Newspack_Blocks
13
13
  */
@@ -15,7 +15,7 @@
15
15
  define( 'NEWSPACK_BLOCKS__PLUGIN_FILE', __FILE__ );
16
16
  define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
17
17
  define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( NEWSPACK_BLOCKS__PLUGIN_FILE ) );
18
- define( 'NEWSPACK_BLOCKS__VERSION', '1.53.0' );
18
+ define( 'NEWSPACK_BLOCKS__VERSION', '1.53.1' );
19
19
 
20
20
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks.php';
21
21
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-api.php';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/newspack-blocks",
3
- "version": "1.53.0",
3
+ "version": "1.53.1",
4
4
  "author": "Automattic",
5
5
  "devDependencies": {
6
6
  "@rushstack/eslint-patch": "^1.1.3",
@@ -20,7 +20,7 @@
20
20
  "@stripe/stripe-js": "^1.31.0",
21
21
  "classnames": "^2.3.1",
22
22
  "lodash": "^4.17.21",
23
- "newspack-components": "^2.0.3",
23
+ "newspack-components": "^2.1.0",
24
24
  "react": "^17.0.2",
25
25
  "redux": "^4.2.0",
26
26
  "redux-saga": "^1.1.3",
@@ -133,6 +133,7 @@ export const avatarSizeOptions = [
133
133
 
134
134
  const AuthorProfile = ( { attributes, setAttributes } ) => {
135
135
  const [ author, setAuthor ] = useState( null );
136
+ const [ suggestions, setSuggestions ] = useState( null );
136
137
  const [ error, setError ] = useState( null );
137
138
  const [ isLoading, setIsLoading ] = useState( false );
138
139
  const [ maxItemsToSuggest, setMaxItemsToSuggest ] = useState( 0 );
@@ -155,7 +156,7 @@ const AuthorProfile = ( { attributes, setAttributes } ) => {
155
156
  if ( 0 !== authorId ) {
156
157
  getAuthorById();
157
158
  }
158
- }, [ authorId, avatarHideDefault ] );
159
+ }, [ authorId, avatarHideDefault, isGuestAuthor ] );
159
160
 
160
161
  const getAuthorById = async () => {
161
162
  setError( null );
@@ -367,6 +368,7 @@ const AuthorProfile = ( { attributes, setAttributes } ) => {
367
368
  <SingleAuthor author={ author } attributes={ attributes } />
368
369
  ) : (
369
370
  <Placeholder
371
+ className="newspack-blocks-author-profile"
370
372
  icon={ <Icon icon={ postAuthor } /> }
371
373
  label={ __( 'Author Profile', 'newspack-blocks' ) }
372
374
  >
@@ -389,8 +391,11 @@ const AuthorProfile = ( { attributes, setAttributes } ) => {
389
391
  'newspack-blocks'
390
392
  ) }
391
393
  fetchSuggestions={ async ( search = null, offset = 0 ) => {
394
+ // Reset suggestions in state.
395
+ setSuggestions( null );
396
+
392
397
  // If we already have a selected author, no need to fetch suggestions.
393
- if ( authorId ) {
398
+ if ( authorId && ! error ) {
394
399
  return [];
395
400
  }
396
401
 
@@ -399,7 +404,6 @@ const AuthorProfile = ( { attributes, setAttributes } ) => {
399
404
  path: addQueryArgs( '/newspack-blocks/v1/authors', {
400
405
  search,
401
406
  offset,
402
- isGuestAuthor: true,
403
407
  fields: 'id,name',
404
408
  } ),
405
409
  } );
@@ -412,17 +416,36 @@ const AuthorProfile = ( { attributes, setAttributes } ) => {
412
416
  setMaxItemsToSuggest( total );
413
417
  }
414
418
 
415
- return authors.map( _author => ( {
419
+ const _suggestions = authors.map( _author => ( {
416
420
  value: _author.id,
417
421
  label: decodeEntities( _author.name ) || __( '(no name)', 'newspack' ),
418
422
  isGuestAuthor: _author.is_guest,
419
423
  } ) );
424
+
425
+ setSuggestions( _suggestions );
426
+
427
+ return _suggestions;
420
428
  } }
421
429
  maxItemsToSuggest={ maxItemsToSuggest }
422
430
  onChange={ items => {
431
+ let selectionIsGuest = false;
432
+ const selection = items[ 0 ];
433
+
434
+ // We need to check whether the selected author is a guest author or not.
435
+ if ( suggestions ) {
436
+ suggestions.forEach( suggestion => {
437
+ if (
438
+ parseInt( selection?.value ) === parseInt( suggestion?.value ) &&
439
+ suggestion?.isGuestAuthor
440
+ ) {
441
+ selectionIsGuest = true;
442
+ }
443
+ } );
444
+ }
445
+
423
446
  setAttributes( {
424
- authorId: parseInt( items[ 0 ]?.value || 0 ),
425
- isGuestAuthor: items[ 0 ]?.isGuestAuthor || false,
447
+ authorId: parseInt( selection?.value || 0 ),
448
+ isGuestAuthor: selectionIsGuest,
426
449
  } );
427
450
  } }
428
451
  postTypeLabel={ __( 'author', 'newspack-blocks' ) }
@@ -1,7 +1,7 @@
1
1
  @import './view';
2
2
 
3
3
  .editor-styles-wrapper {
4
- .wp-block-newspack-blocks-author-profile {
4
+ .newspack-blocks-author-profile {
5
5
  .components-notice {
6
6
  margin: 0 0 2rem 0;
7
7
  width: 100%;
@@ -4,4 +4,4 @@
4
4
 
5
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
6
 
7
- return ComposerAutoloaderInit23e7353bf7a8e11d2c7c2cc21cce61d6::getLoader();
7
+ return ComposerAutoloaderInitddb9ed3d8a2769081f45868acf01cf2e::getLoader();
@@ -2,7 +2,7 @@
2
2
 
3
3
  // autoload_real.php @generated by Composer
4
4
 
5
- class ComposerAutoloaderInit23e7353bf7a8e11d2c7c2cc21cce61d6
5
+ class ComposerAutoloaderInitddb9ed3d8a2769081f45868acf01cf2e
6
6
  {
7
7
  private static $loader;
8
8
 
@@ -22,15 +22,15 @@ class ComposerAutoloaderInit23e7353bf7a8e11d2c7c2cc21cce61d6
22
22
  return self::$loader;
23
23
  }
24
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInit23e7353bf7a8e11d2c7c2cc21cce61d6', 'loadClassLoader'), true, true);
25
+ spl_autoload_register(array('ComposerAutoloaderInitddb9ed3d8a2769081f45868acf01cf2e', 'loadClassLoader'), true, true);
26
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
27
- spl_autoload_unregister(array('ComposerAutoloaderInit23e7353bf7a8e11d2c7c2cc21cce61d6', 'loadClassLoader'));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInitddb9ed3d8a2769081f45868acf01cf2e', 'loadClassLoader'));
28
28
 
29
29
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
30
  if ($useStaticLoader) {
31
31
  require __DIR__ . '/autoload_static.php';
32
32
 
33
- call_user_func(\Composer\Autoload\ComposerStaticInit23e7353bf7a8e11d2c7c2cc21cce61d6::getInitializer($loader));
33
+ call_user_func(\Composer\Autoload\ComposerStaticInitddb9ed3d8a2769081f45868acf01cf2e::getInitializer($loader));
34
34
  } else {
35
35
  $map = require __DIR__ . '/autoload_namespaces.php';
36
36
  foreach ($map as $namespace => $path) {
@@ -4,7 +4,7 @@
4
4
 
5
5
  namespace Composer\Autoload;
6
6
 
7
- class ComposerStaticInit23e7353bf7a8e11d2c7c2cc21cce61d6
7
+ class ComposerStaticInitddb9ed3d8a2769081f45868acf01cf2e
8
8
  {
9
9
  public static $classMap = array (
10
10
  'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -13,7 +13,7 @@ class ComposerStaticInit23e7353bf7a8e11d2c7c2cc21cce61d6
13
13
  public static function getInitializer(ClassLoader $loader)
14
14
  {
15
15
  return \Closure::bind(function () use ($loader) {
16
- $loader->classMap = ComposerStaticInit23e7353bf7a8e11d2c7c2cc21cce61d6::$classMap;
16
+ $loader->classMap = ComposerStaticInitddb9ed3d8a2769081f45868acf01cf2e::$classMap;
17
17
 
18
18
  }, null, ClassLoader::class);
19
19
  }
@@ -5,7 +5,7 @@
5
5
  'type' => 'wordpress-plugin',
6
6
  'install_path' => __DIR__ . '/../../',
7
7
  'aliases' => array(),
8
- 'reference' => 'f7f4a31da32051a3cdbb44ab64515f863368e08b',
8
+ 'reference' => '085efaf431b70ad15514a0d33c7ad0ce0697387e',
9
9
  'name' => 'automattic/newspack-blocks',
10
10
  'dev' => false,
11
11
  ),
@@ -16,7 +16,7 @@
16
16
  'type' => 'wordpress-plugin',
17
17
  'install_path' => __DIR__ . '/../../',
18
18
  'aliases' => array(),
19
- 'reference' => 'f7f4a31da32051a3cdbb44ab64515f863368e08b',
19
+ 'reference' => '085efaf431b70ad15514a0d33c7ad0ce0697387e',
20
20
  'dev_requirement' => false,
21
21
  ),
22
22
  ),