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

knowledgepixels / nanodash / 17837235071

18 Sep 2025 05:58PM UTC coverage: 13.87%. Remained the same
17837235071

push

github

tkuhn
chore: Remove serialVersionUIDs

443 of 4022 branches covered (11.01%)

Branch coverage included in aggregate %.

1133 of 7341 relevant lines covered (15.43%)

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

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

13
import java.net.URLEncoder;
14
import java.util.List;
15

16
import static java.nio.charset.StandardCharsets.UTF_8;
17

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

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

33
        final NanodashSession session = NanodashSession.get();
×
34
        final UserData userData = User.getUserData();
×
35
        final IRI userIri = session.getUserIri();
×
36

37
        add(new DataView<NanopubAction>("menulist", new ListDataProvider<NanopubAction>(menuItems)) {
×
38

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

66
        });
67

68
        setVisible(!menuItems.isEmpty());
×
69
    }
×
70

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