Skip to content

Commit 0db5e24

Browse files
modified the system message approach
1 parent 0c637a3 commit 0db5e24

File tree

5 files changed

+44
-167
lines changed

5 files changed

+44
-167
lines changed

core/src/main/java/jenkins/model/Jenkins.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,17 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
472472
*/
473473
private String systemMessage;
474474

475+
/**
476+
* @since TODO
477+
*/
478+
public enum SystemMessageSeverity {
479+
WARNING,
480+
INFO,
481+
DANGER
482+
}
483+
484+
private SystemMessageSeverity systemMessageSeverity = SystemMessageSeverity.WARNING;
485+
475486
private MarkupFormatter markupFormatter;
476487

477488
/**
@@ -1683,6 +1694,14 @@ public String getSystemMessage() {
16831694
return systemMessage;
16841695
}
16851696

1697+
public SystemMessageSeverity getSystemMessageSeverity() {
1698+
return systemMessageSeverity != null ? systemMessageSeverity : SystemMessageSeverity.WARNING;
1699+
}
1700+
1701+
public void setSystemMessageSeverity(SystemMessageSeverity systemMessageSeverity) {
1702+
this.systemMessageSeverity = systemMessageSeverity;
1703+
}
1704+
16861705
/**
16871706
* Gets the markup formatter used in the system.
16881707
*

core/src/main/resources/hudson/model/View/index.jelly

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -42,44 +42,27 @@ THE SOFTWARE.
4242
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout">
4343

4444
<j:if test="${app.systemMessage!=null}">
45-
<st:adjunct includes="hudson.model.View.system-message"/>
46-
47-
<j:set var="msgUpper" value="${app.systemMessage.toUpperCase()}"/>
48-
49-
<j:set var="alertType" value="jenkins-alert-warning"/>
50-
<j:set var="alertLabel" value="${%System Message}"/>
51-
<j:set var="iconPath" value="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm6-6v-5c0-3.07-1.63-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.64 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2zm-2 1H8v-6c0-2.48 1.51-4.5 4-4.5s4 2.02 4 4.5v6z"/>
52-
53-
<j:if test="${msgUpper.contains('[URGENT]')}">
54-
<j:set var="alertType" value="jenkins-alert-danger"/>
55-
<j:set var="alertLabel" value="${%Critical Alert}"/>
56-
<j:set var="iconPath" value="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"/>
57-
</j:if>
58-
<j:if test="${msgUpper.contains('[UPDATE]')}">
59-
<j:set var="alertType" value="jenkins-alert-info"/>
60-
<j:set var="alertLabel" value="${%System Update}"/>
61-
<j:set var="iconPath" value="M11 17h2v-6h-2v6zm1-15C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zM11 9h2V7h-2v2z"/>
62-
</j:if>
63-
<j:if test="${msgUpper.contains('[MAINTENANCE]')}">
64-
<j:set var="alertType" value="jenkins-alert-warning"/>
65-
<j:set var="alertLabel" value="${%Maintenance}"/>
66-
<j:set var="iconPath" value="M22.7 19l-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4z"/>
67-
</j:if>
45+
<j:set var="severity" value="${app.systemMessageSeverity.toString().toLowerCase()}"/>
46+
47+
<div class="jenkins-alert jenkins-alert-${severity}" id="systemmessage">
48+
<j:if test="${severity == 'warning'}">
49+
<l:icon src="symbol-status-warning" class="jenkins-alert__icon"/>
50+
</j:if>
51+
<j:if test="${severity == 'danger'}">
52+
<l:icon src="symbol-status-error" class="jenkins-alert__icon"/>
53+
</j:if>
54+
<j:if test="${severity == 'info'}">
55+
<l:icon src="symbol-status-blue" class="jenkins-alert__icon"/>
56+
</j:if>
6857

69-
<div class="jenkins-alert ${alertType}" id="systemmessage">
70-
<div style="display: flex; align-items: flex-start;">
71-
<div style="margin-right: 15px; flex-shrink: 0;">
72-
<svg viewBox="0 0 24 24" style="width: 24px; height: 24px; fill: currentColor;"><path d="${iconPath}"/></svg>
73-
</div>
74-
<div style="flex-grow: 1;">
75-
<h4 class="jenkins-alert__title" style="margin-top: 0; margin-bottom: 0.5rem; font-weight: bold;">${alertLabel}</h4>
76-
<div id="system-message-content" class="jenkins-alert__content" data-raw="${app.systemMessage}">
77-
<j:out value="${app.systemMessage}" />
78-
</div>
79-
</div>
80-
</div>
81-
</div>
82-
</j:if>
58+
<div class="jenkins-alert__content">
59+
<h4 class="jenkins-alert__title">
60+
${%System Message}
61+
</h4>
62+
<j:out value="${app.markupFormatter.translate(app.systemMessage)}" />
63+
</div>
64+
</div>
65+
</j:if>
8366

8467
</j:jelly>
8568
<t:editableDescription permission="${it.CONFIGURE}"/>

core/src/main/resources/hudson/model/View/system-message.js

Lines changed: 0 additions & 93 deletions
This file was deleted.

core/src/main/resources/jenkins/model/Jenkins/configure.jelly

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ THE SOFTWARE.
5858
<f:entry title="${%System Message}" description="${%This message will be displayed at the top of the Jenkins main page. This can be useful for posting notifications to your users}">
5959
<f:textarea name="system_message" value="${it.systemMessage}" disabled="${readOnlyMode?'true':null}" readonly="${readOnlyMode?'true':null}"
6060
codemirror-mode="${app.markupFormatter.codeMirrorMode}" codemirror-config="${app.markupFormatter.codeMirrorConfig}" previewEndpoint="/markupFormatter/previewDescription"/>
61+
<f:entry title="${%System Message Severity}" field="systemMessageSeverity">
62+
<f:enum field="systemMessageSeverity">
63+
${it.name()}
64+
</f:enum>
65+
</f:entry>
6166
</f:entry>
6267
</f:section>
6368

core/src/main/resources/lib/layout/layout.jelly

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -217,43 +217,6 @@ THE SOFTWARE.
217217
</div>
218218
</footer>
219219
</j:if>
220-
<j:if test="${app.systemMessage!=null}">
221-
<st:adjunct includes="hudson.model.View.system-message"/>
222-
223-
<j:set var="msgUpper" value="${app.systemMessage.toUpperCase()}"/>
224-
<j:set var="indicatorColor" value="var(--warning-color)"/>
225-
226-
<j:if test="${msgUpper.contains('[URGENT]')}"><j:set var="indicatorColor" value="var(--danger-color)"/></j:if>
227-
<j:if test="${msgUpper.contains('[UPDATE]')}"><j:set var="indicatorColor" value="var(--blue)"/></j:if>
228-
229-
<div id="jenkins-global-toast"
230-
data-message="${app.systemMessage}"
231-
style="position: fixed; bottom: 20px; right: 20px; z-index: 2000;
232-
background: var(--background); border: 1px solid var(--panel-border-color);
233-
border-left: 5px solid ${indicatorColor};
234-
padding: 15px; padding-right: 30px; border-radius: 5px; box-shadow: 0 5px 15px rgba(0,0,0,0.2);
235-
max-width: 300px; display: none; cursor: pointer; font-family: inherit;"
236-
title="${%Click to read full message}">
237-
238-
<span id="toast-close-btn"
239-
style="position: absolute; top: 5px; right: 8px; font-weight: bold;
240-
color: var(--text-color-secondary); font-size: 18px; line-height: 1;">
241-
&#215;
242-
</span>
243-
244-
<div style="font-weight: bold; margin-bottom: 5px; color: var(--text-color);">
245-
<svg viewBox="0 0 24 24" style="width: 16px; height: 16px; margin-right: 5px; fill: ${indicatorColor};">
246-
<path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm6-6v-5c0-3.07-1.63-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.64 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2zm-2 1H8v-6c0-2.48 1.51-4.5 4-4.5s4 2.02 4 4.5v6z"/>
247-
</svg>
248-
${%System Message}
249-
</div>
250-
<div style="font-size: 0.9em; color: var(--text-color-secondary); overflow: hidden;">
251-
<span id="jenkins-toast-content">
252-
${%Click to view details...}
253-
</span>
254-
</div>
255-
</div>
256-
</j:if>
257220
</body>
258221
</html>
259222
</l:view>

0 commit comments

Comments
 (0)