@eeacms/volto-cca-policy 0.3.124 → 0.3.126

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,132 @@
1
+ # Link Integrity — Block Field Coverage Report
2
+
3
+ **Date:** 2026-05-18
4
+ **Scope:** All blocks registered by `volto-cca-policy`, analyzed against the link integrity retrievers available in `plone.restapi` and `eea.climateadapt`.
5
+
6
+ ---
7
+
8
+ ## Retrievers in Play
9
+
10
+ Three retrievers scan block data when content is saved:
11
+
12
+ | Retriever | Source | Order | Fields Scanned | Scope |
13
+ |---|---|---|---|---|
14
+ | `GenericBlockLinksRetriever` | `plone.restapi` | 1 | `url`, `href`, `preview_image` (top-level only) | All blocks (`block_type = None`) |
15
+ | `TextBlockLinksRetriever` | `plone.restapi` | 100 | DraftJS `entityMap` LINK entities (`href`, `url`) | `block_type = "text"` |
16
+ | `SlateBlockLinksRetriever` | `plone.restapi` | 100 | Slate nodes: `handle_a` → `data.link.internal.internal_link[0]["@id"]`, `handle_link` → `data.url` | `block_type = "slate"` |
17
+ | `CCAObjectListLinksRetriever` | `eea.climateadapt` | 10 | `items[*].source`, `items[*].href`, `items[*].url`, top-level `linkTo`, top-level `image` | All blocks (`block_type = None`) |
18
+
19
+ **Key constraint:** `GenericBlockLinksRetriever` only checks **top-level** fields named exactly `url`, `href`, or `preview_image`. It does NOT recurse into lists, dicts, or nested structures. Any link stored in a non-standard field name or nested inside a list requires the `CCAObjectListLinksRetriever` (or a new custom retriever).
20
+
21
+ ---
22
+
23
+ ## Block-by-Block Analysis
24
+
25
+ ### 1. Blocks WITH internal link fields — FULLY COVERED
26
+
27
+ These blocks use standard top-level field names (`href`, `url`) that `GenericBlockLinksRetriever` catches, or their nested `items` are covered by `CCAObjectListLinksRetriever`.
28
+
29
+ | Block | Field(s) | Widget | Covered By | Notes |
30
+ |---|---|---|---|---|
31
+ | **RedirectBlock** | `href` | `object_browser` | `GenericBlockLinksRetriever` | Standard `href` at top level |
32
+ | **CountryMapObservatory** | `href` | `object_browser` | `GenericBlockLinksRetriever` | Standard `href` at top level |
33
+ | **CollectionStatistics** | `href` | `object_browser` | `GenericBlockLinksRetriever` | Standard `href` at top level |
34
+ | **ASTNavigation** | `href` (top-level) | `object_browser` | `GenericBlockLinksRetriever` | Main entry page link |
35
+ | **ASTNavigation** | `items[*].href` | `object_browser` (in `object_list`) | `CCAObjectListLinksRetriever` | Nav items — `items` list with `href` field |
36
+ | **ContentLinks** | `items[*].source` | `object_browser` (in `object_list`) | `CCAObjectListLinksRetriever` | `source` in items is explicitly handled |
37
+ | **RelevantAceContent** | `items[*].source` | `object_browser` (in `object_list`) | `CCAObjectListLinksRetriever` | `source` in items is explicitly handled |
38
+
39
+ ### 2. Blocks WITH internal link fields — NOT COVERED (GAP)
40
+
41
+ These blocks have fields that store internal links (via `object_browser`, path strings, or similar) but the field name or structure is **not** recognized by any existing retriever.
42
+
43
+ | Block | Field(s) | Widget / Type | Why Not Covered | Risk |
44
+ |---|---|---|---|---|
45
+ | **Listing** (standard, extended) | `linkHref` | `object_browser` | Field name is `linkHref` — not in `GenericBlockLinksRetriever` (`url`, `href`, `preview_image`) and not in `CCAObjectListLinksRetriever` (`linkTo`, `image`). The CCA retriever checks `linkTo` but Volto core uses `linkHref`. | **Medium** — The "Link to..." / "More..." button link is silently missed. |
46
+ | **RASTBlock** | `root_path` | plain `string` (path) | Stores a plain path string (e.g., `/en/knowledge-and-data/...`), NOT a `resolveuid/` URL. The retrievers only match strings containing `resolveuid`. | **Low** — Editors type paths manually; no object_browser. Moving the target folder breaks the link with no warning. |
47
+
48
+ ### 3. Blocks WITHOUT internal link fields — NO ACTION NEEDED
49
+
50
+ These blocks either have no link-bearing fields, fetch content dynamically from the server, or use server-side `@components` views.
51
+
52
+ | Block | Rationale |
53
+ |---|---|
54
+ | **C3SIndicatorsGlossaryBlock** | Empty schema. Content fetched from `@components` view `c3s_indicators_glossary_table`. |
55
+ | **C3SIndicatorsListingBlock** | Empty schema. Content fetched from `@components` view `c3s_indicators_listing`. |
56
+ | **C3SIndicatorsOverviewBlock** | Empty schema (category field commented out). Content fetched from `@components` view `c3s_indicators_overview`. |
57
+ | **CaseStudyExplorer** | No schema file. Loads data from ArcGIS JSON endpoint (`@@case-studies-map.arcgis.json`). No content links stored in block data. |
58
+ | **CountryMapHeatIndex** | No schema file. Renders country map from static GeoJSON + metadata endpoint. No content links in block data. |
59
+ | **CountryMapProfile** | No schema file. Same pattern as CountryMapHeatIndex. No content links in block data. |
60
+ | **CountryProfileDetail** | No schema file. Renders HTML from `@components` view `countryprofile`. |
61
+ | **ECDEIndicators** | No schema file. Embeds CDS toolbox apps by region code. No content links in block data. |
62
+ | **FilterAceContent** | Schema has only filter parameters (vocabularies, search text, sort). No `object_browser` or link fields. Results are fetched dynamically. |
63
+ | **SearchAceContent** | Same as FilterAceContent — only filter/search parameters. No content links stored. |
64
+ | **FlourishEmbedBlock** | `embed_code` is a `textarea` with raw HTML/JS. Not parsed by any retriever. Links (if any) are external Flourish URLs. |
65
+ | **ReadMore** | Behavioral block only (labels, height, position). No links. |
66
+ | **DataConnectedEmbedBlock** | Extends `@eeacms/volto-datablocks`. Only adds a `languageParam` string field. The base block's URL fields (if any) are handled by the base package's own mechanisms. |
67
+ | **TransRegionSelect** | `region` is a vocabulary choice (not a link). Renders links dynamically from `@components` view. |
68
+ | **TabsBlock (Spotlight)** | Container block. Links in child blocks are discovered recursively by `visit_blocks`. The spotlight variation's `image` field (in tab settings) is covered by `CCAObjectListLinksRetriever` (top-level `image`). |
69
+
70
+ ---
71
+
72
+ ## Summary of Gaps
73
+
74
+ ### Gap 1: Listing block — `linkHref` field
75
+
76
+ **Problem:** The standard Volto listing block stores its "More..." link in a field named `linkHref`. The `GenericBlockLinksRetriever` only scans `url`, `href`, `preview_image`. The `CCAObjectListLinksRetriever` scans `linkTo` and `image` — neither matches `linkHref`.
77
+
78
+ **Impact:** If an editor configures a listing block with a "Link to..." destination, and that destination is moved or made private, the link integrity system will NOT report this listing block as a breacher.
79
+
80
+ **Remediation options:**
81
+ 1. **Extend `CCAObjectListLinksRetriever`** to also scan `linkHref` (add it to the top-level fields list alongside `linkTo` and `image`). This is the simplest fix — one line change.
82
+ 2. **Register a dedicated `ListingBlockLinksRetriever`** adapted to `block_type = "listing"`. More explicit but more code.
83
+
84
+ **Recommendation:** Option 1 — add `linkHref` to the top-level fields in `CCAObjectListLinksRetriever`.
85
+
86
+ ### Gap 2: RASTBlock — `root_path` field
87
+
88
+ **Problem:** `root_path` stores a plain content path (e.g., `/en/knowledge-and-data/rast`) as a string. It is NOT stored as `resolveuid/<UID>`, so even if the field name were recognized, `get_urls_from_value` would not match it (it checks for `resolveuid` in the string).
89
+
90
+ **Impact:** If the root folder is moved, the RAST block silently points to a 404. No link integrity warning.
91
+
92
+ **Remediation options:**
93
+ 1. **Change the widget** to `object_browser` and store as `resolveuid/` — then add `root_path` to a retriever. This is a schema change with migration implications.
94
+ 2. **Accept the risk** — the field is typed manually by editors and is inherently fragile regardless of link integrity.
95
+ 3. **Add a custom deserializer** that converts the path to `resolveuid/` on save, then add `root_path` to a retriever.
96
+
97
+ **Recommendation:** Option 2 (accept risk) for now — the field is a single path string used by a small number of blocks, and converting it to `object_browser` would be a larger UX change. Document the limitation.
98
+
99
+ ---
100
+
101
+ ## Coverage Matrix
102
+
103
+ | Block | Link Fields | Generic Retriever | CCA Retriever | Gap? |
104
+ |---|---|---|---|---|
105
+ | RedirectBlock | `href` | ✅ | — | No |
106
+ | CountryMapObservatory | `href` | ✅ | — | No |
107
+ | CollectionStatistics | `href` | ✅ | — | No |
108
+ | ASTNavigation | `href` (top) | ✅ | — | No |
109
+ | ASTNavigation | `items[*].href` | ❌ | ✅ | No |
110
+ | ContentLinks | `items[*].source` | ❌ | ✅ | No |
111
+ | RelevantAceContent | `items[*].source` | ❌ | ✅ | No |
112
+ | **Listing** | `linkHref` | ❌ | ❌ | **Yes** |
113
+ | RASTBlock | `root_path` | ❌ | ❌ | Yes (low risk) |
114
+ | FlourishEmbedBlock | `embed_code` | ❌ | ❌ | N/A (external) |
115
+ | All others | (none) | — | — | No |
116
+
117
+ ---
118
+
119
+ ## Notes on plone.restapi / plone.volto Checkouts
120
+
121
+ - **plone.restapi** is checked out at `backend/sources/plone.restapi/`. It provides `GenericBlockLinksRetriever` (fields: `url`, `href`, `preview_image`), `TextBlockLinksRetriever` (DraftJS), and `SlateBlockLinksRetriever`.
122
+ - **plone.volto** is NOT checked out in `backend/sources/`. It is installed as a packaged dependency in the backend venv. No custom link integrity retrievers were found in the EEA policy package (`eea.volto.policy`) — it only provides serialization/deserialization transformers, not link retrievers.
123
+ - The `CCAObjectListLinksRetriever` in `eea.climateadapt` is the **only** custom link integrity retriever in the project. It runs at order 10 (before Generic at order 1, but both return independent lists that are unioned).
124
+
125
+ ---
126
+
127
+ ## Recommendations
128
+
129
+ 1. **Fix the Listing gap immediately** — add `linkHref` to `CCAObjectListLinksRetriever`'s top-level field scan (one-line change in `blocks_linkintegrity.py`).
130
+ 2. **Consider adding `image` to Generic coverage analysis** — `CCAObjectListLinksRetriever` already covers `image`, but if a future block uses `image` without items, it would only be caught by CCA's retriever.
131
+ 3. **Document the RASTBlock limitation** in the block's developer notes or BLOCKS.md.
132
+ 4. **Future blocks:** Always name link fields `href` or `url` at the top level, or `items[*].href` / `items[*].source` for nested lists, to benefit from existing retrievers.
@@ -0,0 +1,52 @@
1
+ # Volto Block Link Integrity Analysis Report - volto-cca-policy
2
+
3
+ ## Objective
4
+ Identify blocks within the `volto-cca-policy` add-on that contain internal links in fields or structures not covered by the standard Plone/Volto link integrity discovery mechanisms.
5
+
6
+ ## Standard Coverage Recap
7
+
8
+ The following mechanisms are provided by core packages:
9
+
10
+ 1. **`plone.restapi` (Generic Retriever)**: Automatically extracts links from top-level fields: `url`, `href`, `preview_image`.
11
+ 2. **`plone.restapi` (Visitors)**: Recursively visits sub-blocks stored in `blocks` or `data.blocks`.
12
+ 3. **`plone.volto` (Visitors/Retrievers)**: Recursively visits sub-blocks stored in `columns`, `hrefList`, and `slides`.
13
+ 4. **`eea.climateadapt` (Backend Custom Retriever)**: Specifically covers `items[*].source`, `items[*].href`, `items[*].url`, and top-level `linkTo` and `image`.
14
+
15
+ ## Analysis of volto-cca-policy Blocks
16
+
17
+ | Block (@type) | Field Location | Covered? | Reason / Mechanism |
18
+ | :--- | :--- | :--- | :--- |
19
+ | `ContentLinks` | `items[*].source` | **Yes** | `CCAObjectListLinksRetriever` (Backend) |
20
+ | `RelevantAceContent` | `items[*].source` | **Yes** | `CCAObjectListLinksRetriever` (Backend) |
21
+ | `ASTNavigation` | `items[*].href` | **Yes** | `CCAObjectListLinksRetriever` (Backend) |
22
+ | `Listing` (Shadowed) | `linkTo` | **Yes** | `CCAObjectListLinksRetriever` (Backend) |
23
+ | `RedirectBlock` | `href` | **Yes** | `GenericBlockLinksRetriever` (Core) |
24
+ | `CountryMapObservatory`| `href` | **Yes** | `GenericBlockLinksRetriever` (Core) |
25
+ | `CollectionStatistics` | `href` | **Yes** | `GenericBlockLinksRetriever` (Core) |
26
+ | `TabsBlock` (Spotlight)| `tabs[*].blocks` | **NO** | `tabs` key is not visited by core visitors. |
27
+ | `TabsBlock` (Spotlight)| `tabs[*].image` | **NO** | `tabs` structure is not scanned for link fields. |
28
+ | `FlourishEmbedBlock` | `embed_code` | **NO** | Raw HTML/JS (requires parsing). |
29
+ | `CaseStudyExplorer` | `adaptation_options_links` | **NO** | Raw HTML (often dynamic source). |
30
+ | `RASTBlock` | `root_path` | **NO** | Hardcoded string path (not a UID). |
31
+
32
+ ## Detailed Findings
33
+
34
+ ### 1. TabsBlock (Spotlight Variation)
35
+ The `TabsBlock` in `volto-cca-policy` uses a custom `tabs` key to store a dictionary of tab data. Each tab can contain its own sub-blocks (`blocks` key) and a promotional `image`.
36
+ * **Sub-blocks Visibility**: Since neither `plone.restapi` nor `plone.volto` includes `tabs` in their `IBlockVisitor` implementations, the backend link integrity system is "blind" to any blocks placed inside a spotlight tab.
37
+ * **Image Visibility**: The `image` field within a tab is nested inside the `tabs` object list/map, which is not scanned by the generic or CCA-specific retrievers.
38
+
39
+ ### 2. FlourishEmbedBlock
40
+ This block stores raw HTML or Javascript snippets for embedding Flourish charts. Internal links within these snippets are not tracked because they are not stored as structured data or `resolveuid/` patterns.
41
+
42
+ ### 3. RASTBlock
43
+ Uses a `root_path` field which stores an absolute path as a string (e.g., `/en/knowledge-and-data/...`). Link integrity tracking depends on `resolveuid/` patterns and `zc.relation` objects. Paths are not automatically tracked or updated if the target moves.
44
+
45
+ ## Recommendations
46
+
47
+ 1. **Expand Backend Retriever**: Update `CCAObjectListLinksRetriever` (or add a new one) to handle the `tabs` structure:
48
+ * Visit each item in the `tabs` dictionary.
49
+ * Extract links from the `image` field if present.
50
+ * (Optional) If `tabs` items contain their own blocks, a custom `IBlockVisitor` should be registered to allow core recursion to reach them.
51
+ 2. **Refactor RASTBlock**: If possible, change `root_path` to use a proper object browser widget and store a UID.
52
+ 3. **Documentation**: Advise developers to stick to `blocks`, `columns`, or `slides` for sub-block storage, or `items` for list-based links to benefit from existing retrievers.
@@ -0,0 +1,143 @@
1
+ # Understanding Link Integrity in Plone and Volto
2
+
3
+ ## Use Case
4
+ A user is editing a content item and decides to change its workflow state to "Private". Before this action is finalized, the system should check if other content items on the website are linking to this item. If such links exist, the user should be informed that these links will effectively "break" for public users (leading to an unauthorized screen).
5
+
6
+ ## Goal
7
+ Identify a programmatic way (ideally a REST API endpoint) to retrieve a list of content items that link to a specific object.
8
+
9
+ ## Research Findings
10
+
11
+ ### 1. `plone.app.linkintegrity`
12
+ - **Mechanism**: Tracks internal links using the `zc.relation` catalog with the relationship name `isReferencing`.
13
+ - **Logic**: Extracts links from Dexterity `RichText` fields and Volto blocks (via `plone.volto`).
14
+ - **Querying**: Provides utility functions in `plone.app.linkintegrity.utils`, notably `getIncomingLinks(obj)`.
15
+
16
+ ### 2. `plone.restapi`
17
+ - **Existing Endpoints**:
18
+ - **`/@linkintegrity?uids=<UID>`**: Returns "breaches" (items linking to the specified UIDs). This is the same logic used by Plone's delete confirmation screen.
19
+ - **`/@relations?target=<UID>&relation=isReferencing`**: A more generic endpoint to query the relation catalog. Omitting the `relation` parameter returns all types of incoming relations (including `relatedItems`).
20
+ - **Recommendation**: For the "warn before private" use case, `/@linkintegrity` is highly suitable because it returns structured data specifically designed for notifying users about broken links. However, `/@relations` is better if a simple list of *any* linking item is needed.
21
+
22
+ ### 3. `plone.volto` / Volto Frontend
23
+ - **Backend**: Ensures that internal links within Volto blocks (columns, teasers, etc.) are correctly indexed by `plone.app.linkintegrity`.
24
+ - **Frontend Logic**:
25
+ - Volto has a `linkIntegrityCheck` action in `@plone/volto/actions` that calls the `/@linkintegrity` endpoint.
26
+ - The results are stored in the `linkIntegrity` reducer.
27
+ - The `ContentsDeleteModal` component in Volto core is the canonical example of how to display these breaches.
28
+ - **Workflow Integration**: The state transition dropdown is managed by the `Workflow` component (`@plone/volto/components/manage/Workflow/Workflow`).
29
+
30
+ ## Recommended Solution
31
+
32
+ To implement the "warn before private" feature:
33
+
34
+ 1. **Backend Endpoint**: Use `GET /@linkintegrity?uids=<UID>`.
35
+ 2. **Frontend Integration (Shadowing)**:
36
+ - Shadow the core `Workflow` component by copying it to `frontend/src/addons/volto-cca-policy/src/customizations/volto/components/manage/Workflow/Workflow.jsx`.
37
+ - Intercept the `onChange` handler in the shadowed component.
38
+ - If the target state is "Private" (or similar), trigger the `linkIntegrityCheck`.
39
+ - Show a confirmation modal (similar to `ContentsDeleteModal`) if breaches are found.
40
+
41
+ ## Volto Implementation Details
42
+
43
+ ### Shadowing Path
44
+ ```
45
+ frontend/src/addons/volto-cca-policy/src/customizations/volto/components/manage/Workflow/Workflow.jsx
46
+ ```
47
+
48
+ ### Logic Hook
49
+ In the shadowed `Workflow.jsx`, modify the `transition` function:
50
+
51
+ ```javascript
52
+ const transition = (selectedOption) => {
53
+ const isPrivateTransition = ['private', 'reject', 'retract'].includes(selectedOption.value) ||
54
+ selectedOption.url.endsWith('/reject') ||
55
+ selectedOption.url.endsWith('/retract');
56
+
57
+ if (isPrivateTransition) {
58
+ setPendingOption(selectedOption);
59
+ dispatch(linkIntegrityCheck([content.UID]));
60
+ setShowWarningModal(true);
61
+ } else {
62
+ executeTransition(selectedOption);
63
+ }
64
+ };
65
+ ```
66
+
67
+ ### Components to reuse
68
+ - `Confirm` from `semantic-ui-react` for the modal wrapper.
69
+ * **Existing Actions**: `linkIntegrityCheck` from `@plone/volto/actions`.
70
+ * **Existing Reducers**: `state.linkIntegrity.result` to access the breaches.
71
+ * **UI Reference**: `ContentsDeleteModal.jsx` in Volto core for the table rendering logic of broken links.
72
+
73
+ ## Final Implementation
74
+
75
+ The feature was implemented in the `volto-cca-policy` add-on on a dedicated branch.
76
+
77
+ ### Git Branch
78
+ - **Branch Name**: `link-integrity-workflow`
79
+
80
+ ### Files Created/Modified
81
+ 1. **Shadowed Component**: `src/customizations/volto/components/manage/Workflow/Workflow.jsx`
82
+ - Shadowed from `@plone/volto/components/manage/Workflow/Workflow.jsx`.
83
+ - Modified to intercept state changes to `private`, `reject`, and `retract`.
84
+ - Integrated with `linkIntegrityCheck` action and `WorkflowLinkIntegrityModal`.
85
+ 2. **New Component**: `src/components/manage/Workflow/WorkflowLinkIntegrityModal.jsx`
86
+ - A custom confirmation modal that displays link integrity breaches.
87
+ - Uses `semantic-ui-react` for the UI (Confirm, Table, Loader).
88
+ - Accesses `state.linkIntegrity.result` to render the list of affected content.
89
+ 3. **Components Index**: `src/components/index.js`
90
+ - Exported `WorkflowLinkIntegrityModal` for use in the shadowed `Workflow` component.
91
+
92
+ ### Logic Summary
93
+ - **Trigger**: When the user selects a "Private" transition in the workflow dropdown.
94
+ - **Verification**: The `linkIntegrityCheck` action is dispatched for the current object's UID.
95
+ - **Race Condition Prevention**: The system explicitly waits for the `linkIntegrity.loaded` state to be true before deciding whether to auto-proceed or show the modal. This prevents transitions from executing prematurely due to stale or initial empty state.
96
+ - **Activity Indicators (UX)**:
97
+ - During the link integrity check, a `Dimmer` and `Loader` are shown within the `WorkflowLinkIntegrityModal` with the message "Checking references...".
98
+ - During the actual workflow transition execution, a `Dimmer` and `Loader` are shown over the state selection dropdown to indicate that the transition is in progress.
99
+ - **Interaction**:
100
+ - If no incoming links exist (`breaches.length === 0`), the transition proceeds automatically once the check is loaded.
101
+ - If incoming links are found, the `WorkflowLinkIntegrityModal` displays the list of referencing pages.
102
+ - The user can either "Cancel" the transition or select "Change state anyway" to proceed.
103
+
104
+ ## User Story: Testing the Link Integrity Warning
105
+
106
+ ### Description
107
+ As a Content Editor, I want to be warned when I am about to make a page private if other pages are linking to it, so that I can avoid creating broken links for visitors.
108
+
109
+ ### Acceptance Criteria
110
+ 1. **Positive Case (Breaches Found)**:
111
+ - Given a "Target Page" that is published.
112
+ - Given a "Source Page" that contains a link to "Target Page".
113
+ - When I go to "Target Page" and select "Make Private" (or "Reject" / "Retract") from the state dropdown.
114
+ - Then I should see a "Checking references..." loading indicator.
115
+ - Then I should see a warning modal titled "Warning: Potential broken links".
116
+ - Then the modal should list "Source Page" as an item that will have a broken link.
117
+ - When I click "Cancel", the modal should close and the page should remain "Published".
118
+ - When I click "Change state anyway", the modal should close and the page should transition to "Private".
119
+
120
+ 2. **Negative Case (No Breaches)**:
121
+ - Given a "Target Page" that is published and has NO incoming links.
122
+ - When I select "Make Private" from the state dropdown.
123
+ - Then I should see a brief "Checking references..." indicator.
124
+ - Then the page should transition to "Private" immediately without showing a warning modal.
125
+
126
+ ### Test Procedure
127
+ 1. **Setup Content**:
128
+ - Create a page named "Linked Page" and Publish it.
129
+ - Create another page named "Referencing Page".
130
+ - In "Referencing Page", add a Text block and insert an internal link to "Linked Page". Publish "Referencing Page".
131
+ 2. **Verify Warning**:
132
+ - Navigate to "Linked Page".
133
+ - Open the state dropdown in the toolbar.
134
+ - Select "Make Private".
135
+ - **Observe**: The "Checking references..." dimmer should appear briefly.
136
+ - **Verify**: The warning modal should appear listing "Referencing Page".
137
+ 3. **Test Cancellation**:
138
+ - Click "Cancel" in the modal.
139
+ - **Verify**: The page is still in "Published" state.
140
+ 4. **Test Confirmation**:
141
+ - Select "Make Private" again.
142
+ - Click "Change state anyway" in the modal.
143
+ - **Verify**: The page state changes to "Private" and a success toast appears.
@@ -0,0 +1,63 @@
1
+ # Volto Block Link Discovery Analysis - volto-cca-policy
2
+
3
+ This document analyzes the custom blocks defined in the `volto-cca-policy` add-on to identify which fields contain internal links and whether they are covered by the standard Plone/Volto link integrity discovery mechanism.
4
+
5
+ ## Standard Discovery Mechanism Recap
6
+
7
+ As documented in `volto-block-link-discovery.md`, the `GenericBlockLinksRetriever` automatically extracts internal links from the following top-level fields:
8
+ - `url`
9
+ - `href`
10
+ - `preview_image`
11
+
12
+ Any field not named exactly like one of these, or any link nested within a list or dictionary (unless it's a `blocks` container), requires a specialized retriever on the backend.
13
+
14
+ ## Analysis of volto-cca-policy Blocks
15
+
16
+ ### 1. Blocks Covered by Generic Retriever
17
+ The following blocks use standard field names at the top level and should be automatically tracked.
18
+
19
+ | Block | Field | Description |
20
+ |---|---|---|
21
+ | `RedirectBlock` | `href` | The target object for the redirection. |
22
+ | `CountryMapObservatory` | `href` | The parent location of all country profiles. |
23
+ | `CollectionStatistics` | `href` | The destination listing page. |
24
+ | `ASTNavigation` | `href` | The main entry page to AST/UAST (top-level). |
25
+
26
+ ### 2. Blocks NOT Covered (Custom Field Names)
27
+ The following blocks use field names that are not recognized by the generic retriever.
28
+
29
+ | Block | Field | Description |
30
+ |---|---|---|
31
+ | `Listing` (Shadowed) | `linkTo` | Standard Volto listing block uses `linkTo` for the "More..." link. |
32
+
33
+ ### 3. Blocks NOT Covered (Nested Links)
34
+ The following blocks store links within an `object_list`. The generic retriever does not scan inside these lists.
35
+
36
+ | Block | Field Path | Description |
37
+ |---|---|---|
38
+ | `ContentLinks` | `items[*].source` | A list of hand-picked content items. |
39
+ | `RelevantAceContent` | `items[*].source` | A list of hand-picked content items (assigned items). |
40
+ | `ASTNavigation` | `items[*].href` | Individual navigation steps in the AST map. |
41
+
42
+ ### 4. Special Cases
43
+
44
+ #### `FlourishEmbedBlock`
45
+ - **Field**: `embed_code` (Textarea)
46
+ - **Status**: Not covered.
47
+ - **Reason**: Contains raw HTML/JS snippets. Discovery would require parsing the HTML for URLs, which is not performed by the standard block retrievers.
48
+
49
+ #### `TabsBlock` (Spotlight Variation)
50
+ - **Status**: Covered (indirectly).
51
+ - **Reason**: This is a container block. The `NestedBlocksVisitor` handles the recursion into its child blocks, so any links within those children will be discovered normally.
52
+
53
+ #### `ReadMore`
54
+ - **Status**: No Links.
55
+ - **Reason**: This is a behavioral block that manipulates the DOM of its siblings on the frontend. It does not store links in its own block data.
56
+
57
+ ## Recommendations for Link Integrity
58
+
59
+ To ensure full coverage for `volto-cca-policy` content, the following actions are recommended:
60
+
61
+ 1. **Backend Adapters**: Register custom `IBlockFieldLinkIntegrityRetriever` adapters for `ContentLinks`, `RelevantAceContent`, and `ASTNavigation` to extract links from their `items` lists.
62
+ 2. **Field Mapping**: If possible, refactor `ContentLinks` and `RelevantAceContent` to use `href` or `url` instead of `source` for individual items, although a custom retriever is still needed for the list structure.
63
+ 3. **Core Coverage**: Verify if `plone.restapi` or `plone.volto` provides a specialized retriever for the `listing` block's `linkTo` field. If not, one should be added.
@@ -0,0 +1,60 @@
1
+ # How Volto Discovers Links in Blocks for Link Integrity
2
+
3
+ When a content item is saved in Plone, the system needs to know which other internal items it links to, so it can maintain the `zc.relation` catalog (specifically using the `isReferencing` relationship).
4
+
5
+ For traditional Plone, this meant parsing HTML in `RichText` fields. For Volto, the content is stored as JSON blocks, requiring a recursive discovery mechanism.
6
+
7
+ ## Sub-block Storage and Discovery
8
+
9
+ Sub-blocks are stored in the JSON data of a parent block using one of two primary patterns. The Plone backend uses a recursive generator called `visit_blocks` (defined in `plone.restapi.blocks`) to walk this tree.
10
+
11
+ ### 1. Dictionary Mapping (Key-Value)
12
+ This is the standard Volto pattern for container-like blocks.
13
+ - **Storage Pattern**: A dictionary where keys are UUIDs and values are the sub-block data.
14
+ - **Common Keys**: `blocks` or `data["blocks"]`.
15
+ - **Discovery**: `plone.restapi.blocks.NestedBlocksVisitor` is registered for these keys. It yields each value in the dictionary.
16
+
17
+ ### 2. Sequential Lists
18
+ This pattern is used by layout-oriented blocks where the order is strictly positional.
19
+ - **Storage Pattern**: A simple list of block data objects.
20
+ - **Core Volto Keys**: `columns`, `slides`, `hrefList`.
21
+ - **Discovery**: `plone.volto.transforms.NestedBlocksVisitor` handles these keys. It iterates through the list and yields each block.
22
+
23
+ ### 3. Recursive Discovery Logic
24
+ The `visit_blocks` function uses `IBlockVisitor` subscribers to find children. When a visitor yields a sub-block, `visit_blocks` immediately recurses into that sub-block. This ensures that a block tree of any depth (e.g., a Grid containing Columns containing Teasers) is fully flattened during the discovery phase.
25
+
26
+ ## Internal Link Extraction
27
+
28
+ Once a block is discovered, the `BlocksRetriever` (in `plone.restapi.blocks_linkintegrity`) uses `IBlockFieldLinkIntegrityRetriever` subscribers to find internal links within that specific block's fields.
29
+
30
+ ### Automatic Link Detection (The Generic Retriever)
31
+ The `GenericBlockLinksRetriever` provides a "zero-configuration" discovery for most custom blocks. It automatically scans the following fields if they contain the `resolveuid/` pattern:
32
+ - `url`
33
+ - `href`
34
+ - `preview_image`
35
+
36
+ **Note**: If a block uses custom field names for links (e.g., `source`, `target`, `link_to`), they will **NOT** be caught by the generic retriever unless they are specifically registered.
37
+
38
+ ### Complex Data Extraction
39
+ Some blocks store links deep within complex JSON structures rather than simple top-level strings. These require specialized retrievers:
40
+
41
+ 1. **Slate Blocks (Rich Text)**:
42
+ - Uses `SlateBlockLinksRetriever`.
43
+ - Recursively walks the Slate node tree.
44
+ - Extracts UIDs from `data.link.internal.internal_link[0]["@id"]` and `data.url`.
45
+
46
+ 2. **DraftJS Blocks (Legacy Text)**:
47
+ - Uses `TextBlockLinksRetriever`.
48
+ - Parses the `entityMap` for `LINK` entities.
49
+ - Extracts data from `url` and `href` keys within the entity data.
50
+
51
+ ## Redundancy and Reliability
52
+ To ensure maximum reliability, `plone.volto` includes a `NestedBlockLinkRetriever` (registered with `block_type = None`). This serves as a fail-safe that manually walks the `columns`, `hrefList`, and `slides` keys to trigger link extraction, providing a second layer of defense for nested layouts.
53
+
54
+ ## Summary for Developers
55
+ To ensure a custom block is correctly tracked by the link integrity system:
56
+
57
+ 1. **Field Naming**: Prefer naming your link fields `url` or `href` to benefit from the generic retriever.
58
+ 2. **Nesting**: If your block contains sub-blocks, store them in a dictionary under the key `blocks`.
59
+ 3. **Link Format**: Always store internal links using the `resolveuid/<UID>` format.
60
+ 4. **Custom Retrievers**: If you must use unique field names or storage patterns, register a custom `IBlockFieldLinkIntegrityRetriever` adapter for your block's `@type` in the backend.