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

Replace YUI tooltips with Tippy.js #6408

Merged
merged 120 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
0ff896b
Add yarn deps
janfaracik Mar 15, 2022
db1928d
Add initial JS files
janfaracik Mar 15, 2022
09e9109
WB
janfaracik Mar 15, 2022
491b1f1
Update hudson-behavior.js
janfaracik Mar 15, 2022
1fbcc55
Update tooltips.less
janfaracik Mar 15, 2022
940d51a
WB
janfaracik Mar 15, 2022
7e6c576
Fix tooltip showing when it shouldn't, improve appearance
janfaracik Mar 15, 2022
df6847a
Now possible to reregister tooltips
janfaracik Mar 15, 2022
7e43dfa
Update buildHealth.jelly
janfaracik Mar 15, 2022
133c486
Update header tooltips, add base tooltip styling
janfaracik Mar 15, 2022
7223890
Add percentage symbol
janfaracik Mar 15, 2022
22f300a
Merge branch 'master' into tippy-1-tooltip
janfaracik Mar 17, 2022
9be65d6
Update prototype.js
janfaracik Mar 18, 2022
60e4232
Update tooltips.js
janfaracik Mar 18, 2022
93632d3
Merge branch 'master' into tippy-1-tooltip
janfaracik Mar 22, 2022
bfce09a
Fix new lines in tooltips, fix empty tooltips showing
janfaracik Mar 27, 2022
f7659aa
Fix last build successful from having a title
janfaracik Mar 27, 2022
d5608a1
Fix new line in queue tooltip
janfaracik Mar 28, 2022
32d790a
Now possible to reregister tooltips for a specific container
janfaracik Mar 28, 2022
7c52bc0
Merge branch 'master' into tippy-1-tooltip
janfaracik Mar 29, 2022
9365c34
Fix 1 test
timja Mar 30, 2022
68b0aea
Fix hetero list tooltip
janfaracik Mar 30, 2022
43d61dd
Remove escaping for tooltip
janfaracik Mar 30, 2022
b5c0656
Make html-tooltips interactive
janfaracik Apr 4, 2022
2a9e85c
Fix backdrop filter for Firefox, fix table squared corners in Firefox…
janfaracik Apr 6, 2022
684956a
Remove SVG tooltip test as all tooltips are escaped by default
janfaracik Apr 6, 2022
468cbcf
Remove more
janfaracik Apr 6, 2022
4fd7150
Use background colour for tooltip bg
janfaracik Apr 6, 2022
78eef78
Fix unit test
janfaracik Apr 7, 2022
16fe806
Update RepeatableTest.java
janfaracik Apr 8, 2022
9ff6c65
Update RepeatableTest.java
janfaracik Apr 8, 2022
ef041dc
Merge branch 'master' into tippy-1-tooltip
timja Apr 8, 2022
1e8b7b8
Update new line replacement list
janfaracik Apr 12, 2022
4d62a20
Set title for screenreaders, remove on interactino
janfaracik Apr 12, 2022
a552b93
Merge branch 'tippy-1-tooltip' of https://github.com/janfaracik/jenki…
janfaracik Apr 12, 2022
0f33db2
Merge branch 'master' into tippy-1-tooltip
janfaracik Apr 14, 2022
ec3c851
Create yarn.lock
janfaracik Apr 14, 2022
daaa710
Attempt at passing build
janfaracik Apr 14, 2022
228c1fa
Fix JS (htmlunit is not my friend)
janfaracik Apr 17, 2022
cf491b1
Merge branch 'master' into tippy-1-tooltip
janfaracik Apr 17, 2022
bbc1528
Update tooltips.js
janfaracik Apr 17, 2022
0be118f
Merge branch 'master' into tippy-1-tooltip
NotMyFault Apr 18, 2022
9eec535
Merge branch 'master' into tippy-1-tooltip
timja May 1, 2022
eff05c8
Fix tooltip appearance for super wordy tooltips
janfaracik May 2, 2022
e409234
Replace all br in tooltip not just first
timja May 2, 2022
dfec00f
Merge branch 'master' into tippy-1-tooltip
timja May 7, 2022
7b6caca
HtmlUnit doesn't support replaceAll -.-
timja May 7, 2022
e15f08c
Don't apply tooltip and html-tooltip together, remove interactive
timja May 7, 2022
65c7379
Merge branch 'master' into tippy-1-tooltip
janfaracik May 13, 2022
75ac99d
Merge branch 'master' into tippy-1-tooltip
janfaracik May 23, 2022
b1ce8f6
Merge branch 'master' into tippy-1-tooltip
daniel-beck May 31, 2022
07c0005
Merge branch 'master' into tippy-1-tooltip
janfaracik May 31, 2022
50100c3
Merge branch 'master' into tippy-1-tooltip
janfaracik Jun 2, 2022
dcf52ce
Merge branch 'master' into tippy-1-tooltip
timja Jun 22, 2022
9b006ba
Merge branch 'master' into tippy-1-tooltip
timja Jun 23, 2022
9344488
html-tooltip support for icons
timja Jun 23, 2022
2dd9d9f
Escape html-tooltip
timja Jun 26, 2022
61f6553
Use data attribute as otherwise it invalidates html
timja Jun 26, 2022
66acbc1
Merge branch 'tippy-1-tooltip' of github.com:janfaracik/jenkins into …
timja Jun 26, 2022
1eef1ce
Revert unintended change
timja Jun 27, 2022
edda0e7
Tweak docs
timja Jun 27, 2022
cdad587
Merge branch 'master' into tippy-1-tooltip
janfaracik Jul 7, 2022
b61dd7e
Update yarn.lock
janfaracik Jul 7, 2022
8be0610
Merge branch 'master' into tippy-1-tooltip
janfaracik Jul 7, 2022
cc4a090
Merge branch 'master' into tippy-1-tooltip
janfaracik Jul 24, 2022
fd121b2
Lint, fix test
janfaracik Jul 24, 2022
462601e
Merge branch 'master' into tippy-1-tooltip
janfaracik Jul 24, 2022
683512c
Merge remote-tracking branch 'jenkinsci/master' into tippy-1-tooltip
daniel-beck Aug 12, 2022
0bcf83d
Merge remote-tracking branch 'origin/master' into tippy-1-tooltip
basil Aug 12, 2022
8ea8741
Merge remote-tracking branch 'origin/master' into tippy-1-tooltip
basil Aug 22, 2022
893d3c1
Merge remote-tracking branch 'origin/master' into tippy-1-tooltip
basil Aug 25, 2022
6f9055e
yarn lint
basil Aug 26, 2022
c51d1a6
Merge branch 'master' into tippy-1-tooltip
basil Aug 26, 2022
b52e3aa
Merge branch 'master' into tippy-1-tooltip
janfaracik Aug 29, 2022
1c779d3
Merge branch 'tippy-1-tooltip' of https://github.com/janfaracik/jenki…
janfaracik Aug 29, 2022
27fc179
Merge branch 'master' into tippy-1-tooltip
janfaracik Aug 29, 2022
0ac63d4
Update core/src/main/resources/lib/layout/icon.jelly
janfaracik Aug 29, 2022
87345f1
Small progress
janfaracik Aug 29, 2022
d0f7d21
Merge branch 'master' into tippy-1-tooltip
janfaracik Aug 29, 2022
5adcee3
Merge branch 'master' into tippy-1-tooltip
janfaracik Aug 30, 2022
5d0cded
Use shim
janfaracik Aug 30, 2022
e2cbf27
Apply suggestions from code review
janfaracik Aug 30, 2022
adaddab
Tidy up code
janfaracik Aug 30, 2022
db3c974
Merge remote-tracking branch 'jenkinsci/master' into tippy-1-tooltip
daniel-beck Aug 31, 2022
afa9ccc
Merge branch 'master' into tippy-1-tooltip
daniel-beck Sep 2, 2022
c166c7c
Merge branch 'master' into tippy-1-tooltip
timja Sep 23, 2022
f728b6c
Move hoverNotification setter to bottom of init
janfaracik Sep 23, 2022
76062ba
Update Security2776Test.java
janfaracik Sep 23, 2022
e009f9f
Update selector for tooltip
janfaracik Sep 26, 2022
e472a5d
Merge branch 'master' into tippy-1-tooltip
janfaracik Sep 27, 2022
816d168
Use Tippy show method
janfaracik Sep 27, 2022
94cbd3b
Change variable for tooltip backplates, alter table border radius
janfaracik Sep 27, 2022
28347fd
Hopefully fix tests
janfaracik Sep 28, 2022
a52f3ea
Refactor test
janfaracik Sep 29, 2022
80c80bd
Update Security2776Test.java
janfaracik Sep 29, 2022
185d41c
Update Security2776Test.java
janfaracik Sep 30, 2022
d0b645c
Merge branch 'master' into tippy-1-tooltip
janfaracik Sep 30, 2022
c790ca3
Update yarn.lock
janfaracik Sep 30, 2022
8d295a1
Restore tests
janfaracik Sep 30, 2022
7332213
Trigger Build
janfaracik Sep 30, 2022
3c6a349
Merge branch 'master' into tippy-1-tooltip
timja Oct 1, 2022
562e205
Merge branch 'master' into tippy-1-tooltip
janfaracik Oct 5, 2022
d21a32c
Fix test
janfaracik Oct 5, 2022
adc397a
Merge branch 'master' into tippy-1-tooltip
janfaracik Oct 5, 2022
9d84fc0
Update tooltips.less
janfaracik Oct 5, 2022
f735286
Merge branch 'tippy-1-tooltip' of https://github.com/janfaracik/jenki…
janfaracik Oct 5, 2022
374adad
Update prototype.js
janfaracik Oct 5, 2022
ad04817
Add support for interactive tooltips
janfaracik Oct 6, 2022
7e7dd24
Merge branch 'master' into tippy-1-tooltip
janfaracik Oct 9, 2022
573b6c4
Merge branch 'master' into tippy-1-tooltip
timja Oct 17, 2022
08e63ab
Merge branch 'master' into tippy-1-tooltip
janfaracik Oct 19, 2022
49bda1b
Update buildHealth.jelly
janfaracik Oct 19, 2022
0801d1f
Merge branch 'master' into tippy-1-tooltip
janfaracik Oct 19, 2022
cdf830d
Merge branch 'master' into tippy-1-tooltip
timja Nov 3, 2022
07c0d94
Merge branch 'master' into tippy-1-tooltip
timja Nov 13, 2022
a1e2f9a
Update core/src/main/java/org/jenkins/ui/icon/IconSet.java
timja Nov 14, 2022
d31a25a
Remove need for double escaping
timja Nov 14, 2022
084d703
Fix some of the tests
timja Nov 14, 2022
c1e1bb6
More fixes
timja Nov 20, 2022
c6735ca
Remove double escaping
timja Nov 20, 2022
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 @@ -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)}">
janfaracik marked this conversation as resolved.
Show resolved Hide resolved
<l:breakable value="${item.task.fullDisplayName}"/>
</a>
<!-- TODO include estimated number as in BuildHistoryWidget/entries.jelly if possible -->
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/resources/lib/layout/layout.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ THE SOFTWARE.
</footer>
</j:if>

<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 -->
<script src="${resURL}/scripts/svgxuse.min.js" type="text/javascript" async="true" />
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 @@ -58,6 +58,7 @@
"lodash": "^4.17.20",
"raf": "^3.4.1",
"sortablejs": "^1.13.0",
"tippy.js": "^6.3.7",
"window-handle": "^1.0.0"
},
"browserslist": [
Expand Down
76 changes: 76 additions & 0 deletions war/src/main/js/tooltips.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
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)
*/
function registerTooltips() {
tooltipInstances.forEach(instance => {
instance.destroy()
})

tippy("[tooltip]:not([tooltip=\"\"])", {
content: element => element.getAttribute("tooltip")
.replace("<br>", "\n")
.replace("<br/>", "\n")
timja marked this conversation as resolved.
Show resolved Hide resolved
.replace("\\n", "\n"),
janfaracik marked this conversation as resolved.
Show resolved Hide resolved
...TOOLTIP_BASE
})

tippy("[html-tooltip]", {
content: element => element.getAttribute("html-tooltip"),
allowHTML: true,
...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;
janfaracik marked this conversation as resolved.
Show resolved Hide resolved
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;
}
Comment on lines +52 to +57
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular, this is the hunk that fixes JENKINS-70369. Could possibly be backported to stable-2.375 if desired, but likely not worth the effort for such a minor issue.

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