New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 2 users

Issue metadata

Status: Released
Last visit > 30 days ago
Closed: Oct 2017

Sign in to add a comment

Issue 5329: Support find-owners plugin

Reported by, Jan 24 2017 Project Member

Issue description

Please post links to the code, or list APIs used.

Comment 1 by, Jan 24 2017

Current find-owners plugin uses:

* post(REVISION_KIND, "find-owners").to(FindOwnersAction.class);
  in a RestApiModule.configure() function to add a post REST API.

* DynamicSet.bind(binder(), WebUiPlugin.class)
  .toInstance(new JavaScriptPlugin("find-owners.js"));
  in an AbstractModule.configure() function to add the JavaScript.

* FindOwersAction.getDescription() function to decide dynamically
  if the "Find Owners" button should be visible:
    return new Description()
        .setLabel("Find Owners")
        .setTitle("Find owners to add to Reviewers list")

* The find-owners.js script uses pretty common pattern:

Gerrit.install(function(self) {
  function onFindOwners(c) {
    // Other helper functions use Gerrit.{get,post,delete,refresh} to
    // get/update informations from the gerrit server.
    const changeId = c.change._number;
    const message = c.revision.commit.message;
    function showFindOwnersResults(result) {
      // Other functions to create elements like c.button,, etc.
    }{change: changeId}, showFindOwnersResults);
    // or
    // self.get('change/' + changeId, showFindOwnersResults);
  self.onAction('revision', 'find-owners', onFindOwners);

Comment 2 by, Jan 24 2017

Project Member
Status: Accepted (was: New)

Comment 3 by, May 4 2017

Project Member

Comment 4 by, May 4 2017

Project Member
Components: plugins>PluginInfrastructure

Comment 5 by, Jul 5 2017

Do we now have a PolyGerrit design to support plugin buttons like the "Find Owners"?

Comment 6 by, Jul 6 2017

Project Member
PolyGerrit plugin API is still WIP.
I'll update this bug once it's ready for testing/integration.

Comment 7 Deleted

Comment 8 Deleted

Comment 9 by, Aug 29 2017

The find-owners plugin has been simplified to depend on fewer Gerrit APIs.
Not all APIs mentioned in #1 are used now, but the following are still needed:

(1) Some way to add a "Find Owners" button to the PolyGerrit change page.
(2) Gerrit JavaScript APIs:

I found that self.{get,post} can be used instead of Gerrit.{get,post},
but self.delete is missing too.
Could you add those APIs in (2) first?

Comment 10 by, Sep 5 2017

Project Member
Delete API method added in

For Gerrit.refresh(), see
Full page refresh ( can be used meanwhile, but it's quite slow, so we're trying to provide faster options.

Comment 11 by, Sep 6 2017

Thanks for adding Plugin.delete.

I have already changed find-owners plugin to fall back to
self.delete if Gerrit.delete is missing,
and location.reload if Gerrit.refresh is missing.

My code looks like this:

      (!!Gerrit.delete) ? Gerrit.delete(url, callback) :
          ((!!self.delete) ? self.delete('/../..' + url, callback) :
              httpError('DELETE ' + url, callback));

      (!!Gerrit.refresh) ? Gerrit.refresh() : location.reload();

'location.reload()' works for me now, although it is very slow.

self.delete does not work for me as implemented now in Plugin.delete.
I call Gerrit.delete with url like: /changes/50/reviewers/1000002
or self.delete with url like: /../../changes/50/reviewers/1000002
to delete reviewer 1000002 from change number 50.

When Plugin.delete checked the response.status, it got 400 and
then called Promise.reject instead of my callback function.

Could Plugin.delete be implemented like Plugin.get and

  Plugin.prototype.delete = function(url, opt_callback) {
    return this._send('DELETE', url, opt_callback);

That will work for me to replace the Gerrit.delete.

Comment 12 by, Sep 6 2017

Project Member
> Could Plugin.delete be implemented like Plugin.get and

Yes, this is exactly how it's implemented ( I'm not sure it's deployed on yet, though.

Comment 13 by, Sep 6 2017

I pulled the change in 124870 to build locally and it did not work due to returned status 400. After that, I modified it in my local build to only
      return this._send('DELETE', url, opt_callback);
That worked.

Comment 14 by, Sep 6 2017

Project Member
Could you elaborate on this? I've re-tested self.delete method again and was able to use HTTP DELETE to remove a vote.

Isn't 400 an error code? Let's chat about this.

Comment 15 by, Sep 15 2017

Project Member

Comment 16 by, Sep 15 2017

Thank you. The only feature missing now is some way to add a "Find Owners" button to the PolyGerrit change page.

Comment 17 by, Oct 18 2017

What is preventing the button from being added to the PolyGerrit change page? This is blocking usage on Android, which is increasingly dependent on PolyGerrit (instead of the legacy UI).

Comment 18 by, Oct 19 2017

Project Member
Sorry for the delay. Unfortunately, as of now there is no direct replacement for the old API in question. Here are some hacks, if that's a priority - but clearly, this would need cleanup later if used.

Overall, there is no clear path at the moment for developing advanced plugins that target both GWT and PG. We're working to provide one, but it's WIP.

There is undocumented API that can be used right now, for PolyGerrit only.

Here's the sample code:
var buttonId = self.changeActions().add('change', 'Find Owners');
self.changeActions().addTapListener(buttonId, onFindOwners);

Downside is that there's no context available, and to get it another non-documented method should be used:

self.on('showchange', function(change, revision) {

Comment 19 by, Oct 25 2017

Project Member
Update: I've tested find-owners with, and looks like it's working.

Comment 20 by, Oct 27 2017

Project Member
Components: plugins>find-owners

Comment 21 by, Oct 27 2017

Project Member

Comment 22 by, Oct 27 2017

Thanks for the changes. We should see after next week's Android Gerrit server push the new "Find Onwers" item in the "MORE" pull down action list.

Comment 23 by, Nov 1 2017

Project Member
Status: Released (was: Submitted)

Comment 24 by, Nov 20

Labels: FixedIn-2.16

Sign in to add a comment