Merge "JS API: Expose logged in user"
This commit is contained in:
@@ -60,6 +60,11 @@ self.get(url, callback)
|
|||||||
a string, otherwise the result is a JavaScript object or array,
|
a string, otherwise the result is a JavaScript object or array,
|
||||||
as described in the relevant REST API documentation.
|
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]]
|
||||||
=== self.getPluginName()
|
=== self.getPluginName()
|
||||||
Returns the name this plugin was installed as by the server
|
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]]
|
||||||
=== Gerrit.getPluginName()
|
=== Gerrit.getPluginName()
|
||||||
Returns the name this plugin was installed as by the server
|
Returns the name this plugin was installed as by the server
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ package com.google.gerrit.client.api;
|
|||||||
|
|
||||||
import com.google.gerrit.client.ErrorDialog;
|
import com.google.gerrit.client.ErrorDialog;
|
||||||
import com.google.gerrit.client.Gerrit;
|
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.JavaScriptObject;
|
||||||
import com.google.gwt.core.client.JsArray;
|
import com.google.gwt.core.client.JsArray;
|
||||||
import com.google.gwt.user.client.History;
|
import com.google.gwt.user.client.History;
|
||||||
@@ -66,6 +67,7 @@ public class ApiGlue {
|
|||||||
refresh: @com.google.gerrit.client.api.ApiGlue::refresh(),
|
refresh: @com.google.gerrit.client.api.ApiGlue::refresh(),
|
||||||
refreshMenuBar: @com.google.gerrit.client.api.ApiGlue::refreshMenuBar(),
|
refreshMenuBar: @com.google.gerrit.client.api.ApiGlue::refreshMenuBar(),
|
||||||
showError: @com.google.gerrit.client.api.ApiGlue::showError(Ljava/lang/String;),
|
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)},
|
on: function (e,f){(this.events[e] || (this.events[e]=[])).push(f)},
|
||||||
onAction: function (t,n,c){this._onAction(this.getPluginName(),t,n,c)},
|
onAction: function (t,n,c){this._onAction(this.getPluginName(),t,n,c)},
|
||||||
@@ -194,6 +196,10 @@ public class ApiGlue {
|
|||||||
Gerrit.display(History.getToken());
|
Gerrit.display(History.getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final AccountInfo getCurrentUser() {
|
||||||
|
return Gerrit.getUserAccountInfo();
|
||||||
|
}
|
||||||
|
|
||||||
private static final void refreshMenuBar() {
|
private static final void refreshMenuBar() {
|
||||||
Gerrit.refreshMenuBar();
|
Gerrit.refreshMenuBar();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ final class Plugin extends JavaScriptObject {
|
|||||||
var G = $wnd.Gerrit;
|
var G = $wnd.Gerrit;
|
||||||
@com.google.gerrit.client.api.Plugin::TYPE.prototype = {
|
@com.google.gerrit.client.api.Plugin::TYPE.prototype = {
|
||||||
getPluginName: function(){return this.name},
|
getPluginName: function(){return this.name},
|
||||||
|
getCurrentUser: @com.google.gerrit.client.api.ApiGlue::getCurrentUser(),
|
||||||
go: @com.google.gerrit.client.api.ApiGlue::go(Ljava/lang/String;),
|
go: @com.google.gerrit.client.api.ApiGlue::go(Ljava/lang/String;),
|
||||||
refresh: @com.google.gerrit.client.api.ApiGlue::refresh(),
|
refresh: @com.google.gerrit.client.api.ApiGlue::refresh(),
|
||||||
refreshMenuBar: @com.google.gerrit.client.api.ApiGlue::refreshMenuBar(),
|
refreshMenuBar: @com.google.gerrit.client.api.ApiGlue::refreshMenuBar(),
|
||||||
|
|||||||
Reference in New Issue
Block a user