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

[JENKINS-71326] - Support colored badges in breadcrumb dropdown #8853

Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions core/src/main/java/jenkins/management/Badge.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public String getTooltip() {
*
* @return severity as String
*/
@Exported(visibility = 999)
public String getSeverity() {
return severity.toString().toLowerCase(Locale.US);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ THE SOFTWARE.
<a href="${m.urlName}">
<div class="jenkins-section__item__icon" aria-hidden="true">
<l:icon src="${m.iconFileName}" class="icon" />
<j:set var="badge" value="${m.badge}"/>
<j:if test="${badge != null}">
<div tooltip="${badge.tooltip}" class="jenkins-section__item__icon__badge alert-${badge.severity}">
${badge.text}
</div>
</j:if>
<l:badge badge="${m.badge}"/>
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved
</div>
<dl>
<dt>${m.displayName}</dt>
Expand Down
37 changes: 37 additions & 0 deletions core/src/main/resources/lib/layout/badge.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
The MIT License

Copyright (c) 2012- CloudBees, Inc.
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved
<st:documentation>
If a Badge is informed it will be displayed, otherwise nothing is done.
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved
<st:attribute name="badge">
Badge to be displayed, accepts null value.
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved
</st:attribute>
</st:documentation>
<j:if test="${badge != null}">
<span class="badge alert-${attrs.badge.severity}" tooltip="${badge.tooltip}">
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved
${badge.text}
</span>
</j:if>
</j:jelly>
18 changes: 3 additions & 15 deletions core/src/main/resources/lib/layout/task.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,7 @@ THE SOFTWARE.
<l:icon src="${icon}" />
</span>
<span class="task-link-text">${title}</span>
<j:if test="${attrs.badge != null}">
<span class="task-icon-badge" tooltip="${attrs.badge.tooltip}">
${attrs.badge.text}
</span>
</j:if>
<l:badge badge="${attrs.badge}"/>
</span>
</span>
</div>
Expand All @@ -181,11 +177,7 @@ THE SOFTWARE.
<l:icon src="${icon}" />
</span>
<span>${title}</span>
<j:if test="${attrs.badge != null}">
<span class="task-icon-badge" tooltip="${attrs.badge.tooltip}">
${attrs.badge.text}
</span>
</j:if>
<l:badge badge="${attrs.badge}"/>
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved
</l:confirmationLink>
</j:when>

Expand All @@ -202,11 +194,7 @@ THE SOFTWARE.
<l:icon src="${icon}" />
</span>
<span class="task-link-text">${title}</span>
<j:if test="${attrs.badge != null}">
<span class="task-icon-badge" tooltip="${attrs.badge.tooltip}">
${attrs.badge.text}
</span>
</j:if>
<l:badge badge="${attrs.badge}"/>
</m:a>
<st:adjunct includes="lib.layout.task.task" />
</j:otherwise>
Expand Down
4 changes: 3 additions & 1 deletion war/src/main/js/components/dropdowns/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ function menuItem(options) {
const label = xmlEscape(itemOptions.label);
let badgeText;
let badgeTooltip;
let badgeSeverity;
if (itemOptions.badge) {
badgeText = xmlEscape(itemOptions.badge.text);
badgeTooltip = xmlEscape(itemOptions.badge.tooltip);
badgeSeverity = xmlEscape(itemOptions.badge.severity);
}
const tag = itemOptions.type === "link" ? "a" : "button";

Expand All @@ -58,7 +60,7 @@ function menuItem(options) {
${label}
${
itemOptions.badge != null
? `<span class="jenkins-dropdown__item__badge" tooltip="${badgeTooltip}">${badgeText}</span>`
? `<span class="badge alert-${badgeSeverity}" tooltip="${badgeTooltip}">${badgeText}</span>`
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved
: ``
}
${
Expand Down
28 changes: 28 additions & 0 deletions war/src/main/scss/components/_badges.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,31 @@
.am-badge {
display: inline;
}

.badge {
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved
display: flex;
align-items: center;
justify-content: center;
border-radius: 100px;
font-size: 0.7rem;
min-height: 20px;
min-width: 20px;
padding: 0 0.4rem;
box-shadow: 0 1px 1px rgba(black, 0.1);
animation: animate-in-badge var(--elastic-transition) 0.1s both;

&::after {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(white, black);
border-radius: 100px;
mix-blend-mode: overlay;
opacity: 0.35;
}
}
@keyframes animate-in-badge {
from {
transform: scale(0);
}
}
12 changes: 1 addition & 11 deletions war/src/main/scss/components/_dropdowns.scss
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,9 @@ $dropdown-padding: 0.4rem;
}
}

&__badge {
position: relative;
.badge {
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved
margin-left: auto;
margin-right: -0.85rem;

&::before {
content: "";
position: absolute;
inset: -0.0625rem -0.375rem;
background: var(--text-color-secondary);
opacity: 0.1;
border-radius: 100vmax;
}
}

&__chevron {
Expand Down
38 changes: 6 additions & 32 deletions war/src/main/scss/components/_section.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,39 +90,19 @@
background: var(--item-background--active);
}

.badge{
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved
position: absolute;
top: -4px;
right: -4px;
}

img,
svg {
position: relative;
width: 50% !important;
height: 50% !important;
color: currentColor;
}

&__badge {
position: absolute;
top: -4px;
right: -4px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 100px;
font-size: 0.7rem;
min-height: 20px;
min-width: 20px;
padding: 0 0.4rem;
box-shadow: 0 1px 1px rgba(black, 0.1);
animation: animate-in-badge var(--elastic-transition) 0.1s both;

&::after {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(white, black);
border-radius: 100px;
mix-blend-mode: overlay;
opacity: 0.35;
}
}
}

dt {
Expand All @@ -140,9 +120,3 @@
font-size: 0.925rem;
}
}

@keyframes animate-in-badge {
from {
transform: scale(0);
}
}
20 changes: 1 addition & 19 deletions war/src/main/scss/components/_side-panel-tasks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,8 @@ $background-outset: 0.7rem;
}
}

.task-icon-badge {
position: relative;
color: currentColor;
letter-spacing: 0;
z-index: 0;
.badge {
eduardojandre marked this conversation as resolved.
Show resolved Hide resolved
margin-left: auto;
min-width: 24px;
text-align: center;
padding: 0 8px;
line-height: 0.75rem;
font-size: 0.75rem;

&::before {
content: "";
position: absolute;
inset: -6px 0;
background: var(--item-background--hover);
border-radius: 100px;
z-index: -1;
}
}

.task-link-text {
Expand Down