@wordpress/edit-site 5.5.0 → 5.7.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 (310) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/new-template-part.js +3 -11
  3. package/build/components/add-new-template/new-template-part.js.map +1 -1
  4. package/build/components/add-new-template/new-template.js +23 -17
  5. package/build/components/add-new-template/new-template.js.map +1 -1
  6. package/build/components/add-new-template/utils.js +1 -1
  7. package/build/components/add-new-template/utils.js.map +1 -1
  8. package/build/components/app/index.js +4 -2
  9. package/build/components/app/index.js.map +1 -1
  10. package/build/components/block-editor/editor-canvas.js +7 -9
  11. package/build/components/block-editor/editor-canvas.js.map +1 -1
  12. package/build/components/editor/index.js +2 -4
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/global-styles/border-panel.js +20 -159
  15. package/build/components/global-styles/border-panel.js.map +1 -1
  16. package/build/components/global-styles/context-menu.js +4 -6
  17. package/build/components/global-styles/context-menu.js.map +1 -1
  18. package/build/components/global-styles/hooks.js +0 -72
  19. package/build/components/global-styles/hooks.js.map +1 -1
  20. package/build/components/global-styles/preview.js +3 -4
  21. package/build/components/global-styles/preview.js.map +1 -1
  22. package/build/components/global-styles/screen-block-list.js +5 -7
  23. package/build/components/global-styles/screen-block-list.js.map +1 -1
  24. package/build/components/global-styles/screen-border.js +13 -5
  25. package/build/components/global-styles/screen-border.js.map +1 -1
  26. package/build/components/global-styles/screen-colors.js +22 -211
  27. package/build/components/global-styles/screen-colors.js.map +1 -1
  28. package/build/components/global-styles/screen-root.js +2 -1
  29. package/build/components/global-styles/screen-root.js.map +1 -1
  30. package/build/components/global-styles/screen-style-variations.js +2 -1
  31. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  32. package/build/components/global-styles/screen-typography-element.js +4 -0
  33. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  34. package/build/components/global-styles/screen-typography.js +5 -0
  35. package/build/components/global-styles/screen-typography.js.map +1 -1
  36. package/build/components/global-styles/ui.js +5 -35
  37. package/build/components/global-styles/ui.js.map +1 -1
  38. package/build/components/global-styles-renderer/index.js +1 -2
  39. package/build/components/global-styles-renderer/index.js.map +1 -1
  40. package/build/components/layout/index.js +7 -0
  41. package/build/components/layout/index.js.map +1 -1
  42. package/build/components/list/added-by.js +128 -136
  43. package/build/components/list/added-by.js.map +1 -1
  44. package/build/components/list/index.js +2 -1
  45. package/build/components/list/index.js.map +1 -1
  46. package/build/components/list/table.js +6 -5
  47. package/build/components/list/table.js.map +1 -1
  48. package/build/components/routes/link.js +4 -1
  49. package/build/components/routes/link.js.map +1 -1
  50. package/build/components/save-button/index.js +2 -5
  51. package/build/components/save-button/index.js.map +1 -1
  52. package/build/components/save-hub/index.js +82 -0
  53. package/build/components/save-hub/index.js.map +1 -0
  54. package/build/components/secondary-sidebar/list-view-sidebar.js +6 -1
  55. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  56. package/build/components/sidebar/index.js +2 -4
  57. package/build/components/sidebar/index.js.map +1 -1
  58. package/build/components/sidebar-navigation-screen/index.js +5 -2
  59. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  60. package/build/components/sidebar-navigation-screen-main/index.js +13 -13
  61. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  62. package/build/components/sidebar-navigation-screen-navigation-item/index.js +9 -14
  63. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  64. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +87 -10
  65. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  66. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
  67. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  68. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
  69. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  70. package/build/components/sidebar-navigation-screen-template/index.js +59 -10
  71. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  72. package/build/components/sidebar-navigation-screen-templates/index.js +5 -2
  73. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  74. package/build/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  75. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  76. package/build/components/site-hub/index.js +3 -1
  77. package/build/components/site-hub/index.js.map +1 -1
  78. package/build/components/start-template-options/index.js +44 -9
  79. package/build/components/start-template-options/index.js.map +1 -1
  80. package/build/components/style-book/index.js +133 -19
  81. package/build/components/style-book/index.js.map +1 -1
  82. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  83. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  84. package/build/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
  85. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  86. package/build/components/template-details/index.js +0 -3
  87. package/build/components/template-details/index.js.map +1 -1
  88. package/build/components/template-part-converter/convert-to-regular.js +8 -12
  89. package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
  90. package/build/components/template-part-converter/convert-to-template-part.js +2 -2
  91. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  92. package/build/components/template-part-converter/index.js +19 -14
  93. package/build/components/template-part-converter/index.js.map +1 -1
  94. package/build/components/use-edited-entity-record/index.js +6 -6
  95. package/build/components/use-edited-entity-record/index.js.map +1 -1
  96. package/build/hooks/push-changes-to-global-styles/index.js +1 -0
  97. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  98. package/build/index.js +3 -0
  99. package/build/index.js.map +1 -1
  100. package/build/utils/history.js +8 -2
  101. package/build/utils/history.js.map +1 -1
  102. package/build-module/components/add-new-template/new-template-part.js +3 -9
  103. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  104. package/build-module/components/add-new-template/new-template.js +25 -18
  105. package/build-module/components/add-new-template/new-template.js.map +1 -1
  106. package/build-module/components/add-new-template/utils.js +1 -1
  107. package/build-module/components/add-new-template/utils.js.map +1 -1
  108. package/build-module/components/app/index.js +3 -2
  109. package/build-module/components/app/index.js.map +1 -1
  110. package/build-module/components/block-editor/editor-canvas.js +8 -10
  111. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  112. package/build-module/components/editor/index.js +2 -3
  113. package/build-module/components/editor/index.js.map +1 -1
  114. package/build-module/components/global-styles/border-panel.js +21 -157
  115. package/build-module/components/global-styles/border-panel.js.map +1 -1
  116. package/build-module/components/global-styles/context-menu.js +4 -4
  117. package/build-module/components/global-styles/context-menu.js.map +1 -1
  118. package/build-module/components/global-styles/hooks.js +0 -66
  119. package/build-module/components/global-styles/hooks.js.map +1 -1
  120. package/build-module/components/global-styles/preview.js +3 -4
  121. package/build-module/components/global-styles/preview.js.map +1 -1
  122. package/build-module/components/global-styles/screen-block-list.js +5 -5
  123. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  124. package/build-module/components/global-styles/screen-border.js +11 -2
  125. package/build-module/components/global-styles/screen-border.js.map +1 -1
  126. package/build-module/components/global-styles/screen-colors.js +23 -208
  127. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  128. package/build-module/components/global-styles/screen-root.js +2 -1
  129. package/build-module/components/global-styles/screen-root.js.map +1 -1
  130. package/build-module/components/global-styles/screen-style-variations.js +2 -1
  131. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  132. package/build-module/components/global-styles/screen-typography-element.js +4 -0
  133. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  134. package/build-module/components/global-styles/screen-typography.js +5 -0
  135. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  136. package/build-module/components/global-styles/ui.js +5 -30
  137. package/build-module/components/global-styles/ui.js.map +1 -1
  138. package/build-module/components/global-styles-renderer/index.js +1 -2
  139. package/build-module/components/global-styles-renderer/index.js.map +1 -1
  140. package/build-module/components/layout/index.js +7 -0
  141. package/build-module/components/layout/index.js.map +1 -1
  142. package/build-module/components/list/added-by.js +126 -137
  143. package/build-module/components/list/added-by.js.map +1 -1
  144. package/build-module/components/list/index.js +2 -1
  145. package/build-module/components/list/index.js.map +1 -1
  146. package/build-module/components/list/table.js +6 -5
  147. package/build-module/components/list/table.js.map +1 -1
  148. package/build-module/components/routes/link.js +5 -2
  149. package/build-module/components/routes/link.js.map +1 -1
  150. package/build-module/components/save-button/index.js +2 -5
  151. package/build-module/components/save-button/index.js.map +1 -1
  152. package/build-module/components/save-hub/index.js +68 -0
  153. package/build-module/components/save-hub/index.js.map +1 -0
  154. package/build-module/components/secondary-sidebar/list-view-sidebar.js +6 -2
  155. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  156. package/build-module/components/sidebar/index.js +2 -4
  157. package/build-module/components/sidebar/index.js.map +1 -1
  158. package/build-module/components/sidebar-navigation-screen/index.js +5 -2
  159. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  160. package/build-module/components/sidebar-navigation-screen-main/index.js +13 -13
  161. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  162. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +13 -18
  163. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  164. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +81 -10
  165. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  166. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
  167. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  168. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
  169. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  170. package/build-module/components/sidebar-navigation-screen-template/index.js +60 -13
  171. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  172. package/build-module/components/sidebar-navigation-screen-templates/index.js +5 -2
  173. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  174. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  175. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  176. package/build-module/components/site-hub/index.js +3 -1
  177. package/build-module/components/site-hub/index.js.map +1 -1
  178. package/build-module/components/start-template-options/index.js +45 -10
  179. package/build-module/components/start-template-options/index.js.map +1 -1
  180. package/build-module/components/style-book/index.js +133 -21
  181. package/build-module/components/style-book/index.js.map +1 -1
  182. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  183. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  184. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +9 -7
  185. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  186. package/build-module/components/template-details/index.js +0 -3
  187. package/build-module/components/template-details/index.js.map +1 -1
  188. package/build-module/components/template-part-converter/convert-to-regular.js +9 -13
  189. package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
  190. package/build-module/components/template-part-converter/convert-to-template-part.js +3 -3
  191. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  192. package/build-module/components/template-part-converter/index.js +20 -15
  193. package/build-module/components/template-part-converter/index.js.map +1 -1
  194. package/build-module/components/use-edited-entity-record/index.js +6 -6
  195. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  196. package/build-module/hooks/push-changes-to-global-styles/index.js +1 -0
  197. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  198. package/build-module/index.js +4 -1
  199. package/build-module/index.js.map +1 -1
  200. package/build-module/utils/history.js +9 -3
  201. package/build-module/utils/history.js.map +1 -1
  202. package/build-style/style-rtl.css +172 -128
  203. package/build-style/style.css +172 -128
  204. package/package.json +31 -31
  205. package/src/components/add-new-template/new-template-part.js +1 -6
  206. package/src/components/add-new-template/new-template.js +60 -38
  207. package/src/components/add-new-template/style.scss +12 -1
  208. package/src/components/add-new-template/utils.js +1 -1
  209. package/src/components/app/index.js +9 -6
  210. package/src/components/block-editor/editor-canvas.js +13 -22
  211. package/src/components/editor/index.js +61 -65
  212. package/src/components/global-styles/border-panel.js +24 -199
  213. package/src/components/global-styles/context-menu.js +4 -4
  214. package/src/components/global-styles/hooks.js +0 -101
  215. package/src/components/global-styles/preview.js +1 -1
  216. package/src/components/global-styles/screen-block-list.js +4 -4
  217. package/src/components/global-styles/screen-border.js +9 -2
  218. package/src/components/global-styles/screen-colors.js +25 -229
  219. package/src/components/global-styles/screen-root.js +1 -1
  220. package/src/components/global-styles/screen-style-variations.js +5 -1
  221. package/src/components/global-styles/screen-typography-element.js +4 -0
  222. package/src/components/global-styles/screen-typography.js +6 -0
  223. package/src/components/global-styles/stories/index.js +425 -0
  224. package/src/components/global-styles/style.scss +14 -18
  225. package/src/components/global-styles/ui.js +6 -31
  226. package/src/components/global-styles-renderer/index.js +1 -2
  227. package/src/components/layout/index.js +15 -0
  228. package/src/components/layout/style.scss +1 -3
  229. package/src/components/list/added-by.js +144 -140
  230. package/src/components/list/index.js +3 -1
  231. package/src/components/list/table.js +7 -4
  232. package/src/components/routes/link.js +9 -2
  233. package/src/components/save-button/index.js +2 -2
  234. package/src/components/save-hub/index.js +78 -0
  235. package/src/components/save-hub/style.scss +15 -0
  236. package/src/components/secondary-sidebar/list-view-sidebar.js +4 -3
  237. package/src/components/sidebar/index.js +2 -3
  238. package/src/components/sidebar/style.scss +4 -3
  239. package/src/components/sidebar-button/style.scss +2 -1
  240. package/src/components/sidebar-navigation-item/style.scss +1 -23
  241. package/src/components/sidebar-navigation-screen/index.js +6 -0
  242. package/src/components/sidebar-navigation-screen/style.scss +15 -0
  243. package/src/components/sidebar-navigation-screen-main/index.js +21 -8
  244. package/src/components/sidebar-navigation-screen-navigation-item/index.js +30 -21
  245. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +92 -9
  246. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
  247. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
  248. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +108 -1
  249. package/src/components/sidebar-navigation-screen-template/index.js +82 -11
  250. package/src/components/sidebar-navigation-screen-template/style.scss +25 -0
  251. package/src/components/sidebar-navigation-screen-templates/index.js +7 -0
  252. package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -1
  253. package/src/components/site-hub/index.js +5 -1
  254. package/src/components/site-hub/style.scss +5 -1
  255. package/src/components/start-template-options/index.js +40 -8
  256. package/src/components/style-book/index.js +203 -54
  257. package/src/components/style-book/style.scss +2 -46
  258. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
  259. package/src/components/sync-state-with-url/use-sync-path-with-url.js +12 -7
  260. package/src/components/template-details/index.js +0 -3
  261. package/src/components/template-part-converter/convert-to-regular.js +10 -17
  262. package/src/components/template-part-converter/convert-to-template-part.js +9 -16
  263. package/src/components/template-part-converter/index.js +28 -12
  264. package/src/components/use-edited-entity-record/index.js +26 -18
  265. package/src/hooks/push-changes-to-global-styles/index.js +1 -0
  266. package/src/index.js +5 -1
  267. package/src/store/test/actions.js +0 -2
  268. package/src/style.scss +2 -1
  269. package/src/utils/history.js +13 -9
  270. package/build/components/global-styles/color-utils.js +0 -17
  271. package/build/components/global-styles/color-utils.js.map +0 -1
  272. package/build/components/global-styles/screen-background-color.js +0 -114
  273. package/build/components/global-styles/screen-background-color.js.map +0 -1
  274. package/build/components/global-styles/screen-button-color.js +0 -88
  275. package/build/components/global-styles/screen-button-color.js.map +0 -1
  276. package/build/components/global-styles/screen-heading-color.js +0 -165
  277. package/build/components/global-styles/screen-heading-color.js.map +0 -1
  278. package/build/components/global-styles/screen-link-color.js +0 -105
  279. package/build/components/global-styles/screen-link-color.js.map +0 -1
  280. package/build/components/global-styles/screen-text-color.js +0 -71
  281. package/build/components/global-styles/screen-text-color.js.map +0 -1
  282. package/build/components/navigation-inspector/index.js +0 -161
  283. package/build/components/navigation-inspector/index.js.map +0 -1
  284. package/build/components/navigation-inspector/navigation-menu.js +0 -79
  285. package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
  286. package/build-module/components/global-styles/color-utils.js +0 -9
  287. package/build-module/components/global-styles/color-utils.js.map +0 -1
  288. package/build-module/components/global-styles/screen-background-color.js +0 -97
  289. package/build-module/components/global-styles/screen-background-color.js.map +0 -1
  290. package/build-module/components/global-styles/screen-button-color.js +0 -73
  291. package/build-module/components/global-styles/screen-button-color.js.map +0 -1
  292. package/build-module/components/global-styles/screen-heading-color.js +0 -149
  293. package/build-module/components/global-styles/screen-heading-color.js.map +0 -1
  294. package/build-module/components/global-styles/screen-link-color.js +0 -89
  295. package/build-module/components/global-styles/screen-link-color.js.map +0 -1
  296. package/build-module/components/global-styles/screen-text-color.js +0 -56
  297. package/build-module/components/global-styles/screen-text-color.js.map +0 -1
  298. package/build-module/components/navigation-inspector/index.js +0 -146
  299. package/build-module/components/navigation-inspector/index.js.map +0 -1
  300. package/build-module/components/navigation-inspector/navigation-menu.js +0 -69
  301. package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
  302. package/src/components/global-styles/color-utils.js +0 -14
  303. package/src/components/global-styles/screen-background-color.js +0 -132
  304. package/src/components/global-styles/screen-button-color.js +0 -104
  305. package/src/components/global-styles/screen-heading-color.js +0 -206
  306. package/src/components/global-styles/screen-link-color.js +0 -124
  307. package/src/components/global-styles/screen-text-color.js +0 -62
  308. package/src/components/navigation-inspector/index.js +0 -191
  309. package/src/components/navigation-inspector/navigation-menu.js +0 -84
  310. package/src/components/navigation-inspector/style.scss +0 -46
@@ -1,4 +1,5 @@
1
1
  import { createElement } from "@wordpress/element";
2
+ // @ts-check
2
3
 
3
4
  /**
4
5
  * External dependencies
@@ -8,26 +9,116 @@ import classnames from 'classnames';
8
9
  * WordPress dependencies
9
10
  */
10
11
 
11
- import { __experimentalHStack as HStack, Icon } from '@wordpress/components';
12
+ import { Icon, __experimentalHStack as HStack } from '@wordpress/components';
12
13
  import { store as coreStore } from '@wordpress/core-data';
13
14
  import { useSelect } from '@wordpress/data';
14
15
  import { useState } from '@wordpress/element';
15
16
  import { commentAuthorAvatar as authorIcon, layout as themeIcon, plugins as pluginIcon, globe as globeIcon } from '@wordpress/icons';
16
17
  import { _x } from '@wordpress/i18n';
18
+ /** @typedef {'wp_template'|'wp_template_part'} TemplateType */
19
+
20
+ /** @type {TemplateType} */
21
+
17
22
  const TEMPLATE_POST_TYPE_NAMES = ['wp_template', 'wp_template_part'];
23
+ /**
24
+ * @typedef {'theme'|'plugin'|'site'|'user'} AddedByType
25
+ *
26
+ * @typedef AddedByData
27
+ * @type {Object}
28
+ * @property {AddedByType} type The type of the data.
29
+ * @property {JSX.Element} icon The icon to display.
30
+ * @property {string} [imageUrl] The optional image URL to display.
31
+ * @property {string} [text] The text to display.
32
+ * @property {boolean} isCustomized Whether the template has been customized.
33
+ *
34
+ * @param {TemplateType} postType The template post type.
35
+ * @param {number} postId The template post id.
36
+ * @return {AddedByData} The added by object or null.
37
+ */
38
+
39
+ export function useAddedBy(postType, postId) {
40
+ return useSelect(select => {
41
+ var _user$avatar_urls;
42
+
43
+ const {
44
+ getTheme,
45
+ getPlugin,
46
+ getEntityRecord,
47
+ getMedia,
48
+ getUser,
49
+ getEditedEntityRecord
50
+ } = select(coreStore);
51
+ const template = getEditedEntityRecord('postType', postType, postId);
52
+
53
+ if (TEMPLATE_POST_TYPE_NAMES.includes(template.type)) {
54
+ // Added by theme.
55
+ // Template originally provided by a theme, but customized by a user.
56
+ // Templates originally didn't have the 'origin' field so identify
57
+ // older customized templates by checking for no origin and a 'theme'
58
+ // or 'custom' source.
59
+ if (template.has_theme_file && (template.origin === 'theme' || !template.origin && ['theme', 'custom'].includes(template.source))) {
60
+ var _getTheme, _getTheme$name;
61
+
62
+ return {
63
+ type: 'theme',
64
+ icon: themeIcon,
65
+ text: ((_getTheme = getTheme(template.theme)) === null || _getTheme === void 0 ? void 0 : (_getTheme$name = _getTheme.name) === null || _getTheme$name === void 0 ? void 0 : _getTheme$name.rendered) || template.theme,
66
+ isCustomized: template.source === 'custom'
67
+ };
68
+ } // Added by plugin.
69
+
70
+
71
+ if (template.has_theme_file && template.origin === 'plugin') {
72
+ var _getPlugin;
73
+
74
+ return {
75
+ type: 'plugin',
76
+ icon: pluginIcon,
77
+ text: ((_getPlugin = getPlugin(template.theme)) === null || _getPlugin === void 0 ? void 0 : _getPlugin.name) || template.theme,
78
+ isCustomized: template.source === 'custom'
79
+ };
80
+ } // Added by site.
81
+ // Template was created from scratch, but has no author. Author support
82
+ // was only added to templates in WordPress 5.9. Fallback to showing the
83
+ // site logo and title.
84
+
85
+
86
+ if (!template.has_theme_file && template.source === 'custom' && !template.author) {
87
+ var _getMedia;
88
+
89
+ const siteData = getEntityRecord('root', '__unstableBase');
90
+ return {
91
+ type: 'site',
92
+ icon: globeIcon,
93
+ imageUrl: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined,
94
+ text: siteData === null || siteData === void 0 ? void 0 : siteData.name,
95
+ isCustomized: false
96
+ };
97
+ }
98
+ } // Added by user.
99
+
100
+
101
+ const user = getUser(template.author);
102
+ return {
103
+ type: 'user',
104
+ icon: authorIcon,
105
+ imageUrl: user === null || user === void 0 ? void 0 : (_user$avatar_urls = user.avatar_urls) === null || _user$avatar_urls === void 0 ? void 0 : _user$avatar_urls[48],
106
+ text: user === null || user === void 0 ? void 0 : user.nickname,
107
+ isCustomized: false
108
+ };
109
+ }, [postType, postId]);
110
+ }
111
+ /**
112
+ * @param {Object} props
113
+ * @param {string} props.imageUrl
114
+ */
18
115
 
19
- function BaseAddedBy(_ref) {
116
+ function AvatarImage(_ref) {
20
117
  let {
21
- text,
22
- icon,
23
- imageUrl,
24
- isCustomized,
25
- templateType
118
+ imageUrl
26
119
  } = _ref;
27
120
  const [isImageLoaded, setIsImageLoaded] = useState(false);
28
- return createElement(HStack, {
29
- alignment: "left"
30
- }, imageUrl ? createElement("div", {
121
+ return createElement("div", {
31
122
  className: classnames('edit-site-list-added-by__avatar', {
32
123
  'is-loaded': isImageLoaded
33
124
  })
@@ -35,138 +126,36 @@ function BaseAddedBy(_ref) {
35
126
  onLoad: () => setIsImageLoaded(true),
36
127
  alt: "",
37
128
  src: imageUrl
38
- })) : createElement("div", {
39
- className: "edit-site-list-added-by__icon"
40
- }, createElement(Icon, {
41
- icon: icon
42
- })), createElement("span", null, text, isCustomized && createElement("span", {
43
- className: "edit-site-list-added-by__customized-info"
44
- }, templateType === 'wp_template' ? _x('Customized', 'template') : _x('Customized', 'template part'))));
129
+ }));
45
130
  }
131
+ /**
132
+ * @param {Object} props
133
+ * @param {TemplateType} props.postType The template post type.
134
+ * @param {number} props.postId The template post id.
135
+ */
46
136
 
47
- function AddedByTheme(_ref2) {
48
- var _theme$name;
49
137
 
138
+ export default function AddedBy(_ref2) {
50
139
  let {
51
- slug,
52
- isCustomized,
53
- templateType
140
+ postType,
141
+ postId
54
142
  } = _ref2;
55
- const theme = useSelect(select => select(coreStore).getTheme(slug), [slug]);
56
- return createElement(BaseAddedBy, {
57
- icon: themeIcon,
58
- text: (theme === null || theme === void 0 ? void 0 : (_theme$name = theme.name) === null || _theme$name === void 0 ? void 0 : _theme$name.rendered) || slug,
59
- isCustomized: isCustomized,
60
- templateType: templateType
61
- });
62
- }
63
-
64
- function AddedByPlugin(_ref3) {
65
- let {
66
- slug,
67
- isCustomized,
68
- templateType
69
- } = _ref3;
70
- const plugin = useSelect(select => select(coreStore).getPlugin(slug), [slug]);
71
- return createElement(BaseAddedBy, {
72
- icon: pluginIcon,
73
- text: (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug,
74
- isCustomized: isCustomized,
75
- templateType: templateType
76
- });
77
- }
78
-
79
- function AddedByAuthor(_ref4) {
80
- var _user$avatar_urls;
81
-
82
- let {
83
- id,
84
- templateType
85
- } = _ref4;
86
- const user = useSelect(select => select(coreStore).getUser(id), [id]);
87
- return createElement(BaseAddedBy, {
88
- icon: authorIcon,
89
- imageUrl: user === null || user === void 0 ? void 0 : (_user$avatar_urls = user.avatar_urls) === null || _user$avatar_urls === void 0 ? void 0 : _user$avatar_urls[48],
90
- text: user === null || user === void 0 ? void 0 : user.nickname,
91
- templateType: templateType
92
- });
93
- }
94
-
95
- function AddedBySite(_ref5) {
96
- let {
97
- templateType
98
- } = _ref5;
99
143
  const {
100
- name,
101
- logoURL
102
- } = useSelect(select => {
103
- var _getMedia;
104
-
105
- const {
106
- getEntityRecord,
107
- getMedia
108
- } = select(coreStore);
109
- const siteData = getEntityRecord('root', '__unstableBase');
110
- return {
111
- name: siteData === null || siteData === void 0 ? void 0 : siteData.name,
112
- logoURL: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined
113
- };
114
- }, []);
115
- return createElement(BaseAddedBy, {
116
- icon: globeIcon,
117
- imageUrl: logoURL,
118
- text: name,
119
- templateType: templateType
120
- });
121
- }
122
-
123
- export default function AddedBy(_ref6) {
124
- let {
125
- templateType,
126
- template
127
- } = _ref6;
128
-
129
- if (!template) {
130
- return;
131
- }
132
-
133
- if (TEMPLATE_POST_TYPE_NAMES.includes(templateType)) {
134
- // Template originally provided by a theme, but customized by a user.
135
- // Templates originally didn't have the 'origin' field so identify
136
- // older customized templates by checking for no origin and a 'theme'
137
- // or 'custom' source.
138
- if (template.has_theme_file && (template.origin === 'theme' || !template.origin && ['theme', 'custom'].includes(template.source))) {
139
- return createElement(AddedByTheme, {
140
- slug: template.theme,
141
- isCustomized: template.source === 'custom',
142
- templateType: templateType
143
- });
144
- } // Template originally provided by a plugin, but customized by a user.
145
-
146
-
147
- if (template.has_theme_file && template.origin === 'plugin') {
148
- return createElement(AddedByPlugin, {
149
- slug: template.theme,
150
- isCustomized: template.source === 'custom',
151
- templateType: templateType
152
- });
153
- } // Template was created from scratch, but has no author. Author support
154
- // was only added to templates in WordPress 5.9. Fallback to showing the
155
- // site logo and title.
156
-
157
-
158
- if (!template.has_theme_file && template.source === 'custom' && !template.author) {
159
- return createElement(AddedBySite, {
160
- templateType: templateType
161
- });
162
- }
163
- } // Simply show the author for templates created from scratch that have an
164
- // author or for any other post type.
165
-
166
-
167
- return createElement(AddedByAuthor, {
168
- id: template.author,
169
- templateType: templateType
170
- });
144
+ text,
145
+ icon,
146
+ imageUrl,
147
+ isCustomized
148
+ } = useAddedBy(postType, postId);
149
+ return createElement(HStack, {
150
+ alignment: "left"
151
+ }, imageUrl ? createElement(AvatarImage, {
152
+ imageUrl: imageUrl
153
+ }) : createElement("div", {
154
+ className: "edit-site-list-added-by__icon"
155
+ }, createElement(Icon, {
156
+ icon: icon
157
+ })), createElement("span", null, text, isCustomized && createElement("span", {
158
+ className: "edit-site-list-added-by__customized-info"
159
+ }, postType === 'wp_template' ? _x('Customized', 'template') : _x('Customized', 'template part'))));
171
160
  }
172
161
  //# sourceMappingURL=added-by.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["classnames","__experimentalHStack","HStack","Icon","store","coreStore","useSelect","useState","commentAuthorAvatar","authorIcon","layout","themeIcon","plugins","pluginIcon","globe","globeIcon","_x","TEMPLATE_POST_TYPE_NAMES","BaseAddedBy","text","icon","imageUrl","isCustomized","templateType","isImageLoaded","setIsImageLoaded","AddedByTheme","slug","theme","select","getTheme","name","rendered","AddedByPlugin","plugin","getPlugin","AddedByAuthor","id","user","getUser","avatar_urls","nickname","AddedBySite","logoURL","getEntityRecord","getMedia","siteData","site_logo","source_url","undefined","AddedBy","template","includes","has_theme_file","origin","source","author"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,oBAAoB,IAAIC,MAAjC,EAAyCC,IAAzC,QAAqD,uBAArD;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAn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EF,QAAQ,CAACG,MAAT,KAAoB,OAApB,IACC,CAAEH,QAAQ,CAACG,MAAX,IACD,CAAE,OAAF,EAAW,QAAX,EAAsBF,QAAtB,CAAgCD,QAAQ,CAACI,MAAzC,CAHF,CADD,EAKE;AACD,aACC,cAAC,YAAD;AACC,QAAA,IAAI,EAAGJ,QAAQ,CAACvB,KADjB;AAEC,QAAA,YAAY,EAAGuB,QAAQ,CAACI,MAAT,KAAoB,QAFpC;AAGC,QAAA,YAAY,EAAGhC;AAHhB,QADD;AAOA,KAlBuD,CAoBxD;;;AACA,QAAK4B,QAAQ,CAACE,cAAT,IAA2BF,QAAQ,CAACG,MAAT,KAAoB,QAApD,EAA+D;AAC9D,aACC,cAAC,aAAD;AACC,QAAA,IAAI,EAAGH,QAAQ,CAACvB,KADjB;AAEC,QAAA,YAAY,EAAGuB,QAAQ,CAACI,MAAT,KAAoB,QAFpC;AAGC,QAAA,YAAY,EAAGhC;AAHhB,QADD;AAOA,KA7BuD,CA+BxD;AACA;AACA;;;AACA,QACC,CAAE4B,QAAQ,CAACE,cAAX,IACAF,QAAQ,CAACI,MAAT,KAAoB,QADpB,IAEA,CAAEJ,QAAQ,CAACK,MAHZ,EAIE;AACD,aAAO,cAAC,WAAD;AAAa,QAAA,YAAY,EAAGjC;AAA5B,QAAP;AACA;AACD,GA9C4D,CAgD7D;AACA;;;AACA,SACC,cAAC,aAAD;AAAe,IAAA,EAAE,EAAG4B,QAAQ,CAACK,MAA7B;AAAsC,IAAA,YAAY,EAAGjC;AAArD,IADD;AAGA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n\tglobe as globeIcon,\n} from '@wordpress/icons';\nimport { _x } from '@wordpress/i18n';\n\nconst TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];\n\nfunction BaseAddedBy( { text, icon, imageUrl, isCustomized, templateType } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t{ imageUrl ? (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>\n\t\t\t\t{ text }\n\t\t\t\t{ isCustomized && (\n\t\t\t\t\t<span className=\"edit-site-list-added-by__customized-info\">\n\t\t\t\t\t\t{ templateType === 'wp_template'\n\t\t\t\t\t\t\t? _x( 'Customized', 'template' )\n\t\t\t\t\t\t\t: _x( 'Customized', 'template part' ) }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</HStack>\n\t);\n}\n\nfunction AddedByTheme( { slug, isCustomized, templateType } ) {\n\tconst theme = useSelect(\n\t\t( select ) => select( coreStore ).getTheme( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ themeIcon }\n\t\t\ttext={ theme?.name?.rendered || slug }\n\t\t\tisCustomized={ isCustomized }\n\t\t\ttemplateType={ templateType }\n\t\t/>\n\t);\n}\n\nfunction AddedByPlugin( { slug, isCustomized, templateType } ) {\n\tconst plugin = useSelect(\n\t\t( select ) => select( coreStore ).getPlugin( slug ),\n\t\t[ slug ]\n\t);\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ pluginIcon }\n\t\t\ttext={ plugin?.name || slug }\n\t\t\tisCustomized={ isCustomized }\n\t\t\ttemplateType={ templateType }\n\t\t/>\n\t);\n}\n\nfunction AddedByAuthor( { id, templateType } ) {\n\tconst user = useSelect(\n\t\t( select ) => select( coreStore ).getUser( id ),\n\t\t[ id ]\n\t);\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ authorIcon }\n\t\t\timageUrl={ user?.avatar_urls?.[ 48 ] }\n\t\t\ttext={ user?.nickname }\n\t\t\ttemplateType={ templateType }\n\t\t/>\n\t);\n}\n\nfunction AddedBySite( { templateType } ) {\n\tconst { name, logoURL } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, getMedia } = select( coreStore );\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase' );\n\n\t\treturn {\n\t\t\tname: siteData?.name,\n\t\t\tlogoURL: siteData?.site_logo\n\t\t\t\t? getMedia( siteData.site_logo )?.source_url\n\t\t\t\t: undefined,\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<BaseAddedBy\n\t\t\ticon={ globeIcon }\n\t\t\timageUrl={ logoURL }\n\t\t\ttext={ name }\n\t\t\ttemplateType={ templateType }\n\t\t/>\n\t);\n}\n\nexport default function AddedBy( { templateType, template } ) {\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tif ( TEMPLATE_POST_TYPE_NAMES.includes( templateType ) ) {\n\t\t// Template originally provided by a theme, but customized by a user.\n\t\t// Templates originally didn't have the 'origin' field so identify\n\t\t// older customized templates by checking for no origin and a 'theme'\n\t\t// or 'custom' source.\n\t\tif (\n\t\t\ttemplate.has_theme_file &&\n\t\t\t( template.origin === 'theme' ||\n\t\t\t\t( ! template.origin &&\n\t\t\t\t\t[ 'theme', 'custom' ].includes( template.source ) ) )\n\t\t) {\n\t\t\treturn (\n\t\t\t\t<AddedByTheme\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t\ttemplateType={ templateType }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template originally provided by a plugin, but customized by a user.\n\t\tif ( template.has_theme_file && template.origin === 'plugin' ) {\n\t\t\treturn (\n\t\t\t\t<AddedByPlugin\n\t\t\t\t\tslug={ template.theme }\n\t\t\t\t\tisCustomized={ template.source === 'custom' }\n\t\t\t\t\ttemplateType={ templateType }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Template was created from scratch, but has no author. Author support\n\t\t// was only added to templates in WordPress 5.9. Fallback to showing the\n\t\t// site logo and title.\n\t\tif (\n\t\t\t! template.has_theme_file &&\n\t\t\ttemplate.source === 'custom' &&\n\t\t\t! template.author\n\t\t) {\n\t\t\treturn <AddedBySite templateType={ templateType } />;\n\t\t}\n\t}\n\n\t// Simply show the author for templates created from scratch that have an\n\t// author or for any other post type.\n\treturn (\n\t\t<AddedByAuthor id={ template.author } templateType={ templateType } />\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/added-by.js"],"names":["classnames","Icon","__experimentalHStack","HStack","store","coreStore","useSelect","useState","commentAuthorAvatar","authorIcon","layout","themeIcon","plugins","pluginIcon","globe","globeIcon","_x","TEMPLATE_POST_TYPE_NAMES","useAddedBy","postType","postId","select","getTheme","getPlugin","getEntityRecord","getMedia","getUser","getEditedEntityRecord","template","includes","type","has_theme_file","origin","source","icon","text","theme","name","rendered","isCustomized","author","siteData","imageUrl","site_logo","source_url","undefined","user","avatar_urls","nickname","AvatarImage","isImageLoaded","setIsImageLoaded","AddedBy"],"mappings":";AAAA;;AACA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,EAAeC,oBAAoB,IAAIC,MAAvC,QAAqD,uBAArD;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,S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,GACCH,EAAE,CAAE,YAAF,EAAgB,UAAhB,CADH,GAECA,EAAE,CAAE,YAAF,EAAgB,eAAhB,CAHN,CAHF,CARD,CADD;AAqBA","sourcesContent":["// @ts-check\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Icon, __experimentalHStack as HStack } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport {\n\tcommentAuthorAvatar as authorIcon,\n\tlayout as themeIcon,\n\tplugins as pluginIcon,\n\tglobe as globeIcon,\n} from '@wordpress/icons';\nimport { _x } from '@wordpress/i18n';\n\n/** @typedef {'wp_template'|'wp_template_part'} TemplateType */\n\n/** @type {TemplateType} */\nconst TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];\n\n/**\n * @typedef {'theme'|'plugin'|'site'|'user'} AddedByType\n *\n * @typedef AddedByData\n * @type {Object}\n * @property {AddedByType} type The type of the data.\n * @property {JSX.Element} icon The icon to display.\n * @property {string} [imageUrl] The optional image URL to display.\n * @property {string} [text] The text to display.\n * @property {boolean} isCustomized Whether the template has been customized.\n *\n * @param {TemplateType} postType The template post type.\n * @param {number} postId The template post id.\n * @return {AddedByData} The added by object or null.\n */\nexport function useAddedBy( postType, postId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetTheme,\n\t\t\t\tgetPlugin,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetMedia,\n\t\t\t\tgetUser,\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t} = select( coreStore );\n\t\t\tconst template = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\n\t\t\tif ( TEMPLATE_POST_TYPE_NAMES.includes( template.type ) ) {\n\t\t\t\t// Added by theme.\n\t\t\t\t// Template originally provided by a theme, but customized by a user.\n\t\t\t\t// Templates originally didn't have the 'origin' field so identify\n\t\t\t\t// older customized templates by checking for no origin and a 'theme'\n\t\t\t\t// or 'custom' source.\n\t\t\t\tif (\n\t\t\t\t\ttemplate.has_theme_file &&\n\t\t\t\t\t( template.origin === 'theme' ||\n\t\t\t\t\t\t( ! template.origin &&\n\t\t\t\t\t\t\t[ 'theme', 'custom' ].includes(\n\t\t\t\t\t\t\t\ttemplate.source\n\t\t\t\t\t\t\t) ) )\n\t\t\t\t) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'theme',\n\t\t\t\t\t\ticon: themeIcon,\n\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\tgetTheme( template.theme )?.name?.rendered ||\n\t\t\t\t\t\t\ttemplate.theme,\n\t\t\t\t\t\tisCustomized: template.source === 'custom',\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Added by plugin.\n\t\t\t\tif ( template.has_theme_file && template.origin === 'plugin' ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'plugin',\n\t\t\t\t\t\ticon: pluginIcon,\n\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\tgetPlugin( template.theme )?.name || template.theme,\n\t\t\t\t\t\tisCustomized: template.source === 'custom',\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Added by site.\n\t\t\t\t// Template was created from scratch, but has no author. Author support\n\t\t\t\t// was only added to templates in WordPress 5.9. Fallback to showing the\n\t\t\t\t// site logo and title.\n\t\t\t\tif (\n\t\t\t\t\t! template.has_theme_file &&\n\t\t\t\t\ttemplate.source === 'custom' &&\n\t\t\t\t\t! template.author\n\t\t\t\t) {\n\t\t\t\t\tconst siteData = getEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'__unstableBase'\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'site',\n\t\t\t\t\t\ticon: globeIcon,\n\t\t\t\t\t\timageUrl: siteData?.site_logo\n\t\t\t\t\t\t\t? getMedia( siteData.site_logo )?.source_url\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\ttext: siteData?.name,\n\t\t\t\t\t\tisCustomized: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Added by user.\n\t\t\tconst user = getUser( template.author );\n\t\t\treturn {\n\t\t\t\ttype: 'user',\n\t\t\t\ticon: authorIcon,\n\t\t\t\timageUrl: user?.avatar_urls?.[ 48 ],\n\t\t\t\ttext: user?.nickname,\n\t\t\t\tisCustomized: false,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n}\n\n/**\n * @param {Object} props\n * @param {string} props.imageUrl\n */\nfunction AvatarImage( { imageUrl } ) {\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'edit-site-list-added-by__avatar', {\n\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t} ) }\n\t\t>\n\t\t\t<img\n\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\talt=\"\"\n\t\t\t\tsrc={ imageUrl }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * @param {Object} props\n * @param {TemplateType} props.postType The template post type.\n * @param {number} props.postId The template post id.\n */\nexport default function AddedBy( { postType, postId } ) {\n\tconst { text, icon, imageUrl, isCustomized } = useAddedBy(\n\t\tpostType,\n\t\tpostId\n\t);\n\n\treturn (\n\t\t<HStack alignment=\"left\">\n\t\t\t{ imageUrl ? (\n\t\t\t\t<AvatarImage imageUrl={ imageUrl } />\n\t\t\t) : (\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>\n\t\t\t\t{ text }\n\t\t\t\t{ isCustomized && (\n\t\t\t\t\t<span className=\"edit-site-list-added-by__customized-info\">\n\t\t\t\t\t\t{ postType === 'wp_template'\n\t\t\t\t\t\t\t? _x( 'Customized', 'template' )\n\t\t\t\t\t\t\t: _x( 'Customized', 'template part' ) }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</HStack>\n\t);\n}\n"]}
@@ -23,9 +23,10 @@ export default function List() {
23
23
 
24
24
  const {
25
25
  params: {
26
- postType: templateType
26
+ path
27
27
  }
28
28
  } = useLocation();
29
+ const templateType = path === '/wp_template/all' ? 'wp_template' : 'wp_template_part';
29
30
  useRegisterShortcuts();
30
31
  const {
31
32
  previousShortcut,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["store","coreStore","useSelect","InterfaceSkeleton","__","sprintf","keyboardShortcutsStore","EditorSnackbars","useRegisterShortcuts","Header","Table","useLocation","useTitle","List","params","postType","templateType","previousShortcut","nextShortcut","select","getAllShortcutKeyCombinations","getPostType","labels","name","itemsListLabel","items_list","detailedRegionLabels","header","body","undefined","previous","next"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,iBAAT,QAAkC,sBAAlC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASL,KAAK,IAAIM,sBAAlB,QAAgD,+BAAhD;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,KAAP,MAAkB,SAAlB;AACA,SAASC,WAAT,QAA4B,WAA5B;AACA,OAAOC,QAAP,MAAqB,qBAArB;AAEA,eAAe,SAASC,IAAT,GAAgB;AAAA;;AAC9B,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,QAAQ,EAAEC;AAAZ;AADH,MAEFL,WAAW,EAFf;AAIAH,EAAAA,oBAAoB;AAEpB,QAAM;AAAES,IAAAA,gBAAF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QAAQ,EAAEb,gBADC;AAEXc,MAAAA,IAAI,EAAEb;AAFK;AANb,IADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { InterfaceSkeleton } from '@wordpress/interface';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { EditorSnackbars } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport useRegisterShortcuts from './use-register-shortcuts';\nimport Header from './header';\nimport Table from './table';\nimport { useLocation } from '../routes';\nimport useTitle from '../routes/use-title';\n\nexport default function List() {\n\tconst {\n\t\tparams: { postType: templateType },\n\t} = useLocation();\n\n\tuseRegisterShortcuts();\n\n\tconst { previousShortcut, nextShortcut } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpreviousShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/previous-region' ),\n\t\t\tnextShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),\n\t\t};\n\t}, [] );\n\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tuseTitle( postType?.labels?.name );\n\n\t// `postType` could load in asynchronously. Only provide the detailed region labels if\n\t// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.\n\tconst itemsListLabel = postType?.labels?.items_list;\n\tconst detailedRegionLabels = postType\n\t\t? {\n\t\t\t\theader: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Header' as in the header area of that page.\n\t\t\t\t\t__( '%s - Header' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t\t\tbody: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Content' as in the content area of that page.\n\t\t\t\t\t__( '%s - Content' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t }\n\t\t: undefined;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tclassName=\"edit-site-list\"\n\t\t\tlabels={ detailedRegionLabels }\n\t\t\theader={ <Header templateType={ templateType } /> }\n\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\tcontent={ <Table templateType={ templateType } /> }\n\t\t\tshortcuts={ {\n\t\t\t\tprevious: previousShortcut,\n\t\t\t\tnext: nextShortcut,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/index.js"],"names":["store","coreStore","useSelect","InterfaceSkeleton","__","sprintf","keyboardShortcutsStore","EditorSnackbars","useRegisterShortcuts","Header","Table","useLocation","useTitle","List","params","path","templateType","previousShortcut","nextShortcut","select","getAllShortcutKeyCombinations","postType","getPostType","labels","name","itemsListLabel","items_list","detailedRegionLabels","header","body","undefined","previous","next"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,iBAAT,QAAkC,sBAAlC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASL,KAAK,IAAIM,sBAAlB,QAAgD,+BAAhD;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,KAAP,MAAkB,SAAlB;AACA,SAASC,WAAT,QAA4B,WAA5B;AACA,OAAOC,QAAP,MAAqB,qBAArB;AAEA,eAAe,SAASC,IAAT,GAAgB;AAAA;;AAC9B,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA;AAAF;AADH,MAEFJ,WAAW,EAFf;AAGA,QAAMK,YAAY,GACjBD,IAAI,KAAK,kBAAT,GAA8B,aAA9B,GAA8C,kBAD/C;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EAAGA;AAAtB,MALX;AAMC,IAAA,SAAS,EAAG;AACXe,MAAAA,QAAQ,EAAEd,gBADC;AAEXe,MAAAA,IAAI,EAAEd;AAFK;AANb,IADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { InterfaceSkeleton } from '@wordpress/interface';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { EditorSnackbars } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport useRegisterShortcuts from './use-register-shortcuts';\nimport Header from './header';\nimport Table from './table';\nimport { useLocation } from '../routes';\nimport useTitle from '../routes/use-title';\n\nexport default function List() {\n\tconst {\n\t\tparams: { path },\n\t} = useLocation();\n\tconst templateType =\n\t\tpath === '/wp_template/all' ? 'wp_template' : 'wp_template_part';\n\n\tuseRegisterShortcuts();\n\n\tconst { previousShortcut, nextShortcut } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpreviousShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/previous-region' ),\n\t\t\tnextShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),\n\t\t};\n\t}, [] );\n\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tuseTitle( postType?.labels?.name );\n\n\t// `postType` could load in asynchronously. Only provide the detailed region labels if\n\t// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.\n\tconst itemsListLabel = postType?.labels?.items_list;\n\tconst detailedRegionLabels = postType\n\t\t? {\n\t\t\t\theader: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Header' as in the header area of that page.\n\t\t\t\t\t__( '%s - Header' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t\t\tbody: sprintf(\n\t\t\t\t\t// translators: %s - the name of the page, 'Content' as in the content area of that page.\n\t\t\t\t\t__( '%s - Content' ),\n\t\t\t\t\titemsListLabel\n\t\t\t\t),\n\t\t }\n\t\t: undefined;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tclassName=\"edit-site-list\"\n\t\t\tlabels={ detailedRegionLabels }\n\t\t\theader={ <Header templateType={ templateType } /> }\n\t\t\tnotices={ <EditorSnackbars /> }\n\t\t\tcontent={ <Table templateType={ templateType } /> }\n\t\t\tshortcuts={ {\n\t\t\t\tprevious: previousShortcut,\n\t\t\t\tnext: nextShortcut,\n\t\t\t} }\n\t\t/>\n\t);\n}\n"]}
@@ -72,15 +72,16 @@ export default function Table(_ref) {
72
72
  }, createElement(Link, {
73
73
  params: {
74
74
  postId: template.id,
75
- postType: template.type
75
+ postType: template.type,
76
+ canvas: 'edit'
76
77
  }
77
78
  }, decodeEntities(((_template$title = template.title) === null || _template$title === void 0 ? void 0 : _template$title.rendered) || template.slug))), decodeEntities(template.description)), createElement("td", {
78
79
  className: "edit-site-list-table-column",
79
80
  role: "cell"
80
- }, createElement(AddedBy, {
81
- templateType: templateType,
82
- template: template
83
- })), createElement("td", {
81
+ }, template ? createElement(AddedBy, {
82
+ postType: template.type,
83
+ postId: template.id
84
+ }) : null), createElement("td", {
84
85
  className: "edit-site-list-table-column",
85
86
  role: "cell"
86
87
  }, createElement(Actions, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/list/table.js"],"names":["useSelect","store","coreStore","useEntityRecords","__","sprintf","VisuallyHidden","__experimentalHeading","Heading","decodeEntities","Link","Actions","AddedBy","Table","templateType","records","templates","isResolving","isLoading","per_page","postType","select","getPostType","length","labels","name","toLowerCase","sortedTemplates","sort","a","b","slug","localeCompare","map","template","id","postId","type","title","rendered","description"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK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D,CAtBD,EA4BC;AAAI,QAAA,SAAS,EAAC,6BAAd;AAA4C,QAAA,IAAI,EAAC;AAAjD,SACC,cAAC,OAAD;AAAS,QAAA,QAAQ,EAAGA;AAApB,QADD,CA5BD,CADsB;AAAA,KAArB,CADH,CAxBD;AAHD;AAiEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore, useEntityRecords } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tVisuallyHidden,\n\t__experimentalHeading as Heading,\n} from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport Link from '../routes/link';\nimport Actions from './actions';\nimport AddedBy from './added-by';\n\nexport default function Table( { templateType } ) {\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\ttemplateType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tif ( ! templates || isLoading ) {\n\t\treturn null;\n\t}\n\n\tif ( ! templates.length ) {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: The template type name, should be either \"templates\" or \"template parts\".\n\t\t\t\t\t__( 'No %s found.' ),\n\t\t\t\t\tpostType?.labels?.name?.toLowerCase()\n\t\t\t\t) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst sortedTemplates = [ ...templates ];\n\tsortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );\n\n\treturn (\n\t\t// These explicit aria roles are needed for Safari.\n\t\t// See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables\n\t\t<table className=\"edit-site-list-table\" role=\"table\">\n\t\t\t<thead>\n\t\t\t\t<tr className=\"edit-site-list-table-head\" role=\"row\">\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Template' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Added by' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>\n\t\t\t\t\t</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\n\t\t\t<tbody>\n\t\t\t\t{ sortedTemplates.map( ( template ) => (\n\t\t\t\t\t<tr\n\t\t\t\t\t\tkey={ template.id }\n\t\t\t\t\t\tclassName=\"edit-site-list-table-row\"\n\t\t\t\t\t\trole=\"row\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Heading level={ 4 }>\n\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\tpostType: template.type,\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\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\ttemplate.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\ttemplate.slug\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t\t{ decodeEntities( template.description ) }\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<AddedBy\n\t\t\t\t\t\t\t\ttemplateType={ templateType }\n\t\t\t\t\t\t\t\ttemplate={ template }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Actions template={ template } />\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t) ) }\n\t\t\t</tbody>\n\t\t</table>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/list/table.js"],"names":["useSelect","store","coreStore","useEntityRecords","__","sprintf","VisuallyHidden","__experimentalHeading","Heading","decodeEntities","Link","Actions","AddedBy","Table","templateType","records","templates","isResolving","isLoading","per_page","postType","select","getPostType","length","labels","name","toLowerCase","sortedTemplates","sort","a","b","slug","localeCompare","map","template","id","postId","type","canvas","title","rendered","description"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,EAA6BC,gBAA7B,QAAqD,sBAArD;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,cADD,EAECC,qBAAqB,IAAIC,OAF1B,QAGO,uBAHP;AAIA,SAASC,cAAT,QAA+B,0BAA/B;AAEA;AACA;AACA;;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAOC,OAAP,MAAoB,YAApB;AAEA,eAAe,SAASC,KAAT,OAAmC;AAAA,MAAnB;AAAEC,IAAAA;AAAF,GAAmB;AACjD,QAAM;AAAEC,IAAAA,OAAO,EAAEC,SAAX;AAAsBC,IAAAA,WAAW,EAAEC;AAAnC,MAAiDf,gBAAgB,CACtE,UADsE,EAEtEW,YAFsE,EAGtE;AACCK,IAAAA,QAAQ,EAAE,CAAC;AADZ,GAHsE,CAAvE;AAOA,QAAMC,QAAQ,GAAGpB,SAAS,CACvBqB,MAAF,IAAcA,MAAM,CAAEnB,SAAF,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AGC,QAAA,IAAI,EAAC;AAHN,SAKC;AAAI,QAAA,SAAS,EAAC,6BAAd;AAA4C,QAAA,IAAI,EAAC;AAAjD,SACC,cAAC,OAAD;AAAS,QAAA,KAAK,EAAG;AAAjB,SACC,cAAC,IAAD;AACC,QAAA,MAAM,EAAG;AACRC,UAAAA,MAAM,EAAEF,QAAQ,CAACC,EADT;AAERf,UAAAA,QAAQ,EAAEc,QAAQ,CAACG,IAFX;AAGRC,UAAAA,MAAM,EAAE;AAHA;AADV,SAOG7B,cAAc,CACf,oBAAAyB,QAAQ,CAACK,KAAT,oEAAgBC,QAAhB,KACCN,QAAQ,CAACH,IAFK,CAPjB,CADD,CADD,EAeGtB,cAAc,CAAEyB,QAAQ,CAACO,WAAX,CAfjB,CALD,EAuBC;AAAI,QAAA,SAAS,EAAC,6BAAd;AAA4C,QAAA,IAAI,EAAC;AAAjD,SACGP,QAAQ,GACT,cAAC,OAAD;AACC,QAAA,QAAQ,EAAGA,QAAQ,CAACG,IADrB;AAEC,QAAA,MAAM,EAAGH,QAAQ,CAACC;AAFnB,QADS,GAKN,IANL,CAvBD,EA+BC;AAAI,QAAA,SAAS,EAAC,6BAAd;AAA4C,QAAA,IAAI,EAAC;AAAjD,SACC,cAAC,OAAD;AAAS,QAAA,QAAQ,EAAGD;AAApB,QADD,CA/BD,CADsB;AAAA,KAArB,CADH,CAxBD;AAHD;AAoEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore, useEntityRecords } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tVisuallyHidden,\n\t__experimentalHeading as Heading,\n} from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport Link from '../routes/link';\nimport Actions from './actions';\nimport AddedBy from './added-by';\n\nexport default function Table( { templateType } ) {\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\ttemplateType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst postType = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( templateType ),\n\t\t[ templateType ]\n\t);\n\n\tif ( ! templates || isLoading ) {\n\t\treturn null;\n\t}\n\n\tif ( ! templates.length ) {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: The template type name, should be either \"templates\" or \"template parts\".\n\t\t\t\t\t__( 'No %s found.' ),\n\t\t\t\t\tpostType?.labels?.name?.toLowerCase()\n\t\t\t\t) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst sortedTemplates = [ ...templates ];\n\tsortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );\n\n\treturn (\n\t\t// These explicit aria roles are needed for Safari.\n\t\t// See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables\n\t\t<table className=\"edit-site-list-table\" role=\"table\">\n\t\t\t<thead>\n\t\t\t\t<tr className=\"edit-site-list-table-head\" role=\"row\">\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Template' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Added by' ) }\n\t\t\t\t\t</th>\n\t\t\t\t\t<th\n\t\t\t\t\t\tclassName=\"edit-site-list-table-column\"\n\t\t\t\t\t\trole=\"columnheader\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<VisuallyHidden>{ __( 'Actions' ) }</VisuallyHidden>\n\t\t\t\t\t</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\n\t\t\t<tbody>\n\t\t\t\t{ sortedTemplates.map( ( template ) => (\n\t\t\t\t\t<tr\n\t\t\t\t\t\tkey={ template.id }\n\t\t\t\t\t\tclassName=\"edit-site-list-table-row\"\n\t\t\t\t\t\trole=\"row\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Heading level={ 4 }>\n\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\tparams={ {\n\t\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\t\tpostType: template.type,\n\t\t\t\t\t\t\t\t\t\tcanvas: 'edit',\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\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\ttemplate.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\ttemplate.slug\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t\t{ decodeEntities( template.description ) }\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t{ template ? (\n\t\t\t\t\t\t\t\t<AddedBy\n\t\t\t\t\t\t\t\t\tpostType={ template.type }\n\t\t\t\t\t\t\t\t\tpostId={ template.id }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td className=\"edit-site-list-table-column\" role=\"cell\">\n\t\t\t\t\t\t\t<Actions template={ template } />\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t) ) }\n\t\t\t</tbody>\n\t\t</table>\n\t);\n}\n"]}
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
4
4
  /**
5
5
  * WordPress dependencies
6
6
  */
7
- import { addQueryArgs } from '@wordpress/url';
7
+ import { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';
8
8
  /**
9
9
  * Internal dependencies
10
10
  */
@@ -26,8 +26,11 @@ export function useLink() {
26
26
  }
27
27
  }
28
28
 
29
+ const currentArgs = getQueryArgs(window.location.href);
30
+ const currentUrlWithoutArgs = removeQueryArgs(window.location.href, ...Object.keys(currentArgs));
31
+ const newUrl = addQueryArgs(currentUrlWithoutArgs, params);
29
32
  return {
30
- href: addQueryArgs(window.location.href, params),
33
+ href: newUrl,
31
34
  onClick
32
35
  };
33
36
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/routes/link.js"],"names":["addQueryArgs","useHistory","useLink","params","state","shouldReplace","history","onClick","event","preventDefault","replace","push","href","window","location","Link","children","props"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,SAA3B;AAEA,OAAO,SAASC,OAAT,GAA8D;AAAA,MAA5CC,MAA4C,uEAAnC,EAAmC;AAAA,MAA/BC,KAA+B;AAAA,MAAxBC,aAAwB,uEAAR,KAAQ;AACpE,QAAMC,OAAO,GAAGL,UAAU,EAA1B;;AAEA,WAASM,OAAT,CAAkBC,KAAlB,EAA0B;AACzBA,IAAAA,KAAK,CAACC,cAAN;;AAEA,QAAKJ,aAAL,EAAqB;AACpBC,MAAAA,OAAO,CAACI,OAAR,CAAiBP,MAAjB,EAAyBC,KAAzB;AACA,KAFD,MAEO;AACNE,MAAAA,OAAO,CAACK,IAAR,CAAcR,MAAd,EAAsBC,KAAtB;AACA;AACD;;AAED,SAAO;AACNQ,IAAAA,IAAI,EAAEZ,YAAY,CAAEa,MAAM,CAACC,QAAP,CAAgBF,IAAlB,EAAwBT,MAAxB,CADZ;AAENI,IAAAA;AAFM,GAAP;AAIA;AAED,eAAe,SAASQ,IAAT,OAMX;AAAA,MAN0B;AAC7BZ,IAAAA,MAAM,GAAG,EADoB;AAE7BC,IAAAA,KAF6B;AAG7BM,IAAAA,OAAO,EAAEL,aAAa,GAAG,KAHI;AAI7BW,IAAAA,QAJ6B;AAK7B,OAAGC;AAL0B,GAM1B;AACH,QAAM;AAAEL,IAAAA,IAAF;AAAQL,IAAAA;AAAR,MAAoBL,OAAO,CAAEC,MAAF,EAAUC,KAAV,EAAiBC,aAAjB,CAAjC;AAEA,SACC;AAAG,IAAA,IAAI,EAAGO,IAAV;AAAiB,IAAA,OAAO,EAAGL;AAA3B,KAA0CU,KAA1C,GACGD,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from './index';\n\nexport function useLink( params = {}, state, shouldReplace = false ) {\n\tconst history = useHistory();\n\n\tfunction onClick( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( shouldReplace ) {\n\t\t\thistory.replace( params, state );\n\t\t} else {\n\t\t\thistory.push( params, state );\n\t\t}\n\t}\n\n\treturn {\n\t\thref: addQueryArgs( window.location.href, params ),\n\t\tonClick,\n\t};\n}\n\nexport default function Link( {\n\tparams = {},\n\tstate,\n\treplace: shouldReplace = false,\n\tchildren,\n\t...props\n} ) {\n\tconst { href, onClick } = useLink( params, state, shouldReplace );\n\n\treturn (\n\t\t<a href={ href } onClick={ onClick } { ...props }>\n\t\t\t{ children }\n\t\t</a>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/routes/link.js"],"names":["addQueryArgs","getQueryArgs","removeQueryArgs","useHistory","useLink","params","state","shouldReplace","history","onClick","event","preventDefault","replace","push","currentArgs","window","location","href","currentUrlWithoutArgs","Object","keys","newUrl","Link","children","props"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,YAAvB,EAAqCC,eAArC,QAA4D,gBAA5D;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,SAA3B;AAEA,OAAO,SAASC,OAAT,GAA8D;AAAA,MAA5CC,MAA4C,uEAAnC,EAAmC;AAAA,MAA/BC,KAA+B;AAAA,MAAxBC,aAAwB,uEAAR,KAAQ;AACpE,QAAMC,OAAO,GAAGL,UAAU,EAA1B;;AAEA,WAASM,OAAT,CAAkBC,KAAlB,EAA0B;AACzBA,IAAAA,KAAK,CAACC,cAAN;;AAEA,QAAKJ,aAAL,EAAqB;AACpBC,MAAAA,OAAO,CAACI,OAAR,CAAiBP,MAAjB,EAAyBC,KAAzB;AACA,KAFD,MAEO;AACNE,MAAAA,OAAO,CAACK,IAAR,CAAcR,MAAd,EAAsBC,KAAtB;AACA;AACD;;AAED,QAAMQ,WAAW,GAAGb,YAAY,CAAEc,MAAM,CAACC,QAAP,CAAgBC,IAAlB,CAAhC;AACA,QAAMC,qBAAqB,GAAGhB,eAAe,CAC5Ca,MAAM,CAACC,QAAP,CAAgBC,IAD4B,EAE5C,GAAGE,MAAM,CAACC,IAAP,CAAaN,WAAb,CAFyC,CAA7C;AAIA,QAAMO,MAAM,GAAGrB,YAAY,CAAEkB,qBAAF,EAAyBb,MAAzB,CAA3B;AAEA,SAAO;AACNY,IAAAA,IAAI,EAAEI,MADA;AAENZ,IAAAA;AAFM,GAAP;AAIA;AAED,eAAe,SAASa,IAAT,OAMX;AAAA,MAN0B;AAC7BjB,IAAAA,MAAM,GAAG,EADoB;AAE7BC,IAAAA,KAF6B;AAG7BM,IAAAA,OAAO,EAAEL,aAAa,GAAG,KAHI;AAI7BgB,IAAAA,QAJ6B;AAK7B,OAAGC;AAL0B,GAM1B;AACH,QAAM;AAAEP,IAAAA,IAAF;AAAQR,IAAAA;AAAR,MAAoBL,OAAO,CAAEC,MAAF,EAAUC,KAAV,EAAiBC,aAAjB,CAAjC;AAEA,SACC;AAAG,IAAA,IAAI,EAAGU,IAAV;AAAiB,IAAA,OAAO,EAAGR;AAA3B,KAA0Ce,KAA1C,GACGD,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from './index';\n\nexport function useLink( params = {}, state, shouldReplace = false ) {\n\tconst history = useHistory();\n\n\tfunction onClick( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( shouldReplace ) {\n\t\t\thistory.replace( params, state );\n\t\t} else {\n\t\t\thistory.push( params, state );\n\t\t}\n\t}\n\n\tconst currentArgs = getQueryArgs( window.location.href );\n\tconst currentUrlWithoutArgs = removeQueryArgs(\n\t\twindow.location.href,\n\t\t...Object.keys( currentArgs )\n\t);\n\tconst newUrl = addQueryArgs( currentUrlWithoutArgs, params );\n\n\treturn {\n\t\thref: newUrl,\n\t\tonClick,\n\t};\n}\n\nexport default function Link( {\n\tparams = {},\n\tstate,\n\treplace: shouldReplace = false,\n\tchildren,\n\t...props\n} ) {\n\tconst { href, onClick } = useLink( params, state, shouldReplace );\n\n\treturn (\n\t\t<a href={ href } onClick={ onClick } { ...props }>\n\t\t\t{ children }\n\t\t</a>\n\t);\n}\n"]}
@@ -13,10 +13,7 @@ import { displayShortcut } from '@wordpress/keycodes';
13
13
  */
14
14
 
15
15
  import { store as editSiteStore } from '../../store';
16
- export default function SaveButton(_ref) {
17
- let {
18
- showTooltip = true
19
- } = _ref;
16
+ export default function SaveButton() {
20
17
  const {
21
18
  isDirty,
22
19
  isSaving,
@@ -66,7 +63,7 @@ export default function SaveButton(_ref) {
66
63
  & the tooltip is always rendered even when there's no keyboard shortcut.
67
64
  */
68
65
  ,
69
- showTooltip: showTooltip
66
+ showTooltip: true
70
67
  }, label);
71
68
  }
72
69
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/save-button/index.js"],"names":["useSelect","useDispatch","Button","__","store","coreStore","displayShortcut","editSiteStore","SaveButton","showTooltip","isDirty","isSaving","isSaveViewOpen","select","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","dirtyEntityRecords","isSaveViewOpened","length","some","record","kind","name","key","setIsSaveViewOpened","disabled","label","undefined","primary"],"mappings":";;AAAA;AACA;AACA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,+BAFX;AAGC,qBAAgBsB,QAHjB;AAIC,qBAAgBb,cAJjB;AAKC,IAAA,MAAM,EAAGD,QALV;AAMC,IAAA,OAAO,EAAGc,QAAQ,GAAGE,SAAH,GAAe,MAAMH,mBAAmB,CAAE,IAAF,CAN3D;AAOC,IAAA,KAAK,EAAGE;AACR;AACH;AACA;AACA;AAXE;AAYC,IAAA,QAAQ,EAAGD,QAAQ,GAAGE,SAAH,GAAerB,eAAe,CAACsB,OAAhB,CAAyB,GAAzB;AAClC;AACH;AACA;AACA;AACA;AACA;AAlBE;AAmBC,IAAA,WAAW,EAAGnB;AAnBf,KAqBGiB,KArBH,CADD;AAyBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function SaveButton( { showTooltip = true } ) {\n\tconst { isDirty, isSaving, isSaveViewOpen } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\tconst { isSaveViewOpened } = select( editSiteStore );\n\t\treturn {\n\t\t\tisDirty: dirtyEntityRecords.length > 0,\n\t\t\tisSaving: dirtyEntityRecords.some( ( record ) =>\n\t\t\t\tisSavingEntityRecord( record.kind, record.name, record.key )\n\t\t\t),\n\t\t\tisSaveViewOpen: isSaveViewOpened(),\n\t\t};\n\t}, [] );\n\tconst { setIsSaveViewOpened } = useDispatch( editSiteStore );\n\n\tconst disabled = ! isDirty || isSaving;\n\n\tconst label = __( 'Save' );\n\n\treturn (\n\t\t<Button\n\t\t\tvariant=\"primary\"\n\t\t\tclassName=\"edit-site-save-button__button\"\n\t\t\taria-disabled={ disabled }\n\t\t\taria-expanded={ isSaveViewOpen }\n\t\t\tisBusy={ isSaving }\n\t\t\tonClick={ disabled ? undefined : () => setIsSaveViewOpened( true ) }\n\t\t\tlabel={ label }\n\t\t\t/*\n\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t */\n\t\t\tshortcut={ disabled ? undefined : displayShortcut.primary( 's' ) }\n\t\t\t/*\n\t\t\t * Displaying the keyboard shortcut conditionally makes the tooltip\n\t\t\t * itself show conditionally. This would trigger a full-rerendering\n\t\t\t * of the button that we want to avoid. By setting `showTooltip`,\n\t\t\t & the tooltip is always rendered even when there's no keyboard shortcut.\n\t\t\t */\n\t\t\tshowTooltip={ showTooltip }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/save-button/index.js"],"names":["useSelect","useDispatch","Button","__","store","coreStore","displayShortcut","editSiteStore","SaveButton","isDirty","isSaving","isSaveViewOpen","select","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","dirtyEntityRecords","isSaveViewOpened","length","some","record","kind","name","key","setIsSaveViewOpened","disabled","label","undefined","primary"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,eAAT,QAAgC,qBAAhC;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,UAAT,GAAsB;AACpC,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,QAAX;AAAqBC,IAAAA;AAArB,MAAwCX,SAAS,CAAIY,MAAF,IAAc;AACtE,UAAM;AAAEC,MAAAA,mCAAF;AAAuCC,MAAAA;AAAvC,QACLF,MAAM,CAAEP,SAAF,CADP;;AAEA,UAAMU,kBAAkB,GAAGF,mCAAmC,EAA9D;;AACA,UAAM;AAAEG,MAAAA;AAAF,QAAuBJ,MAAM,CAAEL,aAAF,CAAnC;AACA,WAAO;AACNE,MAAAA,OAAO,EAAEM,kBAAkB,CAACE,MAAnB,GAA4B,CAD/B;AAENP,MAAAA,QAAQ,EAAEK,kBAAkB,CAACG,IAAnB,CAA2BC,MAAF,IAClCL,oBAAoB,CAAEK,MAAM,CAACC,IAAT,EAAeD,MAAM,CAACE,IAAtB,EAA4BF,MAAM,CAACG,GAAnC,CADX,CAFJ;AAKNX,MAAAA,cAAc,EAAEK,gBAAgB;AAL1B,KAAP;AAOA,GAZsD,EAYpD,EAZoD,CAAvD;AAaA,QAAM;AAAEO,IAAAA;AAAF,MAA0BtB,WAAW,CAAEM,aAAF,CAA3C;AAEA,QAAMiB,QAAQ,GAAG,CAAEf,OAAF,IAAaC,QAA9B;;AAEA,QAAMe,KAAK,GAAGtB,EAAE,CAAE,MAAF,CAAhB;;AAEA,SACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,SAAS,EAAC,+BAFX;AAGC,qBAAgBqB,QAHjB;AAIC,qBAAgBb,cAJjB;AAKC,IAAA,MAAM,EAAGD,QALV;AAMC,IAAA,OAAO,EAAGc,QAAQ,GAAGE,SAAH,GAAe,MAAMH,mBAAmB,CAAE,IAAF,CAN3D;AAOC,IAAA,KAAK,EAAGE;AACR;AACH;AACA;AACA;AAXE;AAYC,IAAA,QAAQ,EAAGD,QAAQ,GAAGE,SAAH,GAAepB,eAAe,CAACqB,OAAhB,CAAyB,GAAzB;AAClC;AACH;AACA;AACA;AACA;AACA;AAlBE;AAmBC,IAAA,WAAW;AAnBZ,KAqBGF,KArBH,CADD;AAyBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function SaveButton() {\n\tconst { isDirty, isSaving, isSaveViewOpen } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\tconst { isSaveViewOpened } = select( editSiteStore );\n\t\treturn {\n\t\t\tisDirty: dirtyEntityRecords.length > 0,\n\t\t\tisSaving: dirtyEntityRecords.some( ( record ) =>\n\t\t\t\tisSavingEntityRecord( record.kind, record.name, record.key )\n\t\t\t),\n\t\t\tisSaveViewOpen: isSaveViewOpened(),\n\t\t};\n\t}, [] );\n\tconst { setIsSaveViewOpened } = useDispatch( editSiteStore );\n\n\tconst disabled = ! isDirty || isSaving;\n\n\tconst label = __( 'Save' );\n\n\treturn (\n\t\t<Button\n\t\t\tvariant=\"primary\"\n\t\t\tclassName=\"edit-site-save-button__button\"\n\t\t\taria-disabled={ disabled }\n\t\t\taria-expanded={ isSaveViewOpen }\n\t\t\tisBusy={ isSaving }\n\t\t\tonClick={ disabled ? undefined : () => setIsSaveViewOpened( true ) }\n\t\t\tlabel={ label }\n\t\t\t/*\n\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t */\n\t\t\tshortcut={ disabled ? undefined : displayShortcut.primary( 's' ) }\n\t\t\t/*\n\t\t\t * Displaying the keyboard shortcut conditionally makes the tooltip\n\t\t\t * itself show conditionally. This would trigger a full-rerendering\n\t\t\t * of the button that we want to avoid. By setting `showTooltip`,\n\t\t\t & the tooltip is always rendered even when there's no keyboard shortcut.\n\t\t\t */\n\t\t\tshowTooltip\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n"]}
@@ -0,0 +1,68 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { useSelect, useDispatch } from '@wordpress/data';
7
+ import { Button, __experimentalHStack as HStack } from '@wordpress/components';
8
+ import { sprintf, __, _n } from '@wordpress/i18n';
9
+ import { store as coreStore } from '@wordpress/core-data';
10
+ import { displayShortcut } from '@wordpress/keycodes';
11
+ import { check } from '@wordpress/icons';
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+
16
+ import { store as editSiteStore } from '../../store';
17
+ export default function SaveButton() {
18
+ const {
19
+ countUnsavedChanges,
20
+ isDirty,
21
+ isSaving,
22
+ isSaveViewOpen
23
+ } = useSelect(select => {
24
+ const {
25
+ __experimentalGetDirtyEntityRecords,
26
+ isSavingEntityRecord
27
+ } = select(coreStore);
28
+
29
+ const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
30
+
31
+ const {
32
+ isSaveViewOpened
33
+ } = select(editSiteStore);
34
+ return {
35
+ isDirty: dirtyEntityRecords.length > 0,
36
+ isSaving: dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)),
37
+ isSaveViewOpen: isSaveViewOpened(),
38
+ countUnsavedChanges: dirtyEntityRecords.length
39
+ };
40
+ }, []);
41
+ const {
42
+ setIsSaveViewOpened
43
+ } = useDispatch(editSiteStore);
44
+ const disabled = !isDirty || isSaving;
45
+ const label = disabled ? __('Saved') : __('Save');
46
+ return createElement(HStack, {
47
+ className: "edit-site-save-hub",
48
+ alignment: "right",
49
+ spacing: 4
50
+ }, isDirty && createElement("span", null, sprintf( // translators: %d: number of unsaved changes (number).
51
+ _n('%d unsaved change', '%d unsaved changes', countUnsavedChanges), countUnsavedChanges)), createElement(Button, {
52
+ className: "edit-site-save-hub__button",
53
+ variant: disabled ? undefined : 'primary',
54
+ "aria-disabled": disabled,
55
+ "aria-expanded": isSaveViewOpen,
56
+ isBusy: isSaving,
57
+ onClick: disabled ? undefined : () => setIsSaveViewOpened(true),
58
+ label: label
59
+ /*
60
+ * We want the tooltip to show the keyboard shortcut only when the
61
+ * button does something, i.e. when it's not disabled.
62
+ */
63
+ ,
64
+ shortcut: disabled ? undefined : displayShortcut.primary('s'),
65
+ icon: disabled ? check : undefined
66
+ }, label));
67
+ }
68
+ //# sourceMappingURL=index.js.map