diff options
author | Sebastin Santy <sebastinssanty@gmail.com> | 2017-06-15 19:07:02 +0200 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2017-06-15 19:07:02 +0200 |
commit | 9e71dcae1e1bf233f655ced691f5798cbe430f68 (patch) | |
tree | 52b00f03912ff6cf8fbaedf46f27117c05eeeb43 /extensions/BugModal | |
parent | 8bb543cad58777a76a1a12d60e26b6923b9089e9 (diff) | |
download | bugzilla-9e71dcae1e1bf233f655ced691f5798cbe430f68.tar.gz bugzilla-9e71dcae1e1bf233f655ced691f5798cbe430f68.tar.xz |
Bug 1373000 - New BugModal API for product data and component+product-specific data
Diffstat (limited to 'extensions/BugModal')
-rw-r--r-- | extensions/BugModal/lib/WebService.pm | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/extensions/BugModal/lib/WebService.pm b/extensions/BugModal/lib/WebService.pm index 338129e9b..33fec6bab 100644 --- a/extensions/BugModal/lib/WebService.pm +++ b/extensions/BugModal/lib/WebService.pm @@ -22,11 +22,31 @@ use Bugzilla::Milestone; use Bugzilla::Product; use Bugzilla::Version; use List::MoreUtils qw(any first_value); +use Taint::Util qw(untaint); # these methods are much lighter than our public API calls sub rest_resources { return [ + # return all the products accessible by the user. + # required by new-bug + qr{^/bug_modal/products}, { + GET => { + method => 'products' + }, + }, + + # return all the components pertaining to the product. + # required by new-bug + qr{^/bug_modal/components}, { + GET => { + method => 'components', + params => sub { + return { product_name => Bugzilla->input_params->{product} } + }, + }, + }, + # return all the lazy-loaded data; kept in sync with the UI's # requirements. qr{^/bug_modal/edit/(\d+)$}, { @@ -62,6 +82,24 @@ sub rest_resources { ] } +sub products { + my $user = Bugzilla->user; + return { products => _name($user->get_enterable_products) } +} + +sub components { + my ($self, $params) = @_; + if (!ref $params->{product_name}) { + untaint($params->{product_name}); + } + else { + ThrowCodeError('params_required',{ function => 'BugModal.components', params => ['product'] }); + } + my $product = Bugzilla::Product->check({ name => $params->{product_name}, cache => 1 }); + $product = Bugzilla->user->can_enter_product($product, 1); + return { components => _name($product->components) } +} + # everything we need for edit mode in a single call, returning just the fields # that the ui requires. sub edit { |