-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
/
config.jelly
152 lines (143 loc) · 9.91 KB
/
config.jelly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
Copyright 2018 CloudBees, Inc.
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:f="/lib/form" xmlns:l="/lib/layout" xmlns:i="jelly:fmt">
<st:adjunct includes="jenkins.security.ApiTokenProperty.resources"/>
<f:entry title="${%CurrentTokens(instance.tokenList.size())}" help="${descriptor.getHelpFile('tokenStore')}">
<!-- ignore the whole div to prevent the "Add new token" button to trigger the confirm -->
<div class="token-list ignore-dirty-panel">
<j:set var="isStatisticsEnabled" value="${descriptor.isStatisticsEnabled()}" />
<j:set var="tokenList" value="${instance.tokenList}" />
<div class="token-list-item token-list-empty-item ${tokenList == null || tokenList.isEmpty() ? '' : 'hidden-message'}">
<div class="list-empty-message">${%NoTokenYet}</div>
</div>
<f:repeatable name="tokenStore" var="token" items="${tokenList}" minimum="0" add="${%AddNewToken}"
noAddButton="${!descriptor.hasCurrentUserRightToGenerateNewToken(it)}">
<j:choose>
<j:when test="${token!=null}">
<j:set var="legacyClazz" value="" />
<j:if test="${token.isLegacy}">
<j:set var="legacyClazz" value="legacy-token" />
</j:if>
<!-- force the confirm in case those inputs are changed, to override the parent ignore, for existing token -->
<div class="token-list-item token-list-existing-item force-dirty-panel ${legacyClazz}">
<input type="hidden" class="token-uuid-input" name="tokenUuid" value="${token.uuid}" />
<f:textbox clazz="token-name" name="tokenName" value="${token.name}" />
<j:if test="${token.isLegacy}">
<l:icon class="icon-warning icon-sm" title="${%LegacyToken}"/>
</j:if>
<j:set var="daysOld" value="${token.numDaysCreation}" />
<j:set var="oldClazz" value="age-ok" />
<j:if test="${daysOld > 180}">
<j:set var="oldClazz" value="age-mmmh" />
<j:if test="${daysOld > 360}">
<j:set var="oldClazz" value="age-argh" />
</j:if>
</j:if>
<j:set var="creationDateFormat" value="${%NoCreationDate}" />
<j:set var="creationDateValue" value="${%NoCreationDateValue}" />
<j:if test="${token.creationDate != null}">
<i:formatDate var="creationDateFormat" value="${token.creationDate}" type="both" dateStyle="medium" timeStyle="medium" />
<!--TODO convert to "Today", "Tomorrow", "4 days ago", "2 weeks ago", etc. -->
<j:set var="creationDateValue" value="${%TokenCreation(daysOld)}" />
</j:if>
<span class="token-creation ${oldClazz}" title="${creationDateFormat}">${creationDateValue}</span>
<span class="to-right">
<j:choose>
<j:when test="${isStatisticsEnabled}">
<j:set var="useCounter" value="${token.useCounter}" />
<j:choose>
<j:when test="${useCounter > 0}">
<j:if test="${token.lastUseDate == null}">
<!--Should normally never happen without manual XML modification-->
<span class="token-use-counter" title="${$TokenNeverUsedTooltip}">
${%TokenNeverUsedValue}
</span>
</j:if>
<j:if test="${token.lastUseDate != null}">
<i:formatDate var="lastUseDateFormat" value="${token.lastUseDate}" type="both" dateStyle="medium" timeStyle="medium" />
<span class="token-use-counter" title="${lastUseDateFormat}">
${%TokenLastUse(useCounter, token.numDaysUse)}
</span>
</j:if>
</j:when>
<j:otherwise>
<span class="token-use-counter">
<strong title="${%TokenNeverUsed.Title}">
<l:icon class="icon-warning icon-sm"/>
${%TokenNeverUsed}
</strong>
</span>
</j:otherwise>
</j:choose>
</j:when>
<j:otherwise>
<span class="no-statistics" title="${%StatisticsDisabled.Title}">
${%StatisticsDisabled}
</span>
</j:otherwise>
</j:choose>
<a href="#" onclick="return revokeToken(this)" class="token-revoke"
data-message-if-legacy-revoked="${%RevokedToken}"
data-confirm="${%ConfirmRevokeSingle}"
data-target-url="${descriptor.descriptorFullUrl}/revoke">
<st:include page="/lib/layout/svg-icon-token-revoke.jelly" />
</a>
</span>
</div>
</j:when>
<j:otherwise>
<div class="token-list-item token-list-new-item">
<input type="hidden" class="token-uuid-input" name="tokenUuid" value="${token.uuid}" />
<f:textbox name="tokenName" clazz="token-name" placeholder="${%Default name}"/>
<st:nbsp /><!-- without this non-breakable space, double click on the div will put the focus on the input -->
<span class="new-token-value"><!--will be filled by javascript--></span>
<span class="yui-button token-save">
<button type="button" tabindex="0" data-target-url="${descriptor.descriptorFullUrl}/generateNewToken" onclick="saveApiToken(this)">
${%GenerateNewToken}
</button>
</span>
<span class="token-cancel">
<f:repeatableDeleteButton value="${%Cancel}" />
</span>
<a href="#" onclick="return revokeToken(this)" class="token-revoke hidden-button"
data-confirm="${%ConfirmRevokeSingle}"
data-target-url="${descriptor.descriptorFullUrl}/revoke">
<st:include page="/lib/layout/svg-icon-token-revoke.jelly" />
</a>
<l:copyButton message="${%Copied}" text="" clazz="invisible"/>
<div class="error token-error-message"><!-- filled in case of error --></div>
<div class="warning display-after-generation">${%TokenDisplayedOnce}</div>
</div>
</j:otherwise>
</j:choose>
</f:repeatable>
</div>
</f:entry>
<j:if test="${descriptor.mustDisplayLegacyApiToken(it)}">
<f:advanced title="${%Show Legacy API Token}" align="left">
<f:entry title="${%Legacy API Token}" field="apiToken">
<f:readOnlyTextbox id="apiToken" default="${descriptor.noLegacyToken}"/>
</f:entry>
<f:validateButton title="${%Change API Token}" method="changeToken" clazz="ignore-dirty-panel"/>
</f:advanced>
</j:if>
</j:jelly>