Closed rstavro closed 1 week ago
This issue was caused by the use of non-deterministic naming strategies. While issue #292 will fix the problem for all users employing deterministic strategies, those using non-deterministic strategies will face additional issues. Specifically, the reference will appear valid when clicking "Create Diagram" and generating a valid page, but the reference inside the diagram macro is not updated. When we attempt to retrieve the created diagram by transforming the reference again, the ID is randomized, causing the diagram not to load correctly.
To address this, I updated the code to ensure that the diagram macro always contains a valid reference, which updates whenever changes occur on either the macro-calling page or the diagram page itself. For everything to work correctly, users will need to reindex the wiki to automatically update all existing diagrams. For the reindexing to function as intended, both "Transform names automatically" and "Validate names before saving" need to be enabled under the Administration tab by navigating to Editor -> Name Strategies.
Unfortunately, in the case of unique naming strategies, any diagram macros that already created a diagram will need to be updated manually, as we cannot map the unique ID of the diagram page if there are multiple instances of the diagram macro or if the "Create Diagram" button was clicked multiple times. If the diagram has not yet been created, reindexing will work properly and resolve all future issues, even with a non-deterministic naming strategy.
If the name strategy generates a unique ID (document name), then the "Create diagram" button is still displayed, even after the corresponding diagram gets created.
Steps to reproduce :
{{diagram /}}
macro with no parameters in its content{{diagram /}}
macroAt this point, the "Create diagram" button is still displayed, instead of the actual SVG of the existing diagram. If, for example, you add the reference to the diagram document in the
{{diagram /}}
macro, the SVG is dispalyed as expected.The issue is caused by the fact that when computing the reference of the page to display, the new ID does not correspond to the existing diagram document, because of the uniqueness of the ID.
On the other hand, relying on a predefined document name ("Diagram", or its correspondence in case a name strategy is applied on it), does bring important limitations. When the document defining the diagram is renamed, the diagram is not displayed anymore on the parent document containing the {{diagram /}}` macro.