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