Merge "JS API: Expose logged in user"

This commit is contained in:
David Pursehouse
2014-10-01 09:40:16 +00:00
committed by Gerrit Code Review
3 changed files with 17 additions and 0 deletions

View File

@@ -60,6 +60,11 @@ self.get(url, callback)
a string, otherwise the result is a JavaScript object or array,
as described in the relevant REST API documentation.
[[self_getCurrentUser]]
=== self.getCurrentUser()
Returns the currently signed in user's AccountInfo data; empty account
data if no user is currently signed in.
[[self_getPluginName]]
=== self.getPluginName()
Returns the name this plugin was installed as by the server
@@ -625,6 +630,11 @@ Gerrit.get('/changes/?q=status:open', function (open) {
});
----
[[Gerrit_getCurrentUser]]
=== Gerrit.getCurrentUser()
Returns the currently signed in user's AccountInfo data; empty account
data if no user is currently signed in.
[[Gerrit_getPluginName]]
=== Gerrit.getPluginName()
Returns the name this plugin was installed as by the server

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.client.api;
import com.google.gerrit.client.ErrorDialog;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.account.AccountInfo;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.user.client.History;
@@ -66,6 +67,7 @@ public class ApiGlue {
refresh: @com.google.gerrit.client.api.ApiGlue::refresh(),
refreshMenuBar: @com.google.gerrit.client.api.ApiGlue::refreshMenuBar(),
showError: @com.google.gerrit.client.api.ApiGlue::showError(Ljava/lang/String;),
getCurrentUser: @com.google.gerrit.client.api.ApiGlue::getCurrentUser(),
on: function (e,f){(this.events[e] || (this.events[e]=[])).push(f)},
onAction: function (t,n,c){this._onAction(this.getPluginName(),t,n,c)},
@@ -194,6 +196,10 @@ public class ApiGlue {
Gerrit.display(History.getToken());
}
private static final AccountInfo getCurrentUser() {
return Gerrit.getUserAccountInfo();
}
private static final void refreshMenuBar() {
Gerrit.refreshMenuBar();
}

View File

@@ -50,6 +50,7 @@ final class Plugin extends JavaScriptObject {
var G = $wnd.Gerrit;
@com.google.gerrit.client.api.Plugin::TYPE.prototype = {
getPluginName: function(){return this.name},
getCurrentUser: @com.google.gerrit.client.api.ApiGlue::getCurrentUser(),
go: @com.google.gerrit.client.api.ApiGlue::go(Ljava/lang/String;),
refresh: @com.google.gerrit.client.api.ApiGlue::refresh(),
refreshMenuBar: @com.google.gerrit.client.api.ApiGlue::refreshMenuBar(),