Authored by 姜枫

每次构建支持输入分支

@@ -142,7 +142,7 @@ const p = { @@ -142,7 +142,7 @@ const p = {
142 project_build: async(ctx, next) => { 142 project_build: async(ctx, next) => {
143 let pid = ctx.params.pid; 143 let pid = ctx.params.pid;
144 let env = ctx.request.body.env; 144 let env = ctx.request.body.env;
145 - let branch = ctx.redirect.body.branch; 145 + let branch = ctx.request.body.branch;
146 let p = await Project.findById(pid); 146 let p = await Project.findById(pid);
147 let build = new Build(p); 147 let build = new Build(p);
148 148
@@ -118,13 +118,13 @@ @@ -118,13 +118,13 @@
118 html += data + '</span>'; 118 html += data + '</span>';
119 return html; 119 return html;
120 }, 120 },
121 - targets: 1 121 + targets: 2
122 }, { 122 }, {
123 render: function(data, type, row){ 123 render: function(data, type, row){
124 var disabled = row.state !== 'success'; 124 var disabled = row.state !== 'success';
125 return '<button '+(disabled? 'disabled' : '')+' class="btn btn-success btn-xs deploy-btn" data-id="'+data+'" data-build='+row.buildTime+'>分发</button>'; 125 return '<button '+(disabled? 'disabled' : '')+' class="btn btn-success btn-xs deploy-btn" data-id="'+data+'" data-build='+row.buildTime+'>分发</button>';
126 }, 126 },
127 - targets: 3 127 + targets: 4
128 }] 128 }]
129 }); 129 });
130 130
@@ -153,11 +153,18 @@ @@ -153,11 +153,18 @@
153 153
154 $('.build-btn').click(function(){ 154 $('.build-btn').click(function(){
155 var env = $(this).parents('.panel').data('env'); 155 var env = $(this).parents('.panel').data('env');
156 - $.post('/projects/build/{{project._id}}', {env: env}, function(ret){  
157 - if(ret.code == 200) {  
158 - tables[env].ajax.reload();  
159 - } 156 + var i = layer.prompt({
  157 + title: '请输入需要构建的分支,默认为 {{deploy.branchName}}'
  158 + }, function(branch){
  159 + branch = branch || '{{deploy.branchName}}';
  160 + $.post('/projects/build/{{project._id}}', {env: env, branch: branch}, function(ret){
  161 + if(ret.code == 200) {
  162 + tables[env].ajax.reload();
  163 + layer.close(i);
  164 + }
  165 + });
160 }); 166 });
  167 +
161 }); 168 });
162 169
163 170