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

knowledgepixels / nanodash / 33887130277

04 Sep 2026 03:01PM UTC coverage: 42.596% (+0.06%) from 42.535%
33887130277

push

github

web-flow
Merge pull request #687 from knowledgepixels/fix/684-cold-start-without-query-service

fix(cold start): serve pages when a service cannot answer

3976 of 10121 branches covered (39.28%)

Branch coverage included in aggregate %.

7298 of 16346 relevant lines covered (44.65%)

7.1 hits per line

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

46.53
src/main/java/com/knowledgepixels/nanodash/component/JustPublishedMessagePanel.java
1
package com.knowledgepixels.nanodash.component;
2

3
import com.knowledgepixels.nanodash.NavigationContext;
4
import org.apache.wicket.ajax.AjaxRequestTarget;
5
import org.apache.wicket.ajax.markup.html.AjaxLink;
6
import org.apache.wicket.markup.html.WebMarkupContainer;
7
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
8
import org.apache.wicket.markup.html.link.ExternalLink;
9
import org.apache.wicket.markup.html.panel.Panel;
10
import org.apache.wicket.model.Model;
11
import org.apache.wicket.request.mapper.parameter.PageParameters;
12
import org.nanopub.Nanopub;
13
import org.nanopub.NanopubUtils;
14
import org.nanopub.vocabulary.NPX;
15

16
import com.knowledgepixels.nanodash.NanodashSession;
17
import com.knowledgepixels.nanodash.Utils;
18
import com.knowledgepixels.nanodash.domain.User;
19
import com.knowledgepixels.nanodash.page.ExplorePage;
20
import com.knowledgepixels.nanodash.page.ProfilePage;
21
import com.knowledgepixels.nanodash.page.UserPage;
22

23
/**
24
 * Title-bar message panel rendering up to three stacked boxes:
25
 * <ul>
26
 *   <li>a blue "successfully published" confirmation box, shown only right after
27
 *       publishing (i.e. when the page carries a "just-published" parameter) and
28
 *       dismissable via a close button;</li>
29
 *   <li>a red "you haven't published an introduction yet" warning box, shown on
30
 *       <em>every</em> page (no close button) whenever a logged-in user with a
31
 *       local key has not yet published an introduction linking that key to their
32
 *       ORCID. It disappears only once such an introduction is published; and</li>
33
 *   <li>an amber "your account is pending" notice box, shown on <em>every</em>
34
 *       page whenever the user has an introduction but no approved key yet
35
 *       (issue #625), asking them to share their introduction so an approved
36
 *       user can approve it.</li>
37
 * </ul>
38
 */
39
public class JustPublishedMessagePanel extends Panel {
40

41
    public JustPublishedMessagePanel(String id, PageParameters parameters) {
42
        super(id);
9✔
43
        // Placeholder tag so the centered title-bar slot collapses cleanly when
44
        // there is nothing to show.
45
        setOutputMarkupPlaceholderTag(true);
12✔
46

47
        NanodashSession session = NanodashSession.get();
6✔
48
        String justPublishedId = parameters.get("just-published").toString("");
18✔
49
        boolean justPublished = !justPublishedId.isEmpty();
15!
50

51
        // --- Confirmation box: only right after publishing; dismissable. ---
52
        final WebMarkupContainer confirmBox = new WebMarkupContainer("confirmBox");
15✔
53
        confirmBox.setOutputMarkupPlaceholderTag(true);
12✔
54
        confirmBox.setVisible(justPublished);
12✔
55
        add(confirmBox);
27✔
56
        if (justPublished) {
6!
57
            confirmBox.add(new AjaxLink<Void>("confirmClose") {
×
58
                @Override
59
                public void onClick(AjaxRequestTarget target) {
60
                    confirmBox.setVisible(false);
×
61
                    target.add(confirmBox);
×
62
                }
×
63
            }.setBody(Model.of("×")));
×
64
            Nanopub np = Utils.getAsNanopub(justPublishedId);
×
65
            String label = (np != null ? NanopubUtils.getLabel(np) : null);
×
66
            if (label == null || label.isEmpty()) label = Utils.getShortNameFromURI(justPublishedId);
×
67
            confirmBox.add(new BookmarkablePageLink<Void>("link", ExplorePage.class, new PageParameters().set("id", justPublishedId))
×
68
                    .setBody(Model.of(Utils.truncateLinkLabel(label)))
×
69
                    .add(NavigationContext.pageContextFallback()));
×
70
            // Remember a freshly-published introduction so the warning below clears.
71
            if (np != null && Utils.usesPredicateInAssertion(np, NPX.DECLARED_BY)) session.setIntroPublishedNow();
×
72
        } else {
×
73
            confirmBox.add(new WebMarkupContainer("confirmClose").setVisible(false));
42✔
74
            confirmBox.add(new WebMarkupContainer("link").setVisible(false));
42✔
75
        }
76

77
        // --- Missing-introduction warning: shown on every page (no close button).
78
        // The user can only get rid of it by publishing an introduction. Gated on
79
        // having a local key + ORCID, so users who cannot yet publish one (no
80
        // profile set up) are not nagged. A just-published introduction takes a
81
        // moment to register, so it is suppressed for 5 minutes after publishing. ---
82
        // Both notices below say something about the user's introductions, so neither can be
83
        // said while the user data is only as much as a failing service could tell (issue
84
        // #684): "you haven't published an introduction yet" would then be about what could
85
        // not be loaded rather than about what the user has done.
86
        boolean userDataKnown = User.getUserData().isComplete();
9✔
87
        boolean canPublishIntro = userDataKnown && session.getUserIri() != null && session.getKeyPair() != null;
21!
88
        boolean hasLocalIntro = session.getLocalIntroCount() > 0;
15!
89
        boolean recentlyPublishedIntro = session.getTimeSinceLastIntroPublished() <= 5 * 60 * 1000;
21!
90
        if (canPublishIntro && !hasLocalIntro && session.hasIntroPublished()) User.refreshUsers();
6!
91
        boolean showIntroWarning = canPublishIntro && !hasLocalIntro && !recentlyPublishedIntro;
12!
92
        WebMarkupContainer introBox = new WebMarkupContainer("introBox");
15✔
93
        introBox.setVisible(showIntroWarning);
12✔
94
        String introProfileUrl = session.getUserIri() != null
9!
95
                ? UserPage.MOUNT_PATH + "?id=" + Utils.urlEncode(session.getUserIri()) + "&tab=about"
×
96
                : ProfilePage.MOUNT_PATH + "?message=publish-intro";
6✔
97
        introBox.add(new ExternalLink("profile-link", introProfileUrl));
39✔
98
        add(introBox);
27✔
99

100
        // --- Pending-approval notice: the user has published an introduction, but no
101
        // approved user has approved it yet, and they hold no approved key elsewhere
102
        // either (issue #625). Until approval, their self-signed contributions count
103
        // as pending: they show up marked ⏳ in role listings (e.g. the observers
104
        // table) and on their own page, but stay hidden where approval is required.
105
        // Shown on every page, like the intro warning; it disappears once the
106
        // introduction is approved (via the periodic user-data refresh). Users with
107
        // an approved key elsewhere are not in this pending state — their local-key
108
        // situation is covered by the About-page recommendations instead. ---
109
        boolean anyApprovedKey = session.getUserIri() != null
9!
110
                && !User.getPubkeyhashes(session.getUserIri(), true).isEmpty();
6!
111
        boolean showPendingNotice = canPublishIntro && hasLocalIntro && !anyApprovedKey;
12!
112
        WebMarkupContainer pendingBox = new WebMarkupContainer("pendingBox");
15✔
113
        pendingBox.setVisible(showPendingNotice);
12✔
114
        pendingBox.add(new ExternalLink("about-link", introProfileUrl));
39✔
115
        add(pendingBox);
27✔
116

117
        setVisible(justPublished || showIntroWarning || showPendingNotice);
30!
118
    }
3✔
119
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc