diff --git a/webtools/testopia/Bugzilla/Testopia/Environment.pm b/webtools/testopia/Bugzilla/Testopia/Environment.pm index 135e8452e84..c9f54504580 100644 --- a/webtools/testopia/Bugzilla/Testopia/Environment.pm +++ b/webtools/testopia/Bugzilla/Testopia/Environment.pm @@ -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; } diff --git a/webtools/testopia/template/en/default/testopia/environment/admin/tree.html.tmpl b/webtools/testopia/template/en/default/testopia/environment/admin/tree.html.tmpl index e088533ef15..1cbfeff7835 100644 --- a/webtools/testopia/template/en/default/testopia/environment/admin/tree.html.tmpl +++ b/webtools/testopia/template/en/default/testopia/environment/admin/tree.html.tmpl @@ -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 @@