Ability to delete and archive environment.

You can now create an environment from the new run page.
This commit is contained in:
ghendricks%novell.com 2007-03-07 17:40:54 +00:00
Родитель 89a3a4cd1a
Коммит 3edb93ccda
10 изменённых файлов: 118 добавлений и 73 удалений

Просмотреть файл

@ -49,6 +49,7 @@ use strict;
use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::User;
use Bugzilla::Config;
###############################
#### Initialization ####
@ -471,7 +472,7 @@ sub update {
if ($self->{$field} ne $newvalues->{$field}){
# If the new name is already in use, return.
$product_id = $newvalues->{'product_id'} || $self->{'product_id'};
if ($product_id eq undef) {
unless ($product_id) {
$dbh->bz_unlock_tables;
return 0;
}
@ -552,6 +553,20 @@ sub update_property_value {
return 1;
}
=head2 toggle_hidden
Toggles the archive bit on the build.
=cut
sub toggle_archive {
my $self = shift;
my $dbh = Bugzilla->dbh;
$dbh->do("UPDATE test_environments SET isactive = ?
WHERE environment_id = ?", undef, $self->isactive ? 0 : 1, $self->id);
}
sub delete_element {
my $self = shift;
my ($element_id) = @_;
@ -586,33 +601,6 @@ sub obliterate {
return 1;
}
=head2 archive
Archives this environment.
=cut
sub archive {
my $self = shift;
my $dbh = Bugzilla->dbh;
$dbh->bz_lock_tables('test_runs READ', 'test_environments WRITE','test_environment_map WRITE');
my $used = $dbh->selectrow_array("SELECT 1 FROM test_runs
WHERE environment_id = ?",
undef, $self->{'environment_id'});
if ($used) {
$dbh->bz_unlock_tables;
ThrowUserError("testopia-non-zero-run-count", {'object' => 'Environment'});
}
$dbh->do("UPDATE test_environments SET isactive = 0
WHERE environment_id = ?", undef, $self->{'environment_id'});
$dbh->bz_unlock_tables;
return 1;
}
=head2 get_run_list
Returns a list of run ids associated with this environment.
@ -651,8 +639,9 @@ Returns true if the logged in user has rights to edit this environment.
sub canedit {
my $self = shift;
return 1 if Bugzilla->user->in_group('Testers');
return 1 if Bugzilla->user->can_see_product($self->product->name);}
return 1 if Bugzilla->user->in_group('Testers') && Bugzilla->user->can_see_product($self->product->name);
return 0;
}
=head2 canview
@ -662,8 +651,8 @@ Returns true if the logged in user has rights to view this environment.
sub canview {
my $self = shift;
return 1 if Bugzilla->user->in_group('Testers');
return 1 if Bugzilla->user->can_see_product($self->product->name);
return 0;
}
=head2 candelete
@ -674,8 +663,9 @@ Returns true if the logged in user has rights to delete this environment.
sub candelete {
my $self = shift;
return 0 unless $self->canedit && Param("allow-test-deletion");
return 1 if Bugzilla->user->in_group("admin");
return 0 unless Param("allow-test-deletion");
return 1 if Bugzilla->user->in_group("Testers") && Param('testopia-allow-group-member-deletes');
return 0;
}

Просмотреть файл

@ -53,7 +53,7 @@
load: function(type, data, evt){
hostDiv.innerHTML = data;
},
error: function(type, error){ alert("ERROR");},
error: function(type, error){ alert(error.message);},
mimetype: "text/html"
});
}
@ -79,14 +79,16 @@
function editClicked(selectedNode, controllerId, icon) {
var hostDiv = document.getElementById("message");
var treeSelector = dojo.widget.manager.getWidgetById('treeSelector');
treeSelector.deselect;
treeSelector.doSelect(selectedNode);
dojo.io.bind({
url: "tr_admin_environment.cgi",
content: { action: "edit", id: selectedNode['objectId'], type: selectedNode['widgetId'] },
load: function(type, data, evt){
hostDiv.innerHTML = data;
},
error: function(type, error){ alert("ERROR");},
error: function(type, error){ alert(error.message);},
mimetype: "text/html"
});
}
@ -275,7 +277,7 @@
target.disabled = false;
dojo.byId('element_submit').disabled = false;
},
error: function(type, error){ alert("ERROR");},
error: function(type, error){ alert(error.message);},
mimetype: "text/plain"
});
}
@ -301,7 +303,7 @@
elem.disabled = false;
target.disabled = false;
},
error: function(type, error){ alert("ERROR");},
error: function(type, error){ alert(error.message);},
mimetype: "text/html"
});
}
@ -317,7 +319,7 @@
</div>
<script>
/* setup menu actrions */
/* setup menu actions */
dojo.addOnLoad(function() {
dojo.event.topic.subscribe('treeContextMenuCreate/engage',
@ -363,7 +365,7 @@ function updateCategory(){
cat.edit({title: data.name});
tree.move(cat,newParent,0);
},
error: function(type, error){ alert("ERROR");},
error: function(type, error){ alert(error.message);},
mimetype: "text/json"
});
}
@ -386,7 +388,7 @@ function updateElement(){
obj.edit({title: data.name});
tree.move(obj,newParent,0);
},
error: function(type, error){ alert("ERROR");},
error: function(type, error){ alert(error.message);},
mimetype: "text/json"
});
}
@ -409,7 +411,7 @@ function updateProperty(){
obj.edit({title: data.name});
tree.move(obj,newParent,0);
},
error: function(type, error){ alert("ERROR");},
error: function(type, error){ alert(error.message);},
mimetype: "text/json"
});
}

Просмотреть файл

@ -27,12 +27,7 @@
[% PROCESS global/variables.none.tmpl %]
[% IF attachment.case_id %]
[% SET item = "Test Case $attachment.case_id" %]
[% ELSE %]
[% SET item = "Test Plan $attachment.plan_id" %]
[% END %]
[% title = "Delete Attachment $attachment.description for $item" %]
[% title = "Delete Environment $environment.name" %]
[%############################################################################%]
[%# Page Header #%]
@ -40,17 +35,26 @@
[% PROCESS global/header.html.tmpl %]
[% IF environment.get_run_count %]
<b>This environment is being used by [% environment.get_run_count FILTER none %]
test runs. Please reassign these runs to a different Environment before deleting.
[% IF deleted %]
Environment Deleted
[% ELSE %]
You are about to permanantly delete this environment.
<p>You are about to permanantly delete this environment.</p>
[% IF environment.get_run_count OR environment.case_run_count %]
<b>This environment is being used by <a href="tr_list_runs.cgi?environment_id=[% environment.id FILTER none %]">[% environment.get_run_count FILTER none %]
test runs</a> and <a href="tr_list_caseruns.cgi?environment_id=[% environment.id FILTER none %]">[% environment.case_run_count FILTER none %] case-runs</a>.
These will also be deleted.</b>
[% END %]
<p><span style="font-size:12pt; font-weight:bold; color:#cc0000;">Warning: This action cannot be undone</span></p>
<br>
<form method="POST" action="tr_show_environment.cgi">
<input type="hidden" name="action" value="do_delete" />
<input type="hidden" name="env_id" value="[% environment.id FILTER none %]" />
<input type="submit" value="Continue" />
</form>
[% END %]
<a href="tr_show_environment.cgi?env_id=[% environment.id FILTER none %]">Back to Envrionment - [% environment.name FILTER html %]</a>
[% END %]
[% PROCESS global/footer.html.tmpl %]

Просмотреть файл

@ -71,6 +71,12 @@ values for each of the properties.
</td>
<td><a href="tr_admin_environment.cgi">Edit Environment Variables</a></td>
</tr>
<tr>
<th>Archive</th><td><input type="checkbox" name="isactive" id="isactive" value="1" [% 'checked="checked"' IF NOT environment.isactive %]></td>
[% IF environment.candelete %]
<td><a href="tr_show_environment.cgi?env_id=[% environment.id FILTER none %]&action=delete">Delete his Environment</a></td>
[% END %]
</tr>
<tr>
<td colspan=2" align="right"><input type="button" onclick="update()" value="Commit"></td>
</tr>

Просмотреть файл

@ -40,6 +40,10 @@
[% PROCESS testopia/blocks.html.tmpl %]
[% PROCESS testopia/messages.html.tmpl %]
[% PROCESS testopia/environment/table.html.tmpl %]
[% IF table.list.size > 0 %]
[% PROCESS testopia/environment/table.html.tmpl %]
[% ELSE %]
No environments found.
[% END %]
[% PROCESS global/footer.html.tmpl %]

Просмотреть файл

@ -54,11 +54,12 @@
function update(){
var product = document.getElementById('product_id').value;
var name = document.getElementById('env_name').value;
var isactive = document.getElementById('isactive').checked ? 1 : 0;
var hostDiv = document.getElementById("message");
var env = dojo.widget.manager.getWidgetById("environment[% environment.id %]");
dojo.io.bind({
url: "tr_show_environment.cgi",
content: {action:"edit", product_id: product, env_id: [% environment.id FILTER none %], name: name},
content: {action:"edit", product_id: product, env_id: [% environment.id FILTER none %], name: name, isactive: isactive},
load: function(type,data,evt){
if (data.error){
hostDiv.innerHTML = '<span style="font-color:#F00;">' + data.error + '</span>';

Просмотреть файл

@ -25,17 +25,23 @@
[% link = "${table.get_order_url}&order=" %]
[% DECORATIVE_BORDER_BEGIN %]
<table width="400">
<table>
<tr class="bz_row_header">
<th><a href="[% link %]environment_id">ID</a></th>
<th><a href="[% link %]name">Name</th>
<th><a href="[% link %]product">Product</th>
<th>Actions</th>
</tr>
[% FOREACH env = table.list %]
<tr class="[% loop.count % 2 == 0 ? "bz_row_odd" : "bz_row_even" %]" onclick="sr([% loop.count %]);">
<td align="center"><a href="tr_show_environment.cgi?env_id=[% env.id FILTER none %]">[% env.id FILTER none %]</a></td>
<td>[% env.name FILTER none %]</td>
<td>[% env.product.name FILTER none %]</td>
<td><a href="tr_show_environment.cgi?env_id=[% env.id FILTER none %]&action=[% env.isactive ? 'hide' : 'unhide' %]">[% env.isactive ? 'Archive' : 'Unarchive' %]</a>
[% IF env.candelete %]
&nbsp;|&nbsp;
<a href="tr_show_environment.cgi?env_id=[% env.id FILTER none %]&action=delete">Delete</a>
[% END %]
</tr>
[% END %]
</table>

Просмотреть файл

@ -54,9 +54,9 @@
<tr>
<th align="right">Manager</th>
<td><input name="manager" value="[% run.manager.login ? run.manager.login : user.login FILTER html %]"></td>
<th align="right"><a href="tr_builds.cgi?plan_id=[% run.plan.id FILTER none %]">Build</a></td>
<th align="right"><a href="tr_builds.cgi?product_id=[% run.plan.product_id FILTER none %]">Build</a></td>
<td>
[% PROCESS select sel = { name => "build",
[% PROCESS select sel = { name => "build",
list => run.plan.product.builds(1),
default => run.build.id }
%]
@ -77,7 +77,7 @@
%]
</td>
<th align="right" valign="top">Environment:</th>
<th align="right" valign="top"><a href="tr_list_environments.cgi?product_id=[% run.plan.product_id FILTER none %]">Environment</a></th>
<td valign="top">
<input dojoType="select"
dataUrl="tr_quicksearch.cgi?action=getenv&product_id=[% run.plan.product_id FILTER none %]&search=%{searchString}"
@ -87,7 +87,12 @@
name="environment"
maxListLength="10"
style="width:200px; height:15px"
value="[% run.environment.id FILTER none %]" ></td>
value="[% run.environment.id FILTER none %]" >
[% IF action == 'Add' %]
<b>or New:</b> <input name="new_env">
[% END %]
</td>
</tr>
<tr>
<th align="right">Summary</th>

Просмотреть файл

@ -92,7 +92,7 @@ if ($action eq 'Add'){
print $cgi->multipart_end if $serverpush;
ThrowUserError('testopia-missing-required-field', {'field' => 'summary'});
}
if ($env eq ''){
if ($env eq '' && !$cgi->param('new_env')){
print $cgi->multipart_end if $serverpush;
ThrowUserError('testopia-missing-required-field', {'field' => 'environment'});
}
@ -100,8 +100,6 @@ if ($action eq 'Add'){
print $cgi->multipart_end if $serverpush;
ThrowUserError("invalid_username", { name => $cgi->param('assignee') });
}
validate_test_id($env, 'environment');
detaint_natural($status);
detaint_natural($build);
@ -125,9 +123,31 @@ if ($action eq 'Add'){
'isactive' => 1,
});
my $bid = $b->check_name($new_build);
$bid ? $build = $bid : $build = $b->store;
if($bid){
$build = $bid;
}
else{
$build = $b->store;
}
}
if ($cgi->param('new_env')){
my $new_env = $cgi->param('new_env');
trick_taint($new_env);
my $e = Bugzilla::Testopia::Environment->new({
'name' => $new_env,
'product_id' => $plan->product_id,
'isactive' => 1,
});
my $eid = $e->check_environment($new_env, $plan->product_id);
if($eid){
$env = $eid;
}
else {
$env = $e->store;
}
}
validate_test_id($env, 'environment');
my $reg = qr/c_([\d]+)/;
my @c;
foreach my $p ($cgi->param()){

Просмотреть файл

@ -63,8 +63,6 @@ unless ($env_id || $action){
exit;
}
Bugzilla->batch(1);
if ($action eq 'delete'){
my $env = Bugzilla::Testopia::Environment->new($env_id);
ThrowUserError('testopia-no-delete', {'object' => 'Environment'}) unless $env->candelete;
@ -77,10 +75,19 @@ if ($action eq 'delete'){
elsif ($action eq 'do_delete'){
my $env = Bugzilla::Testopia::Environment->new($env_id);
ThrowUserError('testopia-no-delete', {'object' => 'Environment'}) unless $env->candelete;
ThrowUserError("testopia-non-zero-run-count", {'object' => 'Environment'}) if $env->get_run_count;
$env->obliterate;
$vars->{'tr_message'} = "Environment Deleted";
display_list();
$vars->{'deleted'} = 1;
$template->process("testopia/environment/delete.html.tmpl", $vars)
|| print $template->error();
}
elsif ($action eq 'hide' || $action eq 'unhide'){
my $env = Bugzilla::Testopia::Environment->new($env_id);
ThrowUserError('testopia-read-only', {'object' => 'Build'}) unless $env->canedit;
$env->toggle_archive;
display();
}
####################
@ -90,7 +97,7 @@ elsif ($action eq 'do_delete'){
elsif ($action eq 'edit'){
my $name = $cgi->param('name');
my $product_id = $cgi->param('product_id');
Bugzilla->batch(1);
trick_taint($name);
detaint_natural($product_id);
eval{
@ -102,7 +109,7 @@ elsif ($action eq 'edit'){
}
my $env = Bugzilla::Testopia::Environment->new($env_id);
unless ($env->update({'product_id' => $product_id})){
unless ($env->update({'product_id' => $product_id, 'isactive' => $cgi->param('isactive') ? 0 : 1})){
print "{error: 'Error updating product'}";
exit;
}
@ -232,8 +239,8 @@ else {
sub display {
detaint_natural($env_id);
validate_test_id($env_id, 'environment');
my $env = Bugzilla::Testopia::Environment->new($env_id);
ThrowUserError('testopia-permission-denied', {object => 'Environment'}) unless $env->canedit;
if(!defined($env)){
my $env = Bugzilla::Testopia::Environment->new({'environment_id' => 0});
@ -244,7 +251,7 @@ sub display {
|| print $template->error();
exit;
}
ThrowUserError('testopia-permission-denied', {object => 'Environment'}) unless $env->canedit;
my $category = Bugzilla::Testopia::Environment::Category->new({'id' => 0});
if (Param('useclassification')){
$vars->{'allhaschild'} = $category->get_all_child_count;