Skip to content

Commit d87a78b

Browse files
authored
Merge pull request #132 from thatsdc/add-change-results-colors-option
Added the option to change the results colors
2 parents 2a05b9b + 3299b27 commit d87a78b

File tree

5 files changed

+47
-8
lines changed

5 files changed

+47
-8
lines changed

src/main/css/index.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@
6666
}
6767

6868
.fc-event.event-result-success {
69-
background-color: var(--success-color);
70-
border-color: var(--success-color);
69+
background-color: var(--result-success-color);
70+
border-color: var(--result-success-color);
7171
}
7272

7373
.fc-event.event-result-failure {
74-
background-color: var(--error-color);
75-
border-color:var(--error-color);
74+
background-color: var(--result-failure-color);
75+
border-color:var(--result-failure-color);
7676
}
7777

7878
.fc-event.event-result-unstable {
@@ -102,10 +102,10 @@
102102
background:#aaa;
103103
}
104104
.fc-event.event-result-success.event-selected {
105-
background:var(--light-green);
105+
background:var(--result-success-selected-color);
106106
}
107107
.fc-event.event-result-failure.event-selected {
108-
background:var(--light-red);
108+
background:var(--result-failure-selected-color);
109109
}
110110
.fc-event.event-result-unstable.event-selected {
111111
background:var(--light-orange);

src/main/java/io/jenkins/plugins/view/calendar/CalendarView.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,13 @@ public static enum CalendarViewType {
6767
MONTH, WEEK, DAY;
6868
}
6969

70+
public static enum ResultsColors {
71+
GREEN_RED, CYAN_RED
72+
}
73+
7074
private CalendarViewEventsType calendarViewEventsType;
7175
private CalendarViewType calendarViewType;
76+
private ResultsColors resultsColors;
7277

7378
private Boolean useCustomFormats;
7479
private Boolean useCustomWeekSettings;
@@ -124,6 +129,14 @@ public void setCalendarViewType(final CalendarViewType calendarViewType) {
124129
this.calendarViewType = calendarViewType;
125130
}
126131

132+
public ResultsColors getResultsColors() {
133+
return defaultIfNull(resultsColors, ResultsColors.GREEN_RED);
134+
}
135+
136+
public void setResultsColors(final ResultsColors resultsColors) {
137+
this.resultsColors = resultsColors;
138+
}
139+
127140
public boolean isUseCustomFormats() {
128141
return defaultIfNull(useCustomFormats, false);
129142
}
@@ -366,6 +379,7 @@ private void validate(final StaplerRequest2 req) throws Descriptor.FormException
366379
private void updateFields(final StaplerRequest2 req) {
367380
setCalendarViewEventsType(CalendarViewEventsType.valueOf(req.getParameter("calendarViewEventsType")));
368381
setCalendarViewType(CalendarViewType.valueOf(req.getParameter("calendarViewType")));
382+
setResultsColors(ResultsColors.valueOf(req.getParameter("resultsColors")));
369383

370384
setUseCustomFormats(req.getParameter("useCustomFormats") != null);
371385
setUseCustomWeekSettings(req.getParameter("useCustomWeekSettings") != null);

src/main/js/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ const hashParamOptions = hashParams.parse(window.location.hash);
3838
var timeout = null;
3939

4040
$(function() {
41+
const root = document.documentElement;
42+
if (CalendarViewOptions.resultsColors === 'cyan_red') {
43+
root.style.setProperty('--result-success-color', '#5291CB');
44+
root.style.setProperty('--result-failure-color', '#CF0000');
45+
root.style.setProperty('--result-success-selected-color', '#6A9AC7');
46+
root.style.setProperty('--result-failure-selected-color', '#FF0000');
47+
}
48+
else{
49+
root.style.setProperty('--result-success-color', '#00B80E');
50+
root.style.setProperty('--result-failure-color', '#CF0000');
51+
root.style.setProperty('--result-success-selected-color', '#00E610');
52+
root.style.setProperty('--result-failure-selected-color', '#FF0000');
53+
}
54+
4155
$('#calendar-view').fullCalendar({
4256
events: 'events',
4357
defaultView: hashParamOptions['view'] || CalendarViewOptions.defaultView,

src/main/resources/io/jenkins/plugins/view/calendar/CalendarView/configure-entries.jelly

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ Portions of this code copied from the Jenkins Project. See LICENSE.md for notice
4848
</div>
4949
</f:entry>
5050

51+
<f:entry title="${%Success / Failure Colors}" field="resultsColors">
52+
<div class="calendar-view-config-container">
53+
<f:radio name="resultsColors" value="GREEN_RED" checked="${it.resultsColors=='GREEN_RED'}" title="${%Green / Red}"/>
54+
<f:radio name="resultsColors" value="CYAN_RED" checked="${it.resultsColors=='CYAN_RED'}" title="${%Cyan / Red}"/>
55+
</div>
56+
</f:entry>
57+
5158
<f:optionalBlock name="useCustomWeekSettings" title="${%Use custom week day settings}"
5259
checked="${it.useCustomWeekSettings}">
5360
<f:entry title="${%Weeks}">

src/main/resources/io/jenkins/plugins/view/calendar/CalendarView/main.jelly

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ THE SOFTWARE.
2525
<?jelly escape-by-default='true'?>
2626
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
2727

28+
2829
<j:set var="views" value="${it.owner.views}" />
2930
<j:set var="currentView" value="${it}" />
3031

@@ -35,10 +36,12 @@ THE SOFTWARE.
3536
</div>
3637

3738
<link type="text/css" rel="stylesheet" href="${rootURL}/plugin/calendar-view/bundles/calendar-view.css" />
39+
3840
<st:adjunct includes="io.jenkins.plugins.jquery3"/>
3941
<script id="calendar-view-data" type="application/json">{
40-
"defaultView": "${it.calendarViewType.name().toLowerCase()}-view",
41-
"buttonText": {
42+
"defaultView": "${it.calendarViewType.name().toLowerCase()}-view",
43+
"resultsColors": "${it.resultsColors.name().toLowerCase()}",
44+
"buttonText": {
4245
"today": "${%ButtonText.Today}",
4346
"month-view": "${%ButtonText.Month}",
4447
"week-view": "${%ButtonText.Week}",
@@ -141,6 +144,7 @@ THE SOFTWARE.
141144
}
142145
}</script>
143146
<st:adjunct includes="io.jenkins.plugins.view.calendar.CalendarView.resource"/>
147+
144148
<script type="text/javascript" src="${rootURL}/plugin/calendar-view/bundles/calendar-view.js"></script>
145149

146150
</j:jelly>

0 commit comments

Comments
 (0)