summaryrefslogtreecommitdiffstats
path: root/extensions/UserStory
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-12-03 19:37:10 +0100
committerByron Jones <bjones@mozilla.com>2013-12-03 19:37:10 +0100
commit12e83e35b1ba306428507109fd17ccd75241ab50 (patch)
tree8f1adaf3dbdae342d7b46ea3b3abb01d59385423 /extensions/UserStory
parent17ef78318ced6442cab20e3e5e1369f043eb5d9e (diff)
downloadbugzilla-12e83e35b1ba306428507109fd17ccd75241ab50.tar.gz
bugzilla-12e83e35b1ba306428507109fd17ccd75241ab50.tar.xz
Bug 945501: create 'Firefox :: Developer Tools: User Stories' component and enable the User Story extension on this component
Diffstat (limited to 'extensions/UserStory')
-rw-r--r--extensions/UserStory/Extension.pm21
-rw-r--r--extensions/UserStory/lib/Constants.pm15
-rw-r--r--extensions/UserStory/template/en/default/hook/bug/comments-comment_banner.html.tmpl2
3 files changed, 29 insertions, 9 deletions
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) %]
<div class="user_story">