@redturtle/volto-external-listing-block 0.0.0-stage → 0.1.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.
@@ -0,0 +1,25 @@
1
+ {
2
+ "hooks": {
3
+ "after:bump": [
4
+ "pipx run towncrier build --draft --yes --version ${version} > .changelog.draft",
5
+ "pipx run towncrier build --yes --version ${version}"
6
+ ],
7
+ "after:release": "rm .changelog.draft"
8
+ },
9
+ "npm": {
10
+ "publish": false
11
+ },
12
+ "git": {
13
+ "changelog": "pipx run towncrier build --draft --yes --version 0.0.0",
14
+ "requireUpstream": false,
15
+ "requireCleanWorkingDir": false,
16
+ "commitMessage": "Release @redturtle/volto-external-listing-block ${version}",
17
+ "tagName": "volto-external-listing-block@${version}",
18
+ "tagAnnotation": "Release @redturtle/volto-external-listing-block ${version}"
19
+ },
20
+ "github": {
21
+ "release": true,
22
+ "releaseName": "@redturtle/volto-external-listing-block ${version}",
23
+ "releaseNotes": "cat .changelog.draft"
24
+ }
25
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Release Notes
2
+
3
+ <!-- You should *NOT* be adding new change log entries to this file.
4
+ You should create a file in the news directory instead.
5
+ For helpful instructions, please see:
6
+ https://6.docs.plone.org/contributing/index.html?highlight=towncrier#change-log-entry
7
+ -->
8
+
9
+ <!-- towncrier release notes start -->
10
+
11
+ ## 0.1.0 (2026-12-02)
12
+
13
+ ## 0.1.0-alpha.2 (2026-12-02)
14
+
15
+ ## 0.1.0-alpha.1 (2026-12-02)
16
+
17
+ ### Feature
18
+
19
+ - Initial (experimental) release: "External listing" block that runs the listing query against a remote Plone site configured in `config.settings`.
package/README.md CHANGED
@@ -1,3 +1,148 @@
1
- # Temporary Holding Version
1
+ # Volto External Listing Block (@redturtle/volto-external-listing-block)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **⚠️ Experimental (alpha).** The API, the configuration and the block data
4
+ > may change between releases without a deprecation period.
5
+
6
+ A Volto block, **External listing**, that works like the standard Listing block
7
+ but runs its query on **another Plone site**, chosen from a list of sites
8
+ defined in your project configuration.
9
+
10
+ - The editor builds the query with the usual querystring widget: indexes,
11
+ operators and vocabularies in the block sidebar are the **local** ones.
12
+ - Only the query itself (`@querystring-search`) is executed on the remote site.
13
+ - Results are rendered by the standard Listing **variations** (default, summary,
14
+ image gallery and any variation your project adds), so no templates need to be
15
+ duplicated.
16
+ - The Listing block is not touched: it keeps querying the local site.
17
+
18
+ ## Usage
19
+
20
+ Add the add-on to your project (`package.json` and `volto.config.js` /
21
+ `addons`) and define the remote sites **in your project's config**:
22
+
23
+ ```js
24
+ // src/config.js
25
+ const applyConfig = (config) => {
26
+ config.settings['@redturtle/volto-external-listing-block'] = {
27
+ ...config.settings['@redturtle/volto-external-listing-block'],
28
+ sites: [
29
+ { id: 'site-a', title: 'Remote site A', url: 'https://a.example.org' },
30
+ {
31
+ id: 'site-b',
32
+ title: 'Remote site B',
33
+ url: 'https://b.example.org',
34
+ // optional, default is `<url>/++api++`
35
+ apiUrl: 'https://api.b.example.org',
36
+ },
37
+ ],
38
+ // optional, timeout (ms) of the remote query. Default: 5000
39
+ timeout: 5000,
40
+ };
41
+ return config;
42
+ };
43
+ ```
44
+
45
+ | Key | Description |
46
+ | -------- | ------------------------------------------------------------------------------------ |
47
+ | `id` | Required. Unique, only lowercase letters, digits, `-` and `_`. Stored in the block. |
48
+ | `title` | Label shown in the block sidebar (default: the `id`). |
49
+ | `url` | Public URL of the remote site. The query goes to `<url>/++api++/@querystring-search`. |
50
+ | `apiUrl` | Overrides the base URL of the remote REST API. |
51
+ | `method` | `'post'` (default) or `'get'`. With `'get'` the query is sent as `?query=<json>`, see "Remote site requirements". |
52
+
53
+ ### Different urls per installation (production, staging, ...)
54
+
55
+ The sites can also be provided at **runtime** with the
56
+ `RAZZLE_EXTERNAL_LISTING_SITES` environment variable, a JSON array of sites.
57
+ Volto exposes every `RAZZLE_*` variable to the client at runtime, so the same
58
+ build can point to different remote sites depending on where it runs, with no
59
+ rebuild:
60
+
61
+ ```shell
62
+ # staging
63
+ RAZZLE_EXTERNAL_LISTING_SITES='[{"id":"site-a","url":"https://a.staging.example.org"}]'
64
+ # production
65
+ RAZZLE_EXTERNAL_LISTING_SITES='[{"id":"site-a","url":"https://a.example.org"}]'
66
+ ```
67
+
68
+ The env var is **merged by `id`** with `sites` from the config, and the env var
69
+ wins. So the theme can define `id` and `title` in the config and each
70
+ installation only supplies the urls (an entry in the config without `url` is
71
+ ignored until the env var provides it). An invalid value (malformed JSON, not
72
+ an array) is ignored and an error is logged.
73
+
74
+ The `id` is what is stored in the content: keep it identical in all
75
+ installations, only the url should change. If you read the variable yourself
76
+ in your project, use `runtimeConfig` from `@plone/volto/runtime_config`:
77
+ `process.env.RAZZLE_*` is replaced at build time.
78
+
79
+ The **External listing** block is hidden from the block chooser until at least
80
+ one site is configured. Do not change the `id` of a site that is already used
81
+ in content: blocks pointing to an unknown site render nothing and show a
82
+ warning in edit mode.
83
+
84
+ Load this add-on **after** the add-ons/themes that register Listing variations:
85
+ the block shares the Listing `variations` array.
86
+
87
+ ## Remote site requirements
88
+
89
+ The requests are done **directly from the browser** (and from the Volto server
90
+ when rendering on the server), **anonymously**: no cookie nor token of the local
91
+ site is ever sent. The remote site must therefore:
92
+
93
+ - allow cross-origin requests from your frontend domain
94
+ ([plone.rest CORS](https://plonerestapi.readthedocs.io/en/latest/cors.html),
95
+ or `CORS_ALLOW_ORIGIN` in the Plone docker images) for `GET`, `POST`,
96
+ `OPTIONS` and the `Accept` and `Content-Type` headers;
97
+ - expose the content as public (only what an anonymous user can see is listed).
98
+
99
+ By default the query is sent with a `POST` and a JSON body, which makes the
100
+ browser send a CORS **preflight** (`OPTIONS`): the remote must answer it with
101
+ `Access-Control-Allow-Methods` and `Access-Control-Allow-Headers`
102
+ (`Content-Type`). If the remote only sends `Access-Control-Allow-Origin` (for
103
+ example when CORS is added by a proxy), the preflight fails and the block shows
104
+ no results. Set `method: 'get'` on that site: a `GET` with only the `Accept`
105
+ header is a CORS "simple request", so no preflight is needed and
106
+ `Access-Control-Allow-Origin` is enough. The query travels in the URL, which is
107
+ fine for normal queries but limited by the maximum URL length.
108
+
109
+ ## How it works
110
+
111
+ The block renders Volto's own `ListingBody` with a *marker path*
112
+ (`/@@external-listing--<site id>`) instead of the content path. A redux
113
+ middleware (registered through `config.settings.storeExtenders`, before Volto's
114
+ `api` middleware) intercepts the resulting `GET_QUERYSTRING_RESULTS` actions,
115
+ runs the query on the remote site and dispatches the usual
116
+ `GET_QUERYSTRING_RESULTS_SUCCESS`, so pagination, loading state, SSR
117
+ (`getAsyncData`) and the variations work as in the Listing block, without
118
+ shadowing any Volto component.
119
+
120
+ A remote failure (unreachable site, CORS, timeout, HTTP error) never breaks the
121
+ page: the block shows "no results" and, in edit mode, the error.
122
+
123
+ ## Limitations
124
+
125
+ - Vocabularies and query criteria are the local ones: values chosen in the
126
+ query (types, states, subjects, ...) must exist on the remote site too.
127
+ - Criteria that reference local content (UIDs, absolute paths picked with the
128
+ object browser) make no sense on the remote site. Relative path criteria are
129
+ resolved from the remote site root.
130
+ - Links in the results are absolute and point to the remote site; they open in
131
+ a new tab. Images are served by the remote site.
132
+ - The "link more" fields follow `config.blocks.blocksConfig.listing.showLinkMore`.
133
+ - The block is not enabled inside the Grid block: add it to the grid's
134
+ `blocksConfig` yourself if you need it there.
135
+ - Only the standard `@querystring-search` endpoint is used: `fullobjects`
136
+ variations need the remote site to support it.
137
+
138
+ ## Development
139
+
140
+ This add-on lives in the
141
+ [RedTurtle Add-ons monorepo](https://github.com/RedTurtle/volto-addons), see the
142
+ root README for the development setup.
143
+
144
+ ```shell
145
+ make test
146
+ make lint
147
+ make i18n
148
+ ```
@@ -0,0 +1,17 @@
1
+ module.exports = function (api) {
2
+ api.cache(true);
3
+ const presets = ['razzle'];
4
+ const plugins = [
5
+ [
6
+ 'react-intl', // React Intl extractor, required for the whole i18n infrastructure to work
7
+ {
8
+ messagesDir: './build/messages/',
9
+ },
10
+ ],
11
+ ];
12
+
13
+ return {
14
+ plugins,
15
+ presets,
16
+ };
17
+ };
@@ -0,0 +1,57 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Plone\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2026-12-02T09:00:00.000Z\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
8
+ "Language: \n"
9
+ "Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
10
+ "Content-Type: text/plain; charset=utf-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=1; plural=0;\n"
13
+ "MIME-Version: 1.0\n"
14
+ "Language-Code: en\n"
15
+ "Language-Name: English\n"
16
+ "Preferred-Encodings: utf-8\n"
17
+ "Domain: volto\n"
18
+
19
+ #. Default: "Add at least one query criterion in the block sidebar."
20
+ #: components/ExternalListing/messages
21
+ msgid "Add at least one query criterion in the block sidebar."
22
+ msgstr ""
23
+
24
+ #. Default: "External listing"
25
+ #: components/ExternalListing/messages
26
+ msgid "External listing"
27
+ msgstr ""
28
+
29
+ #. Default: "Remote site"
30
+ #: components/ExternalListing/messages
31
+ msgid "Remote site"
32
+ msgstr ""
33
+
34
+ #. Default: "Results preview from {site}"
35
+ #: components/ExternalListing/messages
36
+ msgid "Results preview from {site}"
37
+ msgstr ""
38
+
39
+ #. Default: "Select the remote site to query in the block sidebar."
40
+ #: components/ExternalListing/messages
41
+ msgid "Select the remote site to query in the block sidebar."
42
+ msgstr ""
43
+
44
+ #. Default: "The query is executed on this site. Query criteria and their values come from the local site."
45
+ #: components/ExternalListing/messages
46
+ msgid "The query is executed on this site. Query criteria and their values come from the local site."
47
+ msgstr ""
48
+
49
+ #. Default: "The remote site could not be queried: {error}"
50
+ #: components/ExternalListing/messages
51
+ msgid "The remote site could not be queried: {error}"
52
+ msgstr ""
53
+
54
+ #. Default: "The site "{site}" is not defined in the configuration anymore. Select another remote site."
55
+ #: components/ExternalListing/messages
56
+ msgid "The site "{site}" is not defined in the configuration anymore. Select another remote site."
57
+ msgstr ""
@@ -0,0 +1,57 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Plone\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2026-12-02T09:00:00.000Z\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
8
+ "Language: \n"
9
+ "Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
10
+ "Content-Type: text/plain; charset=utf-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=1; plural=0;\n"
13
+ "MIME-Version: 1.0\n"
14
+ "Language-Code: it\n"
15
+ "Language-Name: Italian\n"
16
+ "Preferred-Encodings: utf-8\n"
17
+ "Domain: volto\n"
18
+
19
+ #. Default: "Add at least one query criterion in the block sidebar."
20
+ #: components/ExternalListing/messages
21
+ msgid "Add at least one query criterion in the block sidebar."
22
+ msgstr "Aggiungi almeno un criterio di query nella sidebar del blocco."
23
+
24
+ #. Default: "External listing"
25
+ #: components/ExternalListing/messages
26
+ msgid "External listing"
27
+ msgstr "Elenco da sito esterno"
28
+
29
+ #. Default: "Remote site"
30
+ #: components/ExternalListing/messages
31
+ msgid "Remote site"
32
+ msgstr "Sito remoto"
33
+
34
+ #. Default: "Results preview from {site}"
35
+ #: components/ExternalListing/messages
36
+ msgid "Results preview from {site}"
37
+ msgstr "Anteprima dei risultati da {site}"
38
+
39
+ #. Default: "Select the remote site to query in the block sidebar."
40
+ #: components/ExternalListing/messages
41
+ msgid "Select the remote site to query in the block sidebar."
42
+ msgstr "Seleziona nella sidebar del blocco il sito remoto da interrogare."
43
+
44
+ #. Default: "The query is executed on this site. Query criteria and their values come from the local site."
45
+ #: components/ExternalListing/messages
46
+ msgid "The query is executed on this site. Query criteria and their values come from the local site."
47
+ msgstr "La query viene eseguita su questo sito. I criteri della query e i loro valori sono quelli del sito locale."
48
+
49
+ #. Default: "The remote site could not be queried: {error}"
50
+ #: components/ExternalListing/messages
51
+ msgid "The remote site could not be queried: {error}"
52
+ msgstr "Non è stato possibile interrogare il sito remoto: {error}"
53
+
54
+ #. Default: "The site "{site}" is not defined in the configuration anymore. Select another remote site."
55
+ #: components/ExternalListing/messages
56
+ msgid "The site "{site}" is not defined in the configuration anymore. Select another remote site."
57
+ msgstr "Il sito "{site}" non è più definito nella configurazione. Seleziona un altro sito remoto."
@@ -0,0 +1,54 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Plone\n"
4
+ "POT-Creation-Date: 2026-12-01T23:44:12.342Z\n"
5
+ "Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
6
+ "Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
7
+ "Content-Type: text/plain; charset=utf-8\n"
8
+ "Content-Transfer-Encoding: 8bit\n"
9
+ "Plural-Forms: nplurals=1; plural=0;\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Language-Code: en\n"
12
+ "Language-Name: English\n"
13
+ "Preferred-Encodings: utf-8\n"
14
+ "Domain: volto\n"
15
+
16
+ #. Default: "Add at least one query criterion in the block sidebar."
17
+ #: components/ExternalListing/messages
18
+ msgid "Add at least one query criterion in the block sidebar."
19
+ msgstr ""
20
+
21
+ #. Default: "External listing"
22
+ #: components/ExternalListing/messages
23
+ msgid "External listing"
24
+ msgstr ""
25
+
26
+ #. Default: "Remote site"
27
+ #: components/ExternalListing/messages
28
+ msgid "Remote site"
29
+ msgstr ""
30
+
31
+ #. Default: "Results preview from {site}"
32
+ #: components/ExternalListing/messages
33
+ msgid "Results preview from {site}"
34
+ msgstr ""
35
+
36
+ #. Default: "Select the remote site to query in the block sidebar."
37
+ #: components/ExternalListing/messages
38
+ msgid "Select the remote site to query in the block sidebar."
39
+ msgstr ""
40
+
41
+ #. Default: "The query is executed on this site. Query criteria and their values come from the local site."
42
+ #: components/ExternalListing/messages
43
+ msgid "The query is executed on this site. Query criteria and their values come from the local site."
44
+ msgstr ""
45
+
46
+ #. Default: "The remote site could not be queried: {error}"
47
+ #: components/ExternalListing/messages
48
+ msgid "The remote site could not be queried: {error}"
49
+ msgstr ""
50
+
51
+ #. Default: "The site "{site}" is not defined in the configuration anymore. Select another remote site."
52
+ #: components/ExternalListing/messages
53
+ msgid "The site "{site}" is not defined in the configuration anymore. Select another remote site."
54
+ msgstr ""
package/news/.gitkeep ADDED
File without changes
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@redturtle/volto-external-listing-block",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "EXPERIMENTAL: Volto listing block that runs its query against a remote Plone site",
5
+ "main": "src/index.js",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "volto-addon",
9
+ "volto",
10
+ "plone",
11
+ "react",
12
+ "listing",
13
+ "experimental"
14
+ ],
15
+ "author": "RedTurtle",
16
+ "homepage": "https://github.com/RedTurtle/volto-addons#readme",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/RedTurtle/volto-addons"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/RedTurtle/volto-addons/issues"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "i18n": "rm -rf build/messages && NODE_ENV=production i18n --addon",
29
+ "dry-release": "release-it --dry-run",
30
+ "release": "release-it",
31
+ "release-major-alpha": "release-it major --preRelease=alpha",
32
+ "release-alpha": "release-it --preRelease=alpha"
33
+ },
34
+ "peerDependencies": {
35
+ "@plone/volto": "17 || 18",
36
+ "react": "18.2.0",
37
+ "react-dom": "18.2.0"
38
+ },
39
+ "devDependencies": {
40
+ "@plone/scripts": "^3.6.1",
41
+ "@plone/volto": "workspace:^",
42
+ "@types/react": "^18.3.3",
43
+ "@types/react-dom": "^18.3.0",
44
+ "release-it": "^17.1.1"
45
+ }
46
+ }
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useIntl } from 'react-intl';
4
+ import { BlockDataForm } from '@plone/volto/components/manage/Form';
5
+
6
+ /**
7
+ * Sidebar form of the block. Same as Volto's `ListingData` but with the
8
+ * schema of the external listing block. `BlockDataForm` takes care of the
9
+ * variation selector and of the variations' schema enhancers.
10
+ */
11
+ const Data = (props) => {
12
+ const {
13
+ data,
14
+ block,
15
+ blocksConfig,
16
+ blocksErrors,
17
+ onChangeBlock,
18
+ navRoot,
19
+ contentType,
20
+ } = props;
21
+ const intl = useIntl();
22
+ const schema = blocksConfig.externalListing.blockSchema({
23
+ ...props,
24
+ intl,
25
+ });
26
+
27
+ return (
28
+ <BlockDataForm
29
+ schema={schema}
30
+ title={schema.title}
31
+ onChangeField={(id, value) => {
32
+ onChangeBlock(block, {
33
+ ...data,
34
+ [id]: value,
35
+ });
36
+ }}
37
+ onChangeBlock={onChangeBlock}
38
+ formData={data}
39
+ blocksConfig={blocksConfig}
40
+ block={block}
41
+ navRoot={navRoot}
42
+ contentType={contentType}
43
+ errors={blocksErrors}
44
+ />
45
+ );
46
+ };
47
+
48
+ Data.propTypes = {
49
+ data: PropTypes.objectOf(PropTypes.any).isRequired,
50
+ block: PropTypes.string.isRequired,
51
+ onChangeBlock: PropTypes.func.isRequired,
52
+ };
53
+
54
+ export default Data;
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useIntl } from 'react-intl';
4
+ import { useSelector } from 'react-redux';
5
+ import isEqual from 'lodash/isEqual';
6
+ import SidebarPortal from '@plone/volto/components/manage/Sidebar/SidebarPortal';
7
+ import ListingBody from '@plone/volto/components/manage/Blocks/Listing/ListingBody';
8
+ import { withBlockExtensions } from '@plone/volto/helpers/Extensions';
9
+ import { buildMarkerPath } from '../../helpers/sites';
10
+ import { getBlockSite, getSubrequestId, hasQuery } from '../../helpers/block';
11
+ import Data from './Data';
12
+ import messages from './messages';
13
+
14
+ const Notice = ({ children }) => (
15
+ <p className="items-preview external-listing-notice">{children}</p>
16
+ );
17
+
18
+ const Edit = React.memo(
19
+ (props) => {
20
+ const { data, onChangeBlock, block, selected } = props;
21
+ const intl = useIntl();
22
+ const site = getBlockSite(data);
23
+ const subrequestId = getSubrequestId(props);
24
+ const remoteError = useSelector(
25
+ (state) => state.externalListing?.errors?.[subrequestId],
26
+ );
27
+
28
+ let preview;
29
+ if (!data.externalSite) {
30
+ preview = <Notice>{intl.formatMessage(messages.noSite)}</Notice>;
31
+ } else if (!site) {
32
+ preview = (
33
+ <Notice>
34
+ {intl.formatMessage(messages.unknownSite, {
35
+ site: data.externalSite,
36
+ })}
37
+ </Notice>
38
+ );
39
+ } else if (!hasQuery(data)) {
40
+ preview = <Notice>{intl.formatMessage(messages.noQuery)}</Notice>;
41
+ } else {
42
+ preview = (
43
+ <>
44
+ <p className="items-preview">
45
+ {intl.formatMessage(messages.previewFrom, {
46
+ site: site.title || site.id,
47
+ })}
48
+ </p>
49
+ {remoteError && (
50
+ <Notice>
51
+ {intl.formatMessage(messages.remoteError, { error: remoteError })}
52
+ </Notice>
53
+ )}
54
+ <ListingBody
55
+ key={site.id}
56
+ {...props}
57
+ path={buildMarkerPath(site.id)}
58
+ isEditMode
59
+ />
60
+ </>
61
+ );
62
+ }
63
+
64
+ return (
65
+ <>
66
+ {preview}
67
+ <SidebarPortal selected={selected}>
68
+ <Data
69
+ key={block}
70
+ {...props}
71
+ data={data}
72
+ block={block}
73
+ onChangeBlock={onChangeBlock}
74
+ />
75
+ </SidebarPortal>
76
+ </>
77
+ );
78
+ },
79
+ function areEquals(prevProps, nextProps) {
80
+ return !(
81
+ nextProps.selected !== prevProps.selected ||
82
+ nextProps.index !== prevProps.index ||
83
+ !isEqual(prevProps.data, nextProps.data)
84
+ );
85
+ },
86
+ );
87
+
88
+ Edit.propTypes = {
89
+ data: PropTypes.objectOf(PropTypes.any).isRequired,
90
+ index: PropTypes.number.isRequired,
91
+ selected: PropTypes.bool.isRequired,
92
+ block: PropTypes.string.isRequired,
93
+ onSelectBlock: PropTypes.func.isRequired,
94
+ properties: PropTypes.objectOf(PropTypes.any).isRequired,
95
+ };
96
+
97
+ export default withBlockExtensions(Edit);
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cx from 'classnames';
4
+ import { withBlockExtensions } from '@plone/volto/helpers/Extensions';
5
+ import ListingBody from '@plone/volto/components/manage/Blocks/Listing/ListingBody';
6
+ import { buildMarkerPath } from '../../helpers/sites';
7
+ import { getBlockSite, hasQuery } from '../../helpers/block';
8
+
9
+ const View = (props) => {
10
+ const { data, className, style } = props;
11
+ const site = getBlockSite(data);
12
+
13
+ // Nothing to show for visitors until the block is properly configured
14
+ if (!site || !hasQuery(data)) return null;
15
+
16
+ return (
17
+ <div
18
+ className={cx(
19
+ 'block listing external-listing',
20
+ data.variation || 'default',
21
+ className,
22
+ )}
23
+ style={style}
24
+ >
25
+ {/* The marker path makes the add-on middleware run the query on the
26
+ remote site; `key` remounts the body when the site changes, because
27
+ Volto's `withQuerystringResults` freezes the initial path. */}
28
+ <ListingBody key={site.id} {...props} path={buildMarkerPath(site.id)} />
29
+ </div>
30
+ );
31
+ };
32
+
33
+ View.propTypes = {
34
+ data: PropTypes.objectOf(PropTypes.any).isRequired,
35
+ properties: PropTypes.objectOf(PropTypes.any).isRequired,
36
+ block: PropTypes.string,
37
+ };
38
+
39
+ export default withBlockExtensions(View);
@@ -0,0 +1,22 @@
1
+ import getListingBlockAsyncData from '@plone/volto/components/manage/Blocks/Listing/getAsyncData';
2
+ import { buildMarkerPath } from '../../helpers/sites';
3
+ import { getBlockSite, hasQuery } from '../../helpers/block';
4
+
5
+ /**
6
+ * SSR prefetch: delegate to Volto's listing `getAsyncData` with the marker
7
+ * path, so the add-on middleware runs the query on the remote site and the
8
+ * server-rendered HTML already contains the results.
9
+ */
10
+ export default function getExternalListingAsyncData(props) {
11
+ const site = getBlockSite(props.data);
12
+
13
+ if (!site || !hasQuery(props.data)) {
14
+ // `fetchContent` requires a non-empty list of promises
15
+ return [Promise.resolve(null)];
16
+ }
17
+
18
+ return getListingBlockAsyncData({
19
+ ...props,
20
+ path: buildMarkerPath(site.id),
21
+ });
22
+ }