1%{--
2  - Copyright 2018 Rundeck, Inc. (http://rundeck.com)
3  -
4  - Licensed under the Apache License, Version 2.0 (the "License");
5  - you may not use this file except in compliance with the License.
6  - You may obtain a copy of the License at
7  -
8  -     http://www.apache.org/licenses/LICENSE-2.0
9  -
10  - Unless required by applicable law or agreed to in writing, software
11  - distributed under the License is distributed on an "AS IS" BASIS,
12  - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  - See the License for the specific language governing permissions and
14  - limitations under the License.
15  --}%
16
17<%@ page import="com.dtolabs.rundeck.server.authorization.AuthConstants" %>
18<g:set var="authUpdate" value="${auth.jobAllowedTest(job: scheduledExecution, action: [AuthConstants.ACTION_UPDATE])}"/>
19<g:set var="authView" value="${auth.jobAllowedTest(job: scheduledExecution, any: true, action: [AuthConstants.ACTION_READ, AuthConstants.ACTION_VIEW])}"/>
20<g:set var="authRead" value="${auth.jobAllowedTest(job: scheduledExecution, any: true, action: [AuthConstants.ACTION_READ])}"/>
21<g:set var="authDelete" value="${auth.jobAllowedTest(job: scheduledExecution, action: [AuthConstants.ACTION_DELETE])}"/>
22<g:set var="authEnableDisableSchedule" value="${auth.jobAllowedTest(job: scheduledExecution, action: [AuthConstants.ACTION_TOGGLE_SCHEDULE])}"/>
23<g:set var="authEnableDisableExecution" value="${auth.jobAllowedTest(job: scheduledExecution, action: [AuthConstants.ACTION_TOGGLE_EXECUTION])}"/>
24<g:set var="authJobCreate" value="${auth.resourceAllowedTest(kind: 'job', action: AuthConstants.ACTION_CREATE, project: scheduledExecution.project)}"/>
25<g:set var="authOtherProject" value="${auth.resourceAllowedTest(kind: 'job', action: AuthConstants.ACTION_CREATE, project: scheduledExecution.project, others: true)}"/>
26<g:set var="authJobDelete" value="${auth.resourceAllowedTest(kind: 'job', action: AuthConstants.ACTION_DELETE, project: scheduledExecution.project)}"/>
27<g:set var="authProjectExport" value="${auth.resourceAllowedTest(
28        context: 'application',
29        type: 'project',
30        action: [AuthConstants.ACTION_ADMIN, AuthConstants.ACTION_EXPORT],
31        any: true,
32        name: scheduledExecution.project
33)}"/>
34<g:set var="renderedActions" value="${0}"/>
35<g:if test="${authUpdate}">
36    %{renderedActions++}%
37    <li>
38        <g:link controller="scheduledExecution"
39                title="${g.message(code:'scheduledExecution.action.edit.button.tooltip')}"
40                action="edit"
41                params="[project: scheduledExecution.project]"
42                id="${scheduledExecution.extid}" class="">
43            <i class="glyphicon glyphicon-edit"></i>
44            <g:message code="scheduledExecution.action.edit.button.label"/>
45        </g:link>
46    </li>
47</g:if>
48<g:if test="${authRead && authJobCreate}">
49    %{renderedActions++}%
50    <li>
51        <g:link controller="scheduledExecution"
52                title="${g.message(code:'scheduledExecution.action.duplicate.button.tooltip')}"
53                action="copy"
54                params="[project: scheduledExecution.project]"
55                id="${scheduledExecution.extid}" class="">
56            <i class="glyphicon glyphicon-plus"></i>
57            <g:message
58                    code="scheduledExecution.action.duplicate.button.label"/>
59        </g:link>
60    </li>
61</g:if>
62<g:if test="${authRead && authOtherProject}">
63    %{renderedActions++}%
64    <li>
65        <g:link controller="scheduledExecution"
66                title="${g.message(code:'scheduledExecution.action.duplicate.button.tooltip')}"
67                action="copyanother"
68                data-job-id="${enc(attr: scheduledExecution.extid)}"
69                data-action="copy_other_project"
70                class="page_action">
71            <i class="glyphicon glyphicon-plus"></i>
72            <g:message
73                    code="scheduledExecution.action.duplicate.other.button.label"/>
74        </g:link>
75
76    </li>
77</g:if>
78
79<g:unless test="${hideJobDelete}">
80    <g:if test="${authJobDelete && authDelete}">
81        <g:if test="${authUpdate || authRead&&authJobCreate}">
82            <li class="divider"></li>
83        </g:if>
84        %{renderedActions++}%
85        <li>
86            <g:link
87                controller="scheduledExecution"
88                action="delete"
89                params="${[id:scheduledExecution.extid,project: scheduledExecution.project]}"
90                class="page_action"
91                data-action="job_delete_single"
92                data-job-id="${enc(attr: scheduledExecution.extid)}"
93               title="${g.message(code: 'delete.this.job')}">
94                <b class="glyphicon glyphicon-remove-circle"></b>
95                <g:message code="scheduledExecution.action.delete.button.label"/>
96            </g:link>
97        </li>
98    </g:if>
99</g:unless>
100
101<g:if test="${authEnableDisableSchedule && scheduledExecution.scheduled || authEnableDisableExecution}">
102    <li class="divider"></li>
103</g:if>
104<g:if test="${authEnableDisableSchedule && scheduledExecution.scheduled}">
105    <li>
106        %{renderedActions++}%
107        <g:if test="${scheduledExecution.hasScheduleEnabled()}">
108            <g:link controller="scheduledExecution"
109                    action="flipScheduleEnabled"
110                    params="${[id:scheduledExecution.extid,project: scheduledExecution.project, scheduleEnabled: false]}"
111                    data-job-id="${enc(attr: scheduledExecution.extid)}"
112                    class="page_action"
113                    data-action="disable_job_schedule_single"
114                    title="${g.message(code: 'disable.schedule.this.job')}">
115                <b class="glyphicon glyphicon-unchecked"></b>
116                <g:message code="scheduledExecution.action.disable.schedule.button.label"/>
117            </g:link>
118        </g:if>
119        <g:else>
120            <g:link controller="scheduledExecution"
121                    action="flipScheduleEnabled"
122                    params="${[id:scheduledExecution.extid,project: scheduledExecution.project, scheduleEnabled: true]}"
123                    data-job-id="${enc(attr: scheduledExecution.extid)}"
124                    class="page_action"
125                    data-action="enable_job_schedule_single"
126                    title="${g.message(code: 'enable.schedule.this.job')}">
127                <b class="glyphicon glyphicon-check"></b>
128                <g:message code="scheduledExecution.action.enable.schedule.button.label"/>
129            </g:link>
130        </g:else>
131    </li>
132</g:if>
133
134<g:if test="${authEnableDisableExecution}">
135    %{renderedActions++}%
136    <li>
137        <g:if test="${scheduledExecution.hasExecutionEnabled()}">
138            <g:link controller="scheduledExecution"
139                    action="flipExecutionEnabled"
140                    params="${[id:scheduledExecution.extid,project: scheduledExecution.project, executionEnabled: false]}"
141                    data-job-id="${enc(attr: scheduledExecution.extid)}"
142                    class="page_action"
143                    data-action="disable_job_execution_single"
144                    title="${g.message(code: 'disable.execution.this.job')}">
145                <b class="glyphicon glyphicon-unchecked"></b>
146                <g:message code="scheduledExecution.action.disable.execution.button.label"/>
147            </g:link>
148        </g:if>
149        <g:else>
150            <g:link controller="scheduledExecution"
151                    action="flipExecutionEnabled"
152                    params="${[id:scheduledExecution.extid,project: scheduledExecution.project, executionEnabled: true]}"
153                    data-job-id="${enc(attr: scheduledExecution.extid)}"
154                    class="page_action"
155                    data-action="enable_job_execution_single"
156                    title="${g.message(code: 'enable.execution.this.job')}">
157                <b class="glyphicon glyphicon-check"></b>
158                <g:message code="scheduledExecution.action.enable.execution.button.label"/>
159            </g:link>
160        </g:else>
161    </li>
162</g:if>
163
164<g:if test="${authRead}">
165    %{renderedActions++}%
166    <g:if test="${authJobDelete && authDelete || authUpdate || authJobCreate}">
167        <li class="divider"></li>
168    </g:if>
169    <li><g:link controller="scheduledExecution"
170                title="${g.message(code: 'scheduledExecution.action.downloadformat.button.label', args: ['XML'])}"
171                params="[project: scheduledExecution.project,format:'xml']"
172                action="show"
173                id="${scheduledExecution.extid}">
174        <b class="glyphicon glyphicon-file"></b>
175        <g:message code="scheduledExecution.action.downloadformat.button.label"
176                   args="['XML']"/>
177    </g:link>
178    </li>
179    <li>
180        <g:link controller="scheduledExecution"
181                title="${g.message(code: 'scheduledExecution.action.downloadformat.button.label', args: ['YAML'])}"
182                params="[project: scheduledExecution.project,format:'yaml']"
183                action="show"
184                id="${scheduledExecution.extid}">
185            <b class="glyphicon glyphicon-file"></b>
186            <g:message
187                    code="scheduledExecution.action.downloadformat.button.label"
188                    args="['YAML']"/>
189        </g:link>
190    </li>
191</g:if>
192
193<g:if test="${authProjectExport && scmExportEnabled && scmExportStatus?.get(scheduledExecution.extid)}">
194    %{renderedActions++}%
195    <g:if test="${authRead}">
196        <li class="divider"></li>
197    </g:if>
198
199    <li class="dropdown-header"><g:message code="scm.export.plugin" /></li>
200
201    <g:set var="jobstatus" value="${scmExportStatus?.get(scheduledExecution.extid)}"/>
202    <g:set var="exportStateClean" value="${jobstatus?.synchState?.toString()=='CLEAN'}"/>
203    <g:set var="exportStateCreate" value="${'CREATE_NEEDED'==jobstatus?.synchState?.toString()}"/>
204    <g:each in="${jobstatus?.actions}" var="action">
205        <g:if test="${action.id == '-'}">
206            <li class="divider"></li>
207        </g:if>
208        <g:else>
209            <li>
210                <g:render template="/scm/actionLink"
211                          model="[action:action,
212                                  integration:'export',
213                                  project:params.project,
214                                  linkparams:[id: scheduledExecution.extid]]"
215                />
216
217            </li>
218        </g:else>
219    </g:each>
220    <g:unless test="${exportStateCreate}">
221        <li><g:link controller="scm"
222                    params="[project: scheduledExecution.project,id:scheduledExecution.extid,integration: 'export']"
223                    action="diff"
224                    >
225            <g:render template="/scm/statusBadge"
226                      model="[exportStatus: jobstatus?.synchState?.toString(),
227                              importStatus: null,
228                              text  : '',
229                              notext: true,
230                              integration: 'export',
231                              icon:'glyphicon-eye-open',
232                              exportCommit  : jobstatus?.commit]"/>
233            <g:if test="${exportStateClean}">
234                <g:message code="scm.action.diff.clean.button.label" default="View Commit Info"/>
235            </g:if>
236            <g:else>
237                <g:message code="scm.action.diff.button.label" default="Diff Changes"/>
238            </g:else>
239        </g:link>
240        </li>
241    </g:unless>
242</g:if>
243
244<g:if test="${scmImportEnabled && scmImportStatus?.get(scheduledExecution.extid)}">
245    %{renderedActions++}%
246
247
248    <g:set var="jobstatus" value="${scmImportStatus?.get(scheduledExecution.extid)}"/>
249    <g:set var="importStateClean" value="${jobstatus?.synchState?.toString()=='CLEAN'}"/>
250
251    <g:set var="importStateUnknown" value="${'UNKNOWN'==jobstatus?.synchState?.toString()}"/>
252        <g:if test="${authRead}">
253            <li class="divider"></li>
254        </g:if>
255        <li class="dropdown-header"><g:message code="scm.import.plugin" /></li>
256    <g:each in="${jobstatus?.actions}" var="action">
257        <g:if test="${action.id == '-'}">
258            <li class="divider"></li>
259        </g:if>
260        <g:else>
261            <li>
262                <g:render template="/scm/actionLink"
263                          model="[action:action,
264                                  integration:'import',
265                                  project:params.project,
266                                  linkparams:[id: scheduledExecution.extid]]"
267                />
268
269            </li>
270        </g:else>
271    </g:each>
272    <g:unless test="${importStateUnknown}">
273    <li>
274        <g:link controller="scm"
275                params="[project: scheduledExecution.project,id:scheduledExecution.extid,integration: 'import']"
276                action="diff">
277            <g:render template="/scm/statusBadge"
278                  model="[importStatus: jobstatus?.synchState?.toString(),
279                          text  : '',
280                          notext: true,
281                          integration: 'import',
282                          icon:'glyphicon-eye-open',
283                          exportCommit  : jobstatus?.commit]"/>
284            <g:if test="${importStateClean}">
285                <g:message code="scm.action.diff.clean.button.label" default="View Commit Info"/>
286            </g:if>
287            <g:else>
288                <g:message code="scm.action.diff.button.label" default="Diff Changes"/>
289            </g:else>
290        </g:link>
291    </li>
292    </g:unless>
293    <g:if test="${importStateUnknown}">
294        <li class="dropdown-header">
295            <g:render template="/scm/statusBadge"
296                      model="[importStatus: jobstatus?.synchState?.toString(),
297                              exportStatus:null,
298                              text: '',
299                              notext: false,
300                              integration: 'import',
301                              importCommit: jobstatus?.commit]"
302            />
303        </li>
304    </g:if>
305</g:if>
306<g:if test="${renderedActions<1}">
307    <li class="dropdown-header">
308        <g:message code="scheduledExecution.action.menu.none-available" />
309    </li>
310</g:if>
311