Skip to content

Commit

Permalink
Merge branch 'tippy-1-tooltip' into keyboard-shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Mar 28, 2022
2 parents 54b47b5 + 32d790a commit 959f586
Show file tree
Hide file tree
Showing 18 changed files with 191 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<l:icon class="icon-lock icon-sm" tooltip="${%Keep this build forever}:&lt;br/&gt;${h.xmlEscape(build.whyKeepLog)}" xmlns:l="/lib/layout"/>
<l:icon class="icon-lock icon-sm" tooltip="${%Keep this build forever}:\n${h.xmlEscape(build.whyKeepLog)}" xmlns:l="/lib/layout"/>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ THE SOFTWARE.
<td class="build-row-cell">
<div class="pane build-name">
<div class="build-icon">
<a class="build-status-link" href="${link}console"><l:icon alt="${build.iconColor.description} &gt; ${%Console Output}" class="${build.buildStatusIconClassName} icon-sm" tooltip="${build.iconColor.description} &gt; ${%Console Output}"/></a>
<a class="build-status-link" href="${link}console" tooltip="${build.iconColor.description} > ${%Console Output}">
<l:icon class="${build.buildStatusIconClassName} icon-sm" />
</a>
</div>
<a class="model-link inside build-link display-name" update-parent-class=".build-row" href="${link}">${build.displayName}</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ THE SOFTWARE.
class="am-button"
href="#"
data-href="${rootURL}/administrativeMonitorsApi/nonSecurityPopupContent"
title="${%tooltip(activeNonSecurityAMCount)}">
tooltip="${%tooltip(activeNonSecurityAMCount)}">
<l:svgIcon
href="${resURL}/images/material-icons/svg-sprite-social-symbol.svg#ic_notifications_24px"/>
<div class="am-monitor__indicator-mobile"/>
Expand All @@ -57,7 +57,7 @@ THE SOFTWARE.
class="am-button security-am"
href="#"
data-href="${rootURL}/administrativeMonitorsApi/securityPopupContent"
title="${%tooltipSec(activeSecurityAMCount)}">
tooltip="${%tooltipSec(activeSecurityAMCount)}">
<l:svgIcon
href="${resURL}/images/material-icons/svg-sprite-action-symbol.svg#ic_warning_shield_24px"/>
<div class="am-monitor__indicator-mobile"/>
Expand Down
56 changes: 30 additions & 26 deletions core/src/main/resources/lib/hudson/buildHealth.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,36 @@ THE SOFTWARE.
<j:set var="buildHealth" value="${empty(healthReports) ? emptyHealthReport : healthReports[0]}"/>
<j:if test="${td}"><j:set var="useTdElement" value="x"/></j:if>
<x:element name="${useTdElement!=null?'td':'div'}">
<x:attribute name="data">${buildHealth.score}</x:attribute>
<x:attribute name="class">jenkins-table__cell--tight jenkins-table__icon healthReport</x:attribute>
<x:attribute name="data">${buildHealth.score}</x:attribute>
<x:attribute name="class">jenkins-table__cell--tight jenkins-table__icon</x:attribute>
<j:if test="${!empty(healthReports)}">
<x:attribute name="html-tooltip">
<div class="jenkins-tooltip--table-wrapper">
<table class="jenkins-table">
<thead>
<tr>
<th align="left">W</th>
<th align="left">${%Description}</th>
<th align="right">%</th>
</tr>
</thead>
<tbody>
<j:forEach var="rpt" items="${healthReports}">
<tr>
<td align="left" class="jenkins-table__cell--tight jenkins-table__icon">
<div class="jenkins-table__cell__button-wrapper">
<l:icon class="${rpt.iconClassName} icon-sm" />
</div>
</td>
<td>${rpt.localizableDescription}</td>
<td align="right">${rpt.score}</td>
</tr>
</j:forEach>
</tbody>
</table>
</div>
</x:attribute>
</j:if>
<j:if test="${buildHealth!=null}">
<div class="jenkins-table__cell__button-wrapper">
<j:if test="${iconSizeClass == null}">
Expand All @@ -62,29 +90,5 @@ THE SOFTWARE.
</j:choose>
</div>
</j:if>
<j:if test="${!empty(healthReports)}">
<div class="jenkins-tooltip healthReportDetails">
<table class="jenkins-table">
<thead>
<tr>
<th align="left">W</th>
<th align="left">${%Description}</th>
<th align="right">%</th>
</tr>
</thead>
<tbody>
<j:forEach var="rpt" items="${healthReports}">
<tr>
<td align="left">
<l:icon class="${rpt.iconClassName} icon-sm" />
</td>
<td align="left">${rpt.localizableDescription}</td>
<td align="right">${rpt.score}</td>
</tr>
</j:forEach>
</tbody>
</table>
</div>
</j:if>
</x:element>
</j:jelly>
2 changes: 1 addition & 1 deletion core/src/main/resources/lib/hudson/queue.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ THE SOFTWARE.
<j:set var="stuck" value="${item.isStuck()}"/>
<j:choose>
<j:when test="${h.hasPermission(item.task,item.task.READ)}">
<a href="${rootURL}/${item.task.url}" class="model-link inside tl-tr" tooltip="${h.escape(item.causesDescription)}${h.escape(item.why)}${h.escape(item.params)}&lt;br&gt;${%WaitingFor(item.inQueueForString)}">
<a href="${rootURL}/${item.task.url}" class="model-link inside tl-tr" tooltip="${h.escape(item.causesDescription)}${h.escape(item.why)}${h.escape(item.params)}\n${%WaitingFor(item.inQueueForString)}">
<l:breakable value="${item.task.fullDisplayName}"/>
</a>
<!-- TODO include estimated number as in BuildHistoryWidget/entries.jelly if possible -->
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/lib/layout/layout.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ THE SOFTWARE.
</j:if>

<script src="${resURL}/jsbundles/keyboard-shortcuts.js" type="text/javascript"/>
<script src="${resURL}/jsbundles/tooltips.js" type="text/javascript" />

<!-- SVG sprite polyfill for IE 11.
Loaded at the end in order to not make modern browsers wait for it. This causes a flash-of-no-icons on IE 11 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function progressivelyRender(handler, callback, statusId) {
if (r.status == 'done') {
callback(r.data);
$(statusId).style.display = 'none';
registerTooltips();
} else if (r.status == 'canceled') {
// TODO ugly; replace with single tr of class=unknown?
$$('#' + statusId + ' .progress-bar-done')[0].innerHTML = 'Aborted.';
Expand All @@ -40,6 +41,7 @@ function progressivelyRender(handler, callback, statusId) {
$$('#' + statusId + ' .progress-bar-done')[0].style.width = (100 * r.status) + '%';
$$('#' + statusId + ' .progress-bar-left')[0].style.width = (100 - 100 * r.status) + '%';
checkNewsLater(500);
registerTooltips();
}
}
function checkNewsLater(timeout) {
Expand Down
1 change: 1 addition & 0 deletions war/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"raf": "^3.4.1",
"regenerator-runtime": "^0.13.9",
"sortablejs": "^1.13.0",
"tippy.js": "^6.3.7",
"window-handle": "^1.0.0"
},
"browserslist": [
Expand Down
81 changes: 81 additions & 0 deletions war/src/main/js/tooltips.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import tippy from "tippy.js"

const TOOLTIP_BASE = {
arrow: false,
theme: "tooltip",
animation: "tooltip",
appendTo: document.body
}

let tooltipInstances = []
const globalPlugin = {
fn() {
return {
onCreate(instance) {
tooltipInstances = tooltipInstances.concat(instance);
},
onDestroy(instance) {
tooltipInstances = tooltipInstances.filter(i => i !== instance);
}
}
}
}

tippy.setDefaultProps({
plugins: [globalPlugin]
})

registerTooltips()

/**
* Registers tooltips for the page
* If called again, destroys existing tooltips and registers them again (useful for progressive rendering)
* @param {HTMLElement} container - Registers the tooltips for the given container
*/
function registerTooltips(container = document) {
tooltipInstances.forEach(instance => {
if (instance.props.container === container) {
instance.destroy()
}
})

tippy(container.querySelectorAll("[tooltip]:not([tooltip=\"\"])"), {
content: element => element.getAttribute("tooltip")
.replace("<br>", "\n")
.replace("<br/>", "\n")
.replace("\\n", "\n"),
container: container,
...TOOLTIP_BASE
})

tippy(container.querySelectorAll("[html-tooltip]"), {
content: element => element.getAttribute("html-tooltip"),
allowHTML: true,
container: container,
...TOOLTIP_BASE
})
}

/**
* Displays a tooltip for three seconds on the provided element after interaction
* @param {string} text - The tooltip text
* @param {HTMLElement} element - The element to show the tooltip
*/
function hoverNotification(text, element) {
const tooltip = tippy(element, {
interactive: true,
trigger: "hover",
offset: [0, 0],
content: text,
...TOOLTIP_BASE,
onShow(instance) {
setTimeout(() => {
instance.hide()
}, 3000)
},
})
tooltip.show()
}

window.registerTooltips = registerTooltips
window.hoverNotification = hoverNotification
6 changes: 3 additions & 3 deletions war/src/main/less/abstracts/theme.less
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@
--link-font-weight: 600;

// Tooltips
--tooltip-background-color: var(--background);
--tooltip-foreground-color: var(--text-color);
--tooltip-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.05), 0 2px 2px rgba(0, 0, 0, 0.05), 0 10px 20px rgba(0, 0, 0, 0.2);
--tooltip-background: rgba(white, 0.55);
--tooltip-color: var(--text-color);
--tooltip-box-shadow: 0 0 8px 2px rgba(0, 0, 30, 0.05), 0 0 1px 1px rgba(0, 0, 20, 0.025), 0 10px 20px rgba(0, 0, 20, 0.15);

// Dark link
--link-dark-color: var(--text-color);
Expand Down
1 change: 0 additions & 1 deletion war/src/main/less/base/layout-commons.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@import '../abstracts/theme.less';

html {
position: relative;
height: 100%;
box-sizing: border-box;
}
Expand Down
6 changes: 6 additions & 0 deletions war/src/main/less/modules/table.less
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
color: var(--table-header-foreground);
font-weight: 700;
}

svg {
vertical-align: middle;
width: 0.8rem;
height: 0.8rem;
}
}
}
}
Expand Down
54 changes: 44 additions & 10 deletions war/src/main/less/modules/tooltips.less
Original file line number Diff line number Diff line change
@@ -1,12 +1,46 @@
.jenkins-tooltip {
position: absolute;
padding: 5px 10px;
.tippy-box[data-theme~='tooltip'] {
background: var(--tooltip-background);
color: var(--tooltip-color);
padding: 0.55rem 0.8rem;
border-radius: 10px;
background: var(--tooltip-background-color);
box-shadow: var(--tooltip-shadow);
color: var(--tooltip-foreground-color);
font-size: 0.8rem;
z-index: 1001 !important;
overflow: hidden;
max-width: none !important;
box-shadow: var(--tooltip-box-shadow);
font-weight: 500;
font-size: 0.75rem;
backdrop-filter: saturate(2) blur(15px);
max-width: unset !important;
white-space: pre-line;

.tippy-content {
padding: 0;
}

// We style tables as they have additional margin/border radius when in tooltips
.jenkins-tooltip--table-wrapper {
background-color: rgba(black, 0.05);
margin: -0.55rem -0.8rem;
border-radius: 10px;
}

.jenkins-table {
--table-background: transparent;
--table-border-radius: 8px;

margin: 0;
width: 450px;
}
}

.tippy-box[data-animation='tooltip'][data-state='hidden'] {
opacity: 0;
transform: scale(0.995);

&[data-placement^="top"] {
transform-origin: bottom;
transform: translateY(2px) scale(0.995);
}

&[data-placement^="bottom"] {
transform-origin: top;
transform: translateY(-2px) scale(0.995);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 959f586

Please sign in to comment.