Open Bug 317051 Opened 19 years ago Updated 2 years ago

Implement default component for products

Categories

(Bugzilla :: Administration, task, P1)

Tracking

()

People

(Reporter: myk, Unassigned)

References

Details

Attachments

(1 file, 3 obsolete files)

Per bug 36843, Bugzilla admins can specify a default component on bug entry with a template change.  But it would be easier on them to be able to specify a default component per-product and to do so via the admin web interface rather than having to hack a template (and deal with conflicts when upgrading Bugzilla).

Bugzilla should let admins specify a default component for each product which applies when the user doesn't select a component on the bug entry page.
This seems more like an enhancement, to me, than a bug.
Severity: minor → enhancement
It's an enhancement that's blocking a major.
Priority: -- → P1
Attached patch patch - v1 (obsolete) — Splinter Review
Assignee: administration → koosha.khajeh
Status: NEW → ASSIGNED
Attachment #670774 - Flags: review?(glob)
Attachment #670774 - Flags: review?(LpSolit)
Target Milestone: --- → Bugzilla 5.0
Comment on attachment 670774 [details] [diff] [review]
patch - v1

You only need a default_component for products, as we do for the default milestone. It doesn't make sense to have a whole new column in the components table where it's hard to check the integrity.
Attachment #670774 - Flags: review?(glob)
Attachment #670774 - Flags: review?(LpSolit)
Attachment #670774 - Flags: review-
Attached patch patch (trunk) - v2 (obsolete) — Splinter Review
Attachment #670774 - Attachment is obsolete: true
Attachment #672567 - Flags: review?(LpSolit)
Version: 2.18.1 → 4.5
Version: 4.5 → unspecified
Comment on attachment 672567 [details] [diff] [review]
patch (trunk) - v2

>=== modified file 'Bugzilla/DB/Schema.pm'

>+            defaultcomponent  => {TYPE => 'INT2', DEFAULT => 'NULL',

No need to specify DEFAULT => NULL. That's the default behavior already. Drop this part.
Also, the column name should be default_component to follow our guidelines. I know you did it for consistency with defaultmilestone, but if we keep copying old styles, we will never improve our codebase. :)



>=== modified file 'Bugzilla/Install/DB.pm'

>+    $dbh->bz_add_column('products', 'defaultcomponent',
>+                        {TYPE => 'INT2', DEFAULT => 'NULL'});

Same comments as above.


>+    $dbh->bz_add_fk('products', 'defaultcomponent', 
>+                        {TABLE => 'components', COLUMN => 'id', DELETE => 'SET NULL'});

Don't call bz_add_fk() yourself. This is done automatically when the DB schema has been updated.



>=== modified file 'editproducts.cgi'

>         is_active   => scalar $cgi->param('is_active'),
>         allows_unconfirmed => scalar $cgi->param('allows_unconfirmed'),
>         default_milestone  => scalar $cgi->param('defaultmilestone'),
>+        default_component  => scalar $cgi->param('defaultcomponent'),

Use default_component for the CGI parameter here too. While you are on it, bonus point for renaming defaultmilestone to default_milestone (CGI only, not in the DB schema).


>=== modified file 'template/en/default/admin/products/edit.html.tmpl'

>+              <option value="[% c.name FILTER html %]"

I wonder if we shouldn't pass c.id, so that the validator can immediately check that this component exists without having to create a component object. But for WS methods, we may prefer to pass the component name instead. So I suppose c.name is fine here.



>=== modified file 'template/en/default/bug/create/create.html.tmpl'

You must also select the default component when moving the bug into another product, see bug/process/verify-new-product.html.tmpl.


Otherwise looks good.
Attachment #672567 - Flags: review?(LpSolit) → review-
Summary: let admin specify default component per-product → Implement default component for products
Attached patch patch - v2.1Splinter Review
Attachment #672567 - Attachment is obsolete: true
Attachment #682924 - Flags: review?(LpSolit)
Comment on attachment 682924 [details] [diff] [review]
patch - v2.1

>=== modified file 'Bugzilla/Bug.pm'

>-                component => $self->component,
>+                component => $default_component,

You must not go back to the default component if $component_ok is 1. See how this is done for the target milestone.



>=== modified file 'Bugzilla/DB/Schema.pm'

>+            default_component  => {TYPE => 'INT2', DEFAULT => 'NULL',

As said in my previous comment, remove DEFAULT => 'NULL'.



>=== modified file 'Bugzilla/Product.pm'

>+sub _check_default_component {

>+    # Return NULL if the default component is not set
>+    return undef unless ($component && ref $invocant);

This code means it's not possible to set the default component on product creation. As it's mandatory to create a component on product creation, it should be possible to use it immediately.



>=== modified file 'template/en/default/admin/products/edit.html.tmpl'

>+    [% IF product.components.size -%]

No need for this check. All products must have a component.


>+              [%- " selected=\"selected\"" IF c.id == product.default_component %]>

Write ' selected="selected"' instead of escaping quotes.


>=== modified file 'template/en/default/global/select-menu.html.tmpl'

Changes in this template are not needed and have nothing to do with this bug.


You must still fix bug/process/verify-new-product.html.tmpl as we now have a default component. The logic there must be changed to match what is done for the default milestone.
Attachment #682924 - Flags: review?(LpSolit) → review-
Assignee: koosha.khajeh → administration
Status: ASSIGNED → NEW
Target Milestone: Bugzilla 5.0 → ---
Attached file slot.html (obsolete) (deleted) —
The content of attachment 9302158 [details] has been deleted for the following reason:

Spam
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: