Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-74343

[template-workflows] Extract inline script block and event handlers in org/jenkins/plugin/templateWorkflows/TemplatesWorkflowJob/instances-entries.jelly

XMLWordPrintable

      Problems

      == Inline Script Block
      Line: 32
      ----
      <script>
          function setTemplateInstanceName(instanceName) {
          	var foo = <st:bind value="${it}"/>
          	foo.setTemplateInstanceName(instanceName, function(t) {
          		var res = t.responseObject();
          		if (res.result == true) {
          			 window.location.href = '${rootURL}/${it.url}configure';
          		}
          	})
          }
      
           function deleteInstance(instanceName) {
      
          	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
              if (!is_chrome) {
      	    	var msg = "Are you sure you want to delete " + instanceName + "?";
      	        var agree=confirm(msg);
      			if (!agree) {
      				return false;
      			}
              }
      
          	var foo = <st:bind value="${it}"/>
          	foo.deleteInstance(instanceName, function(t) {
          		var res = t.responseObject();
          		if (res.result == true) {
          			notificationBar.show(instanceName + ' Deleted', notificationBar.INFO);
          	    	setTimeout("notificationBar.hide();window.location.href = '${rootURL}/${it.url}configure'",3000);
          		} else {
          			notificationBar.show(res.msg, notificationBar.ERROR);
      				setTimeout("notificationBar.hide();",3000);
      				return false;
          		}
          	})
          }
      
           function executeInstance(instanceName) {
      
           	var foo = <st:bind value="${it}"/>
           	foo.executeWorkflow(instanceName, function(t) {
           		var res = t.responseObject();
           		if (res.result == true) {
           			notificationBar.show(res.msg, notificationBar.OK);
       				setTimeout("notificationBar.hide();",3000);
           		} else {
           			notificationBar.show(res.msg, notificationBar.ERROR);
       				setTimeout("notificationBar.hide();",3000);
       				return false;
           		}
           	})
           }
      
      
        </script>
      ----
      
      == Inline Event Handler
      Line: 10
      ----
      <a style="padding-left:5px;"
                onclick="setTemplateInstanceName('${instance.instanceName}'); return false;"
                href="${rootURL}/${it.url}configure">
      ----
      
      == Inline Event Handler
      Line: 17
      ----
      <input type="image" title="Delete workflow: '${instance.instanceName}' (jobs that were created by this workflow will be deleted)"
                      onclick="deleteInstance('${instance.instanceName}'); return false;"
      				size="16" src="${rootURL}/images/16x16/edit-delete.png"/>
      ----
      
      == Inline Event Handler
      Line: 23
      ----
      <input type="image" title="Execute workflow: '${instance.instanceName}'"
                     onclick="executeInstance('${instance.instanceName}'); return false;"
      			   size="16" src="${rootURL}/images/16x16/clock.gif"/>
      ----
      

      Solutions

      https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks
      https://www.jenkins.io/doc/developer/security/csp/#inline-event-handlers

            Unassigned Unassigned
            basil Basil Crow
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: