Commit e679c186 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 301743: Replace old code from editcomponents.cgi by methods and routines…

Bug 301743: Replace old code from editcomponents.cgi by methods and routines from Component.pm and Product.pm - Patch by Tiago R. Mello <timello@gmail.com> r=LpSolit a=justdave
parent 3223b9f1
......@@ -21,6 +21,7 @@ package Bugzilla::Component;
use Bugzilla::Util;
use Bugzilla::Error;
use Bugzilla::User;
###############################
#### Initialization ####
......@@ -87,6 +88,50 @@ sub _init {
return $self;
}
sub bug_count {
my $self = shift;
my $dbh = Bugzilla->dbh;
if (!defined $self->{'bug_count'}) {
$self->{'bug_count'} = $dbh->selectrow_array(q{
SELECT COUNT(*) FROM bugs
WHERE component_id = ?}, undef, $self->id) || 0;
}
return $self->{'bug_count'};
}
sub bug_ids {
my $self = shift;
my $dbh = Bugzilla->dbh;
if (!defined $self->{'bugs_ids'}) {
$self->{'bugs_ids'} = $dbh->selectcol_arrayref(q{
SELECT bug_id FROM bugs
WHERE component_id = ?}, undef, $self->id);
}
return $self->{'bugs_ids'};
}
sub default_assignee {
my $self = shift;
if (!defined $self->{'default_assignee'}) {
$self->{'default_assignee'} =
new Bugzilla::User($self->{'initialowner'});
}
return $self->{'default_assignee'};
}
sub default_qa_contact {
my $self = shift;
if (!defined $self->{'default_qa_contact'}) {
$self->{'default_qa_contact'} =
new Bugzilla::User($self->{'initialqacontact'});
}
return $self->{'default_qa_contact'};
}
###############################
#### Accessors ####
###############################
......@@ -95,8 +140,6 @@ sub id { return $_[0]->{'id'}; }
sub name { return $_[0]->{'name'}; }
sub description { return $_[0]->{'description'}; }
sub product_id { return $_[0]->{'product_id'}; }
sub default_assignee { return $_[0]->{'initialowner'}; }
sub default_qa_contact { return $_[0]->{'initialqacontact'}; }
###############################
#### Subroutines ####
......@@ -128,6 +171,27 @@ sub get_components_by_product {
return @components;
}
sub check_component {
my ($product, $comp_name) = @_;
$comp_name || ThrowUserError('component_blank_name');
if (length($comp_name) > 64) {
ThrowUserError('component_name_too_long',
{'name' => $comp_name});
}
my $component =
new Bugzilla::Component({product_id => $product->id,
name => $comp_name});
unless ($component) {
ThrowUserError('component_not_valid',
{'product' => $product->name,
'name' => $comp_name});
}
return $component;
}
1;
__END__
......@@ -144,6 +208,8 @@ Bugzilla::Component - Bugzilla product component class.
my $component = new Bugzilla::Component({product_id => 1,
name => 'AcmeComp'});
my $bug_count = $component->bug_count();
my $bug_ids = $component->bug_ids();
my $id = $component->id;
my $name = $component->name;
my $description = $component->description;
......@@ -152,6 +218,7 @@ Bugzilla::Component - Bugzilla product component class.
my $default_qa_contact = $component->default_qa_contact;
my @components = Bugzilla::Component::get_components_by_product($id);
my $component = Bugzilla::Component::check_component($product, 'AcmeComp');
=head1 DESCRIPTION
......@@ -175,6 +242,40 @@ Component.pm represents a Product Component object.
Returns: A Bugzilla::Component object.
=item C<bug_count()>
Description: Returns the total of bugs that belong to the component.
Params: none.
Returns: Integer with the number of bugs.
=item C<bugs_ids()>
Description: Returns all bug IDs that belong to the component.
Params: none.
Returns: A reference to an array of bug IDs.
=item C<default_assignee()>
Description: Returns a user object that represents the default assignee for
the component.
Params: none.
Returns: A Bugzilla::User object.
=item C<default_qa_contact()>
Description: Returns a user object that represents the default QA contact for
the component.
Params: none.
Returns: A Bugzilla::User object.
=back
=head1 SUBROUTINES
......@@ -189,6 +290,17 @@ Component.pm represents a Product Component object.
Returns: An array of Bugzilla::Component objects.
=item C<check_component($product, $comp_name)>
Description: Checks if the component name was passed in and if it is a valid
component.
Params: $product - A Bugzilla::Product object.
$comp_name - String with a component name.
Returns: Bugzilla::Component object.
=back
=cut
......@@ -35,6 +35,8 @@ use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::Series;
use Bugzilla::Util;
use Bugzilla::User;
use Bugzilla::Product;
use Bugzilla::Component;
use Bugzilla::Bug;
use vars qw($template $vars);
......@@ -42,72 +44,6 @@ use vars qw($template $vars);
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $showbugcounts = (defined $cgi->param('showbugcounts'));
# TestProduct: just returns if the specified product does exists
# CheckProduct: same check, optionally emit an error text
# TestComponent: just returns if the specified product/component combination exists
# CheckComponent: same check, optionally emit an error text
sub TestProduct
{
my $prod = shift;
# does the product exist?
SendSQL("SELECT name
FROM products
WHERE name = " . SqlQuote($prod));
return FetchOneColumn();
}
sub CheckProduct
{
my $prod = shift;
# do we have a product?
unless ($prod) {
ThrowUserError('product_not_specified');
}
unless (TestProduct $prod) {
ThrowUserError('product_doesnt_exist',
{'product' => $prod});
}
}
sub TestComponent
{
my ($prod, $comp) = @_;
# does the product/component combination exist?
SendSQL("SELECT components.name
FROM components
INNER JOIN products
ON products.id = components.product_id
WHERE products.name = " . SqlQuote($prod) . "
AND components.name = " . SqlQuote($comp));
return FetchOneColumn();
}
sub CheckComponent
{
my ($prod, $comp) = @_;
# do we have the component?
unless ($comp) {
ThrowUserError('component_not_specified');
}
CheckProduct($prod);
unless (TestComponent $prod, $comp) {
ThrowUserError('component_not_valid',
{'product' => $prod,
'name' => $comp});
}
}
#
# Preliminary checks:
#
......@@ -115,7 +51,7 @@ sub CheckComponent
my $user = Bugzilla->login(LOGIN_REQUIRED);
my $whoid = $user->id;
print Bugzilla->cgi->header();
print $cgi->header();
UserInGroup("editcomponents")
|| ThrowUserError("auth_failure", {group => "editcomponents",
......@@ -125,44 +61,18 @@ UserInGroup("editcomponents")
#
# often used variables
#
my $product = trim($cgi->param('product') || '');
my $component = trim($cgi->param('component') || '');
my $product_name = trim($cgi->param('product') || '');
my $comp_name = trim($cgi->param('component') || '');
my $action = trim($cgi->param('action') || '');
my $showbugcounts = (defined $cgi->param('showbugcounts'));
#
# product = '' -> Show nice list of products
#
unless ($product) {
my @products = ();
if ($showbugcounts){
SendSQL("SELECT products.name, products.description, COUNT(bug_id)
FROM products LEFT JOIN bugs
ON products.id = bugs.product_id " .
$dbh->sql_group_by('products.name', 'products.description') . "
ORDER BY products.name");
} else {
SendSQL("SELECT products.name, products.description
FROM products
ORDER BY products.name");
}
while ( MoreSQLData() ) {
unless ($product_name) {
my $prod = {};
my ($name, $description, $bug_count) = FetchSQLData();
$prod->{'name'} = $name;
$prod->{'description'} = $description;
$prod->{'bug_count'} = $bug_count;
push(@products, $prod);
}
my @products = Bugzilla::Product::get_all_products();
$vars->{'showbugcounts'} = $showbugcounts;
$vars->{'products'} = \@products;
......@@ -174,7 +84,7 @@ unless ($product) {
exit;
}
my $product = Bugzilla::Product::check_product($product_name);
#
# action='' -> Show nice list of components
......@@ -182,50 +92,13 @@ unless ($product) {
unless ($action) {
CheckProduct($product);
my $product_id = get_product_id($product);
my @components = ();
if ($showbugcounts) {
SendSQL("SELECT name, description, initialowner,
initialqacontact, COUNT(bug_id)
FROM components LEFT JOIN bugs
ON components.id = bugs.component_id
WHERE components.product_id = $product_id " .
$dbh->sql_group_by('name',
'description, initialowner, initialqacontact'));
} else {
SendSQL("SELECT name, description, initialowner, initialqacontact
FROM components
WHERE product_id = $product_id " .
$dbh->sql_group_by('name',
'description, initialowner, initialqacontact'));
}
while (MoreSQLData()) {
my $component = {};
my ($name, $desc, $initialownerid, $initialqacontactid, $bug_count)
= FetchSQLData();
$component->{'name'} = $name;
$component->{'description'} = $desc;
$component->{'initialowner'} = DBID_to_name($initialownerid)
if ($initialownerid);
$component->{'initialqacontact'} = DBID_to_name($initialqacontactid)
if ($initialqacontactid);
$component->{'bug_count'} = $bug_count;
push(@components, $component);
}
my @components =
Bugzilla::Component::get_components_by_product($product->id);
$vars->{'showbugcounts'} = $showbugcounts;
$vars->{'product'} = $product;
$vars->{'product'} = $product->name;
$vars->{'components'} = \@components;
$template->process("admin/components/list.html.tmpl",
$vars)
$template->process("admin/components/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
......@@ -240,14 +113,10 @@ unless ($action) {
if ($action eq 'add') {
CheckProduct($product);
$vars->{'product'} = $product;
$template->process("admin/components/create.html.tmpl",
$vars)
$vars->{'product'} = $product->name;
$template->process("admin/components/create.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
}
......@@ -259,73 +128,51 @@ if ($action eq 'add') {
if ($action eq 'new') {
CheckProduct($product);
my $product_id = get_product_id($product);
# Do the user matching
Bugzilla::User::match_field ($cgi, {
'initialowner' => { 'type' => 'single' },
'initialqacontact' => { 'type' => 'single' },
});
# Cleanups and valididy checks
my $default_assignee = trim($cgi->param('initialowner') || '');
my $default_qa_contact = trim($cgi->param('initialqacontact') || '');
my $description = trim($cgi->param('description') || '');
unless ($component) {
ThrowUserError('component_blank_name',
{'name' => $component});
}
if (TestComponent($product, $component)) {
ThrowUserError('component_already_exists',
{'name' => $component});
}
$comp_name || ThrowUserError('component_blank_name');
if (length($component) > 64) {
if (length($comp_name) > 64) {
ThrowUserError('component_name_too_long',
{'name' => $component});
{'name' => $comp_name});
}
my $description = trim($cgi->param('description') || '');
my $component =
new Bugzilla::Component({product_id => $product->id,
name => $comp_name});
if ($description eq '') {
ThrowUserError('component_blank_description',
{'name' => $component});
if ($component) {
ThrowUserError('component_already_exists',
{'name' => $component->name});
}
# Do the user matching
Bugzilla::User::match_field ($cgi, {
'initialowner' => { 'type' => 'single' },
'initialqacontact' => { 'type' => 'single' },
});
$description || ThrowUserError('component_blank_description',
{name => $comp_name});
$default_assignee || ThrowUserError('component_need_initialowner',
{name => $comp_name});
my $initialowner = trim($cgi->param('initialowner') || '');
my $default_assignee_id = login_to_id($default_assignee);
my $default_qa_contact_id = Param('useqacontact') ?
(login_to_id($default_qa_contact) || undef) : undef;
if ($initialowner eq '') {
ThrowUserError('component_need_initialowner',
{'name' => $component});
}
trick_taint($comp_name);
trick_taint($description);
my $initialownerid = login_to_id ($initialowner);
if (!$initialownerid) {
ThrowUserError('component_need_valid_initialowner',
{'name' => $component});
}
my $initialqacontact = trim($cgi->param('initialqacontact') || '');
my $initialqacontactid = login_to_id ($initialqacontact);
if (Param('useqacontact')) {
if (!$initialqacontactid && $initialqacontact ne '') {
ThrowUserError('component_need_valid_initialqacontact',
{'name' => $component});
}
}
my $initialqacontactsql =
$initialqacontact ne '' ? SqlQuote($initialqacontactid) : 'NULL';
# Add the new component
SendSQL("INSERT INTO components ( " .
"product_id, name, description, initialowner, initialqacontact " .
" ) VALUES ( " .
$product_id . "," .
SqlQuote($component) . "," .
SqlQuote($description) . "," .
SqlQuote($initialownerid) . "," .
$initialqacontactsql . ")");
$dbh->do("INSERT INTO components
(product_id, name, description, initialowner,
initialqacontact)
VALUES (?, ?, ?, ?, ?)", undef,
($product->id, $comp_name, $description,
$default_assignee_id, $default_qa_contact_id));
# Insert default charting queries for this product.
# If they aren't using charting, this won't do any harm.
......@@ -333,8 +180,8 @@ if ($action eq 'new') {
my @series;
my $prodcomp = "&product=" . url_quote($product) .
"&component=" . url_quote($component);
my $prodcomp = "&product=" . url_quote($product->name) .
"&component=" . url_quote($comp_name);
# For localisation reasons, we get the title of the queries from the
# submitted form.
......@@ -358,17 +205,17 @@ if ($action eq 'new') {
push(@series, [$closed_name, $resolved]);
foreach my $sdata (@series) {
my $series = new Bugzilla::Series(undef, $product, $component,
$sdata->[0], $::userid, 1,
$sdata->[1], 1);
my $series = new Bugzilla::Series(undef, $product->name,
$comp_name, $sdata->[0],
$::userid, 1, $sdata->[1], 1);
$series->writeToDatabase();
}
# Make versioncache flush
unlink "$datadir/versioncache";
$vars->{'name'} = $component;
$vars->{'product'} = $product;
$vars->{'name'} = $comp_name;
$vars->{'product'} = $product->name;
$template->process("admin/components/created.html.tmpl",
$vars)
|| ThrowTemplateError($template->error());
......@@ -386,52 +233,12 @@ if ($action eq 'new') {
if ($action eq 'del') {
CheckComponent($product, $component);
my $component_id = get_component_id(get_product_id($product), $component);
# display some data about the component
SendSQL("SELECT products.name, products.description,
products.milestoneurl, products.disallownew,
components.name, components.initialowner,
components.initialqacontact, components.description
FROM products
LEFT JOIN components ON products.id = components.product_id
WHERE components.id = $component_id");
my ($product, $product_description, $milestoneurl, $disallownew,
$component, $initialownerid, $initialqacontactid, $description) =
FetchSQLData();
my $initialowner = $initialownerid ? DBID_to_name ($initialownerid) : '';
my $initialqacontact = $initialqacontactid ? DBID_to_name ($initialqacontactid) : '';
$milestoneurl ||= '';
$product_description ||= '';
$disallownew ||= 0;
$description ||= '';
$vars->{'comp'} =
Bugzilla::Component::check_component($product, $comp_name);
if (Param('useqacontact')) {
$vars->{'initialqacontact'} = $initialqacontact;
}
if (Param('usetargetmilestone')) {
$vars->{'milestoneurl'} = $milestoneurl;
}
SendSQL("SELECT count(bug_id)
FROM bugs
WHERE component_id = $component_id");
$vars->{'bug_count'} = FetchOneColumn() || 0;
$vars->{'prod'} = $product;
$vars->{'name'} = $component;
$vars->{'description'} = $description;
$vars->{'initialowner'} = $initialowner;
$vars->{'product'} = $product;
$vars->{'product_description'} = $product_description;
$vars->{'disallownew'} = $disallownew;
$template->process("admin/components/confirm-delete.html.tmpl",
$vars)
$template->process("admin/components/confirm-delete.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
......@@ -444,43 +251,40 @@ if ($action eq 'del') {
#
if ($action eq 'delete') {
CheckComponent($product, $component);
my $component_id = get_component_id(get_product_id($product), $component);
my $bug_ids =
$dbh->selectcol_arrayref("SELECT bug_id FROM bugs WHERE component_id = ?",
undef, $component_id);
my $component =
Bugzilla::Component::check_component($product, $comp_name);
my $nb_bugs = scalar(@$bug_ids);
if ($nb_bugs) {
if ($component->bug_count) {
if (Param("allowbugdeletion")) {
foreach my $bug_id (@$bug_ids) {
foreach my $bug_id (@{$component->bug_ids}) {
my $bug = new Bugzilla::Bug($bug_id, $whoid);
$bug->remove_from_db();
}
}
else {
ThrowUserError("component_has_bugs", { nb => $nb_bugs });
} else {
ThrowUserError("component_has_bugs",
{nb => $component->bug_count });
}
}
$vars->{'deleted_bug_count'} = $nb_bugs;
$vars->{'deleted_bug_count'} = $component->bug_count;
$dbh->bz_lock_tables('components WRITE', 'flaginclusions WRITE',
'flagexclusions WRITE');
$dbh->do("DELETE FROM flaginclusions WHERE component_id = ?",
undef, $component_id);
undef, $component->id);
$dbh->do("DELETE FROM flagexclusions WHERE component_id = ?",
undef, $component_id);
$dbh->do("DELETE FROM components WHERE id = ?", undef, $component_id);
undef, $component->id);
$dbh->do("DELETE FROM components WHERE id = ?",
undef, $component->id);
$dbh->bz_unlock_tables();
unlink "$datadir/versioncache";
$vars->{'name'} = $component;
$vars->{'product'} = $product;
$vars->{'name'} = $component->name;
$vars->{'product'} = $product->name;
$template->process("admin/components/deleted.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
......@@ -496,34 +300,10 @@ if ($action eq 'delete') {
if ($action eq 'edit') {
CheckComponent($product, $component);
my $component_id = get_component_id(get_product_id($product), $component);
$vars->{'comp'} =
Bugzilla::Component::check_component($product, $comp_name);
# get data of component
SendSQL("SELECT products.name,
components.name, components.initialowner,
components.initialqacontact, components.description
FROM products LEFT JOIN components ON
products.id = components.product_id
WHERE components.id = $component_id");
my ($product, $component, $initialownerid, $initialqacontactid,
$description) = FetchSQLData();
my $initialowner = $initialownerid ? DBID_to_name ($initialownerid) : '';
my $initialqacontact = $initialqacontactid ? DBID_to_name ($initialqacontactid) : '';
SendSQL("SELECT count(*)
FROM bugs
WHERE component_id = $component_id");
$vars->{'bug_count'} = FetchOneColumn() || 0;
$vars->{'name'} = $component;
$vars->{'description'} = $description;
$vars->{'initialowner'} = $initialowner;
$vars->{'initialqacontact'} = $initialqacontact;
$vars->{'product'} = $product;
$vars->{'prod'} = $product;
$template->process("admin/components/edit.html.tmpl",
$vars)
......@@ -546,100 +326,88 @@ if ($action eq 'update') {
'initialqacontact' => { 'type' => 'single' },
});
my $componentold = trim($cgi->param('componentold') || '');
my $comp_old_name = trim($cgi->param('componentold') || '');
my $default_assignee = trim($cgi->param('initialowner') || '');
my $default_qa_contact = trim($cgi->param('initialqacontact') || '');
my $description = trim($cgi->param('description') || '');
my $descriptionold = trim($cgi->param('descriptionold') || '');
my $initialowner = trim($cgi->param('initialowner') || '');
my $initialownerold = trim($cgi->param('initialownerold') || '');
my $initialqacontact = trim($cgi->param('initialqacontact') || '');
my $initialqacontactold = trim($cgi->param('initialqacontactold') || '');
if (length($component) > 64) {
my $component_old =
Bugzilla::Component::check_component($product, $comp_old_name);
$comp_name || ThrowUserError('component_blank_name');
if (length($comp_name) > 64) {
ThrowUserError('component_name_too_long',
{'name' => $component});
{'name' => $comp_name});
}
if ($comp_name ne $component_old->name) {
my $component =
new Bugzilla::Component({product_id => $product->id,
name => $comp_name});
if ($component) {
ThrowUserError('component_already_exists',
{'name' => $component->name});
}
}
# Note that the order of this tests is important. If you change
# them, be sure to test for WHERE='$component' or WHERE='$componentold'
$description || ThrowUserError('component_blank_description',
{'name' => $component_old->name});
$default_assignee || ThrowUserError('component_need_initialowner',
{name => $comp_name});
my $default_assignee_id = login_to_id($default_assignee);
my $default_qa_contact_id = login_to_id($default_qa_contact) || undef;
$dbh->bz_lock_tables('components WRITE', 'products READ',
'profiles READ');
CheckComponent($product, $componentold);
my $component_id = get_component_id(get_product_id($product),
$componentold);
if ($description ne $descriptionold) {
unless ($description) {
ThrowUserError('component_blank_description',
{'name' => $componentold});
}
SendSQL("UPDATE components
SET description=" . SqlQuote($description) . "
WHERE id=$component_id");
$vars->{'updated_description'} = 1;
$vars->{'description'} = $description;
}
if ($comp_name ne $component_old->name) {
trick_taint($comp_name);
$dbh->do("UPDATE components SET name = ? WHERE id = ?",
undef, ($comp_name, $component_old->id));
if ($initialowner ne $initialownerold) {
unlink "$datadir/versioncache";
$vars->{'updated_name'} = 1;
my $initialownerid = login_to_id($initialowner);
unless ($initialownerid) {
ThrowUserError('component_need_valid_initialowner',
{'name' => $componentold});
}
SendSQL("UPDATE components
SET initialowner=" . SqlQuote($initialownerid) . "
WHERE id = $component_id");
$vars->{'updated_initialowner'} = 1;
$vars->{'initialowner'} = $initialowner;
if ($description ne $component_old->description) {
}
trick_taint($description);
$dbh->do("UPDATE components SET description = ? WHERE id = ?",
undef, ($description, $component_old->id));
if (Param('useqacontact') && $initialqacontact ne $initialqacontactold) {
my $initialqacontactid = login_to_id($initialqacontact);
if (!$initialqacontactid && $initialqacontact ne '') {
ThrowUserError('component_need_valid_initialqacontact',
{'name' => $componentold});
$vars->{'updated_description'} = 1;
$vars->{'description'} = $description;
}
my $initialqacontactsql =
$initialqacontact ne '' ? SqlQuote($initialqacontactid) : 'NULL';
SendSQL("UPDATE components
SET initialqacontact = $initialqacontactsql
WHERE id = $component_id");
if ($default_assignee ne $component_old->default_assignee->login) {
$vars->{'updated_initialqacontact'} = 1;
$vars->{'initialqacontact'} = $initialqacontact;
}
$dbh->do("UPDATE components SET initialowner = ? WHERE id = ?",
undef, ($default_assignee_id, $component_old->id));
$vars->{'updated_initialowner'} = 1;
$vars->{'initialowner'} = $default_assignee;
if ($component ne $componentold) {
unless ($component) {
ThrowUserError('component_must_have_a_name',
{'name' => $componentold});
}
if (TestComponent($product, $component)) {
ThrowUserError('component_already_exists',
{'name' => $component});
}
SendSQL("UPDATE components SET name=" . SqlQuote($component) .
"WHERE id=$component_id");
unlink "$datadir/versioncache";
$vars->{'updated_name'} = 1;
if (Param('useqacontact')
&& $default_qa_contact ne $component_old->default_qa_contact->login) {
$dbh->do("UPDATE components SET initialqacontact = ?
WHERE id = ?", undef,
($default_qa_contact_id, $component_old->id));
$vars->{'updated_initialqacontact'} = 1;
$vars->{'initialqacontact'} = $default_qa_contact;
}
$dbh->bz_unlock_tables();
$vars->{'name'} = $component;
$vars->{'product'} = $product;
$vars->{'name'} = $comp_name;
$vars->{'product'} = $product->name;
$template->process("admin/components/updated.html.tmpl",
$vars)
|| ThrowTemplateError($template->error());
......@@ -647,8 +415,6 @@ if ($action eq 'update') {
exit;
}
#
# No valid action found
#
......
......@@ -20,29 +20,13 @@
#%]
[%# INTERFACE:
# name: string; The name of the component
#
# description: string; Component description, may be empty
#
# bug_count: number; The number of bugs belonging to the component
#
# initialowner: string; default assignee, may be empty
#
# initialqacontact: string; if system parameter is set to use the default
# qa contact field, then this will be it,
# may be empty
#
# milestoneurl: string; milestone url, if milestones are in use,
# may be empty
#
# product: string; The name of the product
#
# disallownew: boolean; Are new bugs allowed for the product flag
#
# product_description: string; Description of product
# comp: object; Bugzilla::Component object representing the component the
# user wants to delete.
# prod: object; Bugzilla::Product object representing the product to
# which the component belongs.
#%]
[% title = BLOCK %]Delete Component of Product '[% product FILTER html %]'
[% title = BLOCK %]Delete Component of Product '[% prod.name FILTER html %]'
[% END %]
[% PROCESS global/header.html.tmpl
......@@ -56,54 +40,58 @@
</tr>
<tr>
<td valign="top">Component:</td>
<td valign="top">[% name FILTER html %]</td>
<td valign="top">[% comp.name FILTER html %]</td>
</tr>
<tr>
<td valign="top">Component Description:</td>
<td valign="top">[% description FILTER html %]</td>
<td valign="top">[% comp.description FILTER html %]</td>
</tr>
<tr>
<td valign="top">Default assignee:</td>
<td valign="top">[% initialowner FILTER html %]</td>
<td valign="top">[% comp.default_assignee.login FILTER html %]</td>
[% IF Param('useqacontact') %]
</tr>
<tr>
<td valign="top">Default QA contact:</td>
<td valign="top">[% initialqacontact FILTER html %]</td>
<td valign="top">[% comp.default_qa_contact.login FILTER html %]</td>
[% END %]
</tr>
<tr>
<td valign="top">Component of Product:</td>
<td valign="top">[% product FILTER html %]</td>
<td valign="top">[% prod.name FILTER html %]</td>
[% IF product_description %]
[% IF prod.description %]
</tr>
<tr>
<td valign="top">Product Description:</td>
<td valign="top">[% product_description FILTER html %]</td>
<td valign="top">[% prod.description FILTER html %]</td>
[% END %]
[% IF Param('usetargetmilestone') %]
</tr>
<tr>
<td valign="top">Product Milestone URL:</td>
<td valign="top"><a href="[% milestoneurl FILTER uri %]">[% milestoneurl FILTER html %]</a></td>
<td valign="top">
<a href="[% prod.milestone_url FILTER uri %]">
[% prod.milestone_url FILTER html %]
</a>
</td>
[% END %]
</tr>
<tr>
<TD VALIGN="top">Closed for [% terms.bugs %]:</TD>
<TD VALIGN="top">[% IF $disallownew %]Yes[% ELSE %]No[% END %]</td>
<TD VALIGN="top">[% IF prod.disallow_new %]Yes[% ELSE %]No[% END %]</td>
</tr>
<tr>
<td valign="top">[% terms.Bugs %]:</td>
<td valign="top">
[% IF bug_count %]
<a title="List of [% terms.bugs %] for component '[% name FILTER html %]'"
href="buglist.cgi?component=[% name FILTER url_quote %]&amp;product=
[%- product FILTER url_quote %]">[% bug_count %]</a>
[% IF comp.bug_count %]
<a title="List of [% terms.bugs %] for component '[% comp.name FILTER html %]'"
href="buglist.cgi?component=[% comp.name FILTER url_quote %]&amp;product=
[%- prod.name FILTER url_quote %]">[% comp.bug_count %]</a>
[% ELSE %]
None
[% END %]
......@@ -113,21 +101,21 @@
<h2>Confirmation</h2>
[% IF bug_count %]
[% IF comp.bug_count %]
[% IF !Param("allowbugdeletion") %]
Sorry, there
[% IF bug_count > 1 %]
are [% bug_count %] [%+ terms.bugs %]
[% IF comp.bug_count > 1 %]
are [% comp.bug_count %] [%+ terms.bugs %]
[% ELSE %]
is [% bug_count %] [%+ terms.bug %]
is [% comp.bug_count %] [%+ terms.bug %]
[% END %]
outstanding for this component. You must reassign
[% IF bug_count > 1 %]
[% IF comp.bug_count > 1 %]
those [% terms.bugs %]
[% ELSE %]
that [% terms.bug %]
......@@ -139,8 +127,8 @@
<table border="0" cellpadding="20" width="70%" bgcolor="red"><tr><td>
There [% IF bug_count > 1 %]
are [% bug_count %] [%+ terms.bugs %]
There [% IF comp.bug_count > 1 %]
are [% comp.bug_count %] [%+ terms.bugs %]
[% ELSE %]
is 1 [% terms.bug %]
[% END %]
......@@ -153,19 +141,22 @@
[% END %]
[% IF bug_count == 0 || Param('allowbugdeletion') %]
[% IF comp.bug_count == 0 || Param('allowbugdeletion') %]
<p>Do you really want to delete this component?<p>
<form method="post" action="editcomponents.cgi">
<input type="submit" value="Yes, delete">
<input type="hidden" name="action" value="delete">
<input type="hidden" name="product" value="[% product FILTER html %]">
<input type="hidden" name="component" value="[% name FILTER html %]">
<input type="hidden" name="product" value="[% prod.name FILTER html %]">
<input type="hidden" name="component" value="[% comp.name FILTER html %]">
</form>
[% END %]
[% PROCESS admin/components/footer.html.tmpl %]
[% PROCESS admin/components/footer.html.tmpl
name = comp.name
product = prod.name
%]
[% PROCESS global/footer.html.tmpl %]
......@@ -20,22 +20,15 @@
#%]
[%# INTERFACE:
# name: string; The name of the component.
#
# description: string; Component description, may be empty
#
# initialowner: string; default assignee, may be empty
#
# initialqacontact: string; default qa contact, may be empty
#
# product: string; The product the component belongs to
#
# bug_count: number; number of bugs belonging to the component
# comp: object; Bugzilla::Component object representing the component the
# user wants to edit.
# prod: object; Bugzilla::Product object representing the product to
# which the component belongs.
#%]
[% PROCESS global/variables.none.tmpl %]
[% title = BLOCK %]Edit Component '[% name FILTER html %]'[% END %]
[% title = BLOCK %]Edit Component '[% comp.name FILTER html %]'[% END %]
[% PROCESS global/header.html.tmpl
title = title
%]
......@@ -46,12 +39,12 @@
<tr>
<td valign="top">Component:</td>
<td><input size="64" maxlength="64" name="component" value="
[%- name FILTER html %]"></td>
[%- comp.name FILTER html %]"></td>
</tr>
<tr>
<td valign="top">Component Description:</td>
<td><textarea rows="4" cols="64" wrap="virtual"
name="description">[% description FILTER html %]</textarea>
name="description">[% comp.description FILTER html %]</textarea>
</td>
</tr>
<tr>
......@@ -60,7 +53,7 @@
[% INCLUDE global/userselect.html.tmpl
name => "initialowner"
id => "initialowner"
value => initialowner
value => comp.default_assignee.login
size => 64
emptyok => 1
%]
......@@ -74,7 +67,7 @@
[% INCLUDE global/userselect.html.tmpl
name => "initialqacontact"
id => "initialqacontact"
value => initialqacontact
value => comp.default_qa_contact.login
size => 64
emptyok => 1
%]
......@@ -85,11 +78,11 @@
<tr>
<td>[% terms.Bugs %]:</td>
<td>
[% IF bug_count > 0 %]
<a title="Bugs in component '[% name FILTER html %]'"
[% IF comp.bug_count > 0 %]
<a title="Bugs in component '[% comp.name FILTER html %]'"
href="buglist.cgi?component=
[%- name FILTER url_quote %]&amp;product=
[%- product FILTER url_quote %]">[% bug_count %]</a>
[%- comp.name FILTER url_quote %]&amp;product=
[%- prod.name FILTER url_quote %]">[% comp.bug_count %]</a>
[% ELSE %]
None
[% END %]
......@@ -98,26 +91,20 @@
</table>
<input type="hidden" name="componentold" value="
[%- name FILTER html %]">
<input type="hidden" name="descriptionold" value="
[%- description FILTER html %]">
<input type="hidden" name="initialownerold" value="
[%- initialowner FILTER html %]">
<input type="hidden" name="initialqacontactold" value="
[%- initialqacontact FILTER html %]">
<input type="hidden" name="action" value="update">
<input type="hidden" name="product" value="[% product FILTER html %]">
<input type="hidden" name="componentold" value="[% comp.name FILTER html %]">
<input type="hidden" name="product" value="[% prod.name FILTER html %]">
<input type="submit" value="Update"> or <a
href="editcomponents.cgi?action=del&amp;product=
[%- product FILTER url_quote %]&amp;component=
[%- name FILTER url_quote %]">Delete</a> this component.
[%- prod.name FILTER url_quote %]&amp;component=
[%- comp.name FILTER url_quote %]">Delete</a> this component.
</form>
[% PROCESS admin/components/footer.html.tmpl
no_edit_component_link = 1 %]
no_edit_component_link = 1
name = comp.name
product = prod.name
%]
[% PROCESS global/footer.html.tmpl %]
......@@ -20,16 +20,8 @@
#%]
[%# INTERFACE:
# components: array of hashes having the properties:
# - name: string; The name of the component.
# - description: string; The description of the component.
# - initialowner: string; The default assignee of the component.
# - initialqacontact: string; The qa_contact of the component.
# - bug_count: number; The number of bugs in the component
# (if showbugcounts defined).
#
# components: array of component objects
# showbugcounts: if defined, then bug counts should be included in the table
#
# product: string; the name of the product we are editing components for
#%]
......@@ -96,10 +88,31 @@
contentlink => delete_contentlink
}) %]
[%# Overrides the initialowner and the initialqacontact with right values %]
[% overrides.initialowner = [] %]
[% overrides.initialqacontact = [] %]
[% FOREACH component = components %]
[% overrides.initialowner.push({
match_value => component.name
match_field => 'name'
override_content => 1
content => component.default_assignee.login
})
%]
[% overrides.initialqacontact.push({
match_value => component.name
match_field => 'name'
override_content => 1
content => component.default_qa_contact.login
})
%]
[% END %]
[% PROCESS admin/table.html.tmpl
columns = columns
data = components
footer = footer_row
overrides = overrides
%]
<p><a href="editcomponents.cgi?action=add&amp;product=[% product FILTER url_quote %]">Add</a>
......
......@@ -574,7 +574,7 @@
'admin/components/confirm-delete.html.tmpl' => [
'bug_count'
'comp.bug_count'
],
'admin/components/deleted.html.tmpl' => [
......@@ -608,7 +608,7 @@
],
'admin/components/edit.html.tmpl' => [
'bug_count'
'comp.bug_count'
],
'admin/components/list.html.tmpl' => [
......
......@@ -288,16 +288,6 @@
[% title = "Component Requires Default Assignee" %]
You must enter a default assignee for component '[% name FILTER html %]'.
[% ELSIF error == "component_need_valid_initialowner" %]
[% title = "Component Requires A Valid Default Assignee" %]
You must use an existing [% terms.Bugzilla %] account as the default assignee for
component '[% name FILTER html %]'.
[% ELSIF error == "component_need_valid_initialqacontact" %]
[% title = "Component Requires A Valid Default QA Contact" %]
You must use an existing [% terms.Bugzilla %] account as default QA contact for
component '[% name FILTER html %]'.
[% ELSIF error == "product_not_specified" %]
[% title = "No Product Specified" %]
No product specified when trying to edit components, milestones or
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment