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

knowledgepixels / nanodash / 27622721129

16 Jun 2026 01:55PM UTC coverage: 26.963% (+6.3%) from 20.697%
27622721129

Pull #483

github

web-flow
Merge 73a4d0fe1 into 663f14f46
Pull Request #483: Space/resource About pages, ref-aware spaces, and magic query params

1542 of 6717 branches covered (22.96%)

Branch coverage included in aggregate %.

3407 of 11638 relevant lines covered (29.27%)

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

3
import com.knowledgepixels.nanodash.component.menu.BaseDisplayMenu;
4
import org.apache.wicket.ajax.AjaxRequestTarget;
5
import org.apache.wicket.ajax.markup.html.AjaxLink;
6
import org.apache.wicket.markup.html.basic.Label;
7
import org.apache.wicket.markup.html.link.ExternalLink;
8
import org.apache.wicket.markup.html.panel.Panel;
9
import org.apache.wicket.model.IModel;
10
import org.eclipse.rdf4j.model.IRI;
11

12
/**
13
 * External link with Actions Panel that allows to copy the link and explore it through the Nanodash ExplorePage.
14
 */
15
public class ExternalLinkWithActionsPanel extends Panel {
16

17
    private final IModel<String> urlModel;
18
    private IModel<String> labelModel;
19
    private IRI sourceNanopub;
20
    private BaseDisplayMenu customMenu;
21

22
    public ExternalLinkWithActionsPanel(String id, IModel<String> urlModel) {
23
        super(id);
×
24
        this.urlModel = urlModel;
×
25
    }
×
26

27
    public ExternalLinkWithActionsPanel(String id, IModel<String> urlModel, IModel<String> labelModel) {
28
        this(id, urlModel);
×
29
        this.labelModel = labelModel;
×
30
    }
×
31

32
    public ExternalLinkWithActionsPanel(String id, IModel<String> urlModel, IModel<String> labelModel, IRI sourceNanopub) {
33
        this(id, urlModel, labelModel);
×
34
        this.sourceNanopub = sourceNanopub;
×
35
    }
×
36

37
    public ExternalLinkWithActionsPanel(String id, IModel<String> urlModel, IModel<String> labelModel, BaseDisplayMenu customMenu) {
38
        this(id, urlModel, labelModel);
×
39
        this.customMenu = customMenu;
×
40
    }
×
41

42
    @Override
43
    protected void onInitialize() {
44
        super.onInitialize();
×
45

46
        ExternalLink externalLink = new ExternalLink("externalLink", urlModel, urlModel);
×
47
        add(externalLink);
×
48

49
        // The "copy link" action is the single entry of a borderless dropdown menu
50
        // (the .link-copy-menu chevron), not an icon button.
51
        AjaxLink<Void> copyLinkButton = new AjaxLink<>("copyLinkButton") {
×
52
            @Override
53
            public void onClick(AjaxRequestTarget target) {
54
                String url = urlModel.getObject();
×
55
                String escapedUrl = url.replace("'", "\\'");
×
56
                target.appendJavaScript(
×
57
                        "navigator.clipboard.writeText('" + escapedUrl + "')" +
58
                        ".then(function() { showToast('Link copied to clipboard!'); })" +
59
                        ".catch(function(err) { console.error('Copy failed:', err); });"
60
                );
61
            }
×
62
        };
63
        add(copyLinkButton);
×
64

65
        // The "explore" action is now reachable via the resource's Explore tab,
66
        // so this panel no longer shows an explore button or an explore menu.
67
        // A custom menu (e.g. the space admin actions) is still shown when given.
68
        add(new Label("exploreButton", "").setVisible(false));
×
69
        if (customMenu != null) {
×
70
            add(customMenu);
×
71
        } else {
72
            add(new Label("np", "").setVisible(false));
×
73
        }
74
    }
×
75

76
    @Override
77
    protected void onDetach() {
78
        super.onDetach();
×
79
        urlModel.detach();
×
80
        if (labelModel != null) {
×
81
            labelModel.detach();
×
82
        }
83
    }
×
84

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