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

knowledgepixels / nanodash / 22618039211

03 Mar 2026 10:05AM UTC coverage: 16.058% (+0.2%) from 15.884%
22618039211

Pull #365

github

web-flow
Merge 1e7e700f0 into a8c4b4a77
Pull Request #365: Refactor of `ResourceWithProfile` and related classes

699 of 5287 branches covered (13.22%)

Branch coverage included in aggregate %.

1721 of 9783 relevant lines covered (17.59%)

2.41 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.domain.User;
6
import com.knowledgepixels.nanodash.domain.UserData;
7
import com.knowledgepixels.nanodash.page.PublishPage;
8
import org.apache.wicket.markup.html.link.ExternalLink;
9
import org.apache.wicket.markup.html.panel.Panel;
10
import org.apache.wicket.markup.repeater.Item;
11
import org.apache.wicket.markup.repeater.data.DataView;
12
import org.apache.wicket.markup.repeater.data.ListDataProvider;
13
import org.eclipse.rdf4j.model.IRI;
14

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

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

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

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

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

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

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

68
        });
69

70
        setVisible(!menuItems.isEmpty());
×
71
    }
×
72

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