• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanodash / 24123722752

08 Apr 2026 07:37AM UTC coverage: 16.207% (-0.04%) from 16.243%
24123722752

push

github

tkuhn
feat: redirect to profile page after login if no intro published, add "add to my own profile" to view display menus

- After ORCID login, redirect users without an intro to the profile
  details page (unless a redirect URL is already set)
- Redirect to user profile page after publishing intro from profile page
- Add "add to my own profile..." entry to view display dropdown menus
  on other users' profiles

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

790 of 6018 branches covered (13.13%)

Branch coverage included in aggregate %.

1978 of 11061 relevant lines covered (17.88%)

2.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/nanodash/component/menu/ViewDisplayMenu.java
1
package com.knowledgepixels.nanodash.component.menu;
2

3
import com.knowledgepixels.nanodash.ApiCache;
4
import com.knowledgepixels.nanodash.NanodashSession;
5
import com.knowledgepixels.nanodash.NanopubElement;
6
import com.knowledgepixels.nanodash.Utils;
7
import com.knowledgepixels.nanodash.ViewDisplay;
8
import com.knowledgepixels.nanodash.component.GuidedChoiceItem;
9
import com.knowledgepixels.nanodash.domain.AbstractResourceWithProfile;
10
import com.knowledgepixels.nanodash.domain.IndividualAgent;
11
import com.knowledgepixels.nanodash.domain.Space;
12
import com.knowledgepixels.nanodash.page.ExplorePage;
13
import com.knowledgepixels.nanodash.page.PublishPage;
14
import com.knowledgepixels.nanodash.page.QueryPage;
15
import com.knowledgepixels.nanodash.template.TemplateData;
16
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
17
import org.apache.wicket.markup.html.link.ExternalLink;
18
import org.apache.wicket.markup.html.link.Link;
19
import org.apache.wicket.request.mapper.parameter.PageParameters;
20
import org.eclipse.rdf4j.model.IRI;
21
import org.nanopub.extra.services.QueryRef;
22

23
/**
24
 * A dropdown menu panel for view displays, replacing the "^" source link.
25
 * Provides options to show the query, adjust the view display, and see its declaration.
26
 */
27
public class ViewDisplayMenu extends BaseDisplayMenu {
28

29
    /**
30
     * Constructs a ViewDisplayMenu.
31
     *
32
     * @param id           the Wicket component ID
33
     * @param viewDisplay  the view display this menu acts on (must have a non-null nanopub)
34
     * @param queryRef     the query reference used by this view display
35
     * @param pageResource the page-level resource used to determine whether "adjust" is visible
36
     */
37
    public ViewDisplayMenu(String id, ViewDisplay viewDisplay, QueryRef queryRef, AbstractResourceWithProfile pageResource) {
38
        super(id);
×
39

40
        PageParameters showQueryParams = new PageParameters().set("id", queryRef.getQueryId());
×
41
        for (var entry : queryRef.getParams().entries()) {
×
42
            showQueryParams.add("queryparam_" + entry.getKey(), entry.getValue());
×
43
        }
×
44
        addEntry("showQuery", new BookmarkablePageLink<Void>("showQuery", QueryPage.class, showQueryParams));
×
45

46
        IRI nanopubId = viewDisplay.getNanopubId();
×
47

48
        // Determine whether "adjust" should be visible for this user on this page
49
        boolean showAdjust = false;
×
50
        NanodashSession session = NanodashSession.get();
×
51
        if (pageResource instanceof IndividualAgent ia) {
×
52
            showAdjust = ia.isCurrentUser();
×
53
        } else if (pageResource instanceof Space s) {
×
54
            String pubkeyhash = session.getPubkeyhash();
×
55
            showAdjust = pubkeyhash != null && s.isAdminPubkey(pubkeyhash);
×
56
        } else if (pageResource != null) {
×
57
            Space space = pageResource.getSpace();
×
58
            if (space != null) {
×
59
                String pubkeyhash = session.getPubkeyhash();
×
60
                showAdjust = pubkeyhash != null && space.isAdminPubkey(pubkeyhash);
×
61
            }
62
        }
63

64
        // Determine supersede vs derive based on whether this user's pubkey matches the nanopub's
65
        String nanopubPubkey = NanopubElement.get(viewDisplay.getNanopub()).getPubkey();
×
66
        String sessionPubkey = session.getPubkeyString();
×
67
        String adjustParam = (nanopubPubkey != null && nanopubPubkey.equals(sessionPubkey))
×
68
                ? "supersede" : "derive";
×
69

70
        IRI templateId = TemplateData.get().getTemplateId(viewDisplay.getNanopub());
×
71
        String templateUri = templateId != null ? templateId.stringValue()
×
72
                : "http://purl.org/np/RACyK2NjqFgezYLiE8FQu7JI0xY1M1aNQbykeCW8oqXkA";
×
73
        String adjustUrl = PublishPage.MOUNT_PATH + "?template=" + Utils.urlEncode(templateUri)
×
74
                + "&" + adjustParam + "=" + Utils.urlEncode(nanopubId.stringValue())
×
75
                + "&template-version=latest"
76
                + "&context=" + Utils.urlEncode(pageResource.getId());
×
77
        ExternalLink adjustLink = new ExternalLink("adjust", adjustUrl, "edit view display...");
×
78
        adjustLink.setVisible(showAdjust);
×
79
        addEntry("adjust", adjustLink);
×
80

81
        BookmarkablePageLink<Void> deactivateLink = new BookmarkablePageLink<>("deactivate", PublishPage.class,
×
82
                new PageParameters()
83
                        .set("template", "https://w3id.org/np/RAZ47_4JquvEXk30HYnVeSgFRcQqHtpdibcfBOeqHI2j4")
×
84
                        .set("template-version", "latest")
×
85
                        .set("param_resource", pageResource.getId())
×
86
                        .set("param_view", viewDisplay.getViewIri() != null ? viewDisplay.getViewIri().stringValue() : viewDisplay.getView().getId())
×
87
                        .set("context", pageResource.getId())
×
88
                        .set("refresh-upon-publish", pageResource.getId()));
×
89
        deactivateLink.setVisible(showAdjust);
×
90
        addEntry("deactivate", deactivateLink);
×
91

92
        boolean showAddToOwn = session.getUserIri() != null
×
93
                && pageResource instanceof IndividualAgent ia && !ia.isCurrentUser();
×
94
        String addToOwnUrl = "";
×
95
        if (showAddToOwn) {
×
96
            String userIri = session.getUserIri().stringValue();
×
97
            String viewIri = viewDisplay.getViewIri().stringValue();
×
98
            if (viewDisplay.getView() != null && viewDisplay.getView().getLabel() != null) {
×
99
                GuidedChoiceItem.setLabel(viewIri, viewDisplay.getView().getLabel());
×
100
            }
101
            addToOwnUrl = PublishPage.MOUNT_PATH + "?template=" + Utils.urlEncode("https://w3id.org/np/RAQhTCHtfzGCj1YiE1LualWcZjg3thlRiquFWUE14UF-g")
×
102
                    + "&template-version=latest"
103
                    + "&param_resource=" + Utils.urlEncode(userIri)
×
104
                    + "&param_view=" + Utils.urlEncode(viewIri)
×
105
                    + "&context=" + Utils.urlEncode(userIri)
×
106
                    + "&refresh-upon-publish=" + Utils.urlEncode(userIri)
×
107
                    + "&param_appliesToResource=" + Utils.urlEncode(userIri);
×
108
        }
109
        ExternalLink addToOwnLink = new ExternalLink("addToOwn", addToOwnUrl, "add to my own profile...");
×
110
        addToOwnLink.setVisible(showAddToOwn);
×
111
        addEntry("addToOwn", addToOwnLink);
×
112

113
        Link<Void> refreshLink = new Link<>("refreshNow") {
×
114
            @Override
115
            public void onClick() {
116
                ApiCache.clearCache(queryRef, 0);
×
117
                setResponsePage(getPage().getClass(), getPage().getPageParameters());
×
118
            }
×
119
        };
120
        refreshLink.setVisible(session.getUserIri() != null);
×
121
        addEntry("refreshNow", refreshLink);
×
122

123
        addEntry("viewDeclaration", new BookmarkablePageLink<Void>("viewDeclaration", ExplorePage.class,
×
124
                new PageParameters().set("id", nanopubId)));
×
125
    }
×
126

127
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc