Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4984 - Warnings drop-up in the footer no longer opens #4985

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ html, body {
flex: none;
min-height: $page-footer-height;
height: $page-footer-height;
overflow: hidden;
margin-top: 0px;
margin-bottom: 0px;
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,19 @@
<wicket:panel>
<wicket:container wicket:id="warnings">
<div class="dev-warnings ms-2 float-end footer-item-warnings">
<a class="alert alert-warning"
role="button"
tabindex="0"
title="Warnings"
data-bs-container="body"
data-bs-toggle="popover"
data-bs-placement="top"
data-bs-trigger="focus"
data-bs-html="true"
data-bs-popover-content="#warning-popover">
<i class="fas fa-exclamation-triangle"></i> Warnings</a>
<div class="btn-group dropup">
<button type="button" class="alert alert-warning dropdown-toggle" data-bs-toggle="dropdown" tabindex="0">
<i class="fas fa-exclamation-triangle me-2"/>Warnings
</button>
<div class="dropdown-menu p-0" style="--bs-dropdown-min-width: 30rem;">
<ul class="list-group list-group-flush">
<li wicket:id="embeddedDbWarning" class="list-group-item list-group-item-warning"></li>
<li wicket:id="browserWarning" class="list-group-item list-group-item-warning"></li>
</ul>
</div>
</div>
</div>
</wicket:container>

<div id="warning-popover" class="d-none">
<div class="popover-body">
<ul>
<li wicket:id="embeddedDbWarning"></li>
<li wicket:id="browserWarning"></li>
</ul>
</div>
</div>
</wicket:panel>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Session;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
Expand Down Expand Up @@ -59,80 +58,64 @@ public WarningsFooterPanel(String aId)

setOutputMarkupId(true);

Properties settings = SettingsUtil.getSettings();
var settings = SettingsUtil.getSettings();

// set up warnings shown when using an embedded DB or some unsupported browser
boolean isBrowserWarningVisible = isBrowserWarningVisible(settings);
boolean isDatabaseWarningVisible = isDatabaseWarningVisible(settings);
var isBrowserWarningVisible = isBrowserWarningVisible(settings);
var isDatabaseWarningVisible = isDatabaseWarningVisible(settings);

embeddedDbWarning = new Label("embeddedDbWarning", new ResourceModel("warning.database"));
embeddedDbWarning.setVisible(isDatabaseWarningVisible);
add(embeddedDbWarning);
queue(embeddedDbWarning);

browserWarning = new Label("browserWarning", new ResourceModel("warning.browser"));
browserWarning.setVisible(isBrowserWarningVisible);
add(browserWarning);
queue(browserWarning);

warningsContainer = new WebMarkupContainer("warnings");
warningsContainer.setVisible(isBrowserWarningVisible || isDatabaseWarningVisible);
add(warningsContainer);
queue(warningsContainer);
}

@Override
public void renderHead(IHeaderResponse aResponse)
{
super.renderHead(aResponse);

// @formatter:off
String script = String.join("\n",
"$(function () {",
" let panel = document.getElementById('" + getMarkupId() + "');",
" let popoverTriggerList = [].slice.call(panel.querySelectorAll('[data-bs-toggle=\"popover\"]'))",
" let popoverList = popoverTriggerList.map(function (popoverTriggerEl) {",
" return new bootstrap.Popover(popoverTriggerEl, {",
" content: function() {",
" var content = $(this).attr('data-bs-popover-content');",
" return $(content).children('.popover-body').html();",
" }});",
" });",
"});");
// @formatter:on
aResponse.render(JavaScriptHeaderItem.forScript(script, "popover"));
}

private boolean isDatabaseWarningVisible(Properties settings)
{
boolean isUsingEmbeddedDatabase;
try {
String driver = dbDriverService.getDatabaseDriverName();
var driver = dbDriverService.getDatabaseDriverName();
isUsingEmbeddedDatabase = StringUtils.contains(driver.toLowerCase(Locale.US), "hsql");
}
catch (Throwable e) {
LOG.warn("Unable to determine which database is being used", e);
isUsingEmbeddedDatabase = false;
}
boolean ignoreWarning = "false".equalsIgnoreCase(
var ignoreWarning = "false".equalsIgnoreCase(
settings.getProperty(SettingsUtil.CFG_WARNINGS_EMBEDDED_DATABASE));

return isUsingEmbeddedDatabase && !ignoreWarning;
}

private boolean isBrowserWarningVisible(Properties settings)
{
RequestCycle requestCycle = RequestCycle.get();
var requestCycle = RequestCycle.get();
WebClientInfo clientInfo;
if (Session.exists()) {
WebSession session = WebSession.get();
clientInfo = session.getClientInfo();
clientInfo = WebSession.get().getClientInfo();
}
else {
clientInfo = new WebClientInfo(requestCycle);
}

String userAgent = defaultString(clientInfo.getUserAgent(), "").toLowerCase();
boolean isUsingUnsupportedBrowser = !(userAgent.contains("safari")
var userAgent = defaultString(clientInfo.getUserAgent(), "").toLowerCase();
var isUsingUnsupportedBrowser = !(userAgent.contains("safari")
|| userAgent.contains("chrome"));

boolean ignoreWarning = "false".equalsIgnoreCase(
var ignoreWarning = "false".equalsIgnoreCase(
settings.getProperty(SettingsUtil.CFG_WARNINGS_UNSUPPORTED_BROWSER));

return isUsingUnsupportedBrowser && !ignoreWarning;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public AssignWorkDialogContentPanel(String aId,

queue(new Form<>("form", CompoundPropertyModel.of(new AssignWorkRequest())));

queue(new NumberTextField<Integer>("annotatorsPerDocument").setMinimum(1).setMaximum(100));
queue(new NumberTextField<Integer>("annotatorsPerDocument").setMinimum(1).setMaximum(100)
.setOutputMarkupId(true));

queue(new CheckBox("override").setOutputMarkupId(true));

Expand Down
Loading