From 12e83e35b1ba306428507109fd17ccd75241ab50 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 3 Dec 2013 10:37:10 -0800 Subject: Bug 945501: create 'Firefox :: Developer Tools: User Stories' component and enable the User Story extension on this component --- extensions/UserStory/Extension.pm | 21 +++++++++++++++++---- extensions/UserStory/lib/Constants.pm | 15 +++++++++++---- .../hook/bug/comments-comment_banner.html.tmpl | 2 +- 3 files changed, 29 insertions(+), 9 deletions(-) (limited to 'extensions/UserStory') diff --git a/extensions/UserStory/Extension.pm b/extensions/UserStory/Extension.pm index 26f2c6bab..a60b86e0c 100644 --- a/extensions/UserStory/Extension.pm +++ b/extensions/UserStory/Extension.pm @@ -19,12 +19,25 @@ use Bugzilla::Extension::UserStory::Constants; use Text::Diff; BEGIN { - *Bugzilla::Product::user_story_group = \&_product_user_story_group; + *Bugzilla::Bug::user_story_group = \&_bug_user_story_group; } -sub _product_user_story_group { +sub _bug_user_story_group { my ($self) = @_; - return USER_STORY_PRODUCTS->{$self->name}; + if (!exists $self->{user_story_group}) { + my ($product, $component) = ($self->product, $self->component); + my $edit_group = ''; + if (exists USER_STORY->{$product}) { + my $components = USER_STORY->{$product}->{components}; + if (scalar(@$components) == 0 + || grep { $_ eq $component } @$components) + { + $edit_group = USER_STORY->{$product}->{group}; + } + } + $self->{user_story_group} = $edit_group; + } + return $self->{user_story_group}; } # ensure user is allowed to edit the story @@ -34,7 +47,7 @@ sub bug_check_can_change_field { return unless $field eq 'cf_user_story'; my $user = Bugzilla->user; - my $group = $bug->product_obj->user_story_group() + my $group = $bug->user_story_group() || return; if (!$user->in_group($group)) { push (@$priv_results, PRIVILEGES_REQUIRED_EMPOWERED); diff --git a/extensions/UserStory/lib/Constants.pm b/extensions/UserStory/lib/Constants.pm index dca38154c..972e7c53d 100644 --- a/extensions/UserStory/lib/Constants.pm +++ b/extensions/UserStory/lib/Constants.pm @@ -12,11 +12,18 @@ use warnings; use base qw(Exporter); -our @EXPORT = qw( USER_STORY_PRODUCTS ); +our @EXPORT = qw( USER_STORY ); -use constant USER_STORY_PRODUCTS => { - # product group required to edit - Tracking => 'editbugs', +use constant USER_STORY => { + # note - an empty components array means all components + Tracking => { + group => 'editbugs', + components => [], + }, + Firefox => { + group => 'editbugs', + components => [ 'Developer Tools: User Stories' ], + }, }; 1; diff --git a/extensions/UserStory/template/en/default/hook/bug/comments-comment_banner.html.tmpl b/extensions/UserStory/template/en/default/hook/bug/comments-comment_banner.html.tmpl index f58c2fb8b..0f5c0bcd6 100644 --- a/extensions/UserStory/template/en/default/hook/bug/comments-comment_banner.html.tmpl +++ b/extensions/UserStory/template/en/default/hook/bug/comments-comment_banner.html.tmpl @@ -6,7 +6,7 @@ # defined by the Mozilla Public License, v. 2.0. #%] -[% RETURN UNLESS bug.product_obj.user_story_group %] +[% RETURN UNLESS bug.user_story_group %] [% can_edit_story = bug.check_can_change_field('cf_user_story', 0, 1) %]
-- cgit v1.2.3-24-g4f1b