forked from lix-project/hydra
Implement DELETE for jobsets and use it in the web interface
This commit is contained in:
parent
ae13dd3e67
commit
851c3329d0
5 changed files with 46 additions and 40 deletions
|
@ -1,5 +1,6 @@
|
|||
package Hydra::Controller::Jobset;
|
||||
|
||||
use utf8;
|
||||
use strict;
|
||||
use warnings;
|
||||
use base 'Hydra::Base::Controller::ListBuilds';
|
||||
|
@ -135,6 +136,21 @@ sub jobset_PUT {
|
|||
}
|
||||
}
|
||||
|
||||
sub jobset_DELETE {
|
||||
my ($self, $c) = @_;
|
||||
|
||||
requireProjectOwner($c, $c->stash->{project});
|
||||
|
||||
txn_do($c->model('DB')->schema, sub {
|
||||
$c->stash->{jobset}->jobsetevals->delete_all;
|
||||
$c->stash->{jobset}->builds->delete_all;
|
||||
$c->stash->{jobset}->delete;
|
||||
});
|
||||
|
||||
my $uri = $c->uri_for($c->controller('Project')->action_for("project"), [$c->stash->{project}->name]);
|
||||
$self->status_ok($c, entity => { redirect => "$uri" });
|
||||
}
|
||||
|
||||
|
||||
sub jobs_tab : Chained('jobsetChain') PathPart('jobs-tab') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
|
@ -207,15 +223,6 @@ sub submit : Chained('jobsetChain') PathPart Args(0) {
|
|||
requirePost($c);
|
||||
requireProjectOwner($c, $c->stash->{project});
|
||||
|
||||
if (($c->request->params->{submit} // "") eq "delete") {
|
||||
txn_do($c->model('DB')->schema, sub {
|
||||
$c->stash->{jobset}->jobsetevals->delete_all;
|
||||
$c->stash->{jobset}->builds->delete_all;
|
||||
$c->stash->{jobset}->delete;
|
||||
});
|
||||
return $c->res->redirect($c->uri_for($c->controller('Project')->action_for("project"), [$c->stash->{project}->name]));
|
||||
}
|
||||
|
||||
my $newName = trim $c->stash->{params}->{name};
|
||||
my $oldName = trim $c->stash->{jobset}->name;
|
||||
unless ($oldName eq $newName) {
|
||||
|
|
|
@ -452,7 +452,10 @@ BLOCK makePopover %]
|
|||
|
||||
BLOCK menuItem %]
|
||||
<li class="[% IF "${root}${curUri}" == uri %]active[% END %]" [% IF confirmmsg %]onclick="javascript:return confirm('[% confirmmsg %]')"[% END %]>
|
||||
<a href="[% uri %]" [% IF modal %]data-toggle="modal"[% END %]>[% title %]</a>
|
||||
<a href="[% uri %]" [% IF modal %]data-toggle="modal"[% END %]>
|
||||
[% IF icon %]<i class="[% icon %] icon-black"></i> [%+ END %]
|
||||
[% title %]
|
||||
</a>
|
||||
</li>
|
||||
[% END;
|
||||
|
||||
|
|
|
@ -133,18 +133,6 @@
|
|||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary"><i class="icon-ok icon-white"></i> [%IF create %]Create[% ELSE %]Apply changes[% END %]</button>
|
||||
|
||||
[% IF !create %]
|
||||
<button id="delete-jobset" type="submit" class="btn btn-danger" name="submit" value="delete">
|
||||
<i class="icon-trash icon-white"></i>
|
||||
Delete this jobset
|
||||
</button>
|
||||
<script type="text/javascript">
|
||||
$("#delete-jobset").click(function() {
|
||||
return confirm("Are you sure you want to delete this jobset?");
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
|
|
|
@ -49,9 +49,10 @@
|
|||
<b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
[% INCLUDE menuItem uri = c.uri_for('/jobset' project.name jobset.name 'edit') title="Edit configuration" %]
|
||||
[% INCLUDE menuItem uri = c.uri_for('/jobset' project.name jobset.name 'clone') title="Clone this jobset" %]
|
||||
[% INCLUDE menuItem uri = "javascript:confirmEvaluateJobset()" title="Evaluate this jobset" %]
|
||||
[% INCLUDE menuItem title="Edit configuration" icon="icon-edit" uri=c.uri_for(c.controller('Jobset').action_for('edit'), [project.name, jobset.name]) %]
|
||||
[% INCLUDE menuItem title="Delete this jobset" icon="icon-trash" uri="javascript:deleteJobset()" %]
|
||||
[% INCLUDE menuItem title="Clone this jobset" uri=c.uri_for('/jobset' project.name jobset.name 'clone') %]
|
||||
[% INCLUDE menuItem title="Evaluate this jobset" uri="javascript:confirmEvaluateJobset()" %]
|
||||
</ul>
|
||||
</li>
|
||||
[% END %]
|
||||
|
@ -114,8 +115,6 @@
|
|||
|
||||
<div id="tabs-configuration" class="tab-pane">
|
||||
|
||||
<a class="btn pull-right" href="[% c.uri_for('/jobset' project.name jobset.name "edit") %]"><i class="icon-edit"></i> Edit</a>
|
||||
|
||||
<table class="info-table">
|
||||
<tr>
|
||||
<th>Description:</th>
|
||||
|
@ -167,16 +166,25 @@
|
|||
'Are you sure you want to force evaluation of this jobset?',
|
||||
function(c) {
|
||||
if (!c) return;
|
||||
$.post("[% HTML.escape(c.uri_for('/api/push', { jobsets = project.name _ ':' _ jobset.name, force = "1" })) %]")
|
||||
.done(function(data) {
|
||||
if (data.error)
|
||||
bootbox.alert("Unable to schedule the jobset for evaluation: " + data.error);
|
||||
else
|
||||
bootbox.alert("The jobset has been scheduled for evaluation.");
|
||||
})
|
||||
.fail(function() { bootbox.alert("Server request failed!"); });
|
||||
requestJSON({
|
||||
url: "[% HTML.escape(c.uri_for('/api/push', { jobsets = project.name _ ':' _ jobset.name, force = "1" })) %]",
|
||||
success: function(data) {
|
||||
bootbox.alert("The jobset has been scheduled for evaluation.");
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function deleteJobset() {
|
||||
bootbox.confirm(
|
||||
'Are you sure you want to delete this jobset?',
|
||||
function(c) {
|
||||
if (!c) return;
|
||||
redirectJSON({
|
||||
url: "[% c.uri_for(c.controller('Jobset').action_for('jobset'), [project.name, jobset.name]) %]",
|
||||
type: 'DELETE'
|
||||
});
|
||||
});
|
||||
return;
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
<b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="[% c.uri_for('/project' project.name 'edit') %]"><i class="icon-edit icon-black"></i> Edit configuration</a></li>
|
||||
<li><a href="javascript:deleteProject()"><i class="icon-trash icon-black"></i> Delete this project</a></li>
|
||||
[% INCLUDE menuItem uri = c.uri_for(c.controller('Project').action_for('create_jobset'), [project.name]) title = "Create jobset" %]
|
||||
[% INCLUDE menuItem uri = c.uri_for('/project' project.name 'create-release') title = "Create release" %]
|
||||
[% INCLUDE menuItem title="Edit configuration" icon="icon-edit" uri=c.uri_for(c.controller('Project').action_for('edit'), [project.name]) %]
|
||||
[% INCLUDE menuItem title="Delete this project" icon="icon-trash" uri="javascript:deleteProject()" %]
|
||||
[% INCLUDE menuItem title="Create jobset" icon="icon-plus" uri=c.uri_for(c.controller('Project').action_for('create_jobset'), [project.name]) %]
|
||||
[% INCLUDE menuItem title="Create release" icon="icon-plus" uri=c.uri_for(c.controller('Project').action_for('create_release'), [project.name]) %]
|
||||
</ul>
|
||||
</li>
|
||||
[% END %]
|
||||
|
|
Loading…
Reference in a new issue