Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
Upgrade bazlets to latest stable-2.15 to build with 2.15.10 API
Automatically format BUILD file with buildifier lint mode
Upgrade bazlets to latest stable-2.15 to build with 2.15.9 API
Upgrade bazlets to latest stable-2.15 to build with 2.15.8 API
Upgrade bazlets to latest stable-2.14 to build with 2.14.18 API
Bazel: Include eclipse-out directory in .bazelignore
Change-Id: If0abb6191308f0a007c9a60d1588cc95ce3ece67
diff --git a/WORKSPACE b/WORKSPACE
index 429adca..608cb95 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
load("//:bazlets.bzl", "load_bazlets")
load_bazlets(
- commit = "2b1d68959119920e5fa9bdfb9f0cf926bfef4929",
+ commit = "c15e64db2a87c0453427ff45f79d1ed3899b5d92",
#local_path = "/home/<user>/projects/bazlets",
)
diff --git a/src/main/java/com/googlesource/gerrit/plugins/emoticons/GetPreference.java b/src/main/java/com/googlesource/gerrit/plugins/emoticons/GetPreference.java
index edc2a12..4880e46 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/emoticons/GetPreference.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/emoticons/GetPreference.java
@@ -57,7 +57,7 @@
@Override
public ConfigInfo apply(AccountResource rsrc) throws AuthException, PermissionBackendException {
if (self.get() != rsrc.getUser()) {
- permissionBackend.user(self).check(ADMINISTRATE_SERVER);
+ permissionBackend.currentUser().check(ADMINISTRATE_SERVER);
}
ConfigInfo globalCfg = getConfig.get().apply(new ConfigResource());
@@ -66,7 +66,7 @@
info.showEmoticons =
db.getBoolean(
PREFERENCE,
- self.get().getUserName(),
+ self.get().getUserName().orElse(null),
KEY_SHOW_EMOTICONS,
(globalCfg.showEmoticons != null ? globalCfg.showEmoticons : true));
if (!info.showEmoticons) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/emoticons/HttpModule.java b/src/main/java/com/googlesource/gerrit/plugins/emoticons/HttpModule.java
index d6ab5be..3737710 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/emoticons/HttpModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/emoticons/HttpModule.java
@@ -25,5 +25,6 @@
protected void configureServlets() {
DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new GwtPlugin("emoticons"));
DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new JavaScriptPlugin("emoticons.js"));
+ DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new JavaScriptPlugin("emoticons.html"));
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/emoticons/PutPreference.java b/src/main/java/com/googlesource/gerrit/plugins/emoticons/PutPreference.java
index d3bcd91..f9e7416 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/emoticons/PutPreference.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/emoticons/PutPreference.java
@@ -25,11 +25,11 @@
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountResource;
-import com.google.gerrit.server.git.MetaDataUpdate;
-import com.google.gerrit.server.git.ProjectLevelConfig;
+import com.google.gerrit.server.git.meta.MetaDataUpdate;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.ProjectCache;
+import com.google.gerrit.server.project.ProjectLevelConfig;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.googlesource.gerrit.plugins.emoticons.PutConfig.Input;
@@ -63,13 +63,13 @@
throws AuthException, RepositoryNotFoundException, IOException, UnprocessableEntityException,
PermissionBackendException {
if (self.get() != rsrc.getUser()) {
- permissionBackend.user(self).check(ADMINISTRATE_SERVER);
+ permissionBackend.currentUser().check(ADMINISTRATE_SERVER);
}
if (input == null) {
input = new Input();
}
- String username = self.get().getUserName();
+ String username = self.get().getUserName().orElse(null);
ProjectLevelConfig storage = projectCache.getAllProjects().getConfig(pluginName + ".config");
Config db = storage.get();
diff --git a/src/main/resources/static/emoticons.html b/src/main/resources/static/emoticons.html
new file mode 100644
index 0000000..21bf3ab
--- /dev/null
+++ b/src/main/resources/static/emoticons.html
@@ -0,0 +1,17 @@
+// Copyright (C) 2018 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+<dom-module id="emoticons">
+ <script src="./emoticons.js"></script>
+</dom-module>
diff --git a/src/main/resources/static/emoticons.js b/src/main/resources/static/emoticons.js
index f761810..1a29d94 100644
--- a/src/main/resources/static/emoticons.js
+++ b/src/main/resources/static/emoticons.js
@@ -18,7 +18,7 @@
if (prefs !== null) {
insertEmoticons(e, prefs)
} else {
- Gerrit.get('/accounts/self/' + self.getPluginName()
+ self.get('/accounts/self/' + self.getPluginName()
+ '~preference', function(prefs) {
storePrefsInCookie(prefs);
insertEmoticons(e, prefs)
@@ -97,5 +97,5 @@
});
}
- Gerrit.on('comment', onComment);
+ self.on('comment', onComment);
});