");
51 |
52 | $('#back-to-config').click(function() {
53 | $("#pipeline-visual-editor").remove();
54 | win.location.hash = "";
55 | Belay.off();
56 | confEditor.show();
57 | $('#main-panel > form').submit();
58 |
59 | //remove the absolute position from the bottom sticker on return
60 | //otherwise the buttons may not appear until a resize. LOL (probably a better solution)
61 | //TODO: must be a better way.
62 | $('#bottom-sticker').attr('style', function(i, style) {
63 | return style.replace(/position[^;]+;?/g, '');
64 | });
65 | });
66 |
67 |
68 | var pipeline = storage.loadModelOrUseDefault(json.val());
69 |
70 | lines.initSVG();
71 |
72 | if (!storage.existingPipeline(json.val())) {
73 | console.log("Brand new pipeline so saving the changes the first time");
74 | h.writeOutChanges(pipeline, {"script" : script, "json" : json });
75 | }
76 |
77 | h.drawPipeline(pipeline, {"script" : script, "json" : json });
78 | reJoinOnResize(pipeline);
79 |
80 | window.onpopstate = function() {
81 | window.location = window.location.pathname;
82 | };
83 |
84 |
85 | }
86 |
87 |
88 |
89 | /** The bit that holds the pipeline visualisation */
90 | function pipelineEditorArea() {
91 | return '
' +
92 | '' +
93 | '
';
94 | }
95 |
96 |
97 | /** container for holding the specific editors depending on what is clicked */
98 | function detailContainer() {
99 | return '
' +
100 | '
' +
101 | '' +
102 | '
' +
103 | '
' +
104 | '
' +
105 | '
' +
106 | 'Click on a Step to view the details. ' +
107 | '
' +
108 | '
' +
109 | '
' +
110 | '
' +
111 | '
' +
112 | '
';
113 | }
114 |
115 | /**
116 | * This will fix a problem with wrapping elements in bootstrap
117 | * this is documented here: http://stackoverflow.com/questions/25598728/irregular-bootstrap-column-wrapping
118 | * Without this, things won't wrap clearly left to right. Read it.
119 | */
120 | function fixFlowCSS() {
121 | return '';
124 | }
125 |
126 | /**
127 | * As svg lines are overlayed based on positions of divs, when the divs move around
128 | * the lines need to be redrawn.
129 | */
130 | function reJoinOnResize(pipeline) {
131 | $(window).resize(function(){
132 | lines.autoJoin(pipeline);
133 | });
134 | }
135 |
136 |
137 |
138 |
139 | /**
140 | * Originally we used this prototype snipped to create the edit button and clear
141 | * doens't play nice with the new stuff, but kept here for reference as
142 | * some of the behaviour stuff may need to be retrofitted to the jquery based code.
143 | * Behaviour.specify("INPUT.pipeline-editor", 'pipeline-editor-button', 0, function(e) {
144 | var script = e.next("input");
145 | var json = script.next("input");
146 |
147 | makeButton(e,function(_) {
148 | var pageBody = $('page-body');
149 | var row = pageBody.down(".row");
150 |
151 | row.style.display = "none";
152 |
153 | pageBody.insert({bottom:"
pipeline-editor
"});
154 |
155 | var canvas = pageBody.down("> .pipeline-editor");
156 | var accept = canvas.down("> INPUT");
157 |
158 | makeButton(accept,function(_){
159 | // update fhe form values
160 | script.value = "...";
161 | json.value = "...";
162 |
163 | // kill the dialog
164 | canvas.remove();
165 | row.style.display = "block";
166 | });
167 | });
168 | });
169 | */
170 |
--------------------------------------------------------------------------------
/src/main/js/steps/EXTENDING.md:
--------------------------------------------------------------------------------
1 | To extend and add more editors, take a look at an existing one.
2 |
3 | editors are an object that follows a signature like:
4 |
5 | ```
6 | exports.editor = {
7 | description: "Clone a git repository",
8 | renderEditor : function(stepInfo, actionId) {
9 | // provide a form to edit
10 | var template = '
' +
11 | '' +
12 | '' +
13 | '
' +
14 | '
' +
15 | '' +
16 | '' +
17 | '
' +
18 | '';
19 |
20 | return renderTemplate(template, stepInfo, { "actionId" : actionId });
21 | },
22 |
23 | readChanges : function(actionId, currentStep) {
24 | // read the changes from the form and apply them.
25 | // if it all checks out, return true, otherwise don't apply them, and return false.
26 | currentStep.name = $('#' + actionId + "_stepName").val();
27 | currentStep.url = $('#' + actionId + "_url").val();
28 | return true; //this will cause pipeline view to be re-rendered.
29 | },
30 |
31 | generateScript : function(stepInfo){
32 | return 'git ' + stepInfo.url;
33 | },
34 | };
35 | ```
36 |
37 | it is up to each editor to render a form - in this case a template is used that reads value out of the stepInfo object. It also has to save changes back to the current step (in this case only name and url are saved or displayed). Finally the results are rendered as workflow script.
38 |
39 | // TODO: Get this info from Jenkins. See CJP-3974
40 |
--------------------------------------------------------------------------------
/src/main/js/steps/archive.js:
--------------------------------------------------------------------------------
1 | var renderTemplate = require('./template').renderTemplate;
2 | var $ = require('bootstrap-detached').getBootstrap();
3 |
4 |
5 | module.exports = {
6 | description: "Archive an artifact permanently",
7 | renderEditor : function(stepInfo, actionId) {
8 | // provide a form to edit
9 | var template = '
' +
10 | '
Store an artifact permanently as part of a build record.