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

knowledgepixels / nanodash / 28789064412

06 Jul 2026 11:44AM UTC coverage: 28.51% (+0.008%) from 28.502%
28789064412

push

github

web-flow
Merge pull request #535 from knowledgepixels/feat/navigation-context

feat: persistent navigation context with back-link and post-publish forwarding

1811 of 7177 branches covered (25.23%)

Branch coverage included in aggregate %.

3710 of 12188 relevant lines covered (30.44%)

4.52 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/ActionMenu.java
1
package com.knowledgepixels.nanodash.component.menu;
2

3
import com.knowledgepixels.nanodash.*;
4
import com.knowledgepixels.nanodash.action.NanopubAction;
5
import com.knowledgepixels.nanodash.domain.User;
6
import com.knowledgepixels.nanodash.domain.UserData;
7
import com.knowledgepixels.nanodash.page.NanodashPage;
8
import com.knowledgepixels.nanodash.page.PublishPage;
9
import org.apache.wicket.markup.html.link.ExternalLink;
10
import org.apache.wicket.markup.html.panel.Panel;
11
import org.apache.wicket.markup.repeater.Item;
12
import org.apache.wicket.markup.repeater.data.DataView;
13
import org.apache.wicket.markup.repeater.data.ListDataProvider;
14
import org.eclipse.rdf4j.model.IRI;
15

16
import java.net.URLEncoder;
17
import java.util.List;
18

19
import static java.nio.charset.StandardCharsets.UTF_8;
20

21
/**
22
 * A panel that displays a menu of actions that can be performed on a nanopub.
23
 */
24
public class ActionMenu extends Panel {
25

26
    /**
27
     * Constructs an ActionMenu with the given ID, list of actions, and nanopub element.
28
     *
29
     * @param id        the Wicket component ID
30
     * @param menuItems the list of actions to display in the menu
31
     * @param n         the nanopub element associated with the actions
32
     */
33
    public ActionMenu(String id, final List<NanopubAction> menuItems, final NanopubElement n) {
34
        super(id);
×
35

36
        final NanodashSession session = NanodashSession.get();
×
37
        final UserData userData = User.getUserData();
×
38
        final IRI userIri = session.getUserIri();
×
39

40
        add(new DataView<NanopubAction>("menulist", new ListDataProvider<NanopubAction>(menuItems)) {
×
41

42
            @Override
43
            protected void populateItem(Item<NanopubAction> item) {
44
                NanopubAction action = item.getModel().getObject();
×
45
                String location = "";
×
46
                String extraLabel = "";
×
47
                final String pubkey = n.getPubkey();
×
48
                final String pubkeyhash = n.getPubkeyhash();
×
49
                String sigkeyParam = "";
×
50
                if (action.isApplicableToOwnNanopubs() && !action.isApplicableToOthersNanopubs()) {
×
51
                    if (userIri != null && pubkey != null && !session.getPubkeyString().equals(pubkey)) {
×
52
                        IRI keyLocation = userData.getKeyLocationForPubkeyHash(pubkeyhash);
×
53
                        if (keyLocation == null) {
×
54
                            location = "http://localhost:37373";
×
55
                            extraLabel = " at localhost";
×
56
                        } else {
57
                            location = keyLocation.stringValue().replaceFirst("/$", "");
×
58
                            extraLabel = " at " + Utils.getPubkeyLocationName(pubkeyhash, "localhost");
×
59
                        }
60
                        sigkeyParam = "&sigkey=" + URLEncoder.encode(pubkey, UTF_8);
×
61
                    }
62
                }
63
                String contextParam = "";
×
64
                if (getPage() instanceof NanodashPage nanodashPage && nanodashPage.getContextId() != null) {
×
65
                    contextParam = "&context=" + Utils.urlEncode(nanodashPage.getContextId());
×
66
                }
67
                String url = location + PublishPage.MOUNT_PATH + "?template=" + Utils.urlEncode(action.getTemplateUri(n.getNanopub())) +
×
68
                             "&" + action.getParamString(n.getNanopub()) +
×
69
                             "&template-version=latest" + sigkeyParam + contextParam;
70
                item.add(new ExternalLink("menuitem", url, action.getLinkLabel(n.getNanopub()) + extraLabel + "..."));
×
71
            }
×
72

73
        });
74

75
        setVisible(!menuItems.isEmpty());
×
76
    }
×
77

78
}
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