@plone/volto 19.1.6 → 19.2.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 (152) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/locales/af/LC_MESSAGES/volto.po +5 -0
  3. package/locales/af.json +1 -1
  4. package/locales/ar/LC_MESSAGES/volto.po +5 -0
  5. package/locales/ar.json +1 -1
  6. package/locales/bg/LC_MESSAGES/volto.po +5 -0
  7. package/locales/bg.json +1 -1
  8. package/locales/bn/LC_MESSAGES/volto.po +5 -0
  9. package/locales/bn.json +1 -1
  10. package/locales/ca/LC_MESSAGES/volto.po +5 -0
  11. package/locales/ca.json +1 -1
  12. package/locales/cs/LC_MESSAGES/volto.po +5 -0
  13. package/locales/cs.json +1 -1
  14. package/locales/cy/LC_MESSAGES/volto.po +5 -0
  15. package/locales/cy.json +1 -1
  16. package/locales/da/LC_MESSAGES/volto.po +5 -0
  17. package/locales/da.json +1 -1
  18. package/locales/de/LC_MESSAGES/volto.po +5 -0
  19. package/locales/de.json +1 -1
  20. package/locales/el/LC_MESSAGES/volto.po +5 -0
  21. package/locales/el.json +1 -1
  22. package/locales/en/LC_MESSAGES/volto.po +5 -0
  23. package/locales/en.json +1 -1
  24. package/locales/en_AU/LC_MESSAGES/volto.po +5 -0
  25. package/locales/en_AU.json +1 -1
  26. package/locales/en_GB/LC_MESSAGES/volto.po +5 -0
  27. package/locales/en_GB.json +1 -1
  28. package/locales/eo/LC_MESSAGES/volto.po +5 -0
  29. package/locales/eo.json +1 -1
  30. package/locales/es/LC_MESSAGES/volto.po +5 -0
  31. package/locales/es.json +1 -1
  32. package/locales/et/LC_MESSAGES/volto.po +5 -0
  33. package/locales/et.json +1 -1
  34. package/locales/eu/LC_MESSAGES/volto.po +5 -0
  35. package/locales/eu.json +1 -1
  36. package/locales/fa/LC_MESSAGES/volto.po +5 -0
  37. package/locales/fa.json +1 -1
  38. package/locales/fi/LC_MESSAGES/volto.po +5 -0
  39. package/locales/fi.json +1 -1
  40. package/locales/fr/LC_MESSAGES/volto.po +5 -0
  41. package/locales/fr.json +1 -1
  42. package/locales/fu/LC_MESSAGES/volto.po +5 -0
  43. package/locales/fu.json +1 -1
  44. package/locales/gl/LC_MESSAGES/volto.po +5 -0
  45. package/locales/gl.json +1 -1
  46. package/locales/he/LC_MESSAGES/volto.po +5 -0
  47. package/locales/he.json +1 -1
  48. package/locales/hi/LC_MESSAGES/volto.po +5 -0
  49. package/locales/hi.json +1 -1
  50. package/locales/hr/LC_MESSAGES/volto.po +5 -0
  51. package/locales/hr.json +1 -1
  52. package/locales/hu/LC_MESSAGES/volto.po +5 -0
  53. package/locales/hu.json +1 -1
  54. package/locales/hy/LC_MESSAGES/volto.po +5 -0
  55. package/locales/hy.json +1 -1
  56. package/locales/id/LC_MESSAGES/volto.po +5 -0
  57. package/locales/id.json +1 -1
  58. package/locales/it/LC_MESSAGES/volto.po +5 -0
  59. package/locales/it.json +1 -1
  60. package/locales/ja/LC_MESSAGES/volto.po +5 -0
  61. package/locales/ja.json +1 -1
  62. package/locales/ka/LC_MESSAGES/volto.po +5 -0
  63. package/locales/ka.json +1 -1
  64. package/locales/kn/LC_MESSAGES/volto.po +5 -0
  65. package/locales/kn.json +1 -1
  66. package/locales/ko/LC_MESSAGES/volto.po +5 -0
  67. package/locales/ko.json +1 -1
  68. package/locales/lt/LC_MESSAGES/volto.po +5 -0
  69. package/locales/lt.json +1 -1
  70. package/locales/lv/LC_MESSAGES/volto.po +5 -0
  71. package/locales/lv.json +1 -1
  72. package/locales/mi/LC_MESSAGES/volto.po +5 -0
  73. package/locales/mi.json +1 -1
  74. package/locales/mk/LC_MESSAGES/volto.po +5 -0
  75. package/locales/mk.json +1 -1
  76. package/locales/my/LC_MESSAGES/volto.po +5 -0
  77. package/locales/my.json +1 -1
  78. package/locales/nb_NO/LC_MESSAGES/volto.po +5 -0
  79. package/locales/nb_NO.json +1 -1
  80. package/locales/nl/LC_MESSAGES/volto.po +5 -0
  81. package/locales/nl.json +1 -1
  82. package/locales/nn/LC_MESSAGES/volto.po +5 -0
  83. package/locales/nn.json +1 -1
  84. package/locales/pl/LC_MESSAGES/volto.po +5 -0
  85. package/locales/pl.json +1 -1
  86. package/locales/pt/LC_MESSAGES/volto.po +5 -0
  87. package/locales/pt.json +1 -1
  88. package/locales/pt_BR/LC_MESSAGES/volto.po +5 -0
  89. package/locales/pt_BR.json +1 -1
  90. package/locales/rm/LC_MESSAGES/volto.po +5 -0
  91. package/locales/rm.json +1 -1
  92. package/locales/ro/LC_MESSAGES/volto.po +5 -0
  93. package/locales/ro.json +1 -1
  94. package/locales/ru/LC_MESSAGES/volto.po +5 -0
  95. package/locales/ru.json +1 -1
  96. package/locales/sk/LC_MESSAGES/volto.po +5 -0
  97. package/locales/sk.json +1 -1
  98. package/locales/sl/LC_MESSAGES/volto.po +5 -0
  99. package/locales/sl.json +1 -1
  100. package/locales/sm/LC_MESSAGES/volto.po +5 -0
  101. package/locales/sm.json +1 -1
  102. package/locales/sq/LC_MESSAGES/volto.po +5 -0
  103. package/locales/sq.json +1 -1
  104. package/locales/sr/LC_MESSAGES/volto.po +5 -0
  105. package/locales/sr.json +1 -1
  106. package/locales/sr@cyrl/LC_MESSAGES/volto.po +5 -0
  107. package/locales/sr@cyrl.json +1 -1
  108. package/locales/sr@latn/LC_MESSAGES/volto.po +5 -0
  109. package/locales/sr@latn.json +1 -1
  110. package/locales/sv/LC_MESSAGES/volto.po +5 -0
  111. package/locales/sv.json +1 -1
  112. package/locales/ta/LC_MESSAGES/volto.po +5 -0
  113. package/locales/ta.json +1 -1
  114. package/locales/te/LC_MESSAGES/volto.po +5 -0
  115. package/locales/te.json +1 -1
  116. package/locales/th/LC_MESSAGES/volto.po +5 -0
  117. package/locales/th.json +1 -1
  118. package/locales/to/LC_MESSAGES/volto.po +5 -0
  119. package/locales/to.json +1 -1
  120. package/locales/tr/LC_MESSAGES/volto.po +5 -0
  121. package/locales/tr.json +1 -1
  122. package/locales/uk/LC_MESSAGES/volto.po +5 -0
  123. package/locales/uk.json +1 -1
  124. package/locales/vi/LC_MESSAGES/volto.po +5 -0
  125. package/locales/vi.json +1 -1
  126. package/locales/volto.pot +6 -1
  127. package/locales/zh_CN/LC_MESSAGES/volto.po +5 -0
  128. package/locales/zh_CN.json +1 -1
  129. package/locales/zh_Hant/LC_MESSAGES/volto.po +5 -0
  130. package/locales/zh_Hant.json +1 -1
  131. package/locales/zh_Hant_HK/LC_MESSAGES/volto.po +5 -0
  132. package/locales/zh_Hant_HK.json +1 -1
  133. package/package.json +6 -6
  134. package/src/actions/querystringsearch/querystringsearch.test.js +107 -0
  135. package/src/actions/querystringsearch/querystringsearch.ts +135 -0
  136. package/src/components/manage/Blocks/Listing/getAsyncData.js +5 -0
  137. package/src/components/manage/Blocks/Listing/withQuerystringResults.jsx +18 -5
  138. package/src/components/manage/Widgets/QuerystringWidget.jsx +18 -1
  139. package/src/components/manage/Widgets/QuerystringWidget.test.jsx +11 -0
  140. package/src/config/server.js +2 -0
  141. package/src/express-middleware/images.js +0 -1
  142. package/src/express-middleware/portraits.js +34 -0
  143. package/src/helpers/Api/PloneBackendAPIResourceWithAuth.js +39 -0
  144. package/src/helpers/Api/PloneBackendAPIResourceWithAuth.test.js +60 -0
  145. package/src/helpers/Pagination/Pagination.test.ts +259 -0
  146. package/src/helpers/Pagination/Pagination.ts +151 -0
  147. package/types/actions/querystringsearch/querystringsearch.d.ts +51 -3
  148. package/types/components/manage/Widgets/QuerystringWidget.d.ts +6 -0
  149. package/types/express-middleware/portraits.d.ts +1 -0
  150. package/types/helpers/Api/PloneBackendAPIResourceWithAuth.d.ts +1 -0
  151. package/types/helpers/Pagination/Pagination.d.ts +74 -0
  152. package/src/actions/querystringsearch/querystringsearch.js +0 -63
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Pagination helpers.
3
+ * @module helpers/Pagination/Pagination
4
+ */
5
+ /**
6
+ * A value that is meant to represent an integer, but which reaches us from
7
+ * user-editable block settings. The querystring widget stores `offset`,
8
+ * `limit` and `b_size` as JSON schema `number` fields, so a value may arrive
9
+ * as a string (`'3'`), as a float (`3.7`), or not at all.
10
+ */
11
+ export type IntegerLike = number | string | null | undefined;
12
+ /**
13
+ * Compute the `b_start` index for a `@querystring-search` request: the index
14
+ * of the first item the backend should return for the requested page.
15
+ *
16
+ * `offset` shifts the whole result set, letting a listing skip the first N
17
+ * items of its query while paginating over the remainder.
18
+ *
19
+ * Every parameter is coerced to an integer and the result is always a
20
+ * non-negative integer, so a malformed block setting degrades to a sane batch
21
+ * rather than sending `NaN` to the backend. When neither `bSize` nor
22
+ * `defaultPageSize` yields a positive batch size, paging cannot be applied and
23
+ * the result is `offset` alone.
24
+ * @function computeBStart
25
+ * @param {IntegerLike} page 1-based page number. Defaults to the first page.
26
+ * @param {IntegerLike} offset Number of leading items to skip. Defaults to 0.
27
+ * @param {IntegerLike} bSize Batch size configured on the block, if any.
28
+ * @param {IntegerLike} defaultPageSize Batch size to use when bSize is unset.
29
+ * @returns {number} A non-negative integer `b_start` index.
30
+ */
31
+ export declare function computeBStart(page: IntegerLike, offset: IntegerLike, bSize: IntegerLike, defaultPageSize: IntegerLike): number;
32
+ /**
33
+ * Compute the effective `limit` for a `@querystring-search` request.
34
+ *
35
+ * A listing that skips the first `offset` items still wants `limit` items
36
+ * afterwards, so the backend has to return the skipped items on top of the
37
+ * wanted ones: `offset + limit`.
38
+ *
39
+ * A limit of zero, or one that resolves to no usable number, means "no limit"
40
+ * — matching `plone.app.querystring`'s querybuilder, whose `limit` defaults to
41
+ * 0 and is only applied when truthy. Returning `offset` in that case would cap
42
+ * the batch at the very items the listing is about to skip, leaving it empty.
43
+ * @function computeLimit
44
+ * @param {IntegerLike} offset Number of leading items to skip. Defaults to 0.
45
+ * @param {IntegerLike} limit Number of items the listing wants, if capped.
46
+ * @returns {number | null} A positive integer limit, or null for no limit.
47
+ */
48
+ export declare function computeLimit(offset: IntegerLike, limit: IntegerLike): number | null;
49
+ /**
50
+ * Compute how many items a listing can actually show.
51
+ *
52
+ * The `items_total` reported by `@querystring-search` is the length of the
53
+ * whole result set: `plone.restapi`'s HypermediaBatch derives it from the
54
+ * sequence length, so `b_start` never reduces it. The items an offset skips
55
+ * are counted in there even though the listing never renders them.
56
+ * @function computeVisibleTotal
57
+ * @param {IntegerLike} total The `items_total` reported by the backend.
58
+ * @param {IntegerLike} offset Number of leading items skipped. Defaults to 0.
59
+ * @returns {number} A non-negative integer count of reachable items.
60
+ */
61
+ export declare function computeVisibleTotal(total: IntegerLike, offset: IntegerLike): number;
62
+ /**
63
+ * Compute how many pages a listing spans.
64
+ *
65
+ * `total` is expected to be the reachable item count, so pass the result of
66
+ * `computeVisibleTotal` for an offset listing rather than the raw backend
67
+ * total. Otherwise the listing advertises pages that resolve to an empty batch.
68
+ * @function computeTotalPages
69
+ * @param {IntegerLike} total Number of items the listing can show.
70
+ * @param {IntegerLike} bSize Batch size, i.e. items per page.
71
+ * @returns {number} A non-negative integer page count, 0 when there is no
72
+ * usable batch size.
73
+ */
74
+ export declare function computeTotalPages(total: IntegerLike, bSize: IntegerLike): number;
@@ -1,63 +0,0 @@
1
- import { GET_QUERYSTRING_RESULTS } from '@plone/volto/constants/ActionTypes';
2
- import config from '@plone/volto/registry';
3
-
4
- /**
5
- * Get querystring results.
6
- * @function getQueryStringResults
7
- * @param {Object} data Data.
8
- * @returns {Object} Get querystringsearch results action.
9
- */
10
- export function getQueryStringResults(path, data, subrequest, page) {
11
- const { settings } = config;
12
-
13
- // fixes https://github.com/plone/volto/issues/1059
14
- let requestData = JSON.parse(JSON.stringify(data));
15
-
16
- if (data?.depth != null) {
17
- delete requestData.depth;
18
- requestData.query.forEach((q) => {
19
- if (q.i === 'path') {
20
- // fixes https://github.com/plone/volto/issues/8349
21
- // Skip if depth is already embedded in the path value (e.g. set via object browser)
22
- const hasEmbeddedDepth = /::\d+$/.test(q.v);
23
- if (!hasEmbeddedDepth) q.v += '::' + data.depth;
24
- }
25
- });
26
- }
27
-
28
- // fixes https://github.com/plone/volto/issues/2397
29
- if (requestData?.sort_order !== null) {
30
- if (typeof requestData.sort_order === 'boolean') {
31
- requestData.sort_order = requestData.sort_order
32
- ? 'descending'
33
- : 'ascending';
34
- }
35
- }
36
-
37
- const query = {
38
- ...requestData,
39
- ...(!requestData.b_size && {
40
- b_size: settings.defaultPageSize,
41
- }),
42
- ...(page && {
43
- b_start: requestData.b_size
44
- ? data.b_size * (page - 1)
45
- : settings.defaultPageSize * (page - 1),
46
- }),
47
- query: requestData?.query,
48
- };
49
-
50
- return {
51
- type: GET_QUERYSTRING_RESULTS,
52
- subrequest,
53
- request: {
54
- op: settings.querystringSearchGet ? 'get' : 'post',
55
- path: `${path}/@querystring-search${
56
- settings.querystringSearchGet
57
- ? `?query=${encodeURIComponent(JSON.stringify(query))}`
58
- : ''
59
- }`,
60
- data: settings.querystringSearchGet ? null : query,
61
- },
62
- };
63
- }