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 0f7e4d9d..00000000 --- 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 c4c16102..873fd906 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; } /**