summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2014-08-06 08:47:15 +0200
committerByron Jones <glob@mozilla.com>2014-08-06 08:47:15 +0200
commitec10d05697c5e8b89d4a76374563bacaf4238d02 (patch)
tree63c1d6dbaa8f74f3be164e333327f8a46b71ce96
parentb9b47919cc8e335d11d3ea1faa2ddf9346cf3d49 (diff)
downloadbugzilla-ec10d05697c5e8b89d4a76374563bacaf4238d02.tar.gz
bugzilla-ec10d05697c5e8b89d4a76374563bacaf4238d02.tar.xz
Bug 1047131: enable "user story" field on all products
-rw-r--r--extensions/UserStory/Extension.pm35
-rw-r--r--extensions/UserStory/lib/Constants.pm57
-rw-r--r--extensions/UserStory/template/en/default/hook/bug/comments-comment_banner.html.tmpl2
-rw-r--r--extensions/UserStory/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl22
4 files changed, 39 insertions, 77 deletions
diff --git a/extensions/UserStory/Extension.pm b/extensions/UserStory/Extension.pm
index e70b86f5a..2053a0097 100644
--- a/extensions/UserStory/Extension.pm
+++ b/extensions/UserStory/Extension.pm
@@ -21,29 +21,28 @@ use Bugzilla::Extension::BMO::FakeBug;
use Text::Diff;
BEGIN {
- *Bugzilla::Bug::user_story_group = \&_bug_user_story_group;
- *Bugzilla::Extension::BMO::FakeBug::user_story_group = \&_bug_user_story_group;
+ *Bugzilla::Bug::user_story_visible = \&_bug_user_story_visible;
+ *Bugzilla::Extension::BMO::FakeBug::user_story_visible = \&_bug_user_story_visible;
}
-sub _bug_user_story_group {
+sub _bug_user_story_visible {
my ($self) = @_;
- if (!exists $self->{user_story_group}) {
+ if (!exists $self->{user_story_visible}) {
+ # Visible by default
+ $self->{user_story_visible} = 1;
my ($product, $component) = ($self->product, $self->component);
- my $edit_group = '';
- my $components = [];
- if (exists USER_STORY->{$product}) {
- $components = USER_STORY->{$product}->{components};
- if (!$component
- || scalar(@$components) == 0
- || grep { $_ eq $component } @$components)
+ my $exclude_components = [];
+ if (exists USER_STORY_EXCLUDE->{$product}) {
+ $exclude_components = USER_STORY_EXCLUDE->{$product};
+ if (scalar(@$exclude_components) == 0
+ || ($component && grep { $_ eq $component } @$exclude_components))
{
- $edit_group = USER_STORY->{$product}->{group};
+ $self->{user_story_visible} = 0;
}
}
- $self->{user_story_group} = $edit_group;
- $self->{user_story_components} = $components;
+ $self->{user_story_exclude_components} = $exclude_components;
}
- return ($self->{user_story_group}, $self->{user_story_components});
+ return ($self->{user_story_visible}, $self->{user_story_exclude_components});
}
# ensure user is allowed to edit the story
@@ -51,11 +50,7 @@ sub bug_check_can_change_field {
my ($self, $args) = @_;
my ($bug, $field, $priv_results) = @$args{qw(bug field priv_results)};
return unless $field eq 'cf_user_story';
-
- my $user = Bugzilla->user;
- my ($group) = $bug->user_story_group();
- $group || return;
- if (!$user->in_group($group)) {
+ if (!Bugzilla->user->in_group(USER_STORY_GROUP)) {
push (@$priv_results, PRIVILEGES_REQUIRED_EMPOWERED);
}
}
diff --git a/extensions/UserStory/lib/Constants.pm b/extensions/UserStory/lib/Constants.pm
index c59a9d5a6..d09b28fef 100644
--- a/extensions/UserStory/lib/Constants.pm
+++ b/extensions/UserStory/lib/Constants.pm
@@ -12,51 +12,18 @@ use warnings;
use base qw(Exporter);
-our @EXPORT = qw( USER_STORY );
+our @EXPORT = qw( USER_STORY_EXCLUDE USER_STORY_GROUP );
-use constant USER_STORY => {
- # note - an empty components array means all components
- Loop => {
- group => 'editbugs',
- components => [],
- },
- Tracking => {
- group => 'editbugs',
- components => [],
- },
- Firefox => {
- group => 'editbugs',
- components => [
- "Developer Tools",
- "Developer Tools: 3D View",
- "Developer Tools: Canvas Debugger",
- "Developer Tools: Console",
- "Developer Tools: Debugger",
- "Developer Tools: Framework",
- "Developer Tools: Graphic Commandline and Toolbar",
- "Developer Tools: Inspector",
- "Developer Tools: Memory",
- "Developer Tools: Netmonitor",
- "Developer Tools: Object Inspector",
- "Developer Tools: Profiler",
- "Developer Tools: Responsive Mode",
- "Developer Tools: Scratchpad",
- "Developer Tools: Source Editor",
- "Developer Tools: Style Editor",
- "Developer Tools: User Stories",
- "Developer Tools: Web Audio Editor",
- "Developer Tools: WebGL Shader Editor",
- "Developer Tools: WebIDE",
- ],
- },
- 'Firefox OS' => {
- group => 'editbugs',
- components => [],
- },
- 'support.mozilla.org' => {
- group => 'editbugs',
- components => [],
- }
-};
+# Group allowed to set/edit the user story field
+use constant USER_STORY_GROUP => 'editbugs';
+
+# Exclude showing the user story field for these products/components.
+# Examples:
+# Don't show User Story on any Firefox OS component:
+# 'Firefox OS' => [],
+# Don't show User Story on Developer Tools component, visible on all other
+# Firefox components
+# 'Firefox' => ['Developer Tools'],
+use constant USER_STORY_EXCLUDE => { };
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 dcb95524e..c7c202d62 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.user_story_group.0 %]
+[% RETURN UNLESS bug.user_story_visible.0 %]
[% can_edit_story = bug.check_can_change_field('cf_user_story', 0, 1) %]
<div class="user_story">
diff --git a/extensions/UserStory/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl b/extensions/UserStory/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl
index a0c904fe0..04c7f3c04 100644
--- a/extensions/UserStory/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl
+++ b/extensions/UserStory/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl
@@ -6,7 +6,7 @@
# defined by the Mozilla Public License, v. 2.0.
#%]
-[% RETURN UNLESS default.user_story_group.0 && default.check_can_change_field('cf_user_story', 0, 1) %]
+[% RETURN UNLESS default.user_story_visible.0 && default.check_can_change_field('cf_user_story', 0, 1) %]
</tbody>
<tbody id="cf_user_story_container" class="expert_fields bz_default_hidden">
@@ -33,15 +33,15 @@
%]
</div>
<script type="text/javascript">
- var user_story_components = [];
- [% FOREACH c = default.user_story_group.1 %]
- user_story_components.push('[% c FILTER js %]');
+ var user_story_exclude_components = [];
+ [% FOREACH c = default.user_story_visible.1 %]
+ user_story_exclude_components.push('[% c FILTER js %]');
[% END %]
function toggleUserStory() {
if (YAHOO.util.Dom.get('user_story').value != '') {
hideUserStoryEdit();
}
- if (user_story_components.length == 0) {
+ if (user_story_exclude_components.length == 0) {
YAHOO.util.Dom.removeClass('cf_user_story_container', 'bz_default_hidden');
YAHOO.util.Dom.get('user_story').disabled = false;
return;
@@ -55,15 +55,15 @@
index = 0;
}
if (index != -1) {
- for (var i = 0, l = user_story_components.length; i < l; i++) {
- if (user_story_components[i] == components[index]) {
- YAHOO.util.Dom.removeClass('cf_user_story_container', 'bz_default_hidden');
- YAHOO.util.Dom.get('user_story').disabled = false;
+ for (var i = 0, l = user_story_exclude_components.length; i < l; i++) {
+ if (user_story_exclude_components[i] == components[index]) {
+ YAHOO.util.Dom.addClass('cf_user_story_container', 'bz_default_hidden');
+ YAHOO.util.Dom.get('user_story').disabled = true;
return;
}
else {
- YAHOO.util.Dom.addClass('cf_user_story_container', 'bz_default_hidden');
- YAHOO.util.Dom.get('user_story').disabled = true;
+ YAHOO.util.Dom.removeClass('cf_user_story_container', 'bz_default_hidden');
+ YAHOO.util.Dom.get('user_story').disabled = false;
}
}
}