mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 05:48:26 +00:00
Give users a product limited dropdown of environments when creating or updating a run.
This commit is contained in:
parent
492c17dd18
commit
ff30df5a4c
@ -41,7 +41,7 @@ sub environments {
|
||||
push @objs, Bugzilla::Testopia::Environment->new($id);
|
||||
}
|
||||
$self->{'environments'} = \@objs;
|
||||
return $self->{'environmets'};
|
||||
return $self->{'environments'};
|
||||
}
|
||||
|
||||
sub builds {
|
||||
|
@ -38,6 +38,7 @@
|
||||
|
||||
[% PROCESS global/header.html.tmpl %]
|
||||
<script src="testopia/js/util.js" type="text/javascript"></script>
|
||||
<script src="testopia/dojo/dojo.js" type="text/javascript"></script>
|
||||
|
||||
[% PROCESS testopia/style.none.tmpl %]
|
||||
[% PROCESS testopia/search/variables.none.tmpl %]
|
||||
|
@ -18,7 +18,31 @@
|
||||
# Contributor(s): Ed Fuentetaja <efuentetaja@acm.org>
|
||||
# Greg Hendricks <ghendricks@novell.com>
|
||||
#%]
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
dojo.require("dojo.io");
|
||||
function getProdEnvs(product){
|
||||
document.getElementById("env_pick").disabled = true;
|
||||
document.getElementById("action").disabled = true;
|
||||
dojo.io.bind({
|
||||
url: "tr_new_plan.cgi",
|
||||
content: { product_id: product, action: "getenvs" },
|
||||
load: function(type, data, evt){
|
||||
var comps = document.getElementById("env_pick");
|
||||
comps.options.length = 0;
|
||||
for (i in data){
|
||||
var myOp = new Option(data[i].name, data[i].id);
|
||||
addOption(comps, myOp);
|
||||
}
|
||||
document.getElementById("env_pick").disabled = false;
|
||||
document.getElementById("action").disabled = false;
|
||||
},
|
||||
error: function(type, error){ alert(error.message);},
|
||||
mimetype: "text/json"
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<a name="attributes"></a>
|
||||
<input type="hidden" name="run_id" value="[% run.id FILTER none %]">
|
||||
<table border="0" cellpadding="2" cellspacing="0">
|
||||
@ -44,24 +68,6 @@
|
||||
<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">Environment</td>
|
||||
<td><input name="environment" id="environment" value="[% run.environment.id FILTER none %]" />
|
||||
<a href="tr_query.cgi?current_tab=environment" target="blank"><img src="testopia/img/env_lookup.png" title="Search for Environments" align="middle"></a>
|
||||
<a href="tr_new_environment.cgi" target="_blank">New</a>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th align="right">Status</th>
|
||||
<td>
|
||||
[% SET statuslist = [{ id => 1, name => 'Running'}, {id => 0, name=> 'Stopped'}] %]
|
||||
[% PROCESS select sel = { name => "status",
|
||||
list => statuslist,
|
||||
default => run.stop_date ? 0 : 1 }
|
||||
%]
|
||||
|
||||
</td>
|
||||
<th align="right"><a href="tr_builds.cgi?plan_id=[% run.plan.id FILTER none %]">Build</a></td>
|
||||
<td>
|
||||
[% PROCESS select sel = { name => "build",
|
||||
@ -74,6 +80,45 @@
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th align="right">Status</th>
|
||||
<td colspan="3">
|
||||
[% SET statuslist = [{ id => 1, name => 'Running'}, {id => 0, name=> 'Stopped'}] %]
|
||||
[% PROCESS select sel = { name => "status",
|
||||
list => statuslist,
|
||||
default => run.stop_date ? 0 : 1 }
|
||||
%]
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td colspan="4" align="center">
|
||||
<table>
|
||||
<tr><th align="center" colspan="2">Environment</th></tr>
|
||||
<tr>
|
||||
<th align="right">ID</th>
|
||||
<td><input name="environment" id="environment" value="[% run.environment.id FILTER none %]" />
|
||||
<a href="tr_query.cgi?current_tab=environment" target="blank"><img src="testopia/img/env_lookup.png" title="Search for Environments" align="middle"></a>
|
||||
<a href="tr_new_environment.cgi" target="_blank">New</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Or Select from Product</th>
|
||||
<td>
|
||||
[% PROCESS select sel = { name => 'prod_pick',
|
||||
list => user.get_selectable_products,
|
||||
default => run.plan.product_id
|
||||
events => 'onChange="getProdEnvs(this.value)"' } %]
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
[% PROCESS select sel = { name => 'env_pick' }%]
|
||||
</td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align="right">Summary</th>
|
||||
<td colspan="3"><input type="text" size="110" name="summary" value="[% run.summary FILTER html %]"></td>
|
||||
@ -89,5 +134,8 @@
|
||||
</tr>
|
||||
</table>
|
||||
<div class="submits">
|
||||
<input type="submit" name="action" value="[% action %]" />
|
||||
<input type="submit" name="action" id="action" value="[% action %]" />
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
getProdEnvs(document.getElementById('prod_pick').value);
|
||||
</script>
|
||||
|
@ -130,6 +130,21 @@ elsif ($action eq 'getcomps'){
|
||||
print $json->objToJson(\@comps);
|
||||
exit;
|
||||
}
|
||||
elsif ($action eq 'getenvs'){
|
||||
Bugzilla->login;
|
||||
my $product_id = $cgi->param('product_id');
|
||||
|
||||
detaint_natural($product_id);
|
||||
my $product = Bugzilla::Testopia::Product->new($product_id);
|
||||
|
||||
my @envs;
|
||||
foreach my $e (@{$product->environments}){
|
||||
push @envs, {'id' => $e->id, 'name' => $e->name};
|
||||
}
|
||||
my $json = new JSON;
|
||||
print $json->objToJson(\@envs);
|
||||
exit;
|
||||
}
|
||||
####################
|
||||
### Display Form ###
|
||||
####################
|
||||
|
@ -85,7 +85,7 @@ if ($action eq 'Add'){
|
||||
my $build = $cgi->param('build');
|
||||
my $summary = $cgi->param('summary');
|
||||
my $notes = $cgi->param('notes');
|
||||
my $env = $cgi->param('environment');
|
||||
my $env = $cgi->param('environment') ? $cgi->param('environment') : $cgi->param('env_pick');
|
||||
|
||||
ThrowUserError('testopia-missing-required-field', {'field' => 'summary'}) if $summary eq '';
|
||||
ThrowUserError('testopia-missing-required-field', {'field' => 'environment'}) if $env eq '';
|
||||
|
@ -337,8 +337,6 @@ sub get_cc_xml {
|
||||
sub do_update {
|
||||
my ($run) = @_;
|
||||
|
||||
ThrowUserError('testopia-missing-required-field', {'field' => 'summary'}) if ($cgi->param('summary') eq '');
|
||||
ThrowUserError('testopia-missing-required-field', {'field' => 'environment'}) if ($cgi->param('environment') eq '');
|
||||
my $timestamp;
|
||||
$timestamp = $run->stop_date;
|
||||
$timestamp = undef if $cgi->param('status') && $run->stop_date;
|
||||
@ -347,9 +345,12 @@ sub do_update {
|
||||
my $prodver = $cgi->param('product_version');
|
||||
my $planver = $cgi->param('plan_version');
|
||||
my $build = $cgi->param('build');
|
||||
my $env = $cgi->param('environment');
|
||||
my $env = $cgi->param('environment') ? $cgi->param('environment') : $cgi->param('env_pick');
|
||||
my $manager = DBNameToIdAndCheck(trim($cgi->param('manager')));
|
||||
my $notes = trim($cgi->param('notes'));
|
||||
|
||||
ThrowUserError('testopia-missing-required-field', {'field' => 'summary'}) if ($cgi->param('summary') eq '');
|
||||
ThrowUserError('testopia-missing-required-field', {'field' => 'environment'}) if ($env eq '');
|
||||
|
||||
trick_taint($summary);
|
||||
trick_taint($prodver);
|
||||
|
Loading…
x
Reference in New Issue
Block a user