From a60541a1c27deb4f8d5f7f088452ac7c3f6370cd Mon Sep 17 00:00:00 2001
From: Tobias Kuhn
Date: Fri, 28 Aug 2026 09:56:44 +0200
Subject: [PATCH] feat: offer every view-displays action in the space title
menu (#641)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The "⬜ View displays" views now declare a second result-level action,
"➕ add part-level view display", next to the plain one. Its template
("Displaying a view for the parts of a resource",
RAIrUZ9TQfAYeun74aM_BicxYF4uU6GkL6BthX4WdI9dA) drops the top-level
gen:appliesTo pin and un-hides the gen:appliesToInstancesOf /
gen:appliesToNamespace statements, which were nt:AdvancedStatement in
every earlier template — and therefore invisible unless the user found
the form's advanced-mode toggle. That was the reason part-level displays
were hard to add.
The About-tab tables pick both actions up on their own, but the space
title-menu shortcut returned on the first entitled action and so would
have silently shown only one of the two. Return all of them instead, in
the order the view nanopub lists them.
Also drops AddViewDisplayButton, which has had no callers for a while.
Co-Authored-By: Claude Opus 5 (1M context)
---
.../component/AddViewDisplayButton.java | 29 -------------------
.../nanodash/component/PageTitleMenu.java | 28 ++++++++++--------
2 files changed, 16 insertions(+), 41 deletions(-)
delete mode 100644 src/main/java/com/knowledgepixels/nanodash/component/AddViewDisplayButton.java
diff --git a/src/main/java/com/knowledgepixels/nanodash/component/AddViewDisplayButton.java b/src/main/java/com/knowledgepixels/nanodash/component/AddViewDisplayButton.java
deleted file mode 100644
index 0f7e4d9d5..000000000
--- a/src/main/java/com/knowledgepixels/nanodash/component/AddViewDisplayButton.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.knowledgepixels.nanodash.component;
-
-import com.knowledgepixels.nanodash.page.NanodashPage;
-import com.knowledgepixels.nanodash.page.PublishPage;
-import org.apache.wicket.markup.html.link.BookmarkablePageLink;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.request.mapper.parameter.INamedParameters;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-/**
- * A button that links to the PublishPage with pre-filled parameters for adding a new view display.
- */
-public class AddViewDisplayButton extends BookmarkablePageLink {
-
- public AddViewDisplayButton(String id, String template, String templateVersion, String context, String paramResource, PageParameters additionalPageParameters) {
- super(id, PublishPage.class, new PageParameters()
- .set("template", template)
- .set("template-version", templateVersion)
- .set("context", context)
- .set("param_resource", paramResource));
-
- for (INamedParameters.NamedPair param : additionalPageParameters.getAllNamed()) {
- getPageParameters().set(param.getKey(), param.getValue());
- }
-
- setBody(Model.of("+ view display..."));
- }
-
-}
diff --git a/src/main/java/com/knowledgepixels/nanodash/component/PageTitleMenu.java b/src/main/java/com/knowledgepixels/nanodash/component/PageTitleMenu.java
index c4c161029..873fd9067 100644
--- a/src/main/java/com/knowledgepixels/nanodash/component/PageTitleMenu.java
+++ b/src/main/java/com/knowledgepixels/nanodash/component/PageTitleMenu.java
@@ -183,8 +183,8 @@ private static Component build(String id, List groups, List
* an event is later rescheduled. A space that is both gets both submenus.
*
* For viewers of maintainer tier or above, the menu additionally offers "configure"
- * (leading to the space's About tab) and "add view display..." (the About tab's
- * view-displays action, as a direct shortcut).
+ * (leading to the space's About tab) and the About tab's view-displays actions
+ * ("add view display...", "add part-level view display...") as direct shortcuts.
*
* @param id the Wicket component id
* @param space the space to build the menu for
@@ -218,23 +218,27 @@ public static Component forSpace(String id, Space space) {
new PageParameters().set("id", space.getId()).set("tab", "about"));
configure.setBody(Model.of("configure")).setEscapeModelStrings(false);
extraEntries.add(configure);
- AbstractLink addViewDisplay = addViewDisplayLink(space);
- if (addViewDisplay != null) extraEntries.add(addViewDisplay);
+ extraEntries.addAll(addViewDisplayLinks(space));
}
return build(id, groups, extraEntries, space);
}
/**
- * The "add view display..." shortcut: the result-level action of the About tab's
+ * The "add view display..." shortcuts: the result-level actions of the About tab's
* view-displays view ({@link AboutSpacePanel#VIEW_DISPLAYS_VIEW}), rendered the same
- * way the view itself renders it (template link with the space pre-filled as target),
- * so the shortcut stays in sync with the view nanopub's action declaration.
+ * way the view itself renders them (template link with the space pre-filled as target),
+ * so the shortcuts stay in sync with the view nanopub's action declarations.
+ *
+ * The view declares more than one such action (issue #641 added a part-level variant
+ * next to the plain one), and the menu offers all of them the viewer is entitled to, in
+ * the order the view nanopub lists them.
*/
- private static AbstractLink addViewDisplayLink(Space space) {
+ private static List addViewDisplayLinks(Space space) {
+ List links = new ArrayList<>();
try {
View view = View.get(AboutSpacePanel.VIEW_DISPLAYS_VIEW);
- if (view == null) return null;
+ if (view == null) return links;
for (IRI actionIri : view.getViewResultActionList()) {
if (!SpaceMemberRole.isViewerEntitled(view.getActionVisibleTo(actionIri), space, null)) continue;
Template t = view.getTemplateForAction(actionIri);
@@ -256,12 +260,12 @@ private static AbstractLink addViewDisplayLink(Space space) {
} else {
l.setBody(Model.of(label));
}
- return l;
+ links.add(l);
}
} catch (Exception ex) {
- logger.error("Couldn't build add-view-display shortcut for space {}", space.getId(), ex);
+ logger.error("Couldn't build add-view-display shortcuts for space {}", space.getId(), ex);
}
- return null;
+ return links;
}
/**