@wordpress/block-directory 3.8.0 → 3.9.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 (27) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/downloadable-block-list-item/index.js.map +1 -1
  3. package/build/components/downloadable-blocks-list/index.js +3 -7
  4. package/build/components/downloadable-blocks-list/index.js.map +1 -1
  5. package/build/components/downloadable-blocks-panel/index.js.map +1 -1
  6. package/build/components/downloadable-blocks-panel/no-results.js +8 -2
  7. package/build/components/downloadable-blocks-panel/no-results.js.map +1 -1
  8. package/build/store/actions.js.map +1 -1
  9. package/build/store/resolvers.js.map +1 -1
  10. package/build-module/components/downloadable-block-list-item/index.js.map +1 -1
  11. package/build-module/components/downloadable-blocks-list/index.js +2 -5
  12. package/build-module/components/downloadable-blocks-list/index.js.map +1 -1
  13. package/build-module/components/downloadable-blocks-panel/index.js.map +1 -1
  14. package/build-module/components/downloadable-blocks-panel/no-results.js +8 -3
  15. package/build-module/components/downloadable-blocks-panel/no-results.js.map +1 -1
  16. package/build-module/store/actions.js.map +1 -1
  17. package/build-module/store/resolvers.js.map +1 -1
  18. package/build-style/style-rtl.css +0 -1
  19. package/build-style/style.css +0 -1
  20. package/package.json +20 -20
  21. package/src/components/downloadable-block-list-item/index.js +2 -4
  22. package/src/components/downloadable-blocks-list/index.js +2 -5
  23. package/src/components/downloadable-blocks-panel/index.js +2 -4
  24. package/src/components/downloadable-blocks-panel/no-results.js +22 -7
  25. package/src/store/actions.js +130 -128
  26. package/src/store/resolvers.js +17 -17
  27. package/src/store/test/actions.js +1 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.9.0 (2022-06-15)
6
+
5
7
  ## 3.8.0 (2022-06-01)
6
8
 
7
9
  ## 3.7.0 (2022-05-18)
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"names":["getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","DownloadableBlockListItem","composite","item","onClick","author","description","icon","name","isInstallable","select","getErrorNoticeForBlock","isBlockInstalling","blockDirectoryStore","notice","id","hasFatal","isFatal","statusText","Button","event","preventDefault","span"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AACA;;AAOA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AArBA;AACA;AACA;;AAaA;AACA;AACA;AAMA;AACA,SAASA,yBAAT,cAGE;AAAA,MAFD;AAAEC,IAAAA,KAAF;AAASC,IAAAA,MAAT;AAAiBC,IAAAA;AAAjB,GAEC;AAAA,MADD;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,WAAb;AAA0BC,IAAAA;AAA1B,GACC;AACD,QAAMC,KAAK,GAAGC,IAAI,CAACC,KAAL,CAAYP,MAAM,GAAG,GAArB,IAA6B,GAA3C;;AAEA,MAAK,CAAEG,WAAF,IAAiBD,SAAtB,EAAkC;AACjC;AACA,WAAO,mBAAS,sBAAT,EAAiC,kCAAgBH,KAAhB,CAAjC,CAAP;AACA;;AAED,MAAKI,WAAL,EAAmB;AAClB;AACA,WAAO,mBAAS,SAAT,EAAoB,kCAAgBJ,KAAhB,CAApB,CAAP;AACA;;AAED,MAAKK,YAAL,EAAoB;AACnB;AACA,WAAO,mBAAS,gBAAT,EAA2B,kCAAgBL,KAAhB,CAA3B,CAAP;AACA,GAhBA,CAkBD;;;AACA,MAAKE,WAAW,GAAG,CAAnB,EAAuB;AACtB;AACA,WAAO,mBAAS,aAAT,EAAwB,kCAAgBF,KAAhB,CAAxB,CAAP;AACA;;AAED,SAAO;AACN;AACA,gBACC,4CADD,EAEC,6CAFD,EAGCE,WAHD,CAFM,EAON,kCAAgBF,KAAhB,CAPM,EAQNM,KARM,EASNJ,WATM,CAAP;AAWA;;AAED,SAASO,yBAAT,QAAmE;AAAA,MAA/B;AAAEC,IAAAA,SAAF;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{\n\tButton,\n\tSpinner,\n\tVisuallyHidden,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { composite, item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetErrorNoticeForBlock,\n\t\t\t\tisInstalling: isBlockInstalling,\n\t\t\t} = select( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\treturn (\n\t\t<CompositeItem\n\t\t\t__experimentalIsFocusable\n\t\t\trole=\"option\"\n\t\t\tas={ Button }\n\t\t\t{ ...composite }\n\t\t\tclassName=\"block-directory-downloadable-block-list-item\"\n\t\t\tonClick={ ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t\tisBusy={ isInstalling }\n\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\tlabel={ getDownloadableBlockLabel( item, {\n\t\t\t\thasNotice,\n\t\t\t\tisInstalled,\n\t\t\t\tisInstalling,\n\t\t\t} ) }\n\t\t\tshowTooltip={ true }\n\t\t\ttooltipPosition=\"top center\"\n\t\t>\n\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</CompositeItem>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"names":["getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","DownloadableBlockListItem","composite","item","onClick","author","description","icon","name","isInstallable","select","getErrorNoticeForBlock","isBlockInstalling","blockDirectoryStore","notice","id","hasFatal","isFatal","statusText","Button","event","preventDefault","span"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AACA;;AAOA;;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,CAZlC;AAiBC,IAAA,WAAW,EAAG,IAjBf;AAkBC,IAAA,eAAe,EAAC;AAlBjB,MAoBC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,8BAAD;AAAuB,IAAA,IAAI,EAAGU,IAA9B;AAAqC,IAAA,KAAK,EAAGf;AAA7C,IADD,EAEGK,YAAY,GACb;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,4BAAC,mBAAD,OADD,CADa,GAKb,4BAAC,qBAAD;AAAc,IAAA,MAAM,EAAGJ;AAAvB,IAPF,CApBD,EA8BC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACG,uCACD;AACC;AACA,gBAAI,2BAAJ,CAFD,EAGC,kCAAgBD,KAAhB,CAHD,EAICa,MAJD,CADC,EAOD;AACCiB,IAAAA,IAAI,EACH;AAAM,MAAA,SAAS,EAAC;AAAhB;AAFF,GAPC,CADH,CADD,EAgBG3B,SAAS,GACV,4BAAC,gCAAD;AAAyB,IAAA,KAAK,EAAGQ;AAAjC,IADU,GAGV,qDACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACG,CAAC,CAAEe,UAAH,GACCA,UADD,GAEC,kCAAgBZ,WAAhB,CAHJ,CADD,EAMGG,aAAa,IACd,EAAIb,WAAW,IAAIC,YAAnB,CADC,IAEA,4BAAC,0BAAD,QACG,cAAI,eAAJ,CADH,CARH,CAnBF,CA9BD,CADD;AAmEA;;eAEcI,yB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tSpinner,\n\tVisuallyHidden,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { composite, item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\treturn (\n\t\t<CompositeItem\n\t\t\t__experimentalIsFocusable\n\t\t\trole=\"option\"\n\t\t\tas={ Button }\n\t\t\t{ ...composite }\n\t\t\tclassName=\"block-directory-downloadable-block-list-item\"\n\t\t\tonClick={ ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t\tisBusy={ isInstalling }\n\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\tlabel={ getDownloadableBlockLabel( item, {\n\t\t\t\thasNotice,\n\t\t\t\tisInstalled,\n\t\t\t\tisInstalling,\n\t\t\t} ) }\n\t\t\tshowTooltip={ true }\n\t\t\ttooltipPosition=\"top center\"\n\t\t>\n\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</CompositeItem>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"]}
@@ -11,8 +11,6 @@ var _element = require("@wordpress/element");
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
- var _lodash = require("lodash");
15
-
16
14
  var _i18n = require("@wordpress/i18n");
17
15
 
18
16
  var _components = require("@wordpress/components");
@@ -25,10 +23,6 @@ var _downloadableBlockListItem = _interopRequireDefault(require("../downloadable
25
23
 
26
24
  var _store = require("../../store");
27
25
 
28
- /**
29
- * External dependencies
30
- */
31
-
32
26
  /**
33
27
  * WordPress dependencies
34
28
  */
@@ -36,10 +30,12 @@ var _store = require("../../store");
36
30
  /**
37
31
  * Internal dependencies
38
32
  */
33
+ const noop = () => {};
34
+
39
35
  function DownloadableBlocksList(_ref) {
40
36
  let {
41
37
  items,
42
- onHover = _lodash.noop,
38
+ onHover = noop,
43
39
  onSelect
44
40
  } = _ref;
45
41
  const composite = (0, _components.__unstableUseCompositeState)();
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-blocks-list/index.js"],"names":["DownloadableBlocksList","items","onHover","noop","onSelect","composite","installBlockType","blockDirectoryStore","length","map","item","id","name","then","success"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AAIA;;AACA;;AAKA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;AAIA,SAASA,sBAAT,OAAuE;AAAA,MAAtC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,OAAO,GAAGC,YAAnB;AAAyBC,IAAAA;AAAzB,GAAsC;AACtE,QAAMC,SAAS,GAAG,8CAAlB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,YAAb,CAA7B;;AAEA,MAAK,CAAEN,KAAK,CAACO,MAAb,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,+BAAD,6BACMH,SADN;AAEC,IAAA,IAAI,EAAC,SAFN;AAGC,IAAA,SAAS,EAAC,0CAHX;AAIC,kBAAa,cAAI,8BAAJ;AAJd,MAMGJ,KAAK,CAACQ,GAAN,CAAaC,IAAF,IAAY;AACxB,WACC,4BAAC,kCAAD;AACC,MAAA,GAAG,EAAGA,IAAI,CAACC,EADZ;AAEC,MAAA,SAAS,EAAGN,SAFb;AAGC,MAAA,OAAO,EAAG,MAAM;AACf;AACA;AACA;AACA,YAAK,0BAAcK,IAAI,CAACE,IAAnB,CAAL,EAAiC;AAChCR,UAAAA,QAAQ,CAAEM,IAAF,CAAR;AACA,SAFD,MAEO;AACNJ,UAAAA,gBAAgB,CAAEI,IAAF,CAAhB,CAAyBG,IAAzB,CAAiCC,OAAF,IAAe;AAC7C,gBAAKA,OAAL,EAAe;AACdV,cAAAA,QAAQ,CAAEM,IAAF,CAAR;AACA;AACD,WAJD;AAKA;;AACDR,QAAAA,OAAO,CAAE,IAAF,CAAP;AACA,OAjBF;AAkBC,MAAA,OAAO,EAAGA,OAlBX;AAmBC,MAAA,IAAI,EAAGQ;AAnBR,MADD;AAuBA,GAxBC,CANH,CADD;AAkCA;;eAEcV,sB","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n} from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockListItem from '../downloadable-block-list-item';\nimport { store as blockDirectoryStore } from '../../store';\n\nfunction DownloadableBlocksList( { items, onHover = noop, onSelect } ) {\n\tconst composite = useCompositeState();\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Composite\n\t\t\t{ ...composite }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-directory-downloadable-blocks-list\"\n\t\t\taria-label={ __( 'Blocks available for install' ) }\n\t\t>\n\t\t\t{ items.map( ( item ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlockListItem\n\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Check if the block is registered (`getBlockType`\n\t\t\t\t\t\t\t// will return an object). If so, insert the block.\n\t\t\t\t\t\t\t// This prevents installing existing plugins.\n\t\t\t\t\t\t\tif ( getBlockType( item.name ) ) {\n\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tinstallBlockType( item ).then( ( success ) => {\n\t\t\t\t\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Composite>\n\t);\n}\n\nexport default DownloadableBlocksList;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-blocks-list/index.js"],"names":["noop","DownloadableBlocksList","items","onHover","onSelect","composite","installBlockType","blockDirectoryStore","length","map","item","id","name","then","success"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAIA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AASA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,SAASC,sBAAT,OAAuE;AAAA,MAAtC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,OAAO,GAAGH,IAAnB;AAAyBI,IAAAA;AAAzB,GAAsC;AACtE,QAAMC,SAAS,GAAG,8CAAlB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAuB,uBAAaC,YAAb,CAA7B;;AAEA,MAAK,CAAEL,KAAK,CAACM,MAAb,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,+BAAD,6BACMH,SADN;AAEC,IAAA,IAAI,EAAC,SAFN;AAGC,IAAA,SAAS,EAAC,0CAHX;AAIC,kBAAa,cAAI,8BAAJ;AAJd,MAMGH,KAAK,CAACO,GAAN,CAAaC,IAAF,IAAY;AACxB,WACC,4BAAC,kCAAD;AACC,MAAA,GAAG,EAAGA,IAAI,CAACC,EADZ;AAEC,MAAA,SAAS,EAAGN,SAFb;AAGC,MAAA,OAAO,EAAG,MAAM;AACf;AACA;AACA;AACA,YAAK,0BAAcK,IAAI,CAACE,IAAnB,CAAL,EAAiC;AAChCR,UAAAA,QAAQ,CAAEM,IAAF,CAAR;AACA,SAFD,MAEO;AACNJ,UAAAA,gBAAgB,CAAEI,IAAF,CAAhB,CAAyBG,IAAzB,CAAiCC,OAAF,IAAe;AAC7C,gBAAKA,OAAL,EAAe;AACdV,cAAAA,QAAQ,CAAEM,IAAF,CAAR;AACA;AACD,WAJD;AAKA;;AACDP,QAAAA,OAAO,CAAE,IAAF,CAAP;AACA,OAjBF;AAkBC,MAAA,OAAO,EAAGA,OAlBX;AAmBC,MAAA,IAAI,EAAGO;AAnBR,MADD;AAuBA,GAxBC,CANH,CADD;AAkCA;;eAEcT,sB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n} from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockListItem from '../downloadable-block-list-item';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst noop = () => {};\n\nfunction DownloadableBlocksList( { items, onHover = noop, onSelect } ) {\n\tconst composite = useCompositeState();\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Composite\n\t\t\t{ ...composite }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-directory-downloadable-blocks-list\"\n\t\t\taria-label={ __( 'Blocks available for install' ) }\n\t\t>\n\t\t\t{ items.map( ( item ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlockListItem\n\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Check if the block is registered (`getBlockType`\n\t\t\t\t\t\t\t// will return an object). If so, insert the block.\n\t\t\t\t\t\t\t// This prevents installing existing plugins.\n\t\t\t\t\t\t\tif ( getBlockType( item.name ) ) {\n\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tinstallBlockType( item ).then( ( success ) => {\n\t\t\t\t\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Composite>\n\t);\n}\n\nexport default DownloadableBlocksList;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/index.js"],"names":["DownloadableBlocksPanel","downloadableItems","onSelect","onHover","hasLocalBlocks","hasPermission","isLoading","isTyping","length","select","filterValue","rootClientId","getDownloadableBlocks","isRequestingDownloadableBlocks","blockDirectoryStore","canInsertBlockType","blockEditorStore","coreStore","canUser","getInstallableBlocks","term","filter","block"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAQA;AACA;AACA;AAMA,SAASA,uBAAT,OAQI;AAAA,MAR8B;AACjCC,IAAAA,iBADiC;AAEjCC,IAAAA,QAFiC;AAGjCC,IAAAA,OAHiC;AAIjCC,IAAAA,cAJiC;AAKjCC,IAAAA,aALiC;AAMjCC,IAAAA,SANiC;AAOjCC,IAAAA;AAPiC,GAQ9B;;AACH,MAAK,OAAOF,aAAP,KAAyB,WAAzB,IAAwCC,SAAxC,IAAqDC,QAA1D,EAAqE;AACpE,WACC,qDACGF,aAAa,IAAI,CAAED,cAAnB,IACD,qDACC;AAAG,MAAA,SAAS,EAAC;AAAb,OACG,cACD,kDADC,CADH,CADD,EAMC;AAAK,MAAA,SAAS,EAAC;AAAf,MAND,CAFF,EAWC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,4BAAC,mBAAD,OADD,CAXD,CADD;AAiBA;;AAED,MAAK,UAAUC,aAAf,EAA+B;AAC9B,Q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/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Spinner } from '@wordpress/components';\nimport { compose } from '@wordpress/compose';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { withSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlocksList from '../downloadable-blocks-list';\nimport DownloadableBlocksInserterPanel from './inserter-panel';\nimport DownloadableBlocksNoResults from './no-results';\nimport { store as blockDirectoryStore } from '../../store';\n\nfunction DownloadableBlocksPanel( {\n\tdownloadableItems,\n\tonSelect,\n\tonHover,\n\thasLocalBlocks,\n\thasPermission,\n\tisLoading,\n\tisTyping,\n} ) {\n\tif ( typeof hasPermission === 'undefined' || isLoading || isTyping ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasPermission && ! hasLocalBlocks && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'No results available from your installed blocks.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel has-blocks-loading\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif ( false === hasPermission ) {\n\t\tif ( ! hasLocalBlocks ) {\n\t\t\treturn <DownloadableBlocksNoResults />;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\treturn !! downloadableItems.length ? (\n\t\t<DownloadableBlocksInserterPanel\n\t\t\tdownloadableItems={ downloadableItems }\n\t\t\thasLocalBlocks={ hasLocalBlocks }\n\t\t>\n\t\t\t<DownloadableBlocksList\n\t\t\t\titems={ downloadableItems }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tonHover={ onHover }\n\t\t\t/>\n\t\t</DownloadableBlocksInserterPanel>\n\t) : (\n\t\t! hasLocalBlocks && <DownloadableBlocksNoResults />\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select, { filterValue, rootClientId = null } ) => {\n\t\tconst {\n\t\t\tgetDownloadableBlocks,\n\t\t\tisRequestingDownloadableBlocks,\n\t\t} = select( blockDirectoryStore );\n\t\tconst { canInsertBlockType } = select( blockEditorStore );\n\n\t\tconst hasPermission = select( coreStore ).canUser(\n\t\t\t'read',\n\t\t\t'block-directory/search'\n\t\t);\n\n\t\tfunction getInstallableBlocks( term ) {\n\t\t\treturn getDownloadableBlocks( term ).filter( ( block ) =>\n\t\t\t\tcanInsertBlockType( block, rootClientId, true )\n\t\t\t);\n\t\t}\n\n\t\tconst downloadableItems = hasPermission\n\t\t\t? getInstallableBlocks( filterValue )\n\t\t\t: [];\n\t\tconst isLoading = isRequestingDownloadableBlocks( filterValue );\n\n\t\treturn {\n\t\t\tdownloadableItems,\n\t\t\thasPermission,\n\t\t\tisLoading,\n\t\t};\n\t} ),\n] )( DownloadableBlocksPanel );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/index.js"],"names":["DownloadableBlocksPanel","downloadableItems","onSelect","onHover","hasLocalBlocks","hasPermission","isLoading","isTyping","length","select","filterValue","rootClientId","getDownloadableBlocks","isRequestingDownloadableBlocks","blockDirectoryStore","canInsertBlockType","blockEditorStore","coreStore","canUser","getInstallableBlocks","term","filter","block"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAQA;AACA;AACA;AAMA,SAASA,uBAAT,OAQI;AAAA,MAR8B;AACjCC,IAAAA,iBADiC;AAEjCC,IAAAA,QAFiC;AAGjCC,IAAAA,OAHiC;AAIjCC,IAAAA,cAJiC;AAKjCC,IAAAA,aALiC;AAMjCC,IAAAA,SANiC;AAOjCC,IAAA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,CAA8BC,MAA9B,CAAwCC,KAAF,IAC5CP,kBAAkB,CAAEO,KAAF,EAASX,YAAT,EAAuB,IAAvB,CADZ,CAAP;AAGA;;AAED,QAAMV,iBAAiB,GAAGI,aAAa,GACpCc,oBAAoB,CAAET,WAAF,CADgB,GAEpC,EAFH;AAGA,QAAMJ,SAAS,GAAGO,8BAA8B,CAAEH,WAAF,CAAhD;AAEA,SAAO;AACNT,IAAAA,iBADM;AAENI,IAAAA,aAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA,CA1BD,CADuB,CAAT,EA4BVN,uBA5BU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Spinner } from '@wordpress/components';\nimport { compose } from '@wordpress/compose';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { withSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlocksList from '../downloadable-blocks-list';\nimport DownloadableBlocksInserterPanel from './inserter-panel';\nimport DownloadableBlocksNoResults from './no-results';\nimport { store as blockDirectoryStore } from '../../store';\n\nfunction DownloadableBlocksPanel( {\n\tdownloadableItems,\n\tonSelect,\n\tonHover,\n\thasLocalBlocks,\n\thasPermission,\n\tisLoading,\n\tisTyping,\n} ) {\n\tif ( typeof hasPermission === 'undefined' || isLoading || isTyping ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasPermission && ! hasLocalBlocks && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'No results available from your installed blocks.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel has-blocks-loading\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif ( false === hasPermission ) {\n\t\tif ( ! hasLocalBlocks ) {\n\t\t\treturn <DownloadableBlocksNoResults />;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\treturn !! downloadableItems.length ? (\n\t\t<DownloadableBlocksInserterPanel\n\t\t\tdownloadableItems={ downloadableItems }\n\t\t\thasLocalBlocks={ hasLocalBlocks }\n\t\t>\n\t\t\t<DownloadableBlocksList\n\t\t\t\titems={ downloadableItems }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tonHover={ onHover }\n\t\t\t/>\n\t\t</DownloadableBlocksInserterPanel>\n\t) : (\n\t\t! hasLocalBlocks && <DownloadableBlocksNoResults />\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select, { filterValue, rootClientId = null } ) => {\n\t\tconst { getDownloadableBlocks, isRequestingDownloadableBlocks } =\n\t\t\tselect( blockDirectoryStore );\n\t\tconst { canInsertBlockType } = select( blockEditorStore );\n\n\t\tconst hasPermission = select( coreStore ).canUser(\n\t\t\t'read',\n\t\t\t'block-directory/search'\n\t\t);\n\n\t\tfunction getInstallableBlocks( term ) {\n\t\t\treturn getDownloadableBlocks( term ).filter( ( block ) =>\n\t\t\t\tcanInsertBlockType( block, rootClientId, true )\n\t\t\t);\n\t\t}\n\n\t\tconst downloadableItems = hasPermission\n\t\t\t? getInstallableBlocks( filterValue )\n\t\t\t: [];\n\t\tconst isLoading = isRequestingDownloadableBlocks( filterValue );\n\n\t\treturn {\n\t\t\tdownloadableItems,\n\t\t\thasPermission,\n\t\t\tisLoading,\n\t\t};\n\t} ),\n] )( DownloadableBlocksPanel );\n"]}
@@ -11,16 +11,22 @@ var _i18n = require("@wordpress/i18n");
11
11
 
12
12
  var _icons = require("@wordpress/icons");
13
13
 
14
+ var _components = require("@wordpress/components");
15
+
14
16
  /**
15
17
  * WordPress dependencies
16
18
  */
17
19
  function DownloadableBlocksNoResults() {
18
- return (0, _element.createElement)("div", {
20
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("div", {
19
21
  className: "block-editor-inserter__no-results"
20
22
  }, (0, _element.createElement)(_icons.Icon, {
21
23
  className: "block-editor-inserter__no-results-icon",
22
24
  icon: _icons.blockDefault
23
- }), (0, _element.createElement)("p", null, (0, _i18n.__)('No results found.')));
25
+ }), (0, _element.createElement)("p", null, (0, _i18n.__)('No results found.'))), (0, _element.createElement)("div", {
26
+ className: "block-editor-inserter__tips"
27
+ }, (0, _element.createElement)(_components.Tip, null, (0, _element.createElement)("div", null, (0, _element.createElement)("p", null, (0, _i18n.__)('Interested in creating your own block?')), (0, _element.createElement)(_components.ExternalLink, {
28
+ href: "https://developer.wordpress.org/block-editor/"
29
+ }, (0, _i18n.__)('Get started here'), ".")))));
24
30
  }
25
31
 
26
32
  var _default = DownloadableBlocksNoResults;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/no-results.js"],"names":["DownloadableBlocksNoResults","blockDefault"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,SAASA,2BAAT,GAAuC;AACtC,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,WAAD;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,IAAI,EAAGC;AAFR,IADD,EAKC,uCAAK,cAAI,mBAAJ,CAAL,CALD,CADD;AASA;;eAEcD,2B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon, blockDefault } from '@wordpress/icons';\n\nfunction DownloadableBlocksNoResults() {\n\treturn (\n\t\t<div className=\"block-editor-inserter__no-results\">\n\t\t\t<Icon\n\t\t\t\tclassName=\"block-editor-inserter__no-results-icon\"\n\t\t\t\ticon={ blockDefault }\n\t\t\t/>\n\t\t\t<p>{ __( 'No results found.' ) }</p>\n\t\t</div>\n\t);\n}\n\nexport default DownloadableBlocksNoResults;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/no-results.js"],"names":["DownloadableBlocksNoResults","blockDefault"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKA,SAASA,2BAAT,GAAuC;AACtC,SACC,qDACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,WAAD;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,IAAI,EAAGC;AAFR,IADD,EAKC,uCAAK,cAAI,mBAAJ,CAAL,CALD,CADD,EAQC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,eAAD,QACC,yCACC,uCACG,cAAI,wCAAJ,CADH,CADD,EAIC,4BAAC,wBAAD;AAAc,IAAA,IAAI,EAAC;AAAnB,KACG,cAAI,kBAAJ,CADH,MAJD,CADD,CADD,CARD,CADD;AAuBA;;eAEcD,2B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon, blockDefault } from '@wordpress/icons';\nimport { Tip, ExternalLink } from '@wordpress/components';\n\nfunction DownloadableBlocksNoResults() {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"block-editor-inserter__no-results\">\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"block-editor-inserter__no-results-icon\"\n\t\t\t\t\ticon={ blockDefault }\n\t\t\t\t/>\n\t\t\t\t<p>{ __( 'No results found.' ) }</p>\n\t\t\t</div>\n\t\t\t<div className=\"block-editor-inserter__tips\">\n\t\t\t\t<Tip>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __( 'Interested in creating your own block?' ) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<ExternalLink href=\"https://developer.wordpress.org/block-editor/\">\n\t\t\t\t\t\t\t{ __( 'Get started here' ) }.\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t</div>\n\t\t\t\t</Tip>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default DownloadableBlocksNoResults;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/actions.js"],"names":["fetchDownloadableBlocks","filterValue","type","receiveDownloadableBlocks","downloadableBlocks","installBlockType","block","registry","dispatch","id","name","success","clearErrorNotice","setIsInstalling","url","links","method","data","status","response","path","slug","_links","addInstalledBlockType","metadataFields","_fields","catch","then","registeredBlocks","select","blocksStore","getBlockTypes","some","i","Error","noticesStore","createInfoNotice","title","speak","error","message","isFatal","fatalAPIErrors","folder_exists","unable_to_connect_to_filesystem","code","setErrorNotice","createErrorNotice","isDismissible","uninstallBlockType","removeInstalledBlockType","item","blockId","isInstalling"],"mappings":";;;;;;;;;;;;;;;;;AAGA;;AAKA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,uBAAT,CAAkCC,WAAlC,EAAgD;AACtD,SAAO;AAAEC,IAAAA,IAAI,EAAE,2BAAR;AAAqCD,IAAAA;AAArC,GAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,yBAAT,CAAoCC,kBAApC,EAAwDH,WAAxD,EAAsE;AAC5E,SAAO;AACNC,IAAAA,IAAI,EAAE,6BADA;AAENE,IAAAA,kBAFM;AAGNH,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMI,gBAAgB,GAAKC,KAAF,IAAa,cAGtC;AAAA,MAH8C;AACpDC,IAAAA,QADoD;AAEpDC,IAAAA;AAFoD,GAG9C;AACN,QAAM;AAAEC,IAAAA,EAAF;AAAMC,IAAAA;AAAN,MAAeJ,KAArB;AACA,MAAIK,OAAO,GAAG,KAAd;AACAH,EAAAA,QAAQ,CAACI,gBAAT,CAA2BH,EAA3B;;AACA,MAAI;AACHD,IAAAA,QAAQ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AIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAAStC,eAAT,CAA0BuC,OAA1B,EAAmCC,YAAnC,EAAkD;AACxD,SAAO;AACNnD,IAAAA,IAAI,EAAE,sBADA;AAENkD,IAAAA,OAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASP,cAAT,CAAyBM,OAAzB,EAAkCZ,OAAlC,EAA6D;AAAA,MAAlBC,OAAkB,uEAAR,KAAQ;AACnE,SAAO;AACNvC,IAAAA,IAAI,EAAE,kBADA;AAENkD,IAAAA,OAFM;AAGNZ,IAAAA,OAHM;AAINC,IAAAA;AAJM,GAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAAS7B,gBAAT,CAA2BwC,OAA3B,EAAqC;AAC3C,SAAO;AACNlD,IAAAA,IAAI,EAAE,oBADA;AAENkD,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport { pick } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType = ( block ) => async ( {\n\tregistry,\n\tdispatch,\n} ) => {\n\tconst { id, name } = block;\n\tlet success = false;\n\tdispatch.clearErrorNotice( id );\n\ttry {\n\t\tdispatch.setIsInstalling( id, true );\n\n\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\tconst url = getPluginUrl( block );\n\t\tlet links = {};\n\t\tif ( url ) {\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'active' },\n\t\t\t} );\n\t\t} else {\n\t\t\tconst response = await apiFetch( {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t} );\n\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\tlinks = response._links;\n\t\t}\n\n\t\tdispatch.addInstalledBlockType( {\n\t\t\t...block,\n\t\t\tlinks: { ...block.links, ...links },\n\t\t} );\n\n\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\tconst metadataFields = [\n\t\t\t'api_version',\n\t\t\t'title',\n\t\t\t'category',\n\t\t\t'parent',\n\t\t\t'icon',\n\t\t\t'description',\n\t\t\t'keywords',\n\t\t\t'attributes',\n\t\t\t'provides_context',\n\t\t\t'uses_context',\n\t\t\t'supports',\n\t\t\t'styles',\n\t\t\t'example',\n\t\t\t'variations',\n\t\t];\n\t\tawait apiFetch( {\n\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t_fields: metadataFields,\n\t\t\t} ),\n\t\t} )\n\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t.catch( () => {} )\n\t\t\t.then( ( response ) => {\n\t\t\t\tif ( ! response ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t[ name ]: pick( response, metadataFields ),\n\t\t\t\t} );\n\t\t\t} );\n\n\t\tawait loadAssets();\n\t\tconst registeredBlocks = registry.select( blocksStore ).getBlockTypes();\n\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\tthrow new Error(\n\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t);\n\t\t}\n\n\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\tsprintf(\n\t\t\t\t// translators: %s is the block title.\n\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\tblock.title\n\t\t\t),\n\t\t\t{\n\t\t\t\tspeak: true,\n\t\t\t\ttype: 'snackbar',\n\t\t\t}\n\t\t);\n\t\tsuccess = true;\n\t} catch ( error ) {\n\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t// Errors we throw are fatal.\n\t\tlet isFatal = error instanceof Error;\n\n\t\t// Specific API errors that are fatal.\n\t\tconst fatalAPIErrors = {\n\t\t\tfolder_exists: __(\n\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t),\n\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t),\n\t\t};\n\n\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\tisFatal = true;\n\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t}\n\n\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\tspeak: true,\n\t\t\tisDismissible: true,\n\t\t} );\n\t}\n\tdispatch.setIsInstalling( id, false );\n\treturn success;\n};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType = ( block ) => async ( {\n\tregistry,\n\tdispatch,\n} ) => {\n\ttry {\n\t\tconst url = getPluginUrl( block );\n\t\tawait apiFetch( {\n\t\t\tmethod: 'PUT',\n\t\t\turl,\n\t\t\tdata: { status: 'inactive' },\n\t\t} );\n\t\tawait apiFetch( {\n\t\t\tmethod: 'DELETE',\n\t\t\turl,\n\t\t} );\n\t\tdispatch.removeInstalledBlockType( block );\n\t} catch ( error ) {\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createErrorNotice( error.message || __( 'An error occurred.' ) );\n\t}\n};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/store/actions.js"],"names":["fetchDownloadableBlocks","filterValue","type","receiveDownloadableBlocks","downloadableBlocks","installBlockType","block","registry","dispatch","id","name","success","clearErrorNotice","setIsInstalling","url","links","method","data","status","response","path","slug","_links","addInstalledBlockType","metadataFields","_fields","catch","then","registeredBlocks","select","blocksStore","getBlockTypes","some","i","Error","noticesStore","createInfoNotice","title","speak","error","message","isFatal","fatalAPIErrors","folder_exists","unable_to_connect_to_filesystem","code","setErrorNotice","createErrorNotice","isDismissible","uninstallBlockType","removeInstalledBlockType","item","blockId","isInstalling"],"mappings":";;;;;;;;;;;;;;;;;AAGA;;AAKA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,uBAAT,CAAkCC,WAAlC,EAAgD;AACtD,SAAO;AAAEC,IAAAA,IAAI,EAAE,2BAAR;AAAqCD,IAAAA;AAArC,GAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,yBAAT,CAAoCC,kBAApC,EAAwDH,WAAxD,EAAsE;AAC5E,SAAO;AACNC,IAAAA,IAAI,EAAE,6BADA;AAENE,IAAAA,kBAFM;AAGNH,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMI,gBAAgB,GAC1BC,KAAF,IACA,cAAoC;AAAA,MAA5B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;AACnC,QAAM;AAAEC,IAAAA,EAAF;AAAMC,IAAA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;AACA;AACA;AACA;;;AACO,SAASD,wBAAT,CAAmCC,IAAnC,EAA0C;AAChD,SAAO;AACNjD,IAAAA,IAAI,EAAE,6BADA;AAENiD,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAAStC,eAAT,CAA0BuC,OAA1B,EAAmCC,YAAnC,EAAkD;AACxD,SAAO;AACNnD,IAAAA,IAAI,EAAE,sBADA;AAENkD,IAAAA,OAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASP,cAAT,CAAyBM,OAAzB,EAAkCZ,OAAlC,EAA6D;AAAA,MAAlBC,OAAkB,uEAAR,KAAQ;AACnE,SAAO;AACNvC,IAAAA,IAAI,EAAE,kBADA;AAENkD,IAAAA,OAFM;AAGNZ,IAAAA,OAHM;AAINC,IAAAA;AAJM,GAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAAS7B,gBAAT,CAA2BwC,OAA3B,EAAqC;AAC3C,SAAO;AACNlD,IAAAA,IAAI,EAAE,oBADA;AAENkD,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport { pick } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst { id, name } = block;\n\t\tlet success = false;\n\t\tdispatch.clearErrorNotice( id );\n\t\ttry {\n\t\t\tdispatch.setIsInstalling( id, true );\n\n\t\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tlet links = {};\n\t\t\tif ( url ) {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl,\n\t\t\t\t\tdata: { status: 'active' },\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t\t} );\n\t\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\t\tlinks = response._links;\n\t\t\t}\n\n\t\t\tdispatch.addInstalledBlockType( {\n\t\t\t\t...block,\n\t\t\t\tlinks: { ...block.links, ...links },\n\t\t\t} );\n\n\t\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\t\tconst metadataFields = [\n\t\t\t\t'api_version',\n\t\t\t\t'title',\n\t\t\t\t'category',\n\t\t\t\t'parent',\n\t\t\t\t'icon',\n\t\t\t\t'description',\n\t\t\t\t'keywords',\n\t\t\t\t'attributes',\n\t\t\t\t'provides_context',\n\t\t\t\t'uses_context',\n\t\t\t\t'supports',\n\t\t\t\t'styles',\n\t\t\t\t'example',\n\t\t\t\t'variations',\n\t\t\t];\n\t\t\tawait apiFetch( {\n\t\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t\t_fields: metadataFields,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t\t.catch( () => {} )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( ! response ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t\t[ name ]: pick( response, metadataFields ),\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\tawait loadAssets();\n\t\t\tconst registeredBlocks = registry\n\t\t\t\t.select( blocksStore )\n\t\t\t\t.getBlockTypes();\n\t\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s is the block title.\n\t\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\t\tblock.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\tspeak: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tsuccess = true;\n\t\t} catch ( error ) {\n\t\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t\t// Errors we throw are fatal.\n\t\t\tlet isFatal = error instanceof Error;\n\n\t\t\t// Specific API errors that are fatal.\n\t\t\tconst fatalAPIErrors = {\n\t\t\t\tfolder_exists: __(\n\t\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t\t),\n\t\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\t\tisFatal = true;\n\t\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t\t}\n\n\t\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\t\tspeak: true,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}\n\t\tdispatch.setIsInstalling( id, false );\n\t\treturn success;\n\t};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\ttry {\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'inactive' },\n\t\t\t} );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl,\n\t\t\t} );\n\t\t\tdispatch.removeInstalledBlockType( block );\n\t\t} catch ( error ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\terror.message || __( 'An error occurred.' )\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/resolvers.js"],"names":["getDownloadableBlocks","filterValue","dispatch","results","path","blocks","map","result","value","key"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAGO,MAAMA,qBAAqB,GAAKC,WAAF,IAAmB,cAEjD;AAAA,MAFyD;AAC/DC,IAAAA;AAD+D,GAEzD;;AACN,MAAK,CAAED,WAAP,EAAqB;AACpB;AACA;;AAED,MAAI;AACHC,IAAAA,QAAQ,CAAE,sCAAyBD,WAAzB,CAAF,CAAR;AACA,UAAME,OAAO,GAAG,MAAM,uBAAU;AAC/BC,MAAAA,IAAI,EAAG,qCAAqCH,WAAa;AAD1B,KAAV,CAAtB;AAGA,UAAMI,MAAM,GAAGF,OAAO,CAACG,GAAR,CAAeC,MAAF,IAC3B,qBAASA,MAAT,EAAiB,CAAEC,KAAF,EAASC,GAAT,KAAkB,uBAAWA,GAAX,CAAnC,CADc,CAAf;AAIAP,IAAAA,QAAQ,CAAE,wCAA2BG,MAA3B,EAAmCJ,WAAnC,CAAF,CAAR;AACA,GAVD,CAUE,MAAM,CAAE;AACV,CAlBM","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase, mapKeys } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks = ( filterValue ) => async ( {\n\tdispatch,\n} ) => {\n\tif ( ! filterValue ) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\tconst results = await apiFetch( {\n\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t} );\n\t\tconst blocks = results.map( ( result ) =>\n\t\t\tmapKeys( result, ( value, key ) => camelCase( key ) )\n\t\t);\n\n\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t} catch {}\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/store/resolvers.js"],"names":["getDownloadableBlocks","filterValue","dispatch","results","path","blocks","map","result","value","key"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAGO,MAAMA,qBAAqB,GAC/BC,WAAF,IACA,cAA0B;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;;AACzB,MAAK,CAAED,WAAP,EAAqB;AACpB;AACA;;AAED,MAAI;AACHC,IAAAA,QAAQ,CAAE,sCAAyBD,WAAzB,CAAF,CAAR;AACA,UAAME,OAAO,GAAG,MAAM,uBAAU;AAC/BC,MAAAA,IAAI,EAAG,qCAAqCH,WAAa;AAD1B,KAAV,CAAtB;AAGA,UAAMI,MAAM,GAAGF,OAAO,CAACG,GAAR,CAAeC,MAAF,IAC3B,qBAASA,MAAT,EAAiB,CAAEC,KAAF,EAASC,GAAT,KAAkB,uBAAWA,GAAX,CAAnC,CADc,CAAf;AAIAP,IAAAA,QAAQ,CAAE,wCAA2BG,MAA3B,EAAmCJ,WAAnC,CAAF,CAAR;AACA,GAVD,CAUE,MAAM,CAAE;AACV,CAlBK","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase, mapKeys } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tmapKeys( result, ( value, key ) => camelCase( key ) )\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {}\n\t};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"names":["__","_n","sprintf","Button","Spinner","VisuallyHidden","__unstableCompositeItem","CompositeItem","createInterpolateElement","decodeEntities","getBlockType","useSelect","BlockRatings","DownloadableBlockIcon","DownloadableBlockNotice","store","blockDirectoryStore","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","DownloadableBlockListItem","composite","item","onClick","author","description","icon","name","isInstallable","select","getErrorNoticeForBlock","isBlockInstalling","notice","id","hasFatal","isFatal","statusText","event","preventDefault","span"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,EAAb,EAAiBC,OA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lB,CADD,EAMGG,aAAa,IACd,EAAIb,WAAW,IAAIC,YAAnB,CADC,IAEA,cAAC,cAAD,QACGvB,EAAE,CAAE,eAAF,CADL,CARH,CAnBF,CA9BD,CADD;AAmEA;;AAED,eAAe2B,yBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tSpinner,\n\tVisuallyHidden,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { composite, item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetErrorNoticeForBlock,\n\t\t\t\tisInstalling: isBlockInstalling,\n\t\t\t} = select( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\treturn (\n\t\t<CompositeItem\n\t\t\t__experimentalIsFocusable\n\t\t\trole=\"option\"\n\t\t\tas={ Button }\n\t\t\t{ ...composite }\n\t\t\tclassName=\"block-directory-downloadable-block-list-item\"\n\t\t\tonClick={ ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t\tisBusy={ isInstalling }\n\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\tlabel={ getDownloadableBlockLabel( item, {\n\t\t\t\thasNotice,\n\t\t\t\tisInstalled,\n\t\t\t\tisInstalling,\n\t\t\t} ) }\n\t\t\tshowTooltip={ true }\n\t\t\ttooltipPosition=\"top center\"\n\t\t>\n\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</CompositeItem>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"names":["__","_n","sprintf","Button","Spinner","VisuallyHidden","__unstableCompositeItem","CompositeItem","createInterpolateElement","decodeEntities","getBlockType","useSelect","BlockRatings","DownloadableBlockIcon","DownloadableBlockNotice","store","blockDirectoryStore","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","DownloadableBlockListItem","composite","item","onClick","author","description","icon","name","isInstallable","select","getErrorNoticeForBlock","isBlockInstalling","notice","id","hasFatal","isFatal","statusText","event","preventDefault","span"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SACCC,MADD,EAECC,OAFD,EAGCC,cAHD,EAICC,uBAAuB,IAAIC,aAJ5B,QAKO,uBALP;AAMA,SAASC,wBAAT,QAAyC,oBAAzC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,YAAT,QAA6B,mBAA7B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,SAASC,KAAK,IAAIC,mBAAlB,QAA6C,aAA7C,C,CAEA;;AACA,SAASC,yBAAT,cAGE;AAAA,MAFD;AAAEC,IAAAA,KAAF;AAASC,IAAAA,MAAT;AAAiBC,IAAAA;AAAjB,GAEC;AAAA,MADD;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,WAAb;AAA0BC,IAAAA;AAA1B,GACC;AACD,QAAMC,KAAK,GAAGC,IAAI,CAACC,KAAL,CAAYP,MAAM,GAAG,GAArB,IAA6B,GAA3C;;AAEA,MAAK,CAAEG,WAAF,IAAiBD,SAAtB,EAAkC;AACjC;AACA,WAAOnB,OAAO,CAAE,sBAAF,EAA0BO,cAAc,CAAES,KAAF,CAAxC,CAAd;AACA;;AAED,MAAKI,WAAL,EAAmB;AAClB;AACA,WAAOpB,OAAO,C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BN,OAAO;AACN;AACAF,EAAAA,EAAE,CAAE,2BAAF,CAFI,EAGNS,cAAc,CAAES,KAAF,CAHR,EAINa,MAJM,CADkB,EAOzB;AACCe,IAAAA,IAAI,EACH;AAAM,MAAA,SAAS,EAAC;AAAhB;AAFF,GAPyB,CAD3B,CADD,EAgBGzB,SAAS,GACV,cAAC,uBAAD;AAAyB,IAAA,KAAK,EAAGQ;AAAjC,IADU,GAGV,8BACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACG,CAAC,CAAEc,UAAH,GACCA,UADD,GAEClC,cAAc,CAAEuB,WAAF,CAHlB,CADD,EAMGG,aAAa,IACd,EAAIb,WAAW,IAAIC,YAAnB,CADC,IAEA,cAAC,cAAD,QACGvB,EAAE,CAAE,eAAF,CADL,CARH,CAnBF,CA9BD,CADD;AAmEA;;AAED,eAAe2B,yBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tSpinner,\n\tVisuallyHidden,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { composite, item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\treturn (\n\t\t<CompositeItem\n\t\t\t__experimentalIsFocusable\n\t\t\trole=\"option\"\n\t\t\tas={ Button }\n\t\t\t{ ...composite }\n\t\t\tclassName=\"block-directory-downloadable-block-list-item\"\n\t\t\tonClick={ ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t\tisBusy={ isInstalling }\n\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\tlabel={ getDownloadableBlockLabel( item, {\n\t\t\t\thasNotice,\n\t\t\t\tisInstalled,\n\t\t\t\tisInstalling,\n\t\t\t} ) }\n\t\t\tshowTooltip={ true }\n\t\t\ttooltipPosition=\"top center\"\n\t\t>\n\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</CompositeItem>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"]}
@@ -1,14 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { createElement } from "@wordpress/element";
3
3
 
4
- /**
5
- * External dependencies
6
- */
7
- import { noop } from 'lodash';
8
4
  /**
9
5
  * WordPress dependencies
10
6
  */
11
-
12
7
  import { __ } from '@wordpress/i18n';
13
8
  import { __unstableComposite as Composite, __unstableUseCompositeState as useCompositeState } from '@wordpress/components';
14
9
  import { getBlockType } from '@wordpress/blocks';
@@ -20,6 +15,8 @@ import { useDispatch } from '@wordpress/data';
20
15
  import DownloadableBlockListItem from '../downloadable-block-list-item';
21
16
  import { store as blockDirectoryStore } from '../../store';
22
17
 
18
+ const noop = () => {};
19
+
23
20
  function DownloadableBlocksList(_ref) {
24
21
  let {
25
22
  items,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-blocks-list/index.js"],"names":["noop","__","__unstableComposite","Composite","__unstableUseCompositeState","useCompositeState","getBlockType","useDispatch","DownloadableBlockListItem","store","blockDirectoryStore","DownloadableBlocksList","items","onHover","onSelect","composite","installBlockType","length","map","item","id","name","then","success"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,mBAAmB,IAAIC,SADxB,EAECC,2BAA2B,IAAIC,iBAFhC,QAGO,uBAHP;AAIA,SAASC,YAAT,QAA6B,mBAA7B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;A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dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n} from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockListItem from '../downloadable-block-list-item';\nimport { store as blockDirectoryStore } from '../../store';\n\nfunction DownloadableBlocksList( { items, onHover = noop, onSelect } ) {\n\tconst composite = useCompositeState();\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Composite\n\t\t\t{ ...composite }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-directory-downloadable-blocks-list\"\n\t\t\taria-label={ __( 'Blocks available for install' ) }\n\t\t>\n\t\t\t{ items.map( ( item ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlockListItem\n\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Check if the block is registered (`getBlockType`\n\t\t\t\t\t\t\t// will return an object). If so, insert the block.\n\t\t\t\t\t\t\t// This prevents installing existing plugins.\n\t\t\t\t\t\t\tif ( getBlockType( item.name ) ) {\n\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tinstallBlockType( item ).then( ( success ) => {\n\t\t\t\t\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Composite>\n\t);\n}\n\nexport default DownloadableBlocksList;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-blocks-list/index.js"],"names":["__","__unstableComposite","Composite","__unstableUseCompositeState","useCompositeState","getBlockType","useDispatch","DownloadableBlockListItem","store","blockDirectoryStore","noop","DownloadableBlocksList","items","onHover","onSelect","composite","installBlockType","length","map","item","id","name","then","success"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,mBAAmB,IAAIC,SADxB,EAECC,2BAA2B,IAAIC,iBAFhC,QAGO,uBAHP;AAIA,SAASC,YAAT,QAA6B,mBAA7B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,SAASC,KAAK,IAAIC,mBAAlB,QAA6C,aAA7C;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,SAASC,sBAAT,OAAuE;AAAA,MAAtC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,OAAO,GAAGH,IAAnB;AAAyBI,IAAAA;AAAzB,GAAsC;AACtE,QAAMC,SAAS,GAAGX,iBAAiB,EAAnC;AACA,QAAM;AAAEY,IAAAA;AAAF,MAAuBV,WAAW,CAAEG,mBAAF,CAAxC;;AAEA,MAAK,CAAEG,KAAK,CAACK,MAAb,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC,cAAC,SAAD,eACMF,SADN;AAEC,IAAA,IAAI,EAAC,SAFN;AAGC,IAAA,SAAS,EAAC,0CAHX;AAIC,kBAAaf,EAAE,CAAE,8BAAF;AAJhB,MAMGY,KAAK,CAACM,GAAN,CAAaC,IAAF,IAAY;AACxB,WACC,cAAC,yBAAD;AACC,MAAA,GAAG,EAAGA,IAAI,CAACC,EADZ;AAEC,MAAA,SAAS,EAAGL,SAFb;AAGC,MAAA,OAAO,EAAG,MAAM;AACf;AACA;AACA;AACA,YAAKV,YAAY,CAAEc,IAAI,CAACE,IAAP,CAAjB,EAAiC;AAChCP,UAAAA,QAAQ,CAAEK,IAAF,CAAR;AACA,SAFD,MAEO;AACNH,UAAAA,gBAAgB,CAAEG,IAAF,CAAhB,CAAyBG,IAAzB,CAAiCC,OAAF,IAAe;AAC7C,gBAAKA,OAAL,EAAe;AACdT,cAAAA,QAAQ,CAAEK,IAAF,CAAR;AACA;AACD,WAJD;AAKA;;AACDN,QAAAA,OAAO,CAAE,IAAF,CAAP;AACA,OAjBF;AAkBC,MAAA,OAAO,EAAGA,OAlBX;AAmBC,MAAA,IAAI,EAAGM;AAnBR,MADD;AAuBA,GAxBC,CANH,CADD;AAkCA;;AAED,eAAeR,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n} from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockListItem from '../downloadable-block-list-item';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst noop = () => {};\n\nfunction DownloadableBlocksList( { items, onHover = noop, onSelect } ) {\n\tconst composite = useCompositeState();\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Composite\n\t\t\t{ ...composite }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-directory-downloadable-blocks-list\"\n\t\t\taria-label={ __( 'Blocks available for install' ) }\n\t\t>\n\t\t\t{ items.map( ( item ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlockListItem\n\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Check if the block is registered (`getBlockType`\n\t\t\t\t\t\t\t// will return an object). If so, insert the block.\n\t\t\t\t\t\t\t// This prevents installing existing plugins.\n\t\t\t\t\t\t\tif ( getBlockType( item.name ) ) {\n\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tinstallBlockType( item ).then( ( success ) => {\n\t\t\t\t\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Composite>\n\t);\n}\n\nexport default DownloadableBlocksList;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/index.js"],"names":["__","Spinner","compose","store","blockEditorStore","coreStore","withSelect","DownloadableBlocksList","DownloadableBlocksInserterPanel","DownloadableBlocksNoResults","blockDirectoryStore","DownloadableBlocksPanel","downloadableItems","onSelect","onHover","hasLocalBlocks","hasPermission","isLoading","isTyping","length","select","filterValue","rootClientId","getDownloadableBlocks","isRequestingDownloadableBlocks","canInsertBlockType","canUser","getInstallableBlocks","term","filter","block"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASC,UAAT,QAA2B,iBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,6BAAnC;AACA,OAAOC,+BAAP,MAA4C,kBAA5C;AACA,OAAOC,2BAAP,MAAwC,cAAxC;AACA,SAASN,KAAK,IAAIO,mBAAlB,QAA6C,aAA7C;;AAEA,SAASC,uBAAT,OAQI;AAA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,aAAa,GAAGI,MAAM,CAAEf,SAAF,CAAN,CAAoBqB,OAApB,CACrB,MADqB,EAErB,wBAFqB,CAAtB;;AAKA,WAASC,oBAAT,CAA+BC,IAA/B,EAAsC;AACrC,WAAOL,qBAAqB,CAAEK,IAAF,CAArB,CAA8BC,MAA9B,CAAwCC,KAAF,IAC5CL,kBAAkB,CAAEK,KAAF,EAASR,YAAT,EAAuB,IAAvB,CADZ,CAAP;AAGA;;AAED,QAAMV,iBAAiB,GAAGI,aAAa,GACpCW,oBAAoB,CAAEN,WAAF,CADgB,GAEpC,EAFH;AAGA,QAAMJ,SAAS,GAAGO,8BAA8B,CAAEH,WAAF,CAAhD;AAEA,SAAO;AACNT,IAAAA,iBADM;AAENI,IAAAA,aAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA,CA5BS,CADa,CAAF,CAAP,CA8BVN,uBA9BU,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Spinner } from '@wordpress/components';\nimport { compose } from '@wordpress/compose';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { withSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlocksList from '../downloadable-blocks-list';\nimport DownloadableBlocksInserterPanel from './inserter-panel';\nimport DownloadableBlocksNoResults from './no-results';\nimport { store as blockDirectoryStore } from '../../store';\n\nfunction DownloadableBlocksPanel( {\n\tdownloadableItems,\n\tonSelect,\n\tonHover,\n\thasLocalBlocks,\n\thasPermission,\n\tisLoading,\n\tisTyping,\n} ) {\n\tif ( typeof hasPermission === 'undefined' || isLoading || isTyping ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasPermission && ! hasLocalBlocks && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'No results available from your installed blocks.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel has-blocks-loading\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif ( false === hasPermission ) {\n\t\tif ( ! hasLocalBlocks ) {\n\t\t\treturn <DownloadableBlocksNoResults />;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\treturn !! downloadableItems.length ? (\n\t\t<DownloadableBlocksInserterPanel\n\t\t\tdownloadableItems={ downloadableItems }\n\t\t\thasLocalBlocks={ hasLocalBlocks }\n\t\t>\n\t\t\t<DownloadableBlocksList\n\t\t\t\titems={ downloadableItems }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tonHover={ onHover }\n\t\t\t/>\n\t\t</DownloadableBlocksInserterPanel>\n\t) : (\n\t\t! hasLocalBlocks && <DownloadableBlocksNoResults />\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select, { filterValue, rootClientId = null } ) => {\n\t\tconst {\n\t\t\tgetDownloadableBlocks,\n\t\t\tisRequestingDownloadableBlocks,\n\t\t} = select( blockDirectoryStore );\n\t\tconst { canInsertBlockType } = select( blockEditorStore );\n\n\t\tconst hasPermission = select( coreStore ).canUser(\n\t\t\t'read',\n\t\t\t'block-directory/search'\n\t\t);\n\n\t\tfunction getInstallableBlocks( term ) {\n\t\t\treturn getDownloadableBlocks( term ).filter( ( block ) =>\n\t\t\t\tcanInsertBlockType( block, rootClientId, true )\n\t\t\t);\n\t\t}\n\n\t\tconst downloadableItems = hasPermission\n\t\t\t? getInstallableBlocks( filterValue )\n\t\t\t: [];\n\t\tconst isLoading = isRequestingDownloadableBlocks( filterValue );\n\n\t\treturn {\n\t\t\tdownloadableItems,\n\t\t\thasPermission,\n\t\t\tisLoading,\n\t\t};\n\t} ),\n] )( DownloadableBlocksPanel );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/index.js"],"names":["__","Spinner","compose","store","blockEditorStore","coreStore","withSelect","DownloadableBlocksList","DownloadableBlocksInserterPanel","DownloadableBlocksNoResults","blockDirectoryStore","DownloadableBlocksPanel","downloadableItems","onSelect","onHover","hasLocalBlocks","hasPermission","isLoading","isTyping","length","select","filterValue","rootClientId","getDownloadableBlocks","isRequestingDownloadableBlocks","canInsertBlockType","canUser","getInstallableBlocks","term","filter","block"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASC,UAAT,QAA2B,iBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,6BAAnC;AACA,OAAOC,+BAAP,MAA4C,kBAA5C;AACA,OAAOC,2BAAP,MAAwC,cAAxC;AACA,SAASN,KAAK,IAAIO,mBAAlB,QAA6C,aAA7C;;AAEA,SAASC,uBAAT,OAQI;AAAA,MAR8B;AACjCC,IAAAA,iBADiC;AAEjCC,IAAAA,QAFiC;AAGjCC,IAAAA,OAHiC;AAIjCC,IAAAA,cAJiC;AAKjCC,IAAAA,aALiC;AAMjCC,IAAAA,SANiC;AAOjCC,IAAAA;AAPiC,GAQ9B;;AACH,MAAK,OAAOF,aAAP,KAAyB,WAAzB,IAAwCC,SAAxC,IAAqDC,QAA1D,EAAqE;AACpE,WACC,8BACGF,aAAa,IAAI,CAAED,cAAnB,IACD,8BACC;AAAG,MAAA,SAAS,EAAC;AAAb,OACGf,EAAE,CACH,kDADG,CADL,CADD,EAMC;AAAK,MAAA,SAAS,EAAC;AAAf,MAND,CAFF,EAWC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,cA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AAAA,aAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA,CA1BS,CADa,CAAF,CAAP,CA4BVN,uBA5BU,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Spinner } from '@wordpress/components';\nimport { compose } from '@wordpress/compose';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { withSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlocksList from '../downloadable-blocks-list';\nimport DownloadableBlocksInserterPanel from './inserter-panel';\nimport DownloadableBlocksNoResults from './no-results';\nimport { store as blockDirectoryStore } from '../../store';\n\nfunction DownloadableBlocksPanel( {\n\tdownloadableItems,\n\tonSelect,\n\tonHover,\n\thasLocalBlocks,\n\thasPermission,\n\tisLoading,\n\tisTyping,\n} ) {\n\tif ( typeof hasPermission === 'undefined' || isLoading || isTyping ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasPermission && ! hasLocalBlocks && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'No results available from your installed blocks.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel has-blocks-loading\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif ( false === hasPermission ) {\n\t\tif ( ! hasLocalBlocks ) {\n\t\t\treturn <DownloadableBlocksNoResults />;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\treturn !! downloadableItems.length ? (\n\t\t<DownloadableBlocksInserterPanel\n\t\t\tdownloadableItems={ downloadableItems }\n\t\t\thasLocalBlocks={ hasLocalBlocks }\n\t\t>\n\t\t\t<DownloadableBlocksList\n\t\t\t\titems={ downloadableItems }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tonHover={ onHover }\n\t\t\t/>\n\t\t</DownloadableBlocksInserterPanel>\n\t) : (\n\t\t! hasLocalBlocks && <DownloadableBlocksNoResults />\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select, { filterValue, rootClientId = null } ) => {\n\t\tconst { getDownloadableBlocks, isRequestingDownloadableBlocks } =\n\t\t\tselect( blockDirectoryStore );\n\t\tconst { canInsertBlockType } = select( blockEditorStore );\n\n\t\tconst hasPermission = select( coreStore ).canUser(\n\t\t\t'read',\n\t\t\t'block-directory/search'\n\t\t);\n\n\t\tfunction getInstallableBlocks( term ) {\n\t\t\treturn getDownloadableBlocks( term ).filter( ( block ) =>\n\t\t\t\tcanInsertBlockType( block, rootClientId, true )\n\t\t\t);\n\t\t}\n\n\t\tconst downloadableItems = hasPermission\n\t\t\t? getInstallableBlocks( filterValue )\n\t\t\t: [];\n\t\tconst isLoading = isRequestingDownloadableBlocks( filterValue );\n\n\t\treturn {\n\t\t\tdownloadableItems,\n\t\t\thasPermission,\n\t\t\tisLoading,\n\t\t};\n\t} ),\n] )( DownloadableBlocksPanel );\n"]}
@@ -1,18 +1,23 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement, Fragment } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
6
  import { __ } from '@wordpress/i18n';
7
7
  import { Icon, blockDefault } from '@wordpress/icons';
8
+ import { Tip, ExternalLink } from '@wordpress/components';
8
9
 
9
10
  function DownloadableBlocksNoResults() {
10
- return createElement("div", {
11
+ return createElement(Fragment, null, createElement("div", {
11
12
  className: "block-editor-inserter__no-results"
12
13
  }, createElement(Icon, {
13
14
  className: "block-editor-inserter__no-results-icon",
14
15
  icon: blockDefault
15
- }), createElement("p", null, __('No results found.')));
16
+ }), createElement("p", null, __('No results found.'))), createElement("div", {
17
+ className: "block-editor-inserter__tips"
18
+ }, createElement(Tip, null, createElement("div", null, createElement("p", null, __('Interested in creating your own block?')), createElement(ExternalLink, {
19
+ href: "https://developer.wordpress.org/block-editor/"
20
+ }, __('Get started here'), ".")))));
16
21
  }
17
22
 
18
23
  export default DownloadableBlocksNoResults;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/no-results.js"],"names":["__","Icon","blockDefault","DownloadableBlocksNoResults"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,EAAeC,YAAf,QAAmC,kBAAnC;;AAEA,SAASC,2BAAT,GAAuC;AACtC,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,IAAI,EAAGD;AAFR,IADD,EAKC,yBAAKF,EAAE,CAAE,mBAAF,CAAP,CALD,CADD;AASA;;AAED,eAAeG,2BAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon, blockDefault } from '@wordpress/icons';\n\nfunction DownloadableBlocksNoResults() {\n\treturn (\n\t\t<div className=\"block-editor-inserter__no-results\">\n\t\t\t<Icon\n\t\t\t\tclassName=\"block-editor-inserter__no-results-icon\"\n\t\t\t\ticon={ blockDefault }\n\t\t\t/>\n\t\t\t<p>{ __( 'No results found.' ) }</p>\n\t\t</div>\n\t);\n}\n\nexport default DownloadableBlocksNoResults;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/no-results.js"],"names":["__","Icon","blockDefault","Tip","ExternalLink","DownloadableBlocksNoResults"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,EAAeC,YAAf,QAAmC,kBAAnC;AACA,SAASC,GAAT,EAAcC,YAAd,QAAkC,uBAAlC;;AAEA,SAASC,2BAAT,GAAuC;AACtC,SACC,8BACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,IAAI,EAAGH;AAFR,IADD,EAKC,yBAAKF,EAAE,CAAE,mBAAF,CAAP,CALD,CADD,EAQC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,GAAD,QACC,2BACC,yBACGA,EAAE,CAAE,wCAAF,CADL,CADD,EAIC,cAAC,YAAD;AAAc,IAAA,IAAI,EAAC;AAAnB,KACGA,EAAE,CAAE,kBAAF,CADL,MAJD,CADD,CADD,CARD,CADD;AAuBA;;AAED,eAAeK,2BAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon, blockDefault } from '@wordpress/icons';\nimport { Tip, ExternalLink } from '@wordpress/components';\n\nfunction DownloadableBlocksNoResults() {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"block-editor-inserter__no-results\">\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"block-editor-inserter__no-results-icon\"\n\t\t\t\t\ticon={ blockDefault }\n\t\t\t\t/>\n\t\t\t\t<p>{ __( 'No results found.' ) }</p>\n\t\t\t</div>\n\t\t\t<div className=\"block-editor-inserter__tips\">\n\t\t\t\t<Tip>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __( 'Interested in creating your own block?' ) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<ExternalLink href=\"https://developer.wordpress.org/block-editor/\">\n\t\t\t\t\t\t\t{ __( 'Get started here' ) }.\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t</div>\n\t\t\t\t</Tip>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default DownloadableBlocksNoResults;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/actions.js"],"names":["pick","store","blocksStore","unstable__bootstrapServerSideBlockDefinitions","__","sprintf","apiFetch","noticesStore","addQueryArgs","loadAssets","getPluginUrl","fetchDownloadableBlocks","filterValue","type","receiveDownloadableBlocks","downloadableBlocks","installBlockType","block","registry","dispatch","id","name","success","clearErrorNotice","setIsInstalling","url","links","method","data","status","response","path","slug","_links","addInstalledBlockType","metadataFields","_fields","catch","then","registeredBlocks","select","getBlockTypes","some","i","Error","createInfoNotice","title","speak","error","message","isFatal","fatalAPIErrors","folder_exists","unable_to_connect_to_filesystem","code","setErrorNotice","createErrorNotice","isDismissible","uninstallBlockType","removeInstalledBlockType","item","blockId","isInstalling"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SACCC,KAAK,IAAIC,WADV,EAECC,6CAFD,CAEgD;AAFhD,OAGO,mBAHP;AAIA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,SAASL,KAAK,IAAIM,YAAlB,QAAsC,oBAAtC;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,OAAOC,YAAP,MAAyB,wBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,uBAAT,CAAkCC,WAAlC,EAAgD;AACtD,SAAO;AAAEC,IAAAA,IAAI,EAAE,2BAAR;AAAqCD,IAAAA;AAArC,GAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,yBAAT,CAAoCC,kBAApC,EAAwDH,WAAxD,EAAsE;AAC5E,SAAO;AACNC,IAAAA,IAAI,EAAE,6BADA;AAENE,IAAAA,kBAFM;AAGNH,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMI,gBAAgB,GAAKC,KAAF,IAAa,cAGtC;AAAA,MAH8C;AACpDC,IAAAA,QADoD;AAEp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CAACC,OAAN,IAAiB7C,EAAE,CAAE,oBAAF,CAFxC;AAGA;AACD,CArBM;AAuBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAAS8B,qBAAT,CAAgC0B,IAAhC,EAAuC;AAC7C,SAAO;AACN/C,IAAAA,IAAI,EAAE,0BADA;AAEN+C,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASD,wBAAT,CAAmCC,IAAnC,EAA0C;AAChD,SAAO;AACN/C,IAAAA,IAAI,EAAE,6BADA;AAEN+C,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASpC,eAAT,CAA0BqC,OAA1B,EAAmCC,YAAnC,EAAkD;AACxD,SAAO;AACNjD,IAAAA,IAAI,EAAE,sBADA;AAENgD,IAAAA,OAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASP,cAAT,CAAyBM,OAAzB,EAAkCZ,OAAlC,EAA6D;AAAA,MAAlBC,OAAkB,uEAAR,KAAQ;AACnE,SAAO;AACNrC,IAAAA,IAAI,EAAE,kBADA;AAENgD,IAAAA,OAFM;AAGNZ,IAAAA,OAHM;AAINC,IAAAA;AAJM,GAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAAS3B,gBAAT,CAA2BsC,OAA3B,EAAqC;AAC3C,SAAO;AACNhD,IAAAA,IAAI,EAAE,oBADA;AAENgD,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport { pick } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType = ( block ) => async ( {\n\tregistry,\n\tdispatch,\n} ) => {\n\tconst { id, name } = block;\n\tlet success = false;\n\tdispatch.clearErrorNotice( id );\n\ttry {\n\t\tdispatch.setIsInstalling( id, true );\n\n\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\tconst url = getPluginUrl( block );\n\t\tlet links = {};\n\t\tif ( url ) {\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'active' },\n\t\t\t} );\n\t\t} else {\n\t\t\tconst response = await apiFetch( {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t} );\n\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\tlinks = response._links;\n\t\t}\n\n\t\tdispatch.addInstalledBlockType( {\n\t\t\t...block,\n\t\t\tlinks: { ...block.links, ...links },\n\t\t} );\n\n\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\tconst metadataFields = [\n\t\t\t'api_version',\n\t\t\t'title',\n\t\t\t'category',\n\t\t\t'parent',\n\t\t\t'icon',\n\t\t\t'description',\n\t\t\t'keywords',\n\t\t\t'attributes',\n\t\t\t'provides_context',\n\t\t\t'uses_context',\n\t\t\t'supports',\n\t\t\t'styles',\n\t\t\t'example',\n\t\t\t'variations',\n\t\t];\n\t\tawait apiFetch( {\n\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t_fields: metadataFields,\n\t\t\t} ),\n\t\t} )\n\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t.catch( () => {} )\n\t\t\t.then( ( response ) => {\n\t\t\t\tif ( ! response ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t[ name ]: pick( response, metadataFields ),\n\t\t\t\t} );\n\t\t\t} );\n\n\t\tawait loadAssets();\n\t\tconst registeredBlocks = registry.select( blocksStore ).getBlockTypes();\n\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\tthrow new Error(\n\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t);\n\t\t}\n\n\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\tsprintf(\n\t\t\t\t// translators: %s is the block title.\n\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\tblock.title\n\t\t\t),\n\t\t\t{\n\t\t\t\tspeak: true,\n\t\t\t\ttype: 'snackbar',\n\t\t\t}\n\t\t);\n\t\tsuccess = true;\n\t} catch ( error ) {\n\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t// Errors we throw are fatal.\n\t\tlet isFatal = error instanceof Error;\n\n\t\t// Specific API errors that are fatal.\n\t\tconst fatalAPIErrors = {\n\t\t\tfolder_exists: __(\n\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t),\n\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t),\n\t\t};\n\n\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\tisFatal = true;\n\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t}\n\n\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\tspeak: true,\n\t\t\tisDismissible: true,\n\t\t} );\n\t}\n\tdispatch.setIsInstalling( id, false );\n\treturn success;\n};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType = ( block ) => async ( {\n\tregistry,\n\tdispatch,\n} ) => {\n\ttry {\n\t\tconst url = getPluginUrl( block );\n\t\tawait apiFetch( {\n\t\t\tmethod: 'PUT',\n\t\t\turl,\n\t\t\tdata: { status: 'inactive' },\n\t\t} );\n\t\tawait apiFetch( {\n\t\t\tmethod: 'DELETE',\n\t\t\turl,\n\t\t} );\n\t\tdispatch.removeInstalledBlockType( block );\n\t} catch ( error ) {\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createErrorNotice( error.message || __( 'An error occurred.' ) );\n\t}\n};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/store/actions.js"],"names":["pick","store","blocksStore","unstable__bootstrapServerSideBlockDefinitions","__","sprintf","apiFetch","noticesStore","addQueryArgs","loadAssets","getPluginUrl","fetchDownloadableBlocks","filterValue","type","receiveDownloadableBlocks","downloadableBlocks","installBlockType","block","registry","dispatch","id","name","success","clearErrorNotice","setIsInstalling","url","links","method","data","status","response","path","slug","_links","addInstalledBlockType","metadataFields","_fields","catch","then","registeredBlocks","select","getBlockTypes","some","i","Error","createInfoNotice","title","speak","error","message","isFatal","fatalAPIErrors","folder_exists","unable_to_connect_to_filesystem","code","setErrorNotice","createErrorNotice","isDismissible","uninstallBlockType","removeInstalledBlockType","item","blockId","isInstalling"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SACCC,KAAK,IAAIC,WADV,EAECC,6CAFD,CAEgD;AAFhD,OAGO,mBAHP;AAIA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,O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AENgD,IAAAA,OAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASP,cAAT,CAAyBM,OAAzB,EAAkCZ,OAAlC,EAA6D;AAAA,MAAlBC,OAAkB,uEAAR,KAAQ;AACnE,SAAO;AACNrC,IAAAA,IAAI,EAAE,kBADA;AAENgD,IAAAA,OAFM;AAGNZ,IAAAA,OAHM;AAINC,IAAAA;AAJM,GAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAAS3B,gBAAT,CAA2BsC,OAA3B,EAAqC;AAC3C,SAAO;AACNhD,IAAAA,IAAI,EAAE,oBADA;AAENgD,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport { pick } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst { id, name } = block;\n\t\tlet success = false;\n\t\tdispatch.clearErrorNotice( id );\n\t\ttry {\n\t\t\tdispatch.setIsInstalling( id, true );\n\n\t\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tlet links = {};\n\t\t\tif ( url ) {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl,\n\t\t\t\t\tdata: { status: 'active' },\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t\t} );\n\t\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\t\tlinks = response._links;\n\t\t\t}\n\n\t\t\tdispatch.addInstalledBlockType( {\n\t\t\t\t...block,\n\t\t\t\tlinks: { ...block.links, ...links },\n\t\t\t} );\n\n\t\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\t\tconst metadataFields = [\n\t\t\t\t'api_version',\n\t\t\t\t'title',\n\t\t\t\t'category',\n\t\t\t\t'parent',\n\t\t\t\t'icon',\n\t\t\t\t'description',\n\t\t\t\t'keywords',\n\t\t\t\t'attributes',\n\t\t\t\t'provides_context',\n\t\t\t\t'uses_context',\n\t\t\t\t'supports',\n\t\t\t\t'styles',\n\t\t\t\t'example',\n\t\t\t\t'variations',\n\t\t\t];\n\t\t\tawait apiFetch( {\n\t\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t\t_fields: metadataFields,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t\t.catch( () => {} )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( ! response ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t\t[ name ]: pick( response, metadataFields ),\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\tawait loadAssets();\n\t\t\tconst registeredBlocks = registry\n\t\t\t\t.select( blocksStore )\n\t\t\t\t.getBlockTypes();\n\t\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s is the block title.\n\t\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\t\tblock.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\tspeak: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tsuccess = true;\n\t\t} catch ( error ) {\n\t\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t\t// Errors we throw are fatal.\n\t\t\tlet isFatal = error instanceof Error;\n\n\t\t\t// Specific API errors that are fatal.\n\t\t\tconst fatalAPIErrors = {\n\t\t\t\tfolder_exists: __(\n\t\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t\t),\n\t\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\t\tisFatal = true;\n\t\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t\t}\n\n\t\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\t\tspeak: true,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}\n\t\tdispatch.setIsInstalling( id, false );\n\t\treturn success;\n\t};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\ttry {\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'inactive' },\n\t\t\t} );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl,\n\t\t\t} );\n\t\t\tdispatch.removeInstalledBlockType( block );\n\t\t} catch ( error ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\terror.message || __( 'An error occurred.' )\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/resolvers.js"],"names":["camelCase","mapKeys","apiFetch","fetchDownloadableBlocks","receiveDownloadableBlocks","getDownloadableBlocks","filterValue","dispatch","results","path","blocks","map","result","value","key"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,OAApB,QAAmC,QAAnC;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAEA;AACA;AACA;;AACA,SAASC,uBAAT,EAAkCC,yBAAlC,QAAmE,WAAnE;AAEA,OAAO,MAAMC,qBAAqB,GAAKC,WAAF,IAAmB,cAEjD;AAAA,MAFyD;AAC/DC,IAAAA;AAD+D,GAEzD;;AACN,MAAK,CAAED,WAAP,EAAqB;AACpB;AACA;;AAED,MAAI;AACHC,IAAAA,QAAQ,CAAEJ,uBAAuB,CAAEG,WAAF,CAAzB,CAAR;AACA,UAAME,OAAO,GAAG,MAAMN,QAAQ,CAAE;AAC/BO,MAAAA,IAAI,EAAG,qCAAqCH,WAAa;AAD1B,KAAF,CAA9B;AAGA,UAAMI,MAAM,GAAGF,OAAO,CAACG,GAAR,CAAeC,MAAF,IAC3BX,OAAO,CAAEW,MAAF,EAAU,CAAEC,KAAF,EAASC,GAAT,KAAkBd,SAAS,CAAEc,GAAF,CAArC,CADO,CAAf;AAIAP,IAAAA,QAAQ,CAAEH,yBAAyB,CAAEM,MAAF,EAAUJ,WAAV,CAA3B,CAAR;AACA,GAVD,CAUE,MAAM,CAAE;AACV,CAlBM","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase, mapKeys } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks = ( filterValue ) => async ( {\n\tdispatch,\n} ) => {\n\tif ( ! filterValue ) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\tconst results = await apiFetch( {\n\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t} );\n\t\tconst blocks = results.map( ( result ) =>\n\t\t\tmapKeys( result, ( value, key ) => camelCase( key ) )\n\t\t);\n\n\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t} catch {}\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/store/resolvers.js"],"names":["camelCase","mapKeys","apiFetch","fetchDownloadableBlocks","receiveDownloadableBlocks","getDownloadableBlocks","filterValue","dispatch","results","path","blocks","map","result","value","key"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,OAApB,QAAmC,QAAnC;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAEA;AACA;AACA;;AACA,SAASC,uBAAT,EAAkCC,yBAAlC,QAAmE,WAAnE;AAEA,OAAO,MAAMC,qBAAqB,GAC/BC,WAAF,IACA,cAA0B;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;;AACzB,MAAK,CAAED,WAAP,EAAqB;AACpB;AACA;;AAED,MAAI;AACHC,IAAAA,QAAQ,CAAEJ,uBAAuB,CAAEG,WAAF,CAAzB,CAAR;AACA,UAAME,OAAO,GAAG,MAAMN,QAAQ,CAAE;AAC/BO,MAAAA,IAAI,EAAG,qCAAqCH,WAAa;AAD1B,KAAF,CAA9B;AAGA,UAAMI,MAAM,GAAGF,OAAO,CAACG,GAAR,CAAeC,MAAF,IAC3BX,OAAO,CAAEW,MAAF,EAAU,CAAEC,KAAF,EAASC,GAAT,KAAkBd,SAAS,CAAEc,GAAF,CAArC,CADO,CAAf;AAIAP,IAAAA,QAAQ,CAAEH,yBAAyB,CAAEM,MAAF,EAAUJ,WAAV,CAA3B,CAAR;AACA,GAVD,CAUE,MAAM,CAAE;AACV,CAlBK","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase, mapKeys } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tmapKeys( result, ( value, key ) => camelCase( key ) )\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {}\n\t};\n"]}
@@ -153,7 +153,6 @@
153
153
  .block-directory-downloadable-block-list-item.is-busy .block-directory-downloadable-block-list-item__author {
154
154
  border: 0;
155
155
  clip: rect(1px, 1px, 1px, 1px);
156
- -webkit-clip-path: inset(50%);
157
156
  clip-path: inset(50%);
158
157
  height: 1px;
159
158
  margin: -1px;
@@ -153,7 +153,6 @@
153
153
  .block-directory-downloadable-block-list-item.is-busy .block-directory-downloadable-block-list-item__author {
154
154
  border: 0;
155
155
  clip: rect(1px, 1px, 1px, 1px);
156
- -webkit-clip-path: inset(50%);
157
156
  clip-path: inset(50%);
158
157
  height: 1px;
159
158
  margin: -1px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-directory",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "description": "Extend editor with block directory features to search, download and install blocks.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,24 +26,24 @@
26
26
  "react-native": "src/index",
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.16.0",
29
- "@wordpress/a11y": "^3.10.0",
30
- "@wordpress/api-fetch": "^6.7.0",
31
- "@wordpress/block-editor": "^9.2.0",
32
- "@wordpress/blocks": "^11.9.0",
33
- "@wordpress/components": "^19.12.0",
34
- "@wordpress/compose": "^5.8.0",
35
- "@wordpress/core-data": "^4.8.0",
36
- "@wordpress/data": "^6.10.0",
37
- "@wordpress/edit-post": "^6.7.0",
38
- "@wordpress/editor": "^12.9.0",
39
- "@wordpress/element": "^4.8.0",
40
- "@wordpress/hooks": "^3.10.0",
41
- "@wordpress/html-entities": "^3.10.0",
42
- "@wordpress/i18n": "^4.10.0",
43
- "@wordpress/icons": "^9.1.0",
44
- "@wordpress/notices": "^3.10.0",
45
- "@wordpress/plugins": "^4.8.0",
46
- "@wordpress/url": "^3.11.0",
29
+ "@wordpress/a11y": "^3.11.0",
30
+ "@wordpress/api-fetch": "^6.8.0",
31
+ "@wordpress/block-editor": "^9.3.0",
32
+ "@wordpress/blocks": "^11.10.0",
33
+ "@wordpress/components": "^19.13.0",
34
+ "@wordpress/compose": "^5.9.0",
35
+ "@wordpress/core-data": "^4.9.0",
36
+ "@wordpress/data": "^6.11.0",
37
+ "@wordpress/edit-post": "^6.8.0",
38
+ "@wordpress/editor": "^12.10.0",
39
+ "@wordpress/element": "^4.9.0",
40
+ "@wordpress/hooks": "^3.11.0",
41
+ "@wordpress/html-entities": "^3.11.0",
42
+ "@wordpress/i18n": "^4.11.0",
43
+ "@wordpress/icons": "^9.2.0",
44
+ "@wordpress/notices": "^3.11.0",
45
+ "@wordpress/plugins": "^4.9.0",
46
+ "@wordpress/url": "^3.12.0",
47
47
  "lodash": "^4.17.21"
48
48
  },
49
49
  "peerDependencies": {
@@ -53,5 +53,5 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "gitHead": "a3e0b62091e8a8bdf5e2518e42d60d7098af48cc"
56
+ "gitHead": "48d5f37dfb52d2e77c8eeb662f9874cf141b8c6b"
57
57
  }
@@ -69,10 +69,8 @@ function DownloadableBlockListItem( { composite, item, onClick } ) {
69
69
 
70
70
  const { hasNotice, isInstalling, isInstallable } = useSelect(
71
71
  ( select ) => {
72
- const {
73
- getErrorNoticeForBlock,
74
- isInstalling: isBlockInstalling,
75
- } = select( blockDirectoryStore );
72
+ const { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =
73
+ select( blockDirectoryStore );
76
74
  const notice = getErrorNoticeForBlock( item.id );
77
75
  const hasFatal = notice && notice.isFatal;
78
76
  return {
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { noop } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -20,6 +15,8 @@ import { useDispatch } from '@wordpress/data';
20
15
  import DownloadableBlockListItem from '../downloadable-block-list-item';
21
16
  import { store as blockDirectoryStore } from '../../store';
22
17
 
18
+ const noop = () => {};
19
+
23
20
  function DownloadableBlocksList( { items, onHover = noop, onSelect } ) {
24
21
  const composite = useCompositeState();
25
22
  const { installBlockType } = useDispatch( blockDirectoryStore );
@@ -71,10 +71,8 @@ function DownloadableBlocksPanel( {
71
71
 
72
72
  export default compose( [
73
73
  withSelect( ( select, { filterValue, rootClientId = null } ) => {
74
- const {
75
- getDownloadableBlocks,
76
- isRequestingDownloadableBlocks,
77
- } = select( blockDirectoryStore );
74
+ const { getDownloadableBlocks, isRequestingDownloadableBlocks } =
75
+ select( blockDirectoryStore );
78
76
  const { canInsertBlockType } = select( blockEditorStore );
79
77
 
80
78
  const hasPermission = select( coreStore ).canUser(
@@ -3,16 +3,31 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { Icon, blockDefault } from '@wordpress/icons';
6
+ import { Tip, ExternalLink } from '@wordpress/components';
6
7
 
7
8
  function DownloadableBlocksNoResults() {
8
9
  return (
9
- <div className="block-editor-inserter__no-results">
10
- <Icon
11
- className="block-editor-inserter__no-results-icon"
12
- icon={ blockDefault }
13
- />
14
- <p>{ __( 'No results found.' ) }</p>
15
- </div>
10
+ <>
11
+ <div className="block-editor-inserter__no-results">
12
+ <Icon
13
+ className="block-editor-inserter__no-results-icon"
14
+ icon={ blockDefault }
15
+ />
16
+ <p>{ __( 'No results found.' ) }</p>
17
+ </div>
18
+ <div className="block-editor-inserter__tips">
19
+ <Tip>
20
+ <div>
21
+ <p>
22
+ { __( 'Interested in creating your own block?' ) }
23
+ </p>
24
+ <ExternalLink href="https://developer.wordpress.org/block-editor/">
25
+ { __( 'Get started here' ) }.
26
+ </ExternalLink>
27
+ </div>
28
+ </Tip>
29
+ </div>
30
+ </>
16
31
  );
17
32
  }
18
33
 
@@ -57,151 +57,153 @@ export function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {
57
57
  *
58
58
  * @return {boolean} Whether the block was successfully installed & loaded.
59
59
  */
60
- export const installBlockType = ( block ) => async ( {
61
- registry,
62
- dispatch,
63
- } ) => {
64
- const { id, name } = block;
65
- let success = false;
66
- dispatch.clearErrorNotice( id );
67
- try {
68
- dispatch.setIsInstalling( id, true );
60
+ export const installBlockType =
61
+ ( block ) =>
62
+ async ( { registry, dispatch } ) => {
63
+ const { id, name } = block;
64
+ let success = false;
65
+ dispatch.clearErrorNotice( id );
66
+ try {
67
+ dispatch.setIsInstalling( id, true );
69
68
 
70
- // If we have a wp:plugin link, the plugin is installed but inactive.
71
- const url = getPluginUrl( block );
72
- let links = {};
73
- if ( url ) {
74
- await apiFetch( {
75
- method: 'PUT',
76
- url,
77
- data: { status: 'active' },
78
- } );
79
- } else {
80
- const response = await apiFetch( {
81
- method: 'POST',
82
- path: 'wp/v2/plugins',
83
- data: { slug: id, status: 'active' },
84
- } );
85
- // Add the `self` link for newly-installed blocks.
86
- links = response._links;
87
- }
69
+ // If we have a wp:plugin link, the plugin is installed but inactive.
70
+ const url = getPluginUrl( block );
71
+ let links = {};
72
+ if ( url ) {
73
+ await apiFetch( {
74
+ method: 'PUT',
75
+ url,
76
+ data: { status: 'active' },
77
+ } );
78
+ } else {
79
+ const response = await apiFetch( {
80
+ method: 'POST',
81
+ path: 'wp/v2/plugins',
82
+ data: { slug: id, status: 'active' },
83
+ } );
84
+ // Add the `self` link for newly-installed blocks.
85
+ links = response._links;
86
+ }
88
87
 
89
- dispatch.addInstalledBlockType( {
90
- ...block,
91
- links: { ...block.links, ...links },
92
- } );
88
+ dispatch.addInstalledBlockType( {
89
+ ...block,
90
+ links: { ...block.links, ...links },
91
+ } );
93
92
 
94
- // Ensures that the block metadata is propagated to the editor when registered on the server.
95
- const metadataFields = [
96
- 'api_version',
97
- 'title',
98
- 'category',
99
- 'parent',
100
- 'icon',
101
- 'description',
102
- 'keywords',
103
- 'attributes',
104
- 'provides_context',
105
- 'uses_context',
106
- 'supports',
107
- 'styles',
108
- 'example',
109
- 'variations',
110
- ];
111
- await apiFetch( {
112
- path: addQueryArgs( `/wp/v2/block-types/${ name }`, {
113
- _fields: metadataFields,
114
- } ),
115
- } )
116
- // Ignore when the block is not registered on the server.
117
- .catch( () => {} )
118
- .then( ( response ) => {
119
- if ( ! response ) {
120
- return;
121
- }
122
- unstable__bootstrapServerSideBlockDefinitions( {
123
- [ name ]: pick( response, metadataFields ),
93
+ // Ensures that the block metadata is propagated to the editor when registered on the server.
94
+ const metadataFields = [
95
+ 'api_version',
96
+ 'title',
97
+ 'category',
98
+ 'parent',
99
+ 'icon',
100
+ 'description',
101
+ 'keywords',
102
+ 'attributes',
103
+ 'provides_context',
104
+ 'uses_context',
105
+ 'supports',
106
+ 'styles',
107
+ 'example',
108
+ 'variations',
109
+ ];
110
+ await apiFetch( {
111
+ path: addQueryArgs( `/wp/v2/block-types/${ name }`, {
112
+ _fields: metadataFields,
113
+ } ),
114
+ } )
115
+ // Ignore when the block is not registered on the server.
116
+ .catch( () => {} )
117
+ .then( ( response ) => {
118
+ if ( ! response ) {
119
+ return;
120
+ }
121
+ unstable__bootstrapServerSideBlockDefinitions( {
122
+ [ name ]: pick( response, metadataFields ),
123
+ } );
124
124
  } );
125
- } );
126
125
 
127
- await loadAssets();
128
- const registeredBlocks = registry.select( blocksStore ).getBlockTypes();
129
- if ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {
130
- throw new Error(
131
- __( 'Error registering block. Try reloading the page.' )
126
+ await loadAssets();
127
+ const registeredBlocks = registry
128
+ .select( blocksStore )
129
+ .getBlockTypes();
130
+ if ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {
131
+ throw new Error(
132
+ __( 'Error registering block. Try reloading the page.' )
133
+ );
134
+ }
135
+
136
+ registry.dispatch( noticesStore ).createInfoNotice(
137
+ sprintf(
138
+ // translators: %s is the block title.
139
+ __( 'Block %s installed and added.' ),
140
+ block.title
141
+ ),
142
+ {
143
+ speak: true,
144
+ type: 'snackbar',
145
+ }
132
146
  );
133
- }
147
+ success = true;
148
+ } catch ( error ) {
149
+ let message = error.message || __( 'An error occurred.' );
134
150
 
135
- registry.dispatch( noticesStore ).createInfoNotice(
136
- sprintf(
137
- // translators: %s is the block title.
138
- __( 'Block %s installed and added.' ),
139
- block.title
140
- ),
141
- {
142
- speak: true,
143
- type: 'snackbar',
144
- }
145
- );
146
- success = true;
147
- } catch ( error ) {
148
- let message = error.message || __( 'An error occurred.' );
151
+ // Errors we throw are fatal.
152
+ let isFatal = error instanceof Error;
149
153
 
150
- // Errors we throw are fatal.
151
- let isFatal = error instanceof Error;
154
+ // Specific API errors that are fatal.
155
+ const fatalAPIErrors = {
156
+ folder_exists: __(
157
+ 'This block is already installed. Try reloading the page.'
158
+ ),
159
+ unable_to_connect_to_filesystem: __(
160
+ 'Error installing block. You can reload the page and try again.'
161
+ ),
162
+ };
152
163
 
153
- // Specific API errors that are fatal.
154
- const fatalAPIErrors = {
155
- folder_exists: __(
156
- 'This block is already installed. Try reloading the page.'
157
- ),
158
- unable_to_connect_to_filesystem: __(
159
- 'Error installing block. You can reload the page and try again.'
160
- ),
161
- };
164
+ if ( fatalAPIErrors[ error.code ] ) {
165
+ isFatal = true;
166
+ message = fatalAPIErrors[ error.code ];
167
+ }
162
168
 
163
- if ( fatalAPIErrors[ error.code ] ) {
164
- isFatal = true;
165
- message = fatalAPIErrors[ error.code ];
169
+ dispatch.setErrorNotice( id, message, isFatal );
170
+ registry.dispatch( noticesStore ).createErrorNotice( message, {
171
+ speak: true,
172
+ isDismissible: true,
173
+ } );
166
174
  }
167
-
168
- dispatch.setErrorNotice( id, message, isFatal );
169
- registry.dispatch( noticesStore ).createErrorNotice( message, {
170
- speak: true,
171
- isDismissible: true,
172
- } );
173
- }
174
- dispatch.setIsInstalling( id, false );
175
- return success;
176
- };
175
+ dispatch.setIsInstalling( id, false );
176
+ return success;
177
+ };
177
178
 
178
179
  /**
179
180
  * Action triggered to uninstall a block plugin.
180
181
  *
181
182
  * @param {Object} block The blockType object.
182
183
  */
183
- export const uninstallBlockType = ( block ) => async ( {
184
- registry,
185
- dispatch,
186
- } ) => {
187
- try {
188
- const url = getPluginUrl( block );
189
- await apiFetch( {
190
- method: 'PUT',
191
- url,
192
- data: { status: 'inactive' },
193
- } );
194
- await apiFetch( {
195
- method: 'DELETE',
196
- url,
197
- } );
198
- dispatch.removeInstalledBlockType( block );
199
- } catch ( error ) {
200
- registry
201
- .dispatch( noticesStore )
202
- .createErrorNotice( error.message || __( 'An error occurred.' ) );
203
- }
204
- };
184
+ export const uninstallBlockType =
185
+ ( block ) =>
186
+ async ( { registry, dispatch } ) => {
187
+ try {
188
+ const url = getPluginUrl( block );
189
+ await apiFetch( {
190
+ method: 'PUT',
191
+ url,
192
+ data: { status: 'inactive' },
193
+ } );
194
+ await apiFetch( {
195
+ method: 'DELETE',
196
+ url,
197
+ } );
198
+ dispatch.removeInstalledBlockType( block );
199
+ } catch ( error ) {
200
+ registry
201
+ .dispatch( noticesStore )
202
+ .createErrorNotice(
203
+ error.message || __( 'An error occurred.' )
204
+ );
205
+ }
206
+ };
205
207
 
206
208
  /**
207
209
  * Returns an action object used to add a block type to the "newly installed"
@@ -13,22 +13,22 @@ import apiFetch from '@wordpress/api-fetch';
13
13
  */
14
14
  import { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';
15
15
 
16
- export const getDownloadableBlocks = ( filterValue ) => async ( {
17
- dispatch,
18
- } ) => {
19
- if ( ! filterValue ) {
20
- return;
21
- }
16
+ export const getDownloadableBlocks =
17
+ ( filterValue ) =>
18
+ async ( { dispatch } ) => {
19
+ if ( ! filterValue ) {
20
+ return;
21
+ }
22
22
 
23
- try {
24
- dispatch( fetchDownloadableBlocks( filterValue ) );
25
- const results = await apiFetch( {
26
- path: `wp/v2/block-directory/search?term=${ filterValue }`,
27
- } );
28
- const blocks = results.map( ( result ) =>
29
- mapKeys( result, ( value, key ) => camelCase( key ) )
30
- );
23
+ try {
24
+ dispatch( fetchDownloadableBlocks( filterValue ) );
25
+ const results = await apiFetch( {
26
+ path: `wp/v2/block-directory/search?term=${ filterValue }`,
27
+ } );
28
+ const blocks = results.map( ( result ) =>
29
+ mapKeys( result, ( value, key ) => camelCase( key ) )
30
+ );
31
31
 
32
- dispatch( receiveDownloadableBlocks( blocks, filterValue ) );
33
- } catch {}
34
- };
32
+ dispatch( receiveDownloadableBlocks( blocks, filterValue ) );
33
+ } catch {}
34
+ };
@@ -58,8 +58,7 @@ describe( 'actions', () => {
58
58
  links: {
59
59
  'wp:install-plugin': [
60
60
  {
61
- href:
62
- 'https://example.com/wp-json/wp/v2/plugins?slug=waves',
61
+ href: 'https://example.com/wp-json/wp/v2/plugins?slug=waves',
63
62
  },
64
63
  ],
65
64
  },