Make user preferences accessible by plugins

Add methods to the JavaScript API that allows plugins to get and
refresh the preferences of the currently signed in user.

Change-Id: Icabaf8188ccdd19b877856a23d292493cd50a215
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2015-07-22 15:01:59 +02:00
parent ebbad5ecab
commit 936d1ed8d1
8 changed files with 115 additions and 74 deletions

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.client.api;
import com.google.gerrit.client.ErrorDialog;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.info.AccountInfo;
import com.google.gerrit.client.info.AccountPreferencesInfo;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.user.client.History;
@@ -72,6 +73,8 @@ public class ApiGlue {
isSignedIn: @com.google.gerrit.client.api.ApiGlue::isSignedIn(),
showError: @com.google.gerrit.client.api.ApiGlue::showError(Ljava/lang/String;),
getCurrentUser: @com.google.gerrit.client.api.ApiGlue::getCurrentUser(),
getUserPreferences: @com.google.gerrit.client.api.ApiGlue::getUserPreferences(),
refreshUserPreferences: @com.google.gerrit.client.api.ApiGlue::refreshUserPreferences(),
on: function (e,f){(this.events[e] || (this.events[e]=[])).push(f)},
onAction: function (t,n,c){this._onAction(this.getPluginName(),t,n,c)},
@@ -255,6 +258,14 @@ public class ApiGlue {
return Gerrit.getUserAccountInfo();
}
private static final AccountPreferencesInfo getUserPreferences() {
return Gerrit.getUserPreferences();
}
private static final void refreshUserPreferences() {
Gerrit.refreshUserPreferences();
}
private static final void refreshMenuBar() {
Gerrit.refreshMenuBar();
}

View File

@@ -51,6 +51,8 @@ final class Plugin extends JavaScriptObject {
@com.google.gerrit.client.api.Plugin::TYPE.prototype = {
getPluginName: function(){return this.name},
getCurrentUser: @com.google.gerrit.client.api.ApiGlue::getCurrentUser(),
getUserPreferences: @com.google.gerrit.client.api.ApiGlue::getUserPreferences(),
refreshUserPreferences: @com.google.gerrit.client.api.ApiGlue::refreshUserPreferences(),
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(),