Merge "SetLabelIT: Fix some of the assertions"
diff --git a/Documentation/pg-plugin-rest-api.txt b/Documentation/pg-plugin-rest-api.txt
index 70487ef..0d42bf6 100644
--- a/Documentation/pg-plugin-rest-api.txt
+++ b/Documentation/pg-plugin-rest-api.txt
@@ -25,6 +25,17 @@
.Returns
- Promise<string>
+== getConfig
+`repoApi.getConfig()`
+
+Get server config.
+
+.Params
+- None
+
+.Returns
+- Promise<Object>
+
== get
`repoApi.get(url)`
diff --git a/Documentation/rest-api-changes.txt b/Documentation/rest-api-changes.txt
index 10fb741..b6afad5 100644
--- a/Documentation/rest-api-changes.txt
+++ b/Documentation/rest-api-changes.txt
@@ -7018,20 +7018,20 @@
Name of the topic for the revert change. If not set, the default for Revert
endpoint is the topic of the change being reverted, and the default for the
RevertSubmission endpoint is `revert-{submission_id}-{timestamp.now}`.
-|===========================
+|=============================
[[revert-submission-info]]
=== RevertSubmissionInfo
The `RevertSubmissionInfo` describes the revert changes.
[options="header",cols="1,6"]
-|===========================
+|==============================
|Field Name | Description
|`revert_changes` |
-A list of #change-info[ChangeInfo] that describes the revert
-changes. Each entity in that list is a revert change that was created in that
-revert submission.
-|=============================
+A list of link:#change-info[ChangeInfo] that describes the revert changes. Each
+entity in that list is a revert change that was created in that revert
+submission.
+|==============================
[[review-info]]
=== ReviewInfo
diff --git a/Documentation/rest-api-projects.txt b/Documentation/rest-api-projects.txt
index 67f8592..c26d271 100644
--- a/Documentation/rest-api-projects.txt
+++ b/Documentation/rest-api-projects.txt
@@ -3485,6 +3485,25 @@
|`enabled` |optional|Whether the commentlink is enabled, as documented
in link:config-gerrit.html#commentlink.name.enabled[
commentlink.name.enabled]. If not set the commentlink is enabled.
+
+[[commentlink-input]]
+=== CommentLinkInput
+The `CommentLinkInput` entity describes the input for a
+link:config-gerrit.html#commentlink[commentlink].
+
+|==================================================
+[options="header",cols="1,^2,4"]
+|==================================================
+|Field Name | |Description
+|`match` | |A JavaScript regular expression to match
+positions to be replaced with a hyperlink, as documented in
+link:config-gerrit.html#commentlink.name.match[commentlink.name.match].
+|`link` | |The URL to direct the user to whenever the
+regular expression is matched, as documented in
+link:config-gerrit.html#commentlink.name.link[commentlink.name.link].
+|`enabled` |optional|Whether the commentlink is enabled, as documented
+in link:config-gerrit.html#commentlink.name.enabled[
+commentlink.name.enabled]. If not set the commentlink is enabled.
|==================================================
[[config-info]]
@@ -3635,6 +3654,11 @@
Whether empty commits should be rejected when a change is merged.
Can be `TRUE`, `FALSE` or `INHERIT`. +
If not set, this setting is not updated.
+|commentlinks |optional|
+Map of commentlink names to link:#commentlink-input[CommentLinkInput]
+entities to add or update on the project. If the given commentlink
+already exists, it will be updated with the given values, otherwise
+it will be created. If the value is null, that entry is deleted.
|======================================================
[[config-parameter-info]]
diff --git a/WORKSPACE b/WORKSPACE
index e623e42..f99a88b 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1049,8 +1049,8 @@
# and httpasyncclient as necessary.
maven_jar(
name = "elasticsearch-rest-client",
- artifact = "org.elasticsearch.client:elasticsearch-rest-client:7.4.0",
- sha1 = "481fedd31088ec6ba79a2aeffec3eccae4c0772b",
+ artifact = "org.elasticsearch.client:elasticsearch-rest-client:7.4.1",
+ sha1 = "b4e00ab47019103d69b6c9dcfdcbd3bfda00f86e",
)
maven_jar(
diff --git a/java/com/google/gerrit/extensions/api/projects/CommentLinkInput.java b/java/com/google/gerrit/extensions/api/projects/CommentLinkInput.java
new file mode 100644
index 0000000..3aad7e1
--- /dev/null
+++ b/java/com/google/gerrit/extensions/api/projects/CommentLinkInput.java
@@ -0,0 +1,27 @@
+// 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.
+
+package com.google.gerrit.extensions.api.projects;
+
+/*
+ * Input for a commentlink configuration on a project.
+ */
+public class CommentLinkInput {
+ /** A JavaScript regular expression to match positions to be replaced with a hyperlink. */
+ public String match;
+ /** The URL to direct the user to whenever the regular expression is matched. */
+ public String link;
+ /** Whether the commentlink is enabled. */
+ public Boolean enabled;
+}
diff --git a/java/com/google/gerrit/extensions/api/projects/ConfigInput.java b/java/com/google/gerrit/extensions/api/projects/ConfigInput.java
index 1a6d77b..8005fc5 100644
--- a/java/com/google/gerrit/extensions/api/projects/ConfigInput.java
+++ b/java/com/google/gerrit/extensions/api/projects/ConfigInput.java
@@ -38,4 +38,5 @@
public SubmitType submitType;
public ProjectState state;
public Map<String, Map<String, ConfigValue>> pluginConfigValues;
+ public Map<String, CommentLinkInput> commentLinks;
}
diff --git a/java/com/google/gerrit/server/account/AccountManager.java b/java/com/google/gerrit/server/account/AccountManager.java
index 6b5e456..8137b92 100644
--- a/java/com/google/gerrit/server/account/AccountManager.java
+++ b/java/com/google/gerrit/server/account/AccountManager.java
@@ -237,7 +237,6 @@
if (!Strings.isNullOrEmpty(who.getDisplayName())
&& !Objects.equals(user.getAccount().fullName(), who.getDisplayName())) {
- accountUpdates.add(u -> u.setFullName(who.getDisplayName()));
if (realm.allowsEdit(AccountFieldName.FULL_NAME)) {
accountUpdates.add(a -> a.setFullName(who.getDisplayName()));
} else {
diff --git a/java/com/google/gerrit/server/git/GroupCollector.java b/java/com/google/gerrit/server/git/GroupCollector.java
index 6d027c5..1f0dcd4 100644
--- a/java/com/google/gerrit/server/git/GroupCollector.java
+++ b/java/com/google/gerrit/server/git/GroupCollector.java
@@ -123,9 +123,10 @@
/**
* Returns a new {@link GroupCollector} instance.
*
- * <p>Used in production code by using {@link ChangeNotes.Factory} to get a group SHA1 (40 bytes
- * string representation) from a {@link PatchSet.Id}. Unit tests use this method directly by
- * passing their own lookup function.
+ * <p>Used in production code by using {@link com.google.gerrit.server.notedb.ChangeNotes.Factory}
+ * to get a group SHA1 (40 bytes string representation) from a {@link
+ * com.google.gerrit.entities.PatchSet.Id}. Unit tests use this method directly by passing their
+ * own lookup function.
*
* @see GroupCollector for what this class does.
*/
diff --git a/java/com/google/gerrit/server/project/ProjectConfig.java b/java/com/google/gerrit/server/project/ProjectConfig.java
index 9604f28..4d551a2 100644
--- a/java/com/google/gerrit/server/project/ProjectConfig.java
+++ b/java/com/google/gerrit/server/project/ProjectConfig.java
@@ -19,6 +19,7 @@
import static com.google.gerrit.common.data.Permission.isPermission;
import static com.google.gerrit.entities.Project.DEFAULT_SUBMIT_TYPE;
import static com.google.gerrit.server.permissions.PluginPermissionsUtil.isValidPluginPermission;
+import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
@@ -112,10 +113,10 @@
public static final String KEY_CAN_OVERRIDE = "canOverride";
public static final String KEY_BRANCH = "branch";
- private static final String KEY_MATCH = "match";
+ public static final String KEY_MATCH = "match";
private static final String KEY_HTML = "html";
- private static final String KEY_LINK = "link";
- private static final String KEY_ENABLED = "enabled";
+ public static final String KEY_LINK = "link";
+ public static final String KEY_ENABLED = "enabled";
public static final String PROJECT_CONFIG = "project.config";
@@ -291,6 +292,11 @@
commentLinkSections.put(commentLink.name, commentLink);
}
+ public void removeCommentLinkSection(String name) {
+ requireNonNull(name);
+ requireNonNull(commentLinkSections.remove(name));
+ }
+
private ProjectConfig(Project.NameKey projectName, @Nullable StoredConfig baseConfig) {
this.projectName = projectName;
this.baseConfig = baseConfig;
diff --git a/java/com/google/gerrit/server/restapi/change/RevertSubmission.java b/java/com/google/gerrit/server/restapi/change/RevertSubmission.java
index 2c3930a..105ffa2 100644
--- a/java/com/google/gerrit/server/restapi/change/RevertSubmission.java
+++ b/java/com/google/gerrit/server/restapi/change/RevertSubmission.java
@@ -152,12 +152,12 @@
"Failed to check if project state permits write: %s", rsrc.getProject());
}
return new UiAction.Description()
- .setLabel(
+ .setLabel("Revert submission")
+ .setTitle(
"Revert this change and all changes that have been submitted together with this change")
- .setTitle("Revert submission")
.setVisible(
and(
- projectStatePermitsWrite,
+ change.isMerged() && projectStatePermitsWrite,
permissionBackend
.user(rsrc.getUser())
.ref(change.getDest())
diff --git a/java/com/google/gerrit/server/restapi/project/PutConfig.java b/java/com/google/gerrit/server/restapi/project/PutConfig.java
index 696ac37..a0badd7 100644
--- a/java/com/google/gerrit/server/restapi/project/PutConfig.java
+++ b/java/com/google/gerrit/server/restapi/project/PutConfig.java
@@ -14,11 +14,17 @@
package com.google.gerrit.server.restapi.project;
+import static com.google.gerrit.server.project.ProjectConfig.COMMENTLINK;
+import static com.google.gerrit.server.project.ProjectConfig.KEY_ENABLED;
+import static com.google.gerrit.server.project.ProjectConfig.KEY_LINK;
+import static com.google.gerrit.server.project.ProjectConfig.KEY_MATCH;
+
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.entities.BooleanProjectConfig;
import com.google.gerrit.entities.Project;
+import com.google.gerrit.extensions.api.projects.CommentLinkInput;
import com.google.gerrit.extensions.api.projects.ConfigInfo;
import com.google.gerrit.extensions.api.projects.ConfigInput;
import com.google.gerrit.extensions.api.projects.ConfigValue;
@@ -59,6 +65,7 @@
import java.util.regex.Pattern;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
+import org.eclipse.jgit.lib.Config;
@Singleton
public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
@@ -154,6 +161,10 @@
setPluginConfigValues(projectState, projectConfig, input.pluginConfigValues);
}
+ if (input.commentLinks != null) {
+ updateCommentLinks(projectConfig, input.commentLinks);
+ }
+
md.setMessage("Modified project settings\n");
try {
projectConfig.commit(md);
@@ -278,6 +289,25 @@
}
}
+ private void updateCommentLinks(
+ ProjectConfig projectConfig, Map<String, CommentLinkInput> input) {
+ for (Map.Entry<String, CommentLinkInput> e : input.entrySet()) {
+ String name = e.getKey();
+ CommentLinkInput value = e.getValue();
+ if (value != null) {
+ // Add or update the commentlink section
+ Config cfg = new Config();
+ cfg.setString(COMMENTLINK, name, KEY_MATCH, value.match);
+ cfg.setString(COMMENTLINK, name, KEY_LINK, value.link);
+ cfg.setBoolean(COMMENTLINK, name, KEY_ENABLED, value.enabled == null || value.enabled);
+ projectConfig.addCommentLinkSection(ProjectConfig.buildCommentLink(cfg, name, false));
+ } else {
+ // Delete the commentlink section
+ projectConfig.removeCommentLinkSection(name);
+ }
+ }
+ }
+
private static void validateProjectConfigEntryIsEditable(
ProjectConfigEntry projectConfigEntry,
ProjectState projectState,
diff --git a/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java b/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java
index eebcc5b..1a8790a 100644
--- a/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java
@@ -49,6 +49,7 @@
import com.google.gerrit.extensions.annotations.Exports;
import com.google.gerrit.extensions.api.projects.BranchInput;
import com.google.gerrit.extensions.api.projects.CommentLinkInfo;
+import com.google.gerrit.extensions.api.projects.CommentLinkInput;
import com.google.gerrit.extensions.api.projects.ConfigInfo;
import com.google.gerrit.extensions.api.projects.ConfigInput;
import com.google.gerrit.extensions.api.projects.ConfigValue;
@@ -717,6 +718,139 @@
assertCommentLinks(getConfig(), expected);
}
+ @Test
+ public void projectConfigUsesLocallySetCommentlinks() throws Exception {
+ ConfigInput input = new ConfigInput();
+ addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK);
+ addCommentLink(input, JIRA, JIRA_MATCH, JIRA_LINK);
+ ConfigInfo info = setConfig(project, input);
+
+ Map<String, CommentLinkInfo> expected = new HashMap<>();
+ expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK));
+ expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
+ assertCommentLinks(info, expected);
+ assertCommentLinks(getConfig(), expected);
+ }
+
+ @Test
+ @GerritConfig(name = "commentlink.bugzilla.match", value = BUGZILLA_MATCH)
+ @GerritConfig(name = "commentlink.bugzilla.link", value = BUGZILLA_LINK)
+ public void projectConfigUsesCommentLinksFromGlobalAndLocal() throws Exception {
+ Map<String, CommentLinkInfo> expected = new HashMap<>();
+ expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK));
+ assertCommentLinks(getConfig(), expected);
+
+ ConfigInput input = new ConfigInput();
+ addCommentLink(input, JIRA, JIRA_MATCH, JIRA_LINK);
+ ConfigInfo info = setConfig(project, input);
+ expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
+
+ assertCommentLinks(info, expected);
+ assertCommentLinks(getConfig(), expected);
+ }
+
+ @Test
+ @GerritConfig(name = "commentlink.bugzilla.match", value = BUGZILLA_MATCH)
+ @GerritConfig(name = "commentlink.bugzilla.link", value = BUGZILLA_LINK)
+ public void localCommentLinkOverridesGlobalConfig() throws Exception {
+ String otherLink = "https://other.example.com";
+ ConfigInput input = new ConfigInput();
+ addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, otherLink);
+
+ Map<String, CommentLinkInfo> expected = new HashMap<>();
+ expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, otherLink));
+
+ ConfigInfo info = setConfig(project, input);
+ assertCommentLinks(info, expected);
+ assertCommentLinks(getConfig(), expected);
+ }
+
+ @Test
+ public void localCommentLinksAreInheritedFromParent() throws Exception {
+ ConfigInput input = new ConfigInput();
+ addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK);
+ addCommentLink(input, JIRA, JIRA_MATCH, JIRA_LINK);
+ ConfigInfo info = setConfig(project, input);
+
+ Map<String, CommentLinkInfo> expected = new HashMap<>();
+ expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK));
+ expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
+ assertCommentLinks(info, expected);
+
+ Project.NameKey child = projectOperations.newProject().parent(project).create();
+ assertCommentLinks(getConfig(child), expected);
+ }
+
+ @Test
+ public void localCommentLinkOverridesParentCommentLink() throws Exception {
+ ConfigInput input = new ConfigInput();
+ addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK);
+ addCommentLink(input, JIRA, JIRA_MATCH, JIRA_LINK);
+ ConfigInfo info = setConfig(project, input);
+
+ Map<String, CommentLinkInfo> expected = new HashMap<>();
+ expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK));
+ expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
+ assertCommentLinks(info, expected);
+
+ Project.NameKey child = projectOperations.newProject().parent(project).create();
+
+ String otherLink = "https://other.example.com";
+ input = new ConfigInput();
+ addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, otherLink);
+ info = setConfig(child, input);
+
+ expected = new HashMap<>();
+ expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, otherLink));
+ expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
+
+ assertCommentLinks(getConfig(child), expected);
+ }
+
+ @Test
+ public void updateExistingCommentLink() throws Exception {
+ ConfigInput input = new ConfigInput();
+ addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK);
+ addCommentLink(input, JIRA, JIRA_MATCH, JIRA_LINK);
+ ConfigInfo info = setConfig(project, input);
+
+ Map<String, CommentLinkInfo> expected = new HashMap<>();
+ expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK));
+ expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
+ assertCommentLinks(info, expected);
+
+ String otherLink = "https://other.example.com";
+ input = new ConfigInput();
+ addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, otherLink);
+ info = setConfig(project, input);
+
+ expected = new HashMap<>();
+ expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, otherLink));
+ expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
+ assertCommentLinks(getConfig(project), expected);
+ }
+
+ @Test
+ public void removeCommentLink() throws Exception {
+ ConfigInput input = new ConfigInput();
+ addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK);
+ addCommentLink(input, JIRA, JIRA_MATCH, JIRA_LINK);
+ ConfigInfo info = setConfig(project, input);
+
+ Map<String, CommentLinkInfo> expected = new HashMap<>();
+ expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK));
+ expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
+ assertCommentLinks(info, expected);
+
+ input = new ConfigInput();
+ addCommentLink(input, BUGZILLA, null);
+ info = setConfig(project, input);
+
+ expected = new HashMap<>();
+ expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
+ assertCommentLinks(getConfig(project), expected);
+ }
+
private CommentLinkInfo commentLinkInfo(String name, String match, String link) {
return new CommentLinkInfoImpl(name, match, link, null /*html*/, null /*enabled*/);
}
@@ -725,6 +859,21 @@
assertThat(actual.commentlinks).containsExactlyEntriesIn(expected);
}
+ private void addCommentLink(ConfigInput configInput, String name, String match, String link) {
+ CommentLinkInput commentLinkInput = new CommentLinkInput();
+ commentLinkInput.match = match;
+ commentLinkInput.link = link;
+ addCommentLink(configInput, name, commentLinkInput);
+ }
+
+ private void addCommentLink(
+ ConfigInput configInput, String name, CommentLinkInput commentLinkInput) {
+ if (configInput.commentLinks == null) {
+ configInput.commentLinks = new HashMap<>();
+ }
+ configInput.commentLinks.put(name, commentLinkInput);
+ }
+
private ConfigInfo setConfig(Project.NameKey name, ConfigInput input) throws Exception {
return gApi.projects().name(name.get()).config(input);
}
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java b/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java
index 6e3d666..eeb5d37 100644
--- a/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java
+++ b/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java
@@ -61,7 +61,7 @@
case V7_3:
return "blacktop/elasticsearch:7.3.2";
case V7_4:
- return "blacktop/elasticsearch:7.4.0";
+ return "blacktop/elasticsearch:7.4.1";
}
throw new IllegalStateException("No tests for version: " + version.name());
}
diff --git a/javatests/com/google/gerrit/server/git/GroupCollectorTest.java b/javatests/com/google/gerrit/server/git/GroupCollectorTest.java
index 2370ec8..63f83b0 100644
--- a/javatests/com/google/gerrit/server/git/GroupCollectorTest.java
+++ b/javatests/com/google/gerrit/server/git/GroupCollectorTest.java
@@ -305,12 +305,6 @@
return gc.getGroups();
}
- // Helper methods for constructing various map arguments, to avoid lots of
- // type specifications.
- private static ImmutableListMultimap.Builder<ObjectId, PatchSet.Id> patchSets() {
- return ImmutableListMultimap.builder();
- }
-
private static ImmutableListMultimap.Builder<PatchSet.Id, String> groups() {
return ImmutableListMultimap.builder();
}
diff --git a/modules/jgit b/modules/jgit
index d4404fb..078500e 160000
--- a/modules/jgit
+++ b/modules/jgit
@@ -1 +1 @@
-Subproject commit d4404fb438c4cb31725a98e876cef8e3218ebd7f
+Subproject commit 078500ef1c28bfd4a19cafe889f485d7861b7518
diff --git a/plugins/replication b/plugins/replication
index f1cf5e8..94a465e 160000
--- a/plugins/replication
+++ b/plugins/replication
@@ -1 +1 @@
-Subproject commit f1cf5e878f2934573c6667adee99ca45f76815a0
+Subproject commit 94a465e0989ff8124aca3dca8e200aeb870cc9dd
diff --git a/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.html b/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.html
index e5822c5..ac65360 100644
--- a/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.html
+++ b/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.html
@@ -34,7 +34,7 @@
<style include="shared-styles">
:host {
display: block;
- margin-bottom: 1em;
+ margin-bottom: var(--spacing-l);
}
fieldset {
border: 1px solid var(--border-color);
@@ -51,13 +51,13 @@
display: flex;
justify-content: space-between;
min-height: 3em;
- padding: 0 .7em;
+ padding: 0 var(--spacing-m);
}
#deletedContainer {
border-bottom: 0;
}
.sectionContent {
- padding: .7em;
+ padding: var(--spacing-m);
}
#editBtn,
.editing #editBtn.global,
@@ -83,7 +83,7 @@
}
.editing #deleteBtn,
#undoRemoveBtn {
- padding-right: .7em;
+ padding-right: var(--spacing-m);
}
</style>
<style include="gr-form-styles"></style>
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.html b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.html
index f70025d..c7187a9 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.html
+++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.html
@@ -56,7 +56,7 @@
padding: 5px 4px;
}
iron-icon {
- margin: 0 .2em;
+ margin: 0 var(--spacing-xs);
}
.breadcrumb {
align-items: center;
@@ -74,7 +74,7 @@
display: inline-block;
}
main.breadcrumbs:not(.table) {
- margin-top: 1em;
+ margin-top: var(--spacing-l);
}
</style>
<gr-page-nav class="navStyles">
diff --git a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.html b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.html
index 7b88f9e..2a95991 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.html
+++ b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.html
@@ -43,7 +43,7 @@
}
gr-autocomplete {
--gr-autocomplete: {
- padding: 0 .15em;
+ padding: 0 var(--spacing-xs);
}
}
.hide {
diff --git a/polygerrit-ui/app/elements/admin/gr-create-repo-dialog/gr-create-repo-dialog.html b/polygerrit-ui/app/elements/admin/gr-create-repo-dialog/gr-create-repo-dialog.html
index 5c48de1..6b701ca 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-repo-dialog/gr-create-repo-dialog.html
+++ b/polygerrit-ui/app/elements/admin/gr-create-repo-dialog/gr-create-repo-dialog.html
@@ -42,9 +42,8 @@
--gr-autocomplete: {
border: 1px solid var(--border-color);
border-radius: 2px;
- font-size: var(--font-size-normal);
height: 2em;
- padding: 0 .15em;
+ padding: 0 var(--spacing-xs);
width: 20em;
}
}
diff --git a/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members.html b/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members.html
index 033048f..86f66c4 100644
--- a/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members.html
+++ b/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members.html
@@ -43,7 +43,6 @@
gr-autocomplete {
width: 20em;
--gr-autocomplete: {
- font-size: var(--font-size-normal);
height: 2em;
width: 20em;
}
diff --git a/polygerrit-ui/app/elements/admin/gr-group/gr-group.html b/polygerrit-ui/app/elements/admin/gr-group/gr-group.html
index 9cfd63a..19879cb 100644
--- a/polygerrit-ui/app/elements/admin/gr-group/gr-group.html
+++ b/polygerrit-ui/app/elements/admin/gr-group/gr-group.html
@@ -35,7 +35,7 @@
content: ' *';
}
.inputUpdateBtn {
- margin-top: .3em;
+ margin-top: var(--spacing-s);
}
</style>
<style include="gr-form-styles"></style>
diff --git a/polygerrit-ui/app/elements/admin/gr-permission/gr-permission.html b/polygerrit-ui/app/elements/admin/gr-permission/gr-permission.html
index 2954ff4..931e2cd 100644
--- a/polygerrit-ui/app/elements/admin/gr-permission/gr-permission.html
+++ b/polygerrit-ui/app/elements/admin/gr-permission/gr-permission.html
@@ -32,13 +32,13 @@
<style include="shared-styles">
:host {
display: block;
- margin-bottom: .7em;
+ margin-bottom: var(--spacing-m);
}
.header {
align-items: baseline;
display: flex;
justify-content: space-between;
- margin: .3em .7em;
+ margin: var(--spacing-s) var(--spacing-m);
}
.rules {
background: var(--table-header-background-color);
@@ -49,7 +49,7 @@
border-bottom: 1px solid var(--border-color);
}
.title {
- margin-bottom: .3em;
+ margin-bottom: var(--spacing-s);
}
#addRule,
#removeBtn {
@@ -61,11 +61,11 @@
}
.editing #removeBtn {
display: block;
- margin-left: 1.5em;
+ margin-left: var(--spacing-xl);
}
.editing #addRule {
display: block;
- padding: .7em;
+ padding: var(--spacing-m);
}
#deletedContainer,
.deleted #mainContainer {
@@ -76,7 +76,7 @@
border: 1px solid var(--border-color);
display: flex;
justify-content: space-between;
- padding: .7em;
+ padding: var(--spacing-m);
}
#mainContainer {
display: block;
diff --git a/polygerrit-ui/app/elements/admin/gr-plugin-config-array-editor/gr-plugin-config-array-editor.html b/polygerrit-ui/app/elements/admin/gr-plugin-config-array-editor/gr-plugin-config-array-editor.html
index 3c51d82..30ea8a1 100644
--- a/polygerrit-ui/app/elements/admin/gr-plugin-config-array-editor/gr-plugin-config-array-editor.html
+++ b/polygerrit-ui/app/elements/admin/gr-plugin-config-array-editor/gr-plugin-config-array-editor.html
@@ -37,18 +37,18 @@
}
gr-button {
float: right;
- margin-left: .5em;
+ margin-left: var(--spacing-m);
width: 4.5em;
}
.row {
align-items: center;
display: flex;
justify-content: space-between;
- padding: .5em 0;
+ padding: var(--spacing-m) 0;
width: 100%;
}
.existingItems .row {
- padding: .5em;
+ padding: var(--spacing-m);
}
.existingItems .row:not(:first-of-type) {
border-top: 1px solid var(--border-color);
@@ -61,7 +61,7 @@
}
.placeholder {
color: var(--deemphasized-text-color);
- padding-top: .75em;
+ padding-top: var(--spacing-m);
}
</style>
<div class="wrapper gr-form-styles">
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.html b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.html
index 152dd5c..ea12908 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.html
+++ b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.html
@@ -49,20 +49,20 @@
align-items: center;
}
.weblink {
- margin-right: .2em;
+ margin-right: var(--spacing-xs);
}
.weblinks.show,
.referenceContainer {
display: block;
}
.rightsText {
- margin-right: .3rem;
+ margin-right: var(--spacing-s);
}
.editing gr-button,
.admin #editBtn {
display: inline-block;
- margin: 1em 0;
+ margin: var(--spacing-l) 0;
}
.editing #editInheritFromInput {
display: inline-block;
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-command/gr-repo-command.html b/polygerrit-ui/app/elements/admin/gr-repo-command/gr-repo-command.html
index 7c2ead3..29bc02d 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-command/gr-repo-command.html
+++ b/polygerrit-ui/app/elements/admin/gr-repo-command/gr-repo-command.html
@@ -23,7 +23,7 @@
<style include="shared-styles">
:host {
display: block;
- margin-bottom: 2em;
+ margin-bottom: var(--spacing-xxl);
}
</style>
<h3>[[title]]</h3>
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.html b/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.html
index 29f70dc..8af3a92 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.html
+++ b/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.html
@@ -25,7 +25,7 @@
<style include="shared-styles">
:host {
display: block;
- margin-bottom: 2em;
+ margin-bottom: var(--spacing-xxl);
}
.loading #dashboards,
#loadingContainer {
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.html b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.html
index cfdee05..2f244f8 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.html
+++ b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.html
@@ -65,15 +65,14 @@
display: none;
}
.revisionEdit gr-button {
- margin-left: .6em;
+ margin-left: var(--spacing-m);
}
.editBtn {
- margin-left: 1em;
+ margin-left: var(--spacing-l);
}
.canEdit .revisionEdit{
align-items: center;
display: flex;
- line-height: 1;
}
.deleteButton:not(.show) {
display: none;
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.html b/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.html
index e17409e..d2093e4 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.html
+++ b/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.html
@@ -35,14 +35,14 @@
<style include="gr-subpage-styles">
.inherited {
color: var(--deemphasized-text-color);
- margin-left: .5em;
+ margin-left: var(--spacing-m);
}
section.section:not(.ARRAY) .title {
align-items: center;
display: flex;
}
section.section.ARRAY .title {
- padding-top: .75em;
+ padding-top: var(--spacing-m);
}
</style>
<div class="gr-form-styles">
diff --git a/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor.html b/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor.html
index fa5749a..9ec8985 100644
--- a/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor.html
+++ b/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor.html
@@ -31,7 +31,7 @@
<style include="shared-styles">
:host {
border-bottom: 1px solid var(--border-color);
- padding: .7em;
+ padding: var(--spacing-m);
display: block;
}
#removeBtn {
@@ -45,7 +45,7 @@
display: flex;
}
#options > * {
- margin-right: .5em;
+ margin-right: var(--spacing-m);
}
#mainContainer {
align-items: baseline;
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html
index 6d638b4..29f97ce 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.html
@@ -76,7 +76,7 @@
display: inline-flex;
}
.status .comma {
- padding-right: .2rem;
+ padding-right: var(--spacing-xs);
}
/* Used to hide the leading separator comma for statuses. */
.status .comma:first-of-type {
@@ -85,7 +85,7 @@
.size gr-tooltip-content {
margin: -.4rem -.6rem;
max-width: 2.5rem;
- padding: .4rem .6rem;
+ padding: var(--spacing-m) var(--spacing-l);
}
a {
color: inherit;
@@ -107,7 +107,7 @@
}
.label.u-green:not(.u-monospace),
.label.u-red:not(.u-monospace) {
- font-size: 1.2rem;
+ font-size: var(--font-size-h3);
}
.u-gray-background {
background-color: var(--table-header-background-color);
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.html b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.html
index 8a16c47..3ac1d5f 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.html
@@ -36,7 +36,7 @@
}
.loading {
color: var(--deemphasized-text-color);
- padding: 1em var(--default-horizontal-margin);
+ padding: var(--spacing-l);
}
gr-change-list {
width: 100%;
@@ -68,7 +68,7 @@
@media only screen and (max-width: 50em) {
.loading,
.error {
- padding: 0 var(--default-horizontal-margin);
+ padding: 0 var(--spacing-l);
}
}
</style>
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.html b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.html
index 71ef6e4..325bee0 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.html
@@ -36,6 +36,18 @@
border-collapse: collapse;
width: 100%;
}
+ .section-count-label {
+ color: var(--deemphasized-text-color);
+ }
+ a.section-title:hover {
+ text-decoration: none;
+ }
+ a.section-title:hover .section-count-label {
+ text-decoration: none;
+ }
+ a.section-title:hover .section-name {
+ text-decoration: underline;
+ }
</style>
<table id="changeList">
<tr class="topHeader">
@@ -69,8 +81,9 @@
<td class="star" hidden$="[[!showStar]]" hidden></td>
<td class="cell"
colspan$="[[_computeColspan(changeTableColumns, labelNames)]]">
- <a href$="[[_sectionHref(changeSection.query)]]">
- [[changeSection.name]]
+ <a href$="[[_sectionHref(changeSection.query)]]" class="section-title">
+ <span class="section-name">[[changeSection.name]]</span>
+ <span class="section-count-label">[[changeSection.countLabel]]</span>
</a>
</td>
</tr>
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js
index bfd80e7..da0c98d 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.js
@@ -216,8 +216,19 @@
this.sections = changes ? [{results: changes}] : [];
},
+ _processQuery(query) {
+ let tokens = query.split(' ');
+ const invalidTokens = ['limit:', 'age:', '-age:'];
+ tokens = tokens.filter(token => {
+ return !invalidTokens.some(invalidToken => {
+ return token.startsWith(invalidToken);
+ });
+ });
+ return tokens.join(' ');
+ },
+
_sectionHref(query) {
- return Gerrit.Nav.getUrlForSearchQuery(query);
+ return Gerrit.Nav.getUrlForSearchQuery(this._processQuery(query));
},
/**
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html
index 4599f01..87b1665 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.html
@@ -433,6 +433,59 @@
});
});
+ suite('dashboard queries', () => {
+ let element;
+ let sandbox;
+
+ setup(() => {
+ sandbox = sinon.sandbox.create();
+ element = fixture('basic');
+ });
+
+ teardown(() => { sandbox.restore(); });
+
+ test('query without age and limit unchanged', () => {
+ const query = 'status:closed owner:me';
+ assert.deepEqual(element._processQuery(query), query);
+ });
+
+ test('query with age and limit', () => {
+ const query = 'status:closed age:1week limit:10 owner:me';
+ const expectedQuery = 'status:closed owner:me';
+ assert.deepEqual(element._processQuery(query), expectedQuery);
+ });
+
+ test('query with age', () => {
+ const query = 'status:closed age:1week owner:me';
+ const expectedQuery = 'status:closed owner:me';
+ assert.deepEqual(element._processQuery(query), expectedQuery);
+ });
+
+ test('query with limit', () => {
+ const query = 'status:closed limit:10 owner:me';
+ const expectedQuery = 'status:closed owner:me';
+ assert.deepEqual(element._processQuery(query), expectedQuery);
+ });
+
+ test('query with age as value and not key', () => {
+ const query = 'status:closed random:age';
+ const expectedQuery = 'status:closed random:age';
+ assert.deepEqual(element._processQuery(query), expectedQuery);
+ });
+
+ test('query with limit as value and not key', () => {
+ const query = 'status:closed random:limit';
+ const expectedQuery = 'status:closed random:limit';
+ assert.deepEqual(element._processQuery(query), expectedQuery);
+ });
+
+ test('query with -age key', () => {
+ const query = 'status:closed -age:1week';
+ const expectedQuery = 'status:closed';
+ assert.deepEqual(element._processQuery(query), expectedQuery);
+ });
+ });
+
suite('gr-change-list sections', () => {
let element;
let sandbox;
@@ -444,7 +497,7 @@
teardown(() => { sandbox.restore(); });
- test('keyboard shortcuts', () => {
+ test('keyboard shortcuts', done => {
element.selectedIndex = 0;
element.sections = [
{
@@ -507,6 +560,7 @@
MockInteractions.pressAndReleaseKeyOn(element, 82); // 'r'
assert.equal(change.reviewed, false,
'Should mark change as unreviewed');
+ done();
});
});
diff --git a/polygerrit-ui/app/elements/change-list/gr-create-change-help/gr-create-change-help.html b/polygerrit-ui/app/elements/change-list/gr-create-change-help/gr-create-change-help.html
index 0801e80..e88368d 100644
--- a/polygerrit-ui/app/elements/change-list/gr-create-change-help/gr-create-change-help.html
+++ b/polygerrit-ui/app/elements/change-list/gr-create-change-help/gr-create-change-help.html
@@ -30,7 +30,7 @@
#graphic,
#help {
display: inline-block;
- margin: .5em;
+ margin: var(--spacing-m);
}
#graphic #circle {
align-items: center;
@@ -51,14 +51,14 @@
text-align: center;
}
#help {
- padding-top: 1.35em;
+ padding-top: var(--spacing-xl);
vertical-align: top;
}
#help h1 {
- font-size: var(--font-size-large);
+ font-size: var(--font-size-h3);
}
#help p {
- margin-bottom: .6em;
+ margin-bottom: var(--spacing-m);
max-width: 35em;
}
@media only screen and (max-width: 50em) {
diff --git a/polygerrit-ui/app/elements/change-list/gr-create-commands-dialog/gr-create-commands-dialog.html b/polygerrit-ui/app/elements/change-list/gr-create-commands-dialog/gr-create-commands-dialog.html
index 4cef6f7..9e86058 100644
--- a/polygerrit-ui/app/elements/change-list/gr-create-commands-dialog/gr-create-commands-dialog.html
+++ b/polygerrit-ui/app/elements/change-list/gr-create-commands-dialog/gr-create-commands-dialog.html
@@ -25,10 +25,10 @@
<style include="shared-styles">
ol {
list-style: decimal;
- margin-left: 1em;
+ margin-left: var(--spacing-l);
}
p {
- margin-bottom: .75em;
+ margin-bottom: var(--spacing-m);
}
#commandsDialog {
max-width: 40em;
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.html b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.html
index 4990233..41475a0 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.html
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.html
@@ -39,7 +39,7 @@
}
.loading {
color: var(--deemphasized-text-color);
- padding: 1em var(--default-horizontal-margin);
+ padding: var(--spacing-l);
}
gr-change-list {
width: 100%;
@@ -53,7 +53,7 @@
border-bottom: 1px solid var(--border-color);
display: flex;
justify-content: space-between;
- padding: .25em var(--default-horizontal-margin);
+ padding: var(--spacing-xs) var(--spacing-l);
}
.banner gr-button {
--gr-button: {
@@ -68,7 +68,7 @@
}
@media only screen and (max-width: 50em) {
.loading {
- padding: 0 var(--default-horizontal-margin);
+ padding: 0 var(--spacing-l);
}
}
</style>
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
index 832400b..aab0cba 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
@@ -209,7 +209,8 @@
this._showNewUserHelp = lastResultSet.length == 0;
}
this._results = changes.map((results, i) => ({
- name: this._computeSectionName(res.sections[i].name, results),
+ name: res.sections[i].name,
+ countLabel: this._computeSectionCountLabel(results),
query: res.sections[i].query,
results,
isOutgoing: res.sections[i].isOutgoing,
@@ -219,15 +220,14 @@
});
},
- _computeSectionName(name, changes) {
+ _computeSectionCountLabel(changes) {
if (!changes || !changes.length || changes.length == 0) {
- return name;
+ return '';
}
const more = changes[changes.length - 1]._more_changes;
const numChanges = changes.length;
const andMore = more ? ' and more' : '';
- const changeLabel = `change${numChanges > 1 ? 's' : ''}`;
- return `${name} (${numChanges} ${changeLabel}${andMore})`;
+ return `(${numChanges}${andMore})`;
},
_computeUserHeaderClass(params) {
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.html b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.html
index 7918366..41d4192 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.html
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.html
@@ -149,28 +149,24 @@
assert.equal(element._computeTitle('not self'), 'Dashboard for not self');
});
- suite('_computeSectionName', () => {
- test('empty changes dont change name', () => {
- const name = 'Work in progress';
- assert.equal(name, element._computeSectionName(name, []));
+ suite('_computeSectionCountLabel', () => {
+ test('empty changes dont count label', () => {
+ assert.equal('', element._computeSectionCountLabel([]));
});
test('1 change', () => {
- const name = 'Work in progress';
- assert.equal(name + ' (1 change)',
- element._computeSectionName(name, ['1']));
+ assert.equal('(1)',
+ element._computeSectionCountLabel(['1']));
});
test('2 changes', () => {
- const name = 'Work in progress';
- assert.equal(name + ' (2 changes)',
- element._computeSectionName(name, ['1', '2']));
+ assert.equal('(2)',
+ element._computeSectionCountLabel(['1', '2']));
});
test('1 change and more', () => {
- const name = 'Work in progress';
- assert.equal(name + ' (1 change and more)',
- element._computeSectionName(name, [{_more_changes: true}]));
+ assert.equal('(1 and more)',
+ element._computeSectionCountLabel([{_more_changes: true}]));
});
});
@@ -305,7 +301,7 @@
return element._fetchDashboardChanges({sections}, false).then(() => {
assert.equal(element._results.length, 1);
- assert.equal(element._results[0].name, 'test2 (1 change)');
+ assert.equal(element._results[0].name, 'test2');
});
});
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html
index c0d15b2..46b79b1 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html
@@ -62,13 +62,13 @@
color: var(--deemphasized-text-color);
}
#confirmSubmitDialog .changeSubject {
- margin: 1em;
+ margin: var(--spacing-l);
text-align: center;
}
iron-icon {
color: inherit;
height: 1.2rem;
- margin-right: .2rem;
+ margin-right: var(--spacing-xs);
width: 1.2rem;
}
gr-button {
@@ -92,7 +92,7 @@
}
gr-button {
--gr-button: {
- padding: .5em;
+ padding: var(--spacing-m);
white-space: nowrap;
}
}
@@ -101,7 +101,7 @@
margin: 0;
}
#actionLoadingMessage {
- margin: .5em;
+ margin: var(--spacing-m);
text-align: center;
}
#moreMessage {
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
index 3b09270..8fa9f60 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
@@ -193,7 +193,6 @@
Polymer({
is: 'gr-change-actions',
- _legacyUndefinedCheck: true,
/**
* Fired when the change should be reloaded.
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata-it_test.html b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata-it_test.html
index 86f8aaf..e60909c 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata-it_test.html
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata-it_test.html
@@ -89,6 +89,7 @@
teardown(() => {
sandbox.restore();
+ Gerrit._testOnly_resetPlugins();
});
suite('by default', () => {
@@ -141,7 +142,7 @@
new URL('test/plugin.html?' + Math.random(),
window.location.href).toString());
sandbox.stub(Gerrit, '_arePluginsLoaded').returns(true);
- Gerrit._setPluginsPending([]);
+ Gerrit._loadPlugins([]);
element = createElement();
});
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.html b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.html
index 13977a6..1c0edfc 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.html
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.html
@@ -79,14 +79,14 @@
pointer-events: none;
}
.hashtagChip {
- margin-bottom: .5em;
+ margin-bottom: var(--spacing-m);
}
#externalStyle {
display: block;
}
.parentList.merge {
list-style-type: decimal;
- padding-left: 1em;
+ padding-left: var(--spacing-l);
}
.parentList gr-commit-info {
display: inline-block;
@@ -96,7 +96,7 @@
display: none;
}
.icon {
- margin: -.25em 0;
+ margin: -3px 0;
}
.icon.help,
.icon.notTrusted {
@@ -114,8 +114,8 @@
}
.separatedSection {
border-top: 1px solid var(--border-color);
- margin-top: .5em;
- padding: .5em 0;
+ margin-top: var(--spacing-m);
+ padding: var(--spacing-m) 0;
}
.hashtag gr-linked-chip,
.topic gr-linked-chip {
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js
index 9788975..6632b8e 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js
@@ -61,7 +61,6 @@
Polymer({
is: 'gr-change-metadata',
- _legacyUndefinedCheck: true,
/**
* Fired when the change topic is changed.
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html
index fe09869..caa38d9 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html
@@ -725,7 +725,7 @@
},
'0.1',
'http://some/plugins/url.html');
- Gerrit._setPluginsCount(0);
+ Gerrit._loadPlugins([]);
flush(() => {
assert.strictEqual(hookEl.plugin, plugin);
assert.strictEqual(hookEl.change, element.change);
diff --git a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.html b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.html
index 80fc1ae..1e0be09 100644
--- a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.html
+++ b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.html
@@ -57,11 +57,11 @@
}
.title {
min-width: 10em;
- padding: .75em .5em 0 var(--requirements-horizontal-padding);
+ padding: var(--spacing-m) var(--spacing-m) 0 var(--requirements-horizontal-padding);
vertical-align: top;
}
.value {
- padding: .6em .5em 0 0;
+ padding: var(--spacing-m) var(--spacing-m) 0 0;
vertical-align: middle;
}
.title,
@@ -76,8 +76,8 @@
}
.showHide .title {
border-top: 1px solid var(--border-color);
- padding-bottom: .5em;
- padding-top: .5em;
+ padding-bottom: var(--spacing-m);
+ padding-top: var(--spacing-m);
}
.showHide .value {
border-top: 1px solid var(--border-color);
diff --git a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.js b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.js
index 09efa8d..8ec00dd 100644
--- a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.js
+++ b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-change-requirements',
- _legacyUndefinedCheck: true,
properties: {
/** @type {?} */
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html
index 00d5b42..258e516 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html
@@ -63,25 +63,25 @@
}
.container.loading {
color: var(--deemphasized-text-color);
- padding: 1em var(--default-horizontal-margin);
+ padding: var(--spacing-l);
}
.header {
align-items: center;
background-color: var(--table-header-background-color);
border-bottom: 1px solid var(--border-color);
display: flex;
- padding: .55em var(--default-horizontal-margin);
+ padding: var(--spacing-m) var(--spacing-l);
z-index: 99; /* Less than gr-overlay's backdrop */
}
.header.editMode {
background-color: var(--edit-mode-background-color);
}
.header .download {
- margin-right: 1em;
+ margin-right: var(--spacing-l);
}
gr-change-status {
display: initial;
- margin: .1em .1em .1em .4em;
+ margin: var(--spacing-xxs) var(--spacing-xxs) var(--spacing-xxs) var(--spacing-s);
}
gr-change-status:first-child {
margin-left: 0;
@@ -90,17 +90,16 @@
align-items: center;
display: flex;
flex: 1;
- font-size: 1.2rem;
+ font-size: var(--font-size-h3);
}
.headerTitle .headerSubject {
font-weight: var(--font-weight-bold);
}
#replyBtn {
- margin-bottom: 1em;
+ margin-bottom: var(--spacing-l);
}
gr-change-star {
- font-size: var(--font-size-normal);
- margin-right: .25em;
+ margin-right: var(--spacing-xs);
}
gr-reply-dialog {
width: 60em;
@@ -116,7 +115,7 @@
.changeId {
color: var(--deemphasized-text-color);
font-family: var(--font-family);
- margin-top: 1em;
+ margin-top: var(--spacing-l);
}
.changeMetadata {
border-right: 1px solid var(--border-color);
@@ -125,8 +124,8 @@
}
.commitMessage {
font-family: var(--monospace-font-family);
- margin-right: 1em;
- margin-bottom: 1em;
+ margin-right: var(--spacing-l);
+ margin-bottom: var(--spacing-l);
max-width: var(--commit-message-max-width, 72ch);;
}
.commitMessage gr-linked-text {
@@ -136,7 +135,7 @@
min-width: 72ch;
}
.editCommitMessage {
- margin-top: 1em;
+ margin-top: var(--spacing-l);
--gr-button: {
padding: 5px 0px;
@@ -166,7 +165,7 @@
.relatedChanges {
flex: 1 1 auto;
overflow: hidden;
- padding: 1em 0;
+ padding: var(--spacing-l) 0;
}
.mobile {
display: none;
@@ -178,7 +177,7 @@
border: 0;
border-top: 1px solid var(--border-color);
height: 0;
- margin-bottom: 1em;
+ margin-bottom: var(--spacing-l);
}
#commitMessage.collapsed {
max-height: 36em;
@@ -187,7 +186,7 @@
#relatedChanges {
}
#relatedChanges.collapsed {
- margin-bottom: 1.1em;
+ margin-bottom: var(--spacing-l);
max-height: var(--relation-chain-max-height, 2em);
overflow: hidden;
}
@@ -195,8 +194,8 @@
display: flex;
flex-direction: column;
flex-shrink: 0;
- margin: 1em 0;
- padding: 0 1em;
+ margin: var(--spacing-l) 0;
+ padding: 0 var(--spacing-l);
}
.collapseToggleContainer {
display: flex;
@@ -212,7 +211,7 @@
display: block;
}
#relatedChangesToggle {
- margin-left: 1em;
+ margin-left: var(--spacing-l);
padding-top: var(--related-change-btn-top-padding, 0);
}
.showOnEdit {
@@ -255,8 +254,8 @@
}
}
#metadata {
- --metadata-horizontal-padding: 1em;
- padding-top: 1em;
+ --metadata-horizontal-padding: var(--spacing-l);
+ padding-top: var(--spacing-l);
width: 100%;
}
/* NOTE: If you update this breakpoint, also update the
@@ -267,7 +266,7 @@
}
#relatedChanges {
border-top: 1px solid var(--border-color);
- padding-top: 1em;
+ padding-top: var(--spacing-l);
}
#commitAndRelated {
flex-direction: column;
@@ -293,14 +292,14 @@
align-items: flex-start;
flex-direction: column;
flex: 1;
- padding: .5em var(--default-horizontal-margin);
+ padding: var(--spacing-m) var(--spacing-l);
}
gr-change-star {
vertical-align: middle;
}
.headerTitle {
flex-wrap: wrap;
- font-size: 1.1rem;
+ font-size: var(--font-size-h3);
}
.desktop {
display: none;
@@ -322,16 +321,12 @@
}
.commitContainer {
margin: 0;
- padding: 1em;
- }
- .relatedChanges,
- .changeMetadata {
- font-size: var(--font-size-normal);
+ padding: var(--spacing-l);
}
.changeMetadata {
border-bottom: 1px solid var(--border-color);
border-right: none;
- margin-top: .25em;
+ margin-top: var(--spacing-xs);
max-width: none;
}
#metadata,
@@ -340,7 +335,7 @@
}
.commitActions {
display: block;
- margin-top: 1em;
+ margin-top: var(--spacing-l);
width: 100%;
}
.commitMessage {
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
index 4ffcc9b..94f60b1 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
@@ -65,7 +65,6 @@
Polymer({
is: 'gr-change-view',
- _legacyUndefinedCheck: true,
/**
* Fired when the title of the page should change.
@@ -853,7 +852,8 @@
Gerrit.awaitPluginsLoaded()
.then(this._getLoggedIn.bind(this))
.then(loggedIn => {
- if (!loggedIn || this._change.status !== this.ChangeStatus.MERGED) {
+ if (!loggedIn || !this._change ||
+ this._change.status !== this.ChangeStatus.MERGED) {
// Do not display dialog if not logged-in or the change is not
// merged.
return;
@@ -1203,6 +1203,7 @@
},
_getProjectConfig() {
+ if (!this._change) return;
return this.$.restAPI.getProjectConfig(this._change.project).then(
config => {
this._projectConfig = config;
@@ -1317,6 +1318,7 @@
_getLatestCommitMessage() {
return this.$.restAPI.getChangeCommitInfo(this._changeNum,
this.computeLatestPatchNum(this._allPatchSets)).then(commitInfo => {
+ if (!commitInfo) return Promise.resolve();
this._latestCommitMessage =
this._prepareCommitMsgForLinkify(commitInfo.message);
});
@@ -1500,6 +1502,10 @@
},
_getMergeability() {
+ if (!this._change) {
+ this._mergeable = null;
+ return Promise.resolve();
+ }
// If the change is closed, it is not mergeable. Note: already merged
// changes are obviously not mergeable, but the mergeability API will not
// answer for abandoned changes.
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html
index f9c7798..f7d1a18 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html
@@ -81,7 +81,7 @@
});
element = fixture('basic');
sandbox.stub(element.$.actions, 'reload').returns(Promise.resolve());
- Gerrit._setPluginsCount(0);
+ Gerrit._loadPlugins([]);
});
teardown(done => {
diff --git a/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.html b/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.html
index f1d677e..a7e65a3 100644
--- a/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.html
+++ b/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.html
@@ -43,10 +43,10 @@
}
.container {
display: flex;
- margin: .5em 0;
+ margin: var(--spacing-m) 0;
}
.lineNum {
- margin-right: .5em;
+ margin-right: var(--spacing-m);
min-width: 10em;
text-align: right;
}
@@ -57,7 +57,7 @@
@media screen and (max-width: 50em) {
.container {
flex-direction: column;
- margin: 0 0 .5em .5em;
+ margin: 0 0 var(--spacing-m) var(--spacing-m);
}
.lineNum {
min-width: initial;
diff --git a/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.js b/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.js
index 660dfd9..cbc7e42 100644
--- a/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.js
+++ b/polygerrit-ui/app/elements/change/gr-comment-list/gr-comment-list.js
@@ -18,7 +18,6 @@
'use strict';
Polymer({
is: 'gr-comment-list',
- _legacyUndefinedCheck: true,
behaviors: [
Gerrit.BaseUrlBehavior,
diff --git a/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.js b/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.js
index 7e25180..e2fcdff 100644
--- a/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.js
+++ b/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-commit-info',
- _legacyUndefinedCheck: true,
properties: {
change: Object,
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.js b/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.js
index f83ea8f..524876e 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-confirm-abandon-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the confirm button is pressed.
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.js b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.js
index 195027a..a0da331 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-conflict-dialog/gr-confirm-cherrypick-conflict-dialog.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-confirm-cherrypick-conflict-dialog',
- _legacyUndefinedCheck: true,
behaviors: [
Gerrit.FireBehavior,
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.html b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.html
index 303a55c..82d0ae8 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.html
+++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.html
@@ -45,7 +45,6 @@
.main label,
.main input[type="text"] {
display: block;
- font: inherit;
width: 100%;
}
.main .message {
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.js b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.js
index 6159742..bf84003 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.js
@@ -21,7 +21,6 @@
Polymer({
is: 'gr-confirm-cherrypick-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the confirm button is pressed.
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.html b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.html
index 1db5b52..e0e25ad 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.html
+++ b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.html
@@ -48,7 +48,6 @@
.main label,
.main input[type="text"] {
display: block;
- font: inherit;
width: 100%;
}
.main .message {
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.js b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.js
index 3636c9e..23123c3 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.js
@@ -21,7 +21,6 @@
Polymer({
is: 'gr-confirm-move-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the confirm button is pressed.
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.html b/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.html
index 116b26f..184a595 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.html
+++ b/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.html
@@ -41,14 +41,13 @@
.parentRevisionContainer label,
.parentRevisionContainer input[type="text"] {
display: block;
- font: inherit;
width: 100%;
}
.parentRevisionContainer label {
- margin-bottom: .2em;
+ margin-bottom: var(--spacing-xs);
}
.rebaseOption {
- margin: .5em 0;
+ margin: var(--spacing-m) 0;
}
</style>
<gr-dialog
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.js b/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.js
index a2fef69..414182c 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-rebase-dialog/gr-confirm-rebase-dialog.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-confirm-rebase-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the confirm button is pressed.
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-revert-dialog/gr-confirm-revert-dialog.js b/polygerrit-ui/app/elements/change/gr-confirm-revert-dialog/gr-confirm-revert-dialog.js
index c064d14..662b64c 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-revert-dialog/gr-confirm-revert-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-revert-dialog/gr-confirm-revert-dialog.js
@@ -22,7 +22,6 @@
Polymer({
is: 'gr-confirm-revert-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the confirm button is pressed.
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.html b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.html
index 42ecacf..40d4d2d 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.html
+++ b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.html
@@ -29,7 +29,7 @@
min-width: 40em;
}
p {
- margin-bottom: 1em;
+ margin-bottom: var(--spacing-l);
}
@media screen and (max-width: 50em) {
#dialog {
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.js b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.js
index 6b4a886..e86e21c 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-confirm-submit-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the confirm button is pressed.
diff --git a/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.html b/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.html
index 8dc4a2a..e20bbd7 100644
--- a/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.html
+++ b/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.html
@@ -32,7 +32,7 @@
}
section {
display: flex;
- padding: .5em 1.5em;
+ padding: var(--spacing-m) var(--spacing-xl);
}
section:not(:first-of-type) {
border-top: 1px solid var(--border-color);
@@ -40,7 +40,7 @@
.flexContainer {
display: flex;
justify-content: space-between;
- padding-top: .75em;
+ padding-top: var(--spacing-m);
}
.footer {
justify-content: flex-end;
@@ -53,15 +53,15 @@
}
.patchFiles,
.archivesContainer {
- padding-bottom: .5em;
+ padding-bottom: var(--spacing-m);
}
.patchFiles {
- margin-right: 2em;
+ margin-right: var(--spacing-xxl);
}
.patchFiles a,
.archives a {
display: inline-block;
- margin-right: 1em;
+ margin-right: var(--spacing-l);
}
.patchFiles a:last-of-type,
.archives a:last-of-type {
diff --git a/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.js b/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.js
index 4fe902b..90cc60f 100644
--- a/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-download-dialog/gr-download-dialog.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-download-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the user presses the close button.
diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.html b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.html
index 08896ce..480e3a0 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.html
+++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.html
@@ -48,7 +48,7 @@
background-color: var(--table-header-background-color);
border-top: 1px solid var(--border-color);
display: flex;
- padding: 6px var(--default-horizontal-margin);
+ padding: 6px var(--spacing-l);
}
.patchInfo-left {
align-items: baseline;
@@ -144,7 +144,7 @@
margin-right: -5px;
}
.fileViewActionsLabel {
- margin-right: .2rem;
+ margin-right: var(--spacing-xs);
}
@media screen and (max-width: 50em) {
.patchInfo-header .desktop {
diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.js b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.js
index 870be8b..2126433 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.js
+++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.js
@@ -23,7 +23,6 @@
Polymer({
is: 'gr-file-list-header',
- _legacyUndefinedCheck: true,
/**
* @event expand-diffs
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html
index 7378acd..5708ff3 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html
@@ -49,7 +49,7 @@
border-top: 1px solid var(--border-color);
display: flex;
min-height: 2.25em;
- padding: .2em var(--default-horizontal-margin) .2em calc(var(--default-horizontal-margin) - .35rem);
+ padding: var(--spacing-xs) var(--spacing-l) var(--spacing-xs) calc(var(--spacing-l) - .35rem);
}
:host(.loading) .row {
opacity: .5;
@@ -116,16 +116,10 @@
cursor: pointer;
flex: 1;
text-decoration: none;
- white-space: nowrap;
}
.path:hover :first-child {
text-decoration: underline;
}
- .path,
- .path div {
- overflow: hidden;
- text-overflow: ellipsis;
- }
.oldPath {
color: var(--deemphasized-text-color);
}
@@ -138,8 +132,8 @@
min-width: 7.5em;
}
.comments {
- padding-left: 2em;
- min-width: 20em;
+ padding-left: var(--spacing-l);
+ min-width: 7.5em;
}
.row:not(.header-row) .stats,
.total-stats {
@@ -147,7 +141,7 @@
display: flex;
}
.sizeBars {
- margin-left: .5em;
+ margin-left: var(--spacing-m);
min-width: 7em;
text-align: center;
}
@@ -166,18 +160,18 @@
color: var(--vote-text-color-disliked);
text-align: left;
min-width: 4em;
- padding-left: 0.5em;
+ padding-left: var(--spacing-s);
}
.drafts {
color: #C62828;
font-weight: var(--font-weight-bold);
}
.show-hide {
- margin-left: .35em;
+ margin-left: var(--spacing-s);
width: 1.9em;
}
.fileListButton {
- margin: .5em;
+ margin: var(--spacing-m);
}
.totalChanges {
justify-content: flex-end;
@@ -209,7 +203,7 @@
display: none;
}
.reviewed {
- margin-left: 2em;
+ margin-left: var(--spacing-xxl);
width: 15em;
}
.reviewed label {
@@ -235,7 +229,7 @@
}
.reviewedLabel {
color: var(--deemphasized-text-color);
- margin-right: 1em;
+ margin-right: var(--spacing-l);
opacity: 0;
}
.reviewedLabel.isReviewed {
@@ -248,8 +242,8 @@
.markReviewed,
.pathLink {
display: inline-block;
- margin: -.2em 0;
- padding: .4em 0;
+ margin: -2px 0;
+ padding: var(--spacing-s) 0;
}
@media screen and (max-width: 50em) {
.desktop {
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js
index 6b84901..914b4eb 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js
@@ -63,7 +63,6 @@
Polymer({
is: 'gr-file-list',
- _legacyUndefinedCheck: true,
/**
* Fired when a draft refresh should get triggered
diff --git a/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.html b/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.html
index fbebcdb..a1cf752 100644
--- a/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.html
+++ b/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.html
@@ -29,44 +29,41 @@
display: block;
max-height: 80vh;
overflow-y: auto;
- padding: 4.5em 1em 1em 1em;
+ padding: 4.5em var(--spacing-l) var(--spacing-l) var(--spacing-l);
}
header {
background-color: var(--dialog-background-color);
border-bottom: 1px solid var(--border-color);
left: 0;
- padding: 1em;
+ padding: var(--spacing-l);
position: absolute;
right: 0;
top: 0;
}
#title {
display: inline-block;
- font-size: 1.2rem;
- margin-top: .2em;
- }
- h2 {
- font-size: 1rem;
+ font-size: var(--font-size-h3);
+ margin-top: var(--spacing-xs);
}
#filterInput {
display: inline-block;
float: right;
- margin: 0 1em;
- padding: .2em;
+ margin: 0 var(--spacing-l);
+ padding: var(--spacing-xs);
}
.closeButtonContainer {
float: right;
}
ul {
- margin-bottom: 1em;
+ margin-bottom: var(--spacing-l);
}
ul li {
border: 1px solid var(--border-color);
border-radius: .2em;
background: var(--chip-background-color);
display: inline-block;
- margin: 0 .2em .4em .2em;
- padding: .2em .4em;
+ margin: 0 var(--spacing-xs) var(--spacing-s) var(--spacing-xs);
+ padding: var(--spacing-xs) var(--spacing-s);
}
.loading.loaded {
display: none;
@@ -95,7 +92,7 @@
items="[[_computeGroups(_includedIn, _filterText)]]"
as="group">
<div>
- <h2>[[group.title]]:</h2>
+ <span>[[group.title]]:</span>
<ul>
<template is="dom-repeat" items="[[group.items]]">
<li>[[item]]</li>
diff --git a/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.js b/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.js
index 2b7dcb6..4b8ce22 100644
--- a/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-included-in-dialog/gr-included-in-dialog.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-included-in-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the user presses the close button.
diff --git a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.html b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.html
index 571ddf9..b0d2838 100644
--- a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.html
+++ b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.html
@@ -28,12 +28,12 @@
.labelContainer {
align-items: center;
display: flex;
- margin-bottom: .5em;
+ margin-bottom: var(--spacing-m);
}
.labelName {
display: inline-block;
flex: 0 0 auto;
- margin-right: .5em;
+ margin-right: var(--spacing-m);
min-width: 7em;
text-align: left;
width: 20%;
@@ -47,7 +47,7 @@
.selectedValueText {
color: var(--deemphasized-text-color);
font-style: italic;
- margin: 0 .5em 0 .5em;
+ margin: 0 var(--spacing-m);
}
.selectedValueText.hidden {
display: none;
@@ -60,7 +60,7 @@
--gr-button: {
background-color: var(--button-background-color, var(--table-header-background-color));
color: var(--primary-text-color);
- padding: .2em .85em;
+ padding: var(--spacing-xs) var(--spacing-m);
@apply --vote-chip-styles;
}
}
diff --git a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js
index a77b624..2ea63b0 100644
--- a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js
+++ b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-label-score-row',
- _legacyUndefinedCheck: true,
/**
* Fired when any label is changed.
diff --git a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.js b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.js
index 548798f..5b498c2 100644
--- a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.js
+++ b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.js
@@ -19,7 +19,7 @@
Polymer({
is: 'gr-label-scores',
- _legacyUndefinedCheck: true,
+
properties: {
_labels: {
type: Array,
diff --git a/polygerrit-ui/app/elements/change/gr-message/gr-message.html b/polygerrit-ui/app/elements/change/gr-message/gr-message.html
index ca4600b..3b0165e 100644
--- a/polygerrit-ui/app/elements/change/gr-message/gr-message.html
+++ b/polygerrit-ui/app/elements/change/gr-message/gr-message.html
@@ -43,11 +43,11 @@
cursor: auto;
}
:host > div {
- padding: 0 var(--default-horizontal-margin);
+ padding: 0 var(--spacing-l);
}
gr-avatar {
position: absolute;
- left: var(--default-horizontal-margin);
+ left: var(--spacing-l);
}
.collapsed .contentContainer {
align-items: baseline;
@@ -56,11 +56,11 @@
white-space: nowrap;
}
.contentContainer {
- margin-left: calc(var(--default-horizontal-margin) + 2.5em);
+ margin-left: calc(var(--spacing-l) + 2.5em);
padding: 10px 0;
}
.showAvatar.collapsed .contentContainer {
- margin-left: calc(var(--default-horizontal-margin) + 1.75em);
+ margin-left: calc(var(--spacing-l) + 1.75em);
}
.hideAvatar.collapsed .contentContainer,
.hideAvatar.expanded .contentContainer {
@@ -69,10 +69,10 @@
.showAvatar.collapsed .contentContainer,
.hideAvatar.collapsed .contentContainer,
.hideAvatar.expanded .contentContainer {
- padding: .75em 0;
+ padding: var(--spacing-m) 0;
}
.collapsed gr-avatar {
- top: .5em;
+ top: var(--spacing-m);
height: 1.75em;
width: 1.75em;
}
@@ -113,7 +113,7 @@
}
.collapsed .content {
flex: 1;
- margin-right: .25em;
+ margin-right: var(--spacing-xs);
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
@@ -124,15 +124,15 @@
.collapsed .author {
overflow: hidden;
color: var(--primary-text-color);
- margin-right: .4em;
+ margin-right: var(--spacing-s);
}
.expanded .author {
cursor: pointer;
- margin-bottom: .4em;
+ margin-bottom: var(--spacing-s);
}
.dateContainer {
position: absolute;
- right: var(--default-horizontal-margin);
+ right: var(--spacing-l);
top: 10px;
}
span.date {
@@ -145,15 +145,15 @@
cursor: pointer;
}
.replyContainer {
- padding: .5em 0 0 0;
+ padding: var(--spacing-m) 0 0 0;
}
.score {
border: 1px solid rgba(0,0,0,.12);
border-radius: 3px;
color: var(--primary-text-color);
display: inline-block;
- margin: -.1em 0;
- padding: 0 .1em;
+ margin: -1px 0;
+ padding: 0 var(--spacing-xxs);
}
.score.negative {
background-color: var(--vote-color-disliked);
diff --git a/polygerrit-ui/app/elements/change/gr-message/gr-message.js b/polygerrit-ui/app/elements/change/gr-message/gr-message.js
index d2dff92..26e0cd3 100644
--- a/polygerrit-ui/app/elements/change/gr-message/gr-message.js
+++ b/polygerrit-ui/app/elements/change/gr-message/gr-message.js
@@ -22,7 +22,6 @@
Polymer({
is: 'gr-message',
- _legacyUndefinedCheck: true,
/**
* Fired when this message's reply link is tapped.
diff --git a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.html b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.html
index 3a4f8a7..91d970e 100644
--- a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.html
+++ b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.html
@@ -38,10 +38,10 @@
display: flex;
justify-content: space-between;
min-height: 3.2em;
- padding: .5em var(--default-horizontal-margin);
+ padding: var(--spacing-m) var(--spacing-l);
}
#messageControlsContainer {
- padding: 0 var(--default-horizontal-margin);
+ padding: 0 var(--spacing-l);
}
.highlighted {
animation: 3s fadeOut;
@@ -58,7 +58,7 @@
justify-content: center;
}
#messageControlsContainer gr-button {
- padding: 0.4em 0;
+ padding: var(--spacing-s) 0;
}
.container {
align-items: center;
diff --git a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js
index 6e4ddc9..ba4a1a9 100644
--- a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js
+++ b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js
@@ -27,7 +27,6 @@
Polymer({
is: 'gr-messages-list',
- _legacyUndefinedCheck: true,
properties: {
changeNum: Number,
@@ -119,7 +118,7 @@
_computeItems(messages, reviewerUpdates) {
// Polymer 2: check for undefined
if ([messages, reviewerUpdates].some(arg => arg === undefined)) {
- return undefined;
+ return [];
}
messages = messages || [];
@@ -156,15 +155,19 @@
},
_expandedChanged(exp) {
- for (let i = 0; i < this._processedMessages.length; i++) {
- this._processedMessages[i].expanded = exp;
+ if (this._processedMessages) {
+ for (let i = 0; i < this._processedMessages.length; i++) {
+ this._processedMessages[i].expanded = exp;
+ }
}
// _visibleMessages is a subarray of _processedMessages
// _processedMessages contains all items from _visibleMessages
// At this point all _visibleMessages.expanded values are set,
// and notifyPath must be used to notify Polymer about changes.
- for (let i = 0; i < this._visibleMessages.length; i++) {
- this.notifyPath(`_visibleMessages.${i}.expanded`);
+ if (this._visibleMessages) {
+ for (let i = 0; i < this._visibleMessages.length; i++) {
+ this.notifyPath(`_visibleMessages.${i}.expanded`);
+ }
}
},
@@ -381,7 +384,7 @@
if (!labels[key] || !labels[key].values) { continue; }
const values = Object.keys(labels[key].values)
.map(v => parseInt(v, 10));
- values.sort();
+ values.sort((a, b) => a - b);
if (!values.length) { continue; }
extremes[key] = {min: values[0], max: values[values.length - 1]};
}
diff --git a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list_test.html b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list_test.html
index d6b887f..315403e 100644
--- a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list_test.html
+++ b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list_test.html
@@ -569,10 +569,17 @@
{'my-label': {min: -12, max: -12}});
element.labels = {
+ 'my-label': {values: {'-2': {}, '-1': {}, '0': {}, '+1': {}, '+2': {}}},
+ };
+ assert.equal(computeSpy.callCount, 6);
+ assert.deepEqual(computeSpy.lastCall.returnValue,
+ {'my-label': {min: -2, max: 2}});
+
+ element.labels = {
'my-label': {values: {'-12': {}}},
'other-label': {values: {'-1': {}, ' 0': {}, '+1': {}}},
};
- assert.equal(computeSpy.callCount, 6);
+ assert.equal(computeSpy.callCount, 7);
assert.deepEqual(computeSpy.lastCall.returnValue, {
'my-label': {min: -12, max: -12},
'other-label': {min: -1, max: 1},
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.html b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.html
index 5d3291d..696ffdf 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.html
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.html
@@ -30,7 +30,7 @@
display: block;
}
h3 {
- margin: .5em 0 0;
+ margin: var(--spacing-m) 0 0;
}
section {
margin-bottom: 1.4em; /* Same as line height for collapse purposes */
@@ -75,7 +75,7 @@
.status {
color: var(--deemphasized-text-color);
font-weight: var(--font-weight-bold);
- margin-left: .25em;
+ margin-left: var(--spacing-xs);
}
.notCurrent {
color: #e65100;
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js
index 97241ae..76c5980 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-related-changes-list',
- _legacyUndefinedCheck: true,
/**
* Fired when a new section is loaded so that the change view can determine
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.html b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.html
index 7b1dca3..c944bf4 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.html
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.html
@@ -60,7 +60,7 @@
section {
border-top: 1px solid var(--border-color);
flex-shrink: 0;
- padding: .5em 1.5em;
+ padding: var(--spacing-m) var(--spacing-xl);
width: 100%;
}
.actions {
@@ -73,7 +73,7 @@
z-index: 1;
}
.actions .right gr-button {
- margin-left: 1em;
+ margin-left: var(--spacing-l);
}
.peopleContainer,
.labelsContainer {
@@ -85,13 +85,13 @@
}
.peopleList {
display: flex;
- padding-top: .1em;
+ padding-top: var(--spacing-xxs);
}
.peopleListLabel {
color: var(--deemphasized-text-color);
- margin-top: .2em;
+ margin-top: var(--spacing-xs);
min-width: 7em;
- padding-right: .5em;
+ padding-right: var(--spacing-m);
}
gr-account-list {
display: flex;
@@ -100,11 +100,11 @@
min-height: 1.8em;
}
#reviewerConfirmationOverlay {
- padding: 1em;
+ padding: var(--spacing-l);
text-align: center;
}
.reviewerConfirmationButtons {
- margin-top: 1em;
+ margin-top: var(--spacing-l);
}
.groupName {
font-weight: var(--font-weight-bold);
@@ -127,14 +127,14 @@
}
.previewContainer gr-formatted-text {
background: var(--table-header-background-color);
- padding: 1em;
+ padding: var(--spacing-l);
}
.draftsContainer h3 {
- margin-top: .25em;
+ margin-top: var(--spacing-xs);
}
#checkingStatusLabel,
#notLatestLabel {
- margin-left: 1em;
+ margin-left: var(--spacing-l);
}
#checkingStatusLabel {
color: var(--deemphasized-text-color);
@@ -152,8 +152,8 @@
}
#pluginMessage {
color: var(--deemphasized-text-color);
- margin-left: 1em;
- margin-bottom: .5em;
+ margin-left: var(--spacing-l);
+ margin-bottom: var(--spacing-m);
}
#pluginMessage:empty {
display: none;
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js
index 1114160..a78e68f 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.js
@@ -54,7 +54,6 @@
Polymer({
is: 'gr-reply-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when a reply is successfully sent.
diff --git a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.html b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.html
index 4dbe55f..8dbdde1 100644
--- a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.html
+++ b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.html
@@ -36,18 +36,17 @@
position: relative;
}
.hiddenReviewers {
- margin-top: .3em;
+ margin-top: var(--spacing-s);
}
.inputContainer {
display: flex;
- margin-top: .25em;
+ margin-top: var(--spacing-xs);
}
.inputContainer input {
flex: 1;
- font: inherit;
}
gr-account-chip {
- margin-top: .3em;
+ margin-top: var(--spacing-s);
}
gr-button {
--gr-button: {
diff --git a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.js b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.js
index 42bcd09..86e76b4 100644
--- a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.js
+++ b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-reviewer-list',
- _legacyUndefinedCheck: true,
/**
* Fired when the "Add reviewer..." button is tapped.
diff --git a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.html b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.html
index 50782be..4c82d2a 100644
--- a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.html
+++ b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.html
@@ -26,11 +26,11 @@
#threads {
display: block;
min-height: 20rem;
- padding: 1rem;
+ padding: var(--spacing-l);
}
gr-comment-thread {
display: block;
- margin-bottom: .5rem;
+ margin-bottom: var(--spacing-m);
max-width: 80ch;
}
.header {
@@ -41,7 +41,7 @@
display: flex;
justify-content: left;
min-height: 3.2em;
- padding: .5em var(--default-horizontal-margin);
+ padding: var(--spacing-m) var(--spacing-l);
}
.toggleItem.draftToggle {
display: none;
@@ -52,7 +52,7 @@
.toggleItem {
align-items: center;
display: flex;
- margin-right: 1rem;
+ margin-right: var(--spacing-l);
}
.draftsOnly:not(.unresolvedOnly) gr-comment-thread[has-draft],
.unresolvedOnly:not(.draftsOnly) gr-comment-thread[unresolved],
diff --git a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.js b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.js
index 407ef0f..0cbec84 100644
--- a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.js
+++ b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.js
@@ -25,7 +25,6 @@
Polymer({
is: 'gr-thread-list',
- _legacyUndefinedCheck: true,
properties: {
/** @type {?} */
diff --git a/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.html b/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.html
index 72b93be..e3cee56 100644
--- a/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.html
+++ b/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.html
@@ -33,11 +33,11 @@
width: 100%;
}
ol {
- margin-left: 1em;
+ margin-left: var(--spacing-l);
list-style: decimal;
}
p {
- margin-bottom: .75em;
+ margin-bottom: var(--spacing-m);
}
</style>
<gr-dialog
diff --git a/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.js b/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.js
index 59eb805..092204a 100644
--- a/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-upload-help-dialog/gr-upload-help-dialog.js
@@ -29,7 +29,6 @@
Polymer({
is: 'gr-upload-help-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the user presses the close button.
diff --git a/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.html b/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.html
index dc18f8a..3c2096c 100644
--- a/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.html
+++ b/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.html
@@ -26,7 +26,7 @@
<template>
<style include="shared-styles">
gr-dropdown {
- padding: 0 .5em;
+ padding: 0 var(--spacing-m);
--gr-button: {
color: var(--header-text-color);
}
diff --git a/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.js b/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.js
index f8288c6..7cbe988 100644
--- a/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.js
+++ b/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.js
@@ -21,7 +21,6 @@
Polymer({
is: 'gr-account-dropdown',
- _legacyUndefinedCheck: true,
properties: {
account: Object,
diff --git a/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog.js b/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog.js
index 5679408..8d3b58e 100644
--- a/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog.js
+++ b/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-error-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the dismiss button is pressed.
diff --git a/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager.js b/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager.js
index 54cfe19..5865e3c 100644
--- a/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager.js
+++ b/polygerrit-ui/app/elements/core/gr-error-manager/gr-error-manager.js
@@ -27,7 +27,6 @@
Polymer({
is: 'gr-error-manager',
- _legacyUndefinedCheck: true,
behaviors: [
Gerrit.BaseUrlBehavior,
diff --git a/polygerrit-ui/app/elements/core/gr-key-binding-display/gr-key-binding-display.html b/polygerrit-ui/app/elements/core/gr-key-binding-display/gr-key-binding-display.html
index 276db72..08835fe 100644
--- a/polygerrit-ui/app/elements/core/gr-key-binding-display/gr-key-binding-display.html
+++ b/polygerrit-ui/app/elements/core/gr-key-binding-display/gr-key-binding-display.html
@@ -27,7 +27,7 @@
border-radius: 3px;
display: inline-block;
font-weight: var(--font-weight-bold);
- padding: .1em .5em;
+ padding: var(--spacing-xxs) var(--spacing-m);
text-align: center;
}
</style>
diff --git a/polygerrit-ui/app/elements/core/gr-key-binding-display/gr-key-binding-display.js b/polygerrit-ui/app/elements/core/gr-key-binding-display/gr-key-binding-display.js
index e8c6479..89d1091 100644
--- a/polygerrit-ui/app/elements/core/gr-key-binding-display/gr-key-binding-display.js
+++ b/polygerrit-ui/app/elements/core/gr-key-binding-display/gr-key-binding-display.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-key-binding-display',
- _legacyUndefinedCheck: true,
properties: {
/** @type {Array<string>} */
diff --git a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html
index fe758c6..5494f62 100644
--- a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html
+++ b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html
@@ -31,11 +31,11 @@
overflow-y: auto;
}
header{
- padding: 1em;
+ padding: var(--spacing-l);
}
main {
display: flex;
- padding: 0 2em 2em;
+ padding: 0 var(--spacing-xxl) var(--spacing-xxl);
}
header {
align-items: center;
@@ -44,18 +44,18 @@
justify-content: space-between;
}
table:last-of-type {
- margin-left: 3em;
+ margin-left: var(--spacing-xxl);
}
td {
- padding: .2em 0;
+ padding: var(--spacing-xs) 0;
}
td:first-child {
- padding-right: .5em;
+ padding-right: var(--spacing-m);
text-align: right;
}
.header {
font-weight: var(--font-weight-bold);
- padding-top: 1em;
+ padding-top: var(--spacing-l);
}
.modifier {
font-weight: normal;
diff --git a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.js b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.js
index 391ec92..4bc6e11 100644
--- a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.js
+++ b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.js
@@ -21,7 +21,6 @@
Polymer({
is: 'gr-keyboard-shortcuts-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the user presses the close button.
diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html
index 92c0fb8..13629f2 100644
--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html
@@ -63,7 +63,7 @@
}
ul {
list-style: none;
- padding-left: 1em;
+ padding-left: var(--spacing-l);
}
.links > li {
cursor: default;
@@ -87,16 +87,16 @@
justify-content: flex-end;
}
.rightItems gr-endpoint-decorator:not(:empty) {
- margin-left: 1em;
+ margin-left: var(--spacing-l);
}
gr-smart-search {
flex-grow: 1;
- margin-left: .5em;
+ margin-left: var(--spacing-m);
max-width: 500px;
}
gr-dropdown,
.browse {
- padding: .6em .5em;
+ padding: var(--spacing-m);
}
gr-dropdown {
--gr-dropdown-item: {
@@ -104,7 +104,7 @@
}
}
.settingsButton {
- margin-left: .5em;
+ margin-left: var(--spacing-m);
}
.browse {
color: var(--header-text-color);
@@ -129,13 +129,13 @@
.accountContainer {
align-items: center;
display: flex;
- margin: 0 -.5em 0 .5em;
+ margin: 0 calc(0 - var(--spacing-m)) 0 var(--spacing-m);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.loginButton, .registerButton {
- padding: .5em 1em;
+ padding: var(--spacing-m) var(--spacing-l);
}
.dropdown-trigger {
text-decoration: none;
@@ -161,7 +161,7 @@
}
@media screen and (max-width: 50em) {
.bigTitle {
- font-size: var(--font-size-large);
+ font-size: var(--font-size-h3);
font-weight: var(--font-weight-bold);
}
gr-smart-search,
@@ -174,10 +174,10 @@
display: inline-flex;
}
.accountContainer {
- margin-left: .5em !important;
+ margin-left: var(--spacing-m) !important;
}
gr-dropdown {
- padding: .5em 0 .5em .5em;
+ padding: var(--spacing-m) 0 var(--spacing-m) var(--spacing-m);
}
}
</style>
diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js
index 661cd21..773ad68 100644
--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js
@@ -71,7 +71,6 @@
Polymer({
is: 'gr-main-header',
- _legacyUndefinedCheck: true,
hostAttributes: {
role: 'banner',
diff --git a/polygerrit-ui/app/elements/core/gr-reporting/gr-reporting.js b/polygerrit-ui/app/elements/core/gr-reporting/gr-reporting.js
index 0dcd7b8..6306933 100644
--- a/polygerrit-ui/app/elements/core/gr-reporting/gr-reporting.js
+++ b/polygerrit-ui/app/elements/core/gr-reporting/gr-reporting.js
@@ -146,7 +146,6 @@
// eslint-disable-next-line prefer-const
let GrReporting = Polymer({
is: 'gr-reporting',
- _legacyUndefinedCheck: true,
properties: {
category: String,
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.js b/polygerrit-ui/app/elements/core/gr-router/gr-router.js
index b7a5238..70bda79 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.js
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.js
@@ -209,7 +209,6 @@
Polymer({
is: 'gr-router',
- _legacyUndefinedCheck: true,
properties: {
_app: {
diff --git a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.html b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.html
index d766f74..563d7b7 100644
--- a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.html
+++ b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.html
@@ -32,9 +32,8 @@
border: 1px solid var(--border-color);
border-radius: 2px;
flex: 1;
- font: inherit;
outline: none;
- padding: .25em;
+ padding: var(--spacing-xs);
}
</style>
<form>
diff --git a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.js b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.js
index 7f8ee3b..6c7b0fd 100644
--- a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.js
+++ b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.js
@@ -104,7 +104,6 @@
Polymer({
is: 'gr-search-bar',
- _legacyUndefinedCheck: true,
/**
* Fired when a search is committed
diff --git a/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.js b/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.js
index 017310d..94de00c 100644
--- a/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.js
+++ b/polygerrit-ui/app/elements/core/gr-smart-search/gr-smart-search.js
@@ -23,7 +23,6 @@
Polymer({
is: 'gr-smart-search',
- _legacyUndefinedCheck: true,
properties: {
searchQuery: String,
diff --git a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api-mock.js b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api-mock.js
index 7bf71f5..b7994e6 100644
--- a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api-mock.js
+++ b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api-mock.js
@@ -19,7 +19,6 @@
Polymer({
is: 'comment-api-mock',
- _legacyUndefinedCheck: true,
properties: {
_changeComments: Object,
diff --git a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.js b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.js
index b5ff9a3..c3319ba 100644
--- a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.js
+++ b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.js
@@ -259,9 +259,18 @@
*/
ChangeComments.prototype.getCommentsBySideForPath = function(path,
patchRange, opt_projectConfig) {
- const comments = this.comments[path] || [];
- const drafts = this.drafts[path] || [];
- const robotComments = this.robotComments[path] || [];
+ let comments = [];
+ let drafts = [];
+ let robotComments = [];
+ if (this.comments && this.comments[path]) {
+ comments = this.comments[path];
+ }
+ if (this.drafts && this.drafts[path]) {
+ drafts = this.drafts[path];
+ }
+ if (this.robotComments && this.robotComments[path]) {
+ robotComments = this.robotComments[path];
+ }
drafts.forEach(d => { d.__draft = true; });
@@ -482,7 +491,6 @@
Polymer({
is: 'gr-comment-api',
- _legacyUndefinedCheck: true,
properties: {
_changeComments: Object,
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.html b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.html
index 780301b..0a00a01 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.html
@@ -64,7 +64,6 @@
Polymer({
is: 'gr-diff-builder',
- _legacyUndefinedCheck: true,
/**
* Fired when the diff begins rendering.
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.js b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.js
index a18d2f4..d5b9655 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.js
@@ -37,7 +37,6 @@
Polymer({
is: 'gr-diff-cursor',
- _legacyUndefinedCheck: true,
properties: {
/**
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.js b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.js
index 1f6b372..5472489 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-diff-highlight',
- _legacyUndefinedCheck: true,
properties: {
/** @type {!Array<!Gerrit.HoveredRange>} */
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js
index d6aa8ee..539f7b9 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.js
@@ -76,7 +76,6 @@
*/
Polymer({
is: 'gr-diff-host',
- _legacyUndefinedCheck: true,
/**
* Fired when the user selects a line.
@@ -912,8 +911,12 @@
},
_isSyntaxHighlightingEnabled(preferenceChangeRecord, diff) {
- if (!preferenceChangeRecord || !diff) return false;
- if (!preferenceChangeRecord.base.syntax_highlighting) return false;
+ if (!preferenceChangeRecord ||
+ !preferenceChangeRecord.base ||
+ !preferenceChangeRecord.base.syntax_highlighting ||
+ !diff) {
+ return false;
+ }
return !this._anyLineTooLong(diff) &&
this.$.diff.getDiffLength(diff) <= SYNTAX_MAX_DIFF_LENGTH;
},
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector.js b/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector.js
index e2d6a28..88dd91a 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-diff-mode-selector',
- _legacyUndefinedCheck: true,
properties: {
mode: {
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.html b/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.html
index cc29d13..21f6282 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.html
@@ -27,7 +27,7 @@
<style include="shared-styles">
.diffHeader,
.diffActions {
- padding: 1em 1.5em;
+ padding: var(--spacing-l) var(--spacing-xl);
}
.diffHeader,
.diffActions {
@@ -43,7 +43,7 @@
justify-content: flex-end;
}
.diffPrefsOverlay gr-button {
- margin-left: 1em;
+ margin-left: var(--spacing-l);
}
div.edited:after {
color: var(--deemphasized-text-color);
@@ -51,7 +51,7 @@
}
#diffPreferences {
display: flex;
- padding: .35em 1.5em;
+ padding: var(--spacing-s) var(--spacing-xl);
}
</style>
<gr-overlay id="diffPrefsOverlay" with-backdrop>
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.js b/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.js
index f6f48b3..6ecd4d6 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-diff-preferences-dialog',
- _legacyUndefinedCheck: true,
properties: {
/** @type {?} */
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.js b/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.js
index d4b4e2b..87ae7f2 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-processor/gr-diff-processor.js
@@ -104,7 +104,6 @@
*/
Polymer({
is: 'gr-diff-processor',
- _legacyUndefinedCheck: true,
properties: {
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.js b/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.js
index 26104da..d710a85 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.js
@@ -32,7 +32,6 @@
Polymer({
is: 'gr-diff-selection',
- _legacyUndefinedCheck: true,
properties: {
diff: Object,
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
index b9eb518..06ee4dc 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
@@ -72,7 +72,7 @@
justify-content: space-between;
}
header {
- padding: .75em var(--default-horizontal-margin);
+ padding: var(--spacing-m) var(--spacing-l);
}
.patchRangeLeft {
align-items: center;
@@ -87,11 +87,11 @@
white-space: nowrap;
}
.navLink {
- padding: 0 .25em;
+ padding: 0 var(--spacing-xs);
}
.reviewed {
display: inline-block;
- margin: 0 .25em;
+ margin: 0 var(--spacing-xs);
vertical-align: .15em;
}
.jumpToFileContainer {
@@ -101,22 +101,22 @@
display: none;
}
gr-button {
- padding: .3em 0;
+ padding: var(--spacing-s) 0;
text-decoration: none;
}
.loading {
color: var(--deemphasized-text-color);
- font-size: 2rem;
+ font-size: var(--font-size-h1);
height: 100%;
- padding: 1em var(--default-horizontal-margin);
+ padding: var(--spacing-l);
text-align: center;
}
.subHeader {
flex-wrap: wrap;
- padding: 0 var(--default-horizontal-margin) .75em;
+ padding: 0 var(--spacing-l) var(--spacing-m);
}
.subHeader > div {
- margin-top: .25em;
+ margin-top: var(--spacing-xs);
}
.prefsButton {
text-align: right;
@@ -145,7 +145,7 @@
display: flex;
}
.diffModeSelector span {
- margin-right: .2rem;
+ margin-right: var(--spacing-xs);
}
.diffModeSelector.hide,
.separator.hide {
@@ -158,7 +158,7 @@
}
@media screen and (max-width: 50em) {
header {
- padding: .5em var(--default-horizontal-margin);
+ padding: var(--spacing-m) var(--spacing-l);
}
.dash {
display: none;
@@ -169,23 +169,23 @@
.fileNav {
align-items: flex-start;
display: flex;
- margin: 0 .25em;
+ margin: 0 var(--spacing-xs);
}
.fullFileName {
display: block;
font-style: italic;
min-width: 50%;
- padding: 0 .1em;
+ padding: 0 var(--spacing-xxs);
text-align: center;
width: 100%;
word-wrap: break-word;
}
.reviewed {
- vertical-align: -.1em;
+ vertical-align: -1px;
}
.mobileNavLink {
color: var(--primary-text-color);
- font-size: 1.5rem;
+ font-size: var(--font-size-h2);
font-weight: var(--font-weight-bold);
text-decoration: none;
}
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
index b2ba148..8158c96 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
@@ -35,7 +35,6 @@
Polymer({
is: 'gr-diff-view',
- _legacyUndefinedCheck: true,
/**
* Fired when the title of the page should change.
@@ -562,7 +561,7 @@
* @return {?Object}
*/
_getNavLinkPath(path, fileList, direction, opt_noUp) {
- if (!path || fileList.length === 0) { return null; }
+ if (!path || !fileList || fileList.length === 0) { return null; }
let idx = fileList.indexOf(path);
if (idx === -1) {
@@ -640,22 +639,24 @@
promises.push(this._getChangeDetail(this._changeNum).then(change => {
let commit;
let baseCommit;
- for (const commitSha in change.revisions) {
- if (!change.revisions.hasOwnProperty(commitSha)) continue;
- const revision = change.revisions[commitSha];
- const patchNum = revision._number.toString();
- if (patchNum === this._patchRange.patchNum) {
- commit = commitSha;
- const commitObj = revision.commit || {};
- const parents = commitObj.parents || [];
- if (this._patchRange.basePatchNum === PARENT && parents.length) {
- baseCommit = parents[parents.length - 1].commit;
+ if (change) {
+ for (const commitSha in change.revisions) {
+ if (!change.revisions.hasOwnProperty(commitSha)) continue;
+ const revision = change.revisions[commitSha];
+ const patchNum = revision._number.toString();
+ if (patchNum === this._patchRange.patchNum) {
+ commit = commitSha;
+ const commitObj = revision.commit || {};
+ const parents = commitObj.parents || [];
+ if (this._patchRange.basePatchNum === PARENT && parents.length) {
+ baseCommit = parents[parents.length - 1].commit;
+ }
+ } else if (patchNum === this._patchRange.basePatchNum) {
+ baseCommit = commitSha;
}
- } else if (patchNum === this._patchRange.basePatchNum) {
- baseCommit = commitSha;
}
+ this._commitRange = {commit, baseCommit};
}
- this._commitRange = {commit, baseCommit};
}));
promises.push(this._loadComments());
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html
index 7e8dd8a..c99b8ab 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.html
@@ -42,6 +42,11 @@
max-width: var(--content-width, 80ch);
white-space: normal;
}
+ :host {
+ font-family: var(--monospace-font-family, ''), 'Roboto Mono';
+ font-size: var(--font-size, 12px);
+ line-height: var(--line-height-mono, 16px);
+ }
.thread-group {
display: block;
@@ -54,7 +59,7 @@
@apply --diff-container-styles;
}
.diffContainer.hiddenscroll {
- margin-bottom: .8em;
+ margin-bottom: var(--spacing-m);
}
table {
border-collapse: collapse;
@@ -106,8 +111,6 @@
}
.lineNum,
.content {
- /* Set font size based the user's diff preference. */
- font-size: var(--font-size, var(--font-size-normal));
vertical-align: top;
white-space: pre;
}
@@ -119,7 +122,7 @@
user-select: none;
color: var(--deemphasized-text-color);
- padding: 0 .5em;
+ padding: 0 var(--spacing-m);
text-align: right;
}
.canComment .lineNum {
@@ -184,13 +187,14 @@
.contextControl {
background-color: var(--diff-context-control-background-color);
border: 1px solid var(--diff-context-control-border-color);
+ color: var(--diff-context-control-color);
}
.contextControl gr-button {
display: inline-block;
text-decoration: none;
--gr-button: {
color: var(--diff-context-control-color);
- padding: .2em;
+ padding: var(--spacing-xs);
}
}
.contextControl td:not(.lineNum) {
@@ -225,14 +229,12 @@
background-color: var(--table-header-background-color);
border-bottom: 1px solid var(--border-color);
color: var(--link-color);
- font-family: var(--monospace-font-family);
- font-size: var(--font-size, var(--font-size-normal));
- padding: 0.5em 0 0.5em 4em;
+ padding: var(--spacing-m) 0 var(--spacing-m) 48px;
}
#loadingError,
#sizeWarning {
display: none;
- margin: 1em auto;
+ margin: var(--spacing-l) auto;
max-width: 60em;
text-align: center;
}
@@ -240,7 +242,7 @@
color: var(--error-text-color);
}
#sizeWarning gr-button {
- margin: 1em;
+ margin: var(--spacing-l);
}
#loadingError.showError,
#sizeWarning.warn {
@@ -254,9 +256,7 @@
}
td.blame {
display: none;
- font-family: var(--font-family);
- font-size: var(--font-size, var(--font-size-normal));
- padding: 0 .5em;
+ padding: 0 var(--spacing-m);
white-space: pre;
}
:host(.showBlame) col.blame {
@@ -278,11 +278,6 @@
overflow: hidden;
width: 200px;
}
- /** Since the line limit position is determined by charachter size, blank
- lines also need to have the same font size as everything else */
- .full-width .blank {
- font-size: var(--font-size, var(--font-size-normal));
- }
/** Support the line length indicator **/
.full-width td.content,
.full-width td.blank {
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js
index 5b42eed..b55e127 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js
@@ -109,7 +109,6 @@
Polymer({
is: 'gr-diff',
- _legacyUndefinedCheck: true,
/**
* Fired when the user selects a line.
diff --git a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.html b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.html
index 114d840..ee1f536 100644
--- a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.html
+++ b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.html
@@ -34,7 +34,7 @@
}
.arrow {
color: var(--deemphasized-text-color);
- margin: 0 .5em;
+ margin: 0 var(--spacing-m);
}
gr-dropdown-list {
--trigger-style: {
diff --git a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.js b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.js
index f889bfc..cdc5f30 100644
--- a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.js
+++ b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.js
@@ -31,7 +31,6 @@
Polymer({
is: 'gr-patch-range-select',
- _legacyUndefinedCheck: true,
properties: {
availablePatches: Array,
diff --git a/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js b/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js
index 0769104..1e952a3 100644
--- a/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js
+++ b/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js
@@ -28,7 +28,6 @@
Polymer({
is: 'gr-ranged-comment-layer',
- _legacyUndefinedCheck: true,
/**
* Fired when the range in a range comment was malformed and had to be
diff --git a/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.js b/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.js
index 44bf6fb..b1b3e0f 100644
--- a/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.js
+++ b/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-selection-action-box',
- _legacyUndefinedCheck: true,
/**
* Fired when the comment creation action was taken (hotkey, click).
diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js
index b8d199f..0494b96 100644
--- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js
+++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js
@@ -131,7 +131,6 @@
Polymer({
is: 'gr-syntax-layer',
- _legacyUndefinedCheck: true,
properties: {
diff: {
diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-themes/gr-syntax-theme.html b/polygerrit-ui/app/elements/diff/gr-syntax-themes/gr-syntax-theme.html
index a122113..c9f8eb3 100644
--- a/polygerrit-ui/app/elements/diff/gr-syntax-themes/gr-syntax-theme.html
+++ b/polygerrit-ui/app/elements/diff/gr-syntax-themes/gr-syntax-theme.html
@@ -41,7 +41,6 @@
.gr-syntax-keyword,
.gr-syntax-name {
color: var(--syntax-keyword-color);
- line-height: 1;
}
.gr-syntax-number {
color: var(--syntax-number-color);
diff --git a/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search.js b/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search.js
index 995326f..f850b9d 100644
--- a/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search.js
+++ b/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-documentation-search',
- _legacyUndefinedCheck: true,
properties: {
/**
diff --git a/polygerrit-ui/app/elements/edit/gr-default-editor/gr-default-editor.js b/polygerrit-ui/app/elements/edit/gr-default-editor/gr-default-editor.js
index bae838e..ed96bb2 100644
--- a/polygerrit-ui/app/elements/edit/gr-default-editor/gr-default-editor.js
+++ b/polygerrit-ui/app/elements/edit/gr-default-editor/gr-default-editor.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-default-editor',
- _legacyUndefinedCheck: true,
/**
* Fired when the content of the editor changes.
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.html b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.html
index 47dc15e..0b977bc 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.html
+++ b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.html
@@ -43,7 +43,7 @@
display: none;
}
gr-button {
- margin-left: 1em;
+ margin-left: var(--spacing-l);
text-decoration: none;
}
gr-dialog {
@@ -59,18 +59,16 @@
--gr-autocomplete: {
border: 1px solid var(--border-color);
border-radius: 2px;
- font-size: var(--font-size-normal);
height: 2em;
- padding: 0 .15em;
+ padding: 0 var(--spacing-xs);
}
}
input {
border: 1px solid var(--border-color);
border-radius: 2px;
- font-size: var(--font-size-normal);
height: 2em;
- margin: .5em 0;
- padding: 0 .15em;
+ margin: var(--spacing-m) 0;
+ padding: 0 var(--spacing-xs);
width: 100%;
}
@media screen and (max-width: 50em) {
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js
index 35b78ca..ca678a5 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js
+++ b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.js
@@ -19,7 +19,7 @@
Polymer({
is: 'gr-edit-controls',
- _legacyUndefinedCheck: true,
+
properties: {
change: Object,
patchNum: String,
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.html b/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.html
index 1ab08a3..f6c7803 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.html
+++ b/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.html
@@ -32,7 +32,7 @@
justify-content: flex-end;
}
#actions {
- margin-right: 1em;
+ margin-right: var(--spacing-l);
}
gr-button,
gr-dropdown {
@@ -45,7 +45,6 @@
background-color: transparent;
border: none;
color: var(--link-color);
- font-size: inherit;
text-transform: uppercase;
}
}
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.js b/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.js
index 9c59a9a..250816b 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.js
+++ b/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-edit-file-controls',
- _legacyUndefinedCheck: true,
/**
* Fired when an action in the overflow menu is tapped.
diff --git a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.html b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.html
index 79a62a7..2237315 100644
--- a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.html
+++ b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.html
@@ -48,23 +48,23 @@
align-items: center;
display: flex;
justify-content: space-between;
- padding: .75em var(--default-horizontal-margin);
+ padding: var(--spacing-m) var(--spacing-l);
}
header gr-editable-label {
- font-size: var(--font-size-large);
+ font-size: var(--font-size-h3);
--label-style: {
text-overflow: initial;
white-space: initial;
word-break: break-all;
}
--input-style: {
- margin-top: 1em;
+ margin-top: var(--spacing-l);
}
}
.textareaWrapper {
border: 1px solid var(--border-color);
border-radius: 3px;
- margin: var(--default-horizontal-margin);
+ margin: var(--spacing-l);
}
.textareaWrapper .editButtons {
display: none;
@@ -72,7 +72,7 @@
.controlGroup {
align-items: center;
display: flex;
- font-size: var(--font-size-large);
+ font-size: var(--font-size-h3);
}
.rightControls {
justify-content: flex-end;
diff --git a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js
index 08dcf51..95cfaf6 100644
--- a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js
+++ b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js
@@ -26,7 +26,6 @@
Polymer({
is: 'gr-editor-view',
- _legacyUndefinedCheck: true,
/**
* Fired when the title of the page should change.
diff --git a/polygerrit-ui/app/elements/gr-app-element.html b/polygerrit-ui/app/elements/gr-app-element.html
index 193f861..0090130 100644
--- a/polygerrit-ui/app/elements/gr-app-element.html
+++ b/polygerrit-ui/app/elements/gr-app-element.html
@@ -69,7 +69,7 @@
}
gr-main-header {
background: var(--header-background, var(--header-background-color, #eee));
- padding: 0 var(--default-horizontal-margin);
+ padding: 0 var(--spacing-l);
border-bottom: var(--header-border-bottom);
border-image: var(--header-border-image);
border-right: 0;
@@ -81,12 +81,12 @@
border-top: var(--footer-border-top);
display: flex;
justify-content: space-between;
- padding: .5rem var(--default-horizontal-margin);
+ padding: var(--spacing-m) var(--spacing-l);
z-index: 100;
}
main {
flex: 1;
- padding-bottom: 2em;
+ padding-bottom: var(--spacing-xxl);
position: relative;
}
.errorView {
@@ -108,10 +108,10 @@
}
.errorText,
.errorMoreInfo {
- margin-top: .75em;
+ margin-top: var(--spacing-m);
}
.errorText {
- font-size: 1.2rem;
+ font-size: var(--font-size-h3);
}
.errorMoreInfo {
color: var(--deemphasized-text-color);
diff --git a/polygerrit-ui/app/elements/gr-app-element.js b/polygerrit-ui/app/elements/gr-app-element.js
index 385f8e5..fc2ec20 100644
--- a/polygerrit-ui/app/elements/gr-app-element.js
+++ b/polygerrit-ui/app/elements/gr-app-element.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-app-element',
- _legacyUndefinedCheck: true,
/**
* Fired when the URL location changes.
@@ -425,7 +424,8 @@
},
_computePluginScreenName({plugin, screen}) {
- return Gerrit._getPluginScreenName(plugin, screen);
+ if (!plugin || !screen) return '';
+ return `${plugin.getPluginName()}-screen-${screen}`;
},
_logWelcome() {
diff --git a/polygerrit-ui/app/elements/gr-app.html b/polygerrit-ui/app/elements/gr-app.html
index d23de3d..f49d8aa 100644
--- a/polygerrit-ui/app/elements/gr-app.html
+++ b/polygerrit-ui/app/elements/gr-app.html
@@ -27,7 +27,6 @@
<link rel="import" href="/bower_components/polymer/polymer.html">
<link rel="import" href="/bower_components/polymer-resin/standalone/polymer-resin.html">
<!-- TODO(taoalpha): Remove once all legacyUndefinedCheck removed. -->
-<link rel="import" href="/bower_components/polymer/lib/legacy/legacy-data-mixin.html">
<link rel="import" href="../behaviors/safe-types-behavior/safe-types-behavior.html">
<script>
security.polymer_resin.install({
diff --git a/polygerrit-ui/app/elements/plugins/gr-admin-api/gr-admin-api_test.html b/polygerrit-ui/app/elements/plugins/gr-admin-api/gr-admin-api_test.html
index 9cdcf76..2537a37 100644
--- a/polygerrit-ui/app/elements/plugins/gr-admin-api/gr-admin-api_test.html
+++ b/polygerrit-ui/app/elements/plugins/gr-admin-api/gr-admin-api_test.html
@@ -39,7 +39,7 @@
let plugin;
Gerrit.install(p => { plugin = p; }, '0.1',
'http://test.com/plugins/testplugin/static/test.js');
- sandbox.stub(Gerrit, '_arePluginsLoaded').returns(true);
+ Gerrit._loadPlugins([]);
adminApi = plugin.admin();
});
diff --git a/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.html b/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.html
index efd6104..0c4149c 100644
--- a/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.html
+++ b/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.html
@@ -32,7 +32,6 @@
<script>
Polymer({
is: 'some-element',
- _legacyUndefinedCheck: true,
properties: {
fooBar: {
type: Object,
diff --git a/polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks.js b/polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks.js
index e0fa61e..230be0e 100644
--- a/polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks.js
+++ b/polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks.js
@@ -54,7 +54,6 @@
GrDomHook.prototype._createPlaceholder = function(hookName) {
Polymer({
is: hookName,
- _legacyUndefinedCheck: true,
properties: {
plugin: Object,
content: Object,
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js
index f953b1d..c609e20 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.js
@@ -21,7 +21,6 @@
Polymer({
is: 'gr-endpoint-decorator',
- _legacyUndefinedCheck: true,
properties: {
name: String,
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html
index 994d666..b0ad585 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.html
@@ -67,7 +67,7 @@
replacementHook = plugin.registerCustomComponent(
'second', 'other-module', {replace: true});
// Mimic all plugins loaded.
- Gerrit._setPluginsPending([]);
+ Gerrit._loadPlugins([]);
flush(done);
});
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.js b/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.js
index feef57d..c7a2d9a 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.js
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-param/gr-endpoint-param.js
@@ -19,7 +19,7 @@
Polymer({
is: 'gr-endpoint-param',
- _legacyUndefinedCheck: true,
+
properties: {
name: String,
value: {
diff --git a/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper.js b/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper.js
index 414abad..9da9c86 100644
--- a/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper.js
+++ b/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper.js
@@ -34,16 +34,32 @@
};
/**
+ * Alias of onClick
+ * @see onClick
+ */
+ GrEventHelper.prototype.onTap = function(callback) {
+ return this._listen(this.element, callback);
+ };
+
+ /**
* Add a callback to element click or touch.
* The callback may return false to prevent event bubbling.
* @param {function(Event):boolean} callback
* @return {function()} Unsubscribe function.
*/
- GrEventHelper.prototype.onTap = function(callback) {
+ GrEventHelper.prototype.onClick = function(callback) {
return this._listen(this.element, callback);
};
/**
+ * Alias of captureClick
+ * @see captureClick
+ */
+ GrEventHelper.prototype.captureTap = function(callback) {
+ return this._listen(this.element.parentElement, callback, {capture: true});
+ };
+
+ /**
* Add a callback to element click or touch ahead of normal flow.
* Callback is installed on parent during capture phase.
* https://www.w3.org/TR/DOM-Level-3-Events/#event-flow
@@ -51,13 +67,13 @@
* @param {function(Event):boolean} callback
* @return {function()} Unsubscribe function.
*/
- GrEventHelper.prototype.captureTap = function(callback) {
+ GrEventHelper.prototype.captureClick = function(callback) {
return this._listen(this.element.parentElement, callback, {capture: true});
};
GrEventHelper.prototype._listen = function(container, callback, opt_options) {
const capture = opt_options && opt_options.capture;
- const event = opt_options && opt_options.event || 'tap';
+ const event = opt_options && opt_options.event || 'click';
const handler = e => {
if (e.path.indexOf(this.element) !== -1) {
let mayContinue = true;
diff --git a/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper_test.html b/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper_test.html
index 896238f..bd76bd4 100644
--- a/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper_test.html
+++ b/polygerrit-ui/app/elements/plugins/gr-event-helper/gr-event-helper_test.html
@@ -32,7 +32,6 @@
<script>
Polymer({
is: 'some-element',
- _legacyUndefinedCheck: true,
properties: {
fooBar: {
@@ -74,14 +73,23 @@
instance.onTap(() => {
done();
});
- element.fire('tap');
+ MockInteractions.tap(element);
});
test('onTap() cancel', () => {
const tapStub = sandbox.stub();
- element.parentElement.addEventListener('tap', tapStub);
+ Polymer.Gestures.addListener(element.parentElement, 'tap', tapStub);
instance.onTap(() => false);
- element.fire('tap');
+ MockInteractions.tap(element);
+ flushAsynchronousOperations();
+ assert.isFalse(tapStub.called);
+ });
+
+ test('onClick() cancel', () => {
+ const tapStub = sandbox.stub();
+ element.parentElement.addEventListener('click', tapStub);
+ instance.onTap(() => false);
+ MockInteractions.tap(element);
flushAsynchronousOperations();
assert.isFalse(tapStub.called);
});
@@ -90,14 +98,30 @@
instance.captureTap(() => {
done();
});
- element.fire('tap');
+ MockInteractions.tap(element);
+ });
+
+ test('captureClick()', done => {
+ instance.captureClick(() => {
+ done();
+ });
+ MockInteractions.tap(element);
});
test('captureTap() cancels tap()', () => {
const tapStub = sandbox.stub();
- element.addEventListener('tap', tapStub);
+ Polymer.Gestures.addListener(element.parentElement, 'tap', tapStub);
instance.captureTap(() => false);
- element.fire('tap');
+ MockInteractions.tap(element);
+ flushAsynchronousOperations();
+ assert.isFalse(tapStub.called);
+ });
+
+ test('captureClick() cancels click()', () => {
+ const tapStub = sandbox.stub();
+ element.addEventListener('click', tapStub);
+ instance.captureTap(() => false);
+ MockInteractions.tap(element);
flushAsynchronousOperations();
assert.isFalse(tapStub.called);
});
diff --git a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.js b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.js
index f865e77..e90ff30 100644
--- a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.js
+++ b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-external-style',
- _legacyUndefinedCheck: true,
properties: {
name: String,
diff --git a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.js b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.js
index a99f23c..21da106 100644
--- a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.js
+++ b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-plugin-host',
- _legacyUndefinedCheck: true,
properties: {
config: {
@@ -28,33 +27,29 @@
},
},
- behaviors: [
- Gerrit.BaseUrlBehavior,
- ],
-
_configChanged(config) {
const plugins = config.plugin;
- const htmlPlugins = (plugins.html_resource_paths || [])
- .map(p => this._urlFor(p))
- .filter(p => !Gerrit._isPluginPreloaded(p));
+ const htmlPlugins = (plugins.html_resource_paths || []);
const jsPlugins =
- this._handleMigrations(plugins.js_resource_paths || [], htmlPlugins)
- .map(p => this._urlFor(p))
- .filter(p => !Gerrit._isPluginPreloaded(p));
+ this._handleMigrations(plugins.js_resource_paths || [], htmlPlugins);
+
const shouldLoadTheme = config.default_theme &&
!Gerrit._isPluginPreloaded('preloaded:gerrit-theme');
- const defaultTheme =
- shouldLoadTheme ? this._urlFor(config.default_theme) : null;
+ const themeToLoad =
+ shouldLoadTheme ? [config.default_theme] : [];
+
+ // Theme should be loaded first if has one to have better UX
const pluginsPending =
- [].concat(jsPlugins, htmlPlugins, defaultTheme || []);
- Gerrit._setPluginsPending(pluginsPending);
- if (defaultTheme) {
- // Make theme first to be first to load.
- // Load sync to work around rare theme loading race condition.
- this._importHtmlPlugins([defaultTheme], true);
+ themeToLoad.concat(jsPlugins, htmlPlugins);
+
+ const pluginOpts = {};
+
+ if (shouldLoadTheme) {
+ // Theme needs to be loaded synchronous.
+ pluginOpts[config.default_theme] = {sync: true};
}
- this._loadJsPlugins(jsPlugins);
- this._importHtmlPlugins(htmlPlugins);
+
+ Gerrit._loadPlugins(pluginsPending, pluginOpts);
},
/**
@@ -67,53 +62,5 @@
return !htmlPlugins.includes(counterpart);
});
},
-
- /**
- * @suppress {checkTypes}
- * States that it expects no more than 3 parameters, but that's not true.
- * @todo (beckysiegel) check Polymer annotations and submit change.
- * @param {Array} plugins
- * @param {boolean=} opt_sync
- */
- _importHtmlPlugins(plugins, opt_sync) {
- const async = !opt_sync;
- for (const url of plugins) {
- // onload (second param) needs to be a function. When null or undefined
- // were passed, plugins were not loaded correctly.
- (this.importHref || Polymer.importHref)(
- this._urlFor(url), () => {},
- Gerrit._pluginInstallError.bind(null, `${url} import error`),
- async);
- }
- },
-
- _loadJsPlugins(plugins) {
- for (const url of plugins) {
- this._createScriptTag(this._urlFor(url));
- }
- },
-
- _createScriptTag(url) {
- const el = document.createElement('script');
- el.defer = true;
- el.src = url;
- el.onerror = Gerrit._pluginInstallError.bind(null, `${url} load error`);
- return document.body.appendChild(el);
- },
-
- _urlFor(pathOrUrl) {
- if (!pathOrUrl) {
- return pathOrUrl;
- }
- if (pathOrUrl.startsWith('preloaded:') ||
- pathOrUrl.startsWith('http')) {
- // Plugins are loaded from another domain or preloaded.
- return pathOrUrl;
- }
- if (!pathOrUrl.startsWith('/')) {
- pathOrUrl = '/' + pathOrUrl;
- }
- return window.location.origin + this.getBaseUrl() + pathOrUrl;
- },
});
})();
diff --git a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.html b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.html
index e577182..3a8e4d8 100644
--- a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.html
+++ b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.html
@@ -38,195 +38,57 @@
suite('gr-plugin-host tests', () => {
let element;
let sandbox;
- let url;
setup(() => {
element = fixture('basic');
sandbox = sinon.sandbox.create();
sandbox.stub(document.body, 'appendChild');
sandbox.stub(element, 'importHref');
- url = window.location.origin;
});
teardown(() => {
sandbox.restore();
});
- test('counts plugins', () => {
- sandbox.stub(Gerrit, '_setPluginsCount');
+ test('load plugins should be called', () => {
+ sandbox.stub(Gerrit, '_loadPlugins');
element.config = {
plugin: {
html_resource_paths: ['plugins/foo/bar', 'plugins/baz'],
js_resource_paths: ['plugins/42'],
},
};
- assert.isTrue(Gerrit._setPluginsCount.calledWith(3));
+ assert.isTrue(Gerrit._loadPlugins.calledOnce);
+ assert.isTrue(Gerrit._loadPlugins.calledWith([
+ 'plugins/42', 'plugins/foo/bar', 'plugins/baz',
+ ], {}));
});
- test('imports relative html plugins from config', () => {
- sandbox.stub(Gerrit, '_pluginInstallError');
+ test('theme plugins should be loaded if enabled', () => {
+ sandbox.stub(Gerrit, '_loadPlugins');
element.config = {
- plugin: {html_resource_paths: ['foo/bar', 'baz']},
- };
- assert.equal(element.importHref.firstCall.args[0], url + '/foo/bar');
- assert.isTrue(element.importHref.firstCall.args[3]);
-
- assert.equal(element.importHref.secondCall.args[0], url + '/baz');
- assert.isTrue(element.importHref.secondCall.args[3]);
-
- assert.equal(Gerrit._pluginInstallError.callCount, 0);
- element.importHref.firstCall.args[2]();
- assert.equal(Gerrit._pluginInstallError.callCount, 1);
- element.importHref.secondCall.args[2]();
- assert.equal(Gerrit._pluginInstallError.callCount, 2);
- });
-
- test('imports relative html plugins from config with a base url', () => {
- sandbox.stub(Gerrit, '_pluginInstallError');
- sandbox.stub(element, 'getBaseUrl').returns('/the-base');
- element.config = {
- plugin: {html_resource_paths: ['foo/bar', 'baz']}};
- assert.equal(element.importHref.firstCall.args[0],
- url + '/the-base/foo/bar');
- assert.isTrue(element.importHref.firstCall.args[3]);
-
- assert.equal(element.importHref.secondCall.args[0],
- url + '/the-base/baz');
- assert.isTrue(element.importHref.secondCall.args[3]);
- assert.equal(Gerrit._pluginInstallError.callCount, 0);
- element.importHref.firstCall.args[2]();
- assert.equal(Gerrit._pluginInstallError.callCount, 1);
- element.importHref.secondCall.args[2]();
- assert.equal(Gerrit._pluginInstallError.callCount, 2);
- });
-
- test('importHref is not called with null callback functions', () => {
- const plugins = ['path/to/plugin'];
- element._importHtmlPlugins(plugins);
- assert.isTrue(element.importHref.calledOnce);
- assert.isFunction(element.importHref.lastCall.args[1]);
- assert.isFunction(element.importHref.lastCall.args[2]);
- });
-
- test('imports absolute html plugins from config', () => {
- sandbox.stub(Gerrit, '_pluginInstallError');
- element.config = {
+ default_theme: 'gerrit-theme.html',
plugin: {
- html_resource_paths: [
- 'http://example.com/foo/bar',
- 'https://example.com/baz',
- ],
+ html_resource_paths: ['plugins/foo/bar', 'plugins/baz'],
+ js_resource_paths: ['plugins/42'],
},
};
- assert.equal(element.importHref.firstCall.args[0],
- 'http://example.com/foo/bar');
- assert.isTrue(element.importHref.firstCall.args[3]);
-
- assert.equal(element.importHref.secondCall.args[0],
- 'https://example.com/baz');
- assert.isTrue(element.importHref.secondCall.args[3]);
- assert.equal(Gerrit._pluginInstallError.callCount, 0);
- element.importHref.firstCall.args[2]();
- assert.equal(Gerrit._pluginInstallError.callCount, 1);
- element.importHref.secondCall.args[2]();
- assert.equal(Gerrit._pluginInstallError.callCount, 2);
+ assert.isTrue(Gerrit._loadPlugins.calledOnce);
+ assert.isTrue(Gerrit._loadPlugins.calledWith([
+ 'gerrit-theme.html', 'plugins/42', 'plugins/foo/bar', 'plugins/baz',
+ ], {'gerrit-theme.html': {sync: true}}));
});
- test('adds js plugins from config to the body', () => {
- element.config = {plugin: {js_resource_paths: ['foo/bar', 'baz']}};
- assert.isTrue(document.body.appendChild.calledTwice);
- });
-
- test('imports relative js plugins from config', () => {
- sandbox.stub(element, '_createScriptTag');
- element.config = {plugin: {js_resource_paths: ['foo/bar', 'baz']}};
- assert.isTrue(element._createScriptTag.calledWith(url + '/foo/bar'));
- assert.isTrue(element._createScriptTag.calledWith(url + '/baz'));
- });
-
- test('imports relative html plugins from config with a base url', () => {
- sandbox.stub(element, '_createScriptTag');
- sandbox.stub(element, 'getBaseUrl').returns('/the-base');
- element.config = {plugin: {js_resource_paths: ['foo/bar', 'baz']}};
- assert.isTrue(element._createScriptTag.calledWith(
- url + '/the-base/foo/bar'));
- assert.isTrue(element._createScriptTag.calledWith(
- url + '/the-base/baz'));
- });
-
- test('imports absolute html plugins from config', () => {
- sandbox.stub(element, '_createScriptTag');
- element.config = {
- plugin: {
- js_resource_paths: [
- 'http://example.com/foo/bar',
- 'https://example.com/baz',
- ],
- },
- };
- assert.isTrue(element._createScriptTag.calledWith(
- 'http://example.com/foo/bar'));
- assert.isTrue(element._createScriptTag.calledWith(
- 'https://example.com/baz'));
- });
-
- test('default theme is loaded with html plugins', () => {
- sandbox.stub(Gerrit, '_pluginInstallError');
- element.config = {
- default_theme: '/oof',
- plugin: {
- html_resource_paths: ['some'],
- },
- };
- assert.equal(element.importHref.firstCall.args[0], url + '/oof');
- assert.isFalse(element.importHref.firstCall.args[3]);
-
- assert.equal(element.importHref.secondCall.args[0], url + '/some');
- assert.isTrue(element.importHref.secondCall.args[3]);
- assert.equal(Gerrit._pluginInstallError.callCount, 0);
- element.importHref.firstCall.args[2]();
- assert.equal(Gerrit._pluginInstallError.callCount, 1);
- element.importHref.secondCall.args[2]();
- assert.equal(Gerrit._pluginInstallError.callCount, 2);
- });
-
- test('default theme is loaded with html plugins', () => {
- sandbox.stub(Gerrit, '_setPluginsPending');
- element.config = {
- default_theme: '/oof',
- plugin: {},
- };
- assert.isTrue(Gerrit._setPluginsPending.calledWith([url + '/oof']));
- });
-
- test('skips default theme loading if preloaded', () => {
+ test('skip theme if preloaded', () => {
sandbox.stub(Gerrit, '_isPluginPreloaded')
.withArgs('preloaded:gerrit-theme').returns(true);
- sandbox.stub(Gerrit, '_setPluginsPending');
+ sandbox.stub(Gerrit, '_loadPlugins');
element.config = {
default_theme: '/oof',
plugin: {},
};
- assert.isFalse(element.importHref.calledWith(url + '/oof'));
- });
-
- test('skips preloaded plugins', () => {
- sandbox.stub(Gerrit, '_isPluginPreloaded')
- .withArgs(url + '/plugins/foo/bar').returns(true)
- .withArgs(url + '/plugins/42').returns(true);
- sandbox.stub(Gerrit, '_setPluginsCount');
- sandbox.stub(Gerrit, '_setPluginsPending');
- sandbox.stub(element, '_createScriptTag');
- element.config = {
- plugin: {
- html_resource_paths: ['plugins/foo/bar', 'plugins/baz'],
- js_resource_paths: ['plugins/42'],
- },
- };
- assert.isTrue(
- Gerrit._setPluginsPending.calledWith([url + '/plugins/baz']));
- assert.equal(element._createScriptTag.callCount, 0);
- assert.isTrue(element.importHref.calledWith(url + '/plugins/baz'));
+ assert.isTrue(Gerrit._loadPlugins.calledOnce);
+ assert.isTrue(Gerrit._loadPlugins.calledWith([], {}));
});
});
</script>
diff --git a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup.js b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup.js
index 3ef93e4..2e7a2b7 100644
--- a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup.js
+++ b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-plugin-popup.js
@@ -16,15 +16,18 @@
*/
(function(window) {
'use strict';
+
Polymer({
is: 'gr-plugin-popup',
- _legacyUndefinedCheck: true,
+
get opened() {
return this.$.overlay.opened;
},
+
open() {
return this.$.overlay.open();
},
+
close() {
this.$.overlay.close();
},
diff --git a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-plugin-repo-command.html b/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-plugin-repo-command.html
index 2fd4534..593c1e0 100644
--- a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-plugin-repo-command.html
+++ b/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-plugin-repo-command.html
@@ -25,7 +25,6 @@
<script>
Polymer({
is: 'gr-plugin-repo-command',
- _legacyUndefinedCheck: true,
properties: {
title: String,
repoName: String,
diff --git a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api_test.html b/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api_test.html
index 7c7564b..0b32f8a 100644
--- a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api_test.html
+++ b/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api_test.html
@@ -46,7 +46,7 @@
let plugin;
Gerrit.install(p => { plugin = p; }, '0.1',
'http://test.com/plugins/testplugin/static/test.js');
- sandbox.stub(Gerrit, '_arePluginsLoaded').returns(true);
+ Gerrit._loadPlugins([]);
repoApi = plugin.project();
});
diff --git a/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api_test.html b/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api_test.html
index d34ca94..cbc2de6 100644
--- a/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api_test.html
+++ b/polygerrit-ui/app/elements/plugins/gr-settings-api/gr-settings-api_test.html
@@ -48,7 +48,7 @@
let plugin;
Gerrit.install(p => { plugin = p; }, '0.1',
'http://test.com/plugins/testplugin/static/test.js');
- sandbox.stub(Gerrit, '_arePluginsLoaded').returns(true);
+ Gerrit._loadPlugins([]);
settingsApi = plugin.settings();
});
diff --git a/polygerrit-ui/app/elements/plugins/gr-styles-api/gr-styles-api_test.html b/polygerrit-ui/app/elements/plugins/gr-styles-api/gr-styles-api_test.html
index d67a309..46bda6d 100644
--- a/polygerrit-ui/app/elements/plugins/gr-styles-api/gr-styles-api_test.html
+++ b/polygerrit-ui/app/elements/plugins/gr-styles-api/gr-styles-api_test.html
@@ -46,7 +46,7 @@
let plugin;
Gerrit.install(p => { plugin = p; }, '0.1',
'http://test.com/plugins/testplugin/static/test.js');
- sandbox.stub(Gerrit, '_arePluginsLoaded').returns(true);
+ Gerrit._loadPlugins([]);
stylesApi = plugin.styles();
});
@@ -76,7 +76,7 @@
let plugin;
Gerrit.install(p => { plugin = p; }, '0.1',
'http://test.com/plugins/testplugin/static/test.js');
- sandbox.stub(Gerrit, '_arePluginsLoaded').returns(true);
+ Gerrit._loadPlugins([]);
stylesApi = plugin.styles();
displayInlineStyle = stylesApi.css('display: inline');
displayNoneStyle = stylesApi.css('display: none');
diff --git a/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-custom-plugin-header.html b/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-custom-plugin-header.html
index 97966ed..f0eacd2 100644
--- a/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-custom-plugin-header.html
+++ b/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-custom-plugin-header.html
@@ -26,7 +26,7 @@
vertical-align: middle;
}
.title {
- margin-left: .25em;
+ margin-left: var(--spacing-xs);
}
</style>
<span>
@@ -37,7 +37,6 @@
<script>
Polymer({
is: 'gr-custom-plugin-header',
- _legacyUndefinedCheck: true,
properties: {
logoUrl: String,
title: String,
diff --git a/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-theme-api_test.html b/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-theme-api_test.html
index 82eb0f8..6332b91 100644
--- a/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-theme-api_test.html
+++ b/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-theme-api_test.html
@@ -67,7 +67,7 @@
stub('gr-custom-plugin-header', {
ready() { customHeader = this; },
});
- Gerrit._setPluginsPending([]);
+ Gerrit._loadPlugins([]);
});
test('sets logo and title', done => {
diff --git a/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.html b/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.html
index 6b75850..086cc7c 100644
--- a/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.html
+++ b/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.html
@@ -32,7 +32,7 @@
gr-avatar {
height: 120px;
width: 120px;
- margin-right: .15em;
+ margin-right: var(--spacing-xs);
vertical-align: -.25em;
}
div section.hide {
diff --git a/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.js b/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.js
index 246662d..b0c7661 100644
--- a/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.js
+++ b/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-account-info',
- _legacyUndefinedCheck: true,
/**
* Fired when account details are changed.
diff --git a/polygerrit-ui/app/elements/settings/gr-agreements-list/gr-agreements-list.js b/polygerrit-ui/app/elements/settings/gr-agreements-list/gr-agreements-list.js
index fe36a86..41595a98 100644
--- a/polygerrit-ui/app/elements/settings/gr-agreements-list/gr-agreements-list.js
+++ b/polygerrit-ui/app/elements/settings/gr-agreements-list/gr-agreements-list.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-agreements-list',
- _legacyUndefinedCheck: true,
properties: {
_agreements: Array,
diff --git a/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.js b/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.js
index 3909c99..43afdf8 100644
--- a/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.js
+++ b/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-change-table-editor',
- _legacyUndefinedCheck: true,
properties: {
displayedColumns: {
diff --git a/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.html b/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.html
index ae88652..7b58e44 100644
--- a/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.html
+++ b/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.html
@@ -28,17 +28,17 @@
<template>
<style include="shared-styles">
h1 {
- margin-bottom: .6em;
+ margin-bottom: var(--spacing-m);
}
h3 {
- margin-bottom: .5em;
+ margin-bottom: var(--spacing-m);
}
.agreementsUrl {
- border: 0.1em solid #b0bdcc;
- margin-bottom: 1.25em;
- margin-left: 1.25em;
- margin-right: 1.25em;
- padding: 0.3em;
+ border: 1px solid #b0bdcc;
+ margin-bottom: var(--spacing-xl);
+ margin-left: var(--spacing-xl);
+ margin-right: var(--spacing-xl);
+ padding: var(--spacing-s);
}
#claNewAgreementsLabel {
font-weight: var(--font-weight-bold);
@@ -54,15 +54,15 @@
}
.alreadySubmittedText {
color: var(--error-text-color);
- margin: 0 2em;
- padding: .5em;
+ margin: 0 var(--spacing-xxl);
+ padding: var(--spacing-m);
}
.alreadySubmittedText.hide,
.hideAgreementsTextBox {
display: none;
}
main {
- margin: 2em auto;
+ margin: var(--spacing-xxl) auto;
max-width: 50em;
}
</style>
diff --git a/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.js b/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.js
index 11a0f1a..3eb1a22 100644
--- a/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.js
+++ b/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-cla-view',
- _legacyUndefinedCheck: true,
properties: {
_groups: Object,
diff --git a/polygerrit-ui/app/elements/settings/gr-edit-preferences/gr-edit-preferences.js b/polygerrit-ui/app/elements/settings/gr-edit-preferences/gr-edit-preferences.js
index 37bce08..86350f9 100644
--- a/polygerrit-ui/app/elements/settings/gr-edit-preferences/gr-edit-preferences.js
+++ b/polygerrit-ui/app/elements/settings/gr-edit-preferences/gr-edit-preferences.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-edit-preferences',
- _legacyUndefinedCheck: true,
properties: {
hasUnsavedChanges: {
diff --git a/polygerrit-ui/app/elements/settings/gr-email-editor/gr-email-editor.js b/polygerrit-ui/app/elements/settings/gr-email-editor/gr-email-editor.js
index 71d75cc..d08cc90 100644
--- a/polygerrit-ui/app/elements/settings/gr-email-editor/gr-email-editor.js
+++ b/polygerrit-ui/app/elements/settings/gr-email-editor/gr-email-editor.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-email-editor',
- _legacyUndefinedCheck: true,
properties: {
hasUnsavedChanges: {
diff --git a/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.html b/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.html
index dbf5a03..bbc8a66 100644
--- a/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.html
+++ b/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.html
@@ -35,7 +35,7 @@
width: 15em;
}
#viewKeyOverlay {
- padding: 2em;
+ padding: var(--spacing-xxl);
width: 50em;
}
.publicKey {
@@ -50,7 +50,7 @@
right: 2em;
}
#existing {
- margin-bottom: 1em;
+ margin-bottom: var(--spacing-l);
}
</style>
<div class="gr-form-styles">
diff --git a/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.js b/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.js
index 7348067..78025d1 100644
--- a/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.js
+++ b/polygerrit-ui/app/elements/settings/gr-gpg-editor/gr-gpg-editor.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-gpg-editor',
- _legacyUndefinedCheck: true,
properties: {
hasUnsavedChanges: {
diff --git a/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.js b/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.js
index 9531690..d62a241 100644
--- a/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.js
+++ b/polygerrit-ui/app/elements/settings/gr-group-list/gr-group-list.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-group-list',
- _legacyUndefinedCheck: true,
properties: {
_groups: Array,
diff --git a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.html b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.html
index c02f86c3..cdcc684 100644
--- a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.html
+++ b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.html
@@ -29,11 +29,11 @@
font-family: var(--monospace-font-family);
}
#generatedPasswordOverlay {
- padding: 2em;
+ padding: var(--spacing-xxl);
width: 50em;
}
#generatedPasswordDisplay {
- margin: 1em 0;
+ margin: var(--spacing-l) 0;
}
#generatedPasswordDisplay .value {
font-family: var(--monospace-font-family);
diff --git a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.js b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.js
index 99f4504..003e471 100644
--- a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.js
+++ b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-http-password',
- _legacyUndefinedCheck: true,
properties: {
_username: String,
diff --git a/polygerrit-ui/app/elements/settings/gr-identities/gr-identities.html b/polygerrit-ui/app/elements/settings/gr-identities/gr-identities.html
index 09f68de..62a3862 100644
--- a/polygerrit-ui/app/elements/settings/gr-identities/gr-identities.html
+++ b/polygerrit-ui/app/elements/settings/gr-identities/gr-identities.html
@@ -50,7 +50,7 @@
display: none;
}
.space {
- margin-bottom: 1em;
+ margin-bottom: var(--spacing-l);
}
</style>
<div class="gr-form-styles">
diff --git a/polygerrit-ui/app/elements/settings/gr-identities/gr-identities.js b/polygerrit-ui/app/elements/settings/gr-identities/gr-identities.js
index 4560a2e..c927f1e 100644
--- a/polygerrit-ui/app/elements/settings/gr-identities/gr-identities.js
+++ b/polygerrit-ui/app/elements/settings/gr-identities/gr-identities.js
@@ -24,7 +24,6 @@
Polymer({
is: 'gr-identities',
- _legacyUndefinedCheck: true,
properties: {
_identities: Object,
diff --git a/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor.js b/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor.js
index 8587338..aa83bf7 100644
--- a/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor.js
+++ b/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-menu-editor',
- _legacyUndefinedCheck: true,
properties: {
menuItems: Array,
diff --git a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.html b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.html
index 8f54ec7..a020fdd 100644
--- a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.html
+++ b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.html
@@ -45,23 +45,23 @@
display: block;
}
hr {
- margin-top: 1em;
- margin-bottom: 1em;
+ margin-top: var(--spacing-l);
+ margin-bottom: var(--spacing-l);
}
header {
border-bottom: 1px solid var(--border-color);
font-weight: var(--font-weight-bold);
- margin-bottom: 1em;
+ margin-bottom: var(--spacing-l);
}
.container {
- padding: .5em 1.5em;
+ padding: var(--spacing-m) var(--spacing-xl);
}
footer {
display: flex;
justify-content: flex-end;
}
footer gr-button {
- margin-left: 1em;
+ margin-left: var(--spacing-l);
}
input {
width: 20em;
diff --git a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.js b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.js
index 3ce226f..0633416 100644
--- a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.js
+++ b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-registration-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when account details are changed.
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-item.html b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-item.html
index 704a8698d..937ee79 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-item.html
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-item.html
@@ -22,7 +22,7 @@
<style>
:host {
display: block;
- margin-bottom: 2em;
+ margin-bottom: var(--spacing-xxl);
}
</style>
<h2 id="[[anchor]]">[[title]]</h2>
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-item.js b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-item.js
index dc1aa93..dae3b68 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-item.js
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-item.js
@@ -19,7 +19,7 @@
Polymer({
is: 'gr-settings-item',
- _legacyUndefinedCheck: true,
+
properties: {
anchor: String,
title: String,
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-menu-item.js b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-menu-item.js
index 2a56b09..5db0031 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-menu-item.js
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-menu-item.js
@@ -19,7 +19,7 @@
Polymer({
is: 'gr-settings-menu-item',
- _legacyUndefinedCheck: true,
+
properties: {
href: String,
title: String,
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.html b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.html
index 3061281..893b3f5 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.html
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.html
@@ -55,14 +55,14 @@
width: 20em;
}
#email {
- margin-bottom: 1em;
+ margin-bottom: var(--spacing-l);
}
main section.darkToggle {
display: block;
}
.filters p,
.darkToggle p {
- margin-bottom: 1em;
+ margin-bottom: var(--spacing-l);
}
.queryExample em {
color: violet;
@@ -70,8 +70,8 @@
.toggle {
align-items: center;
display: flex;
- margin-bottom: 1rem;
- margin-right: 1rem;
+ margin-bottom: var(--spacing-l);
+ margin-right: var(--spacing-l);
}
</style>
<style include="gr-form-styles"></style>
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js
index cc93c2c..714faab 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js
@@ -47,7 +47,6 @@
Polymer({
is: 'gr-settings-view',
- _legacyUndefinedCheck: true,
/**
* Fired when the title of the page should change.
diff --git a/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.html b/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.html
index e0030ba..d068b9d 100644
--- a/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.html
+++ b/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.html
@@ -35,7 +35,7 @@
width: 7.5em;
}
#viewKeyOverlay {
- padding: 2em;
+ padding: var(--spacing-xxl);
width: 50em;
}
.publicKey {
@@ -50,7 +50,7 @@
right: 2em;
}
#existing {
- margin-bottom: 1em;
+ margin-bottom: var(--spacing-l);
}
#existing .commentColumn {
min-width: 27em;
diff --git a/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.js b/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.js
index 4c423e8..874173a 100644
--- a/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.js
+++ b/polygerrit-ui/app/elements/settings/gr-ssh-editor/gr-ssh-editor.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-ssh-editor',
- _legacyUndefinedCheck: true,
properties: {
hasUnsavedChanges: {
diff --git a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.html b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.html
index c7dc48a..24010e3 100644
--- a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.html
+++ b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.html
@@ -28,7 +28,7 @@
<style include="gr-form-styles">
#watchedProjects .notifType {
text-align: center;
- padding: 0 0.4em;
+ padding: 0 var(--spacing-s);
}
.notifControl {
cursor: pointer;
@@ -40,7 +40,7 @@
.projectFilter {
color: var(--deemphasized-text-color);
font-style: italic;
- margin-left: 1em;
+ margin-left: var(--spacing-l);
}
.newFilterInput {
width: 100%;
diff --git a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.js b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.js
index bd18456..e751ea3 100644
--- a/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.js
+++ b/polygerrit-ui/app/elements/settings/gr-watched-projects-editor/gr-watched-projects-editor.js
@@ -27,7 +27,6 @@
Polymer({
is: 'gr-watched-projects-editor',
- _legacyUndefinedCheck: true,
properties: {
hasUnsavedChanges: {
diff --git a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.html b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.html
index 379e231..5a095a4 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.html
+++ b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.html
@@ -35,7 +35,7 @@
background: var(--chip-background-color);
border-radius: .75em;
display: inline-flex;
- padding: 0 .5em;
+ padding: 0 var(--spacing-m);
}
:host([show-avatar]) .container {
padding-left: 0;
@@ -44,11 +44,10 @@
--gr-remove-button-style: {
border: 0;
color: var(--deemphasized-text-color);
- font-size: 1.7rem;
font-weight: normal;
height: .6em;
- line-height: .6;
- margin-left: .15em;
+ line-height: 10px;
+ margin-left: var(--spacing-xs);
padding: 0;
text-decoration: none;
}
diff --git a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.js b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.js
index 0e85599..10c876d 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.js
+++ b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.js
@@ -20,7 +20,6 @@
Polymer({
is: 'gr-account-chip',
- _legacyUndefinedCheck: true,
/**
* Fired to indicate a key was pressed while this chip was focused.
diff --git a/polygerrit-ui/app/elements/shared/gr-account-entry/gr-account-entry.js b/polygerrit-ui/app/elements/shared/gr-account-entry/gr-account-entry.js
index 63bd252..92836a8 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-entry/gr-account-entry.js
+++ b/polygerrit-ui/app/elements/shared/gr-account-entry/gr-account-entry.js
@@ -23,7 +23,6 @@
*/
Polymer({
is: 'gr-account-entry',
- _legacyUndefinedCheck: true,
/**
* Fired when an account is entered.
diff --git a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.html b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.html
index f807a74..7ed7962 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.html
+++ b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.html
@@ -35,7 +35,7 @@
gr-avatar {
height: 1.3em;
width: 1.3em;
- margin-right: .15em;
+ margin-right: var(--spacing-xs);
vertical-align: -.25em;
}
.text {
diff --git a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.js b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.js
index a778e8b..418d2ea 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.js
+++ b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-account-label',
- _legacyUndefinedCheck: true,
properties: {
/**
diff --git a/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.js b/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.js
index 03967f1..faaf9c3 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.js
+++ b/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-account-link',
- _legacyUndefinedCheck: true,
properties: {
additionalText: String,
diff --git a/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.html b/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.html
index c793c07..2ce608be 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.html
+++ b/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.html
@@ -26,7 +26,7 @@
<style include="shared-styles">
gr-account-chip {
display: inline-block;
- margin: .2em .2em .2em 0;
+ margin: var(--spacing-xs) var(--spacing-xs) var(--spacing-xs) 0;
}
gr-account-entry {
display: flex;
diff --git a/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.js b/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.js
index 1be55d2..6d364c9 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.js
+++ b/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.js
@@ -39,7 +39,6 @@
Polymer({
is: 'gr-account-list',
- _legacyUndefinedCheck: true,
/**
* Fired when user inputs an invalid email address.
diff --git a/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.html b/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.html
index bce8a4d..08c91657 100644
--- a/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.html
+++ b/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.html
@@ -52,7 +52,7 @@
* with the universal selector: *.
*/
.content-wrapper {
- padding: 1em 1.5em;
+ padding: var(--spacing-l) var(--spacing-xl);
}
.text {
color: var(--tooltip-text-color);
@@ -65,7 +65,7 @@
.action {
color: var(--link-color);
font-weight: var(--font-weight-bold);
- margin-left: 1em;
+ margin-left: var(--spacing-l);
text-decoration: none;
--gr-button: {
padding: 0;
diff --git a/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.js b/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.js
index ec7b6eb..e7c8b2c 100644
--- a/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.js
+++ b/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-alert',
- _legacyUndefinedCheck: true,
/**
* Fired when the action button is pressed.
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.html b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.html
index 0d9f04c..c3336b4 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.html
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.html
@@ -42,7 +42,7 @@
cursor: pointer;
display: flex;
justify-content: space-between;
- padding: .5em .75em;
+ padding: var(--spacing-m) var(--spacing-l);
}
li:last-of-type {
border: none;
@@ -69,7 +69,7 @@
}
.label {
color: var(--deemphasized-text-color);
- padding-left: 1em;
+ padding-left: var(--spacing-l);
}
.hide {
display: none;
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.js b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.js
index af0b637..2263113 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.js
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-autocomplete-dropdown',
- _legacyUndefinedCheck: true,
/**
* Fired when the dropdown is closed.
@@ -53,10 +52,7 @@
value: () => [],
observer: '_resetCursorStops',
},
- _suggestionEls: {
- type: Array,
- observer: '_resetCursorIndex',
- },
+ _suggestionEls: Array,
},
behaviors: [
@@ -79,9 +75,9 @@
open() {
this.isHidden = false;
- this.refit();
this._resetCursorStops();
- this._resetCursorIndex();
+ // Refit should run after we call Polymer.flush inside _resetCursorStops
+ this.refit();
},
getCurrentText() {
@@ -163,10 +159,13 @@
_resetCursorStops() {
if (this.suggestions.length > 0) {
- Polymer.dom.flush();
- // Polymer2: querySelectorAll returns NodeList instead of Array.
- this._suggestionEls = Array.from(
- this.$.suggestions.querySelectorAll('li'));
+ if (!this.isHidden) {
+ Polymer.dom.flush();
+ // Polymer2: querySelectorAll returns NodeList instead of Array.
+ this._suggestionEls = Array.from(
+ this.$.suggestions.querySelectorAll('li'));
+ this._resetCursorIndex();
+ }
} else {
this._suggestionEls = [];
}
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.html b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.html
index 1fa3db1..17de8b1 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.html
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.html
@@ -33,7 +33,7 @@
display: inline-block;
}
iron-icon {
- margin: 0 .25em;
+ margin: 0 var(--spacing-xs);
}
paper-input:not(.borderless) {
border: 1px solid var(--border-color);
@@ -46,7 +46,7 @@
padding: 0;
}
--paper-input-container-input: {
- font-size: var(--font-size-normal);
+ font-size: inherit;
}
--paper-input-container-underline: {
display: none;
@@ -61,7 +61,7 @@
paper-input.warnUncommitted {
--paper-input-container-input: {
color: var(--error-text-color);
- font-size: var(--font-size-normal);
+ font-size: inherit;
}
}
</style>
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.js b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.js
index d422df8..2135dee 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.js
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.js
@@ -22,7 +22,6 @@
Polymer({
is: 'gr-autocomplete',
- _legacyUndefinedCheck: true,
/**
* Fired when a value is chosen.
diff --git a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar.js b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar.js
index 2435e58..bf56382 100644
--- a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar.js
+++ b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-avatar',
- _legacyUndefinedCheck: true,
properties: {
account: {
diff --git a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.html b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.html
index 1c2afaa..3456c13 100644
--- a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.html
@@ -117,7 +117,7 @@
assert.strictEqual(element.style.backgroundImage, '');
// Emulate plugins loaded.
- Gerrit._setPluginsPending([]);
+ Gerrit._loadPlugins([]);
Promise.all([
element.$.restAPI.getConfig(),
@@ -155,7 +155,7 @@
assert.isFalse(element.hasAttribute('hidden'));
// Emulate plugins loaded.
- Gerrit._setPluginsPending([]);
+ Gerrit._loadPlugins([]);
return Promise.all([
element.$.restAPI.getConfig(),
@@ -197,7 +197,7 @@
_account_id: 123,
};
// Emulate plugins loaded.
- Gerrit._setPluginsPending([]);
+ Gerrit._loadPlugins([]);
return Promise.all([
element.$.restAPI.getConfig(),
diff --git a/polygerrit-ui/app/elements/shared/gr-button/gr-button.html b/polygerrit-ui/app/elements/shared/gr-button/gr-button.html
index ad5c243..441c4aa 100644
--- a/polygerrit-ui/app/elements/shared/gr-button/gr-button.html
+++ b/polygerrit-ui/app/elements/shared/gr-button/gr-button.html
@@ -64,7 +64,7 @@
user-select: none;
cursor: pointer;
z-index: 0;
- padding: 0.7em 0.57em;
+ padding: var(--spacing-m);
@apply --paper-font-common-base;
@apply --paper-button;
@@ -152,8 +152,8 @@
border-top: .36em solid #ccc;
border-left: .36em solid transparent;
border-right: .36em solid transparent;
- margin-bottom: .05em;
- margin-left: .5em;
+ margin-bottom: var(--spacing-xxs);
+ margin-left: var(--spacing-m);
transition: border-top-color 200ms;
}
:host([down-arrow]) paper-button:hover .downArrow {
diff --git a/polygerrit-ui/app/elements/shared/gr-button/gr-button.js b/polygerrit-ui/app/elements/shared/gr-button/gr-button.js
index d88fdb5..99d4fe4 100644
--- a/polygerrit-ui/app/elements/shared/gr-button/gr-button.js
+++ b/polygerrit-ui/app/elements/shared/gr-button/gr-button.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-button',
- _legacyUndefinedCheck: true,
properties: {
tooltip: String,
diff --git a/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.js b/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.js
index 98fd94a..a83bc2b 100644
--- a/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.js
+++ b/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-change-star',
- _legacyUndefinedCheck: true,
/**
* Fired when star state is toggled.
diff --git a/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status.html b/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status.html
index fa95382..05cbaa1 100644
--- a/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status.html
+++ b/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status.html
@@ -27,9 +27,7 @@
.chip {
border-radius: 4px;
background-color: var(--chip-background-color);
- font-family: var(--font-family);
- font-size: var(--font-size-normal);
- padding: .1em .5em;
+ padding: var(--spacing-xxs) var(--spacing-m);
white-space: nowrap;
}
:host(.merged) .chip {
@@ -66,7 +64,7 @@
}
:host([flat]) .chip {
background-color: transparent;
- padding: .1em;
+ padding: var(--spacing-xxs);
}
:host(:not([flat])) .chip {
color: white;
diff --git a/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status.js b/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status.js
index 70c5d72..3afbe54 100644
--- a/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status.js
+++ b/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status.js
@@ -34,7 +34,6 @@
Polymer({
is: 'gr-change-status',
- _legacyUndefinedCheck: true,
properties: {
flat: {
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.html b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.html
index a796d4d..d834776 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.html
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.html
@@ -29,11 +29,11 @@
<template>
<style include="shared-styles">
gr-button {
- margin-left: .5em;
+ margin-left: var(--spacing-m);
}
#actions {
margin-left: auto;
- padding: .5em .7em;
+ padding: var(--spacing-m);
}
#container {
background-color: var(--comment-background-color);
@@ -59,14 +59,14 @@
#unresolvedLabel {
font-family: var(--font-family);
margin: auto 0;
- padding: .5em .7em;
+ padding: var(--spacing-m);
}
.pathInfo {
display: flex;
align-items: baseline;
}
.descriptionText {
- margin-left: .5rem;
+ margin-left: var(--spacing-m);
font-style: italic;
}
</style>
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.js b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.js
index 615ce3b..093667c 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.js
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.js
@@ -22,7 +22,6 @@
Polymer({
is: 'gr-comment-thread',
- _legacyUndefinedCheck: true,
/**
* Fired when the thread should be discarded.
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html
index 8b69d2e..7c9b441 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.html
@@ -42,7 +42,7 @@
:host {
display: block;
font-family: var(--font-family);
- padding: .7em .7em;
+ padding: var(--spacing-m);
--iron-autogrow-textarea: {
box-sizing: border-box;
padding: 2px;
@@ -63,12 +63,11 @@
align-items: baseline;
cursor: pointer;
display: flex;
- font-family: 'Open Sans', sans-serif;
- margin: -.7em -.7em 0 -.7em;
- padding: .7em;
+ margin: calc(0px - var(--spacing-m)) calc(0px - var(--spacing-m)) 0 calc(0px - var(--spacing-m));
+ padding: var(--spacing-m);
}
.container.collapsed .header {
- margin-bottom: -.7em;
+ margin-bottom: calc(0 - var(--spacing-m));
}
.headerMiddle {
color: var(--deemphasized-text-color);
@@ -104,7 +103,7 @@
padding-top: 0;
}
.action {
- margin-left: 1em;
+ margin-left: var(--spacing-l);
}
.robotActions {
display: flex;
@@ -113,8 +112,8 @@
}
.robotActions .action {
/* Keep button text lined up with output text */
- margin-left: -.3rem;
- margin-right: 1em;
+ margin-left: -4px;
+ margin-right: var(--spacing-l);
}
.rightActions {
display: flex;
@@ -122,7 +121,7 @@
}
.editMessage {
display: none;
- margin: .5em 0;
+ margin: var(--spacing-m) 0;
width: 100%;
}
.container:not(.draft) .actions .hideOnPublished {
@@ -156,27 +155,27 @@
display: block;
}
.show-hide {
- margin-left: .4em;
+ margin-left: var(--spacing-s);
}
.robotId {
color: var(--deemphasized-text-color);
- margin-bottom: .8em;
+ margin-bottom: var(--spacing-m);
margin-top: -.4em;
}
.robotIcon {
- margin-right: .2em;
+ margin-right: var(--spacing-xs);
/* because of the antenna of the robot, it looks off center even when it
is centered. artificially adjust margin to account for this. */
- margin-top: -.3em;
+ margin-top: -4px;
}
.runIdInformation {
- margin: .7em 0;
+ margin: var(--spacing-m) 0;
}
.robotRun {
- margin-left: .5em;
+ margin-left: var(--spacing-m);
}
.robotRunLink {
- margin-left: .5em;
+ margin-left: var(--spacing-m);
}
input.show-hide {
display: none;
@@ -185,9 +184,9 @@
color: var(--comment-text-color);
cursor: pointer;
display: block;
- font-size: .8rem;
+ font-size: var(--font-size-small);
height: 1.1em;
- margin-top: .1em;
+ margin-top: var(--spacing-xxs);
}
#container .collapsedContent {
display: none;
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js
index ecfbf60..918ef15 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.js
@@ -33,7 +33,6 @@
Polymer({
is: 'gr-comment',
- _legacyUndefinedCheck: true,
/**
* Fired when the create fix comment action is triggered.
diff --git a/polygerrit-ui/app/elements/shared/gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog.js b/polygerrit-ui/app/elements/shared/gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog.js
index b441ba8..c2075f0 100644
--- a/polygerrit-ui/app/elements/shared/gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog.js
+++ b/polygerrit-ui/app/elements/shared/gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-confirm-delete-comment-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the confirm button is pressed.
diff --git a/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.html b/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.html
index 06510dc..75b43bb 100644
--- a/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.html
+++ b/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.html
@@ -31,14 +31,13 @@
}
.copyText {
flex-grow: 1;
- margin-right: .3em;
+ margin-right: var(--spacing-s);
}
.hideInput {
display: none;
}
input#input {
font-family: var(--monospace-font-family);
- font-size: inherit;
@apply --text-container-style;
width: 100%;
}
diff --git a/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.js b/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.js
index 550f1df..cabee36 100644
--- a/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.js
+++ b/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.js
@@ -21,7 +21,6 @@
Polymer({
is: 'gr-copy-clipboard',
- _legacyUndefinedCheck: true,
properties: {
text: String,
diff --git a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.js b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.js
index 2c38c2a..be40ce6 100644
--- a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.js
+++ b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.js
@@ -24,7 +24,6 @@
Polymer({
is: 'gr-cursor-manager',
- _legacyUndefinedCheck: true,
properties: {
stops: {
diff --git a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.js b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.js
index a39e170..0360145 100644
--- a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.js
+++ b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.js
@@ -33,7 +33,6 @@
Polymer({
is: 'gr-date-formatter',
- _legacyUndefinedCheck: true,
properties: {
dateStr: {
diff --git a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.html b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.html
index 2059f71..2ef5539 100644
--- a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.html
+++ b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.html
@@ -46,10 +46,10 @@
header,
main,
footer {
- padding: .5em 1.5em;
+ padding: var(--spacing-m) var(--spacing-xl);
}
gr-button {
- margin-left: 1em;
+ margin-left: var(--spacing-l);
}
footer {
display: flex;
diff --git a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.js b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.js
index e0a1947..68dc537 100644
--- a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.js
+++ b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-dialog',
- _legacyUndefinedCheck: true,
/**
* Fired when the confirm button is pressed.
diff --git a/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences.js b/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences.js
index 89c3d74..36fdf5b 100644
--- a/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences.js
+++ b/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-diff-preferences',
- _legacyUndefinedCheck: true,
properties: {
hasUnsavedChanges: {
diff --git a/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.html b/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.html
index d4a2ab2..14a65b2 100644
--- a/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.html
+++ b/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.html
@@ -29,7 +29,7 @@
<style include="shared-styles">
paper-tabs {
height: 3rem;
- margin-bottom: .5em;
+ margin-bottom: var(--spacing-m);
--paper-tabs-selection-bar-color: var(--link-color);
}
paper-tab {
@@ -54,7 +54,7 @@
}
gr-shell-command {
width: 60em;
- margin-bottom: .5em;
+ margin-bottom: var(--spacing-m);
}
.hidden {
display: none;
diff --git a/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.js b/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.js
index ed7c2cc..121aa35 100644
--- a/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.js
+++ b/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.js
@@ -19,7 +19,7 @@
Polymer({
is: 'gr-download-commands',
- _legacyUndefinedCheck: true,
+
properties: {
commands: Array,
_loggedIn: {
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.html b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.html
index de2b58d..e397ae6 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.html
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.html
@@ -46,7 +46,7 @@
background-color: var(--dropdown-background-color);
box-shadow: 0 1px 5px rgba(0, 0, 0, .3);
max-height: 70vh;
- margin-top: 2em;
+ margin-top: var(--spacing-xxl);
min-width: 266px;
@apply --dropdown-content-style;
}
@@ -58,7 +58,7 @@
paper-item {
cursor: pointer;
flex-direction: column;
- font-size: var(--font-size-normal);
+ font-size: inherit;
--paper-item: {
min-height: 0;
padding: 10px 16px;
@@ -78,20 +78,10 @@
}
.bottomContent {
color: var(--deemphasized-text-color);
- /*
- * Should be 16px when the base font size is 13px (browser default of
- * 16px.
- */
- line-height: 1.37rem;
}
.bottomContent,
.topContent {
display: flex;
- /*
- * Should be 16px when the base font size is 13px (browser default of
- * 16px.
- */
- line-height: 1.37rem;
justify-content: space-between;
flex-direction: row;
width: 100%;
@@ -103,7 +93,7 @@
}
gr-date-formatter {
color: var(--deemphasized-text-color);
- margin-left: 2em;
+ margin-left: var(--spacing-xxl);
white-space: nowrap;
}
gr-select {
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.js b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.js
index d87afed..89a0725 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.js
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.js
@@ -47,7 +47,6 @@
Polymer({
is: 'gr-dropdown-list',
- _legacyUndefinedCheck: true,
/**
* Fired when the selected value changes
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.html b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.html
index 791edef..2a05050 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.html
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.html
@@ -63,7 +63,7 @@
li .itemAction {
cursor: pointer;
display: block;
- padding: .85em 1em;
+ padding: var(--spacing-m) var(--spacing-l);
}
li .itemAction {
@apply --gr-dropdown-item;
@@ -90,7 +90,7 @@
}
.topContent {
display: block;
- padding: .85em 1em;
+ padding: var(--spacing-m) var(--spacing-l);
@apply --gr-dropdown-item;
}
.bold-text {
@@ -139,7 +139,7 @@
<span
class$="itemAction [[_computeDisabledClass(link.id, disabledIds.*)]]"
data-id$="[[link.id]]"
- on-tap="_handleItemTap"
+ on-click="_handleItemTap"
hidden$="[[link.url]]"
tabindex="-1">[[link.name]]</span>
<a
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.js b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.js
index b9e221d..50a20d1 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.js
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.js
@@ -22,7 +22,6 @@
Polymer({
is: 'gr-dropdown',
- _legacyUndefinedCheck: true,
/**
* Fired when a non-link dropdown item with the given ID is tapped.
@@ -139,10 +138,10 @@
e.preventDefault();
e.stopPropagation();
if (this.$.dropdown.opened) {
- // TODO(kaspern): This solution will not work in Shadow DOM, and
- // is not particularly robust in general. Find a better solution
- // when page.js has been abstracted away from components.
- const el = this.$.cursor.target.querySelector(':not([hidden])');
+ // TODO(milutin): This solution is not particularly robust in general.
+ // Since gr-tooltip-content click on shadow dom is not propagated down,
+ // we have to target `a` inside it.
+ const el = this.$.cursor.target.querySelector(':not([hidden]) a');
if (el) { el.click(); }
} else {
this._open();
@@ -176,8 +175,8 @@
*/
_open() {
this.$.dropdown.open();
+ this._resetCursorStops();
this.$.cursor.setCursorAtIndex(0);
- Polymer.dom.flush();
this.$.cursor.target.focus();
},
@@ -282,9 +281,8 @@
* Recompute the stops for the dropdown item cursor.
*/
_resetCursorStops() {
- if (this.items && this.items.length > 0) {
+ if (this.items && this.items.length > 0 && this.$.dropdown.opened) {
Polymer.dom.flush();
- // Polymer2: querySelectorAll returns NodeList instead of Array.
this._listElements = Array.from(
Polymer.dom(this.root).querySelectorAll('li'));
}
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_test.html b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_test.html
index bf1c9fa..295f746 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_test.html
@@ -196,7 +196,7 @@
MockInteractions.pressAndReleaseKeyOn(element, 32); // Space
assert.isTrue(element.$.dropdown.opened);
- const el = element.$.cursor.target.querySelector(':not([hidden])');
+ const el = element.$.cursor.target.querySelector(':not([hidden]) a');
const stub = sandbox.stub(el, 'click');
MockInteractions.pressAndReleaseKeyOn(element, 32); // Space
assert.isTrue(stub.called);
diff --git a/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.js b/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.js
index 29c2f6e..1e339dc 100644
--- a/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.js
+++ b/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.js
@@ -22,7 +22,6 @@
Polymer({
is: 'gr-editable-content',
- _legacyUndefinedCheck: true,
/**
* Fired when the save button is pressed.
diff --git a/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.html b/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.html
index f0ad2a9..330f880 100644
--- a/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.html
+++ b/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.html
@@ -36,9 +36,6 @@
label {
width: 100%;
}
- input {
- font: inherit;
- }
label {
color: var(--deemphasized-text-color);
display: inline-block;
@@ -57,17 +54,17 @@
}
.inputContainer {
background-color: var(--dialog-background-color);
- padding: .8em;
+ padding: var(--spacing-m);
@apply --input-style;
}
.buttons {
display: flex;
justify-content: flex-end;
- padding-top: 1.2em;
+ padding-top: var(--spacing-l);
width: 100%;
}
.buttons gr-button {
- margin-left: .5em;
+ margin-left: var(--spacing-m);
}
paper-input {
--paper-input-container: {
@@ -75,7 +72,7 @@
min-width: 15em;
}
--paper-input-container-input: {
- font-size: var(--font-size-normal);
+ font-size: inherit;
}
--paper-input-container-focus-color: var(--link-color);
}
diff --git a/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.js b/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.js
index f21605d..1a5356f 100644
--- a/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.js
+++ b/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.js
@@ -22,7 +22,6 @@
Polymer({
is: 'gr-editable-label',
- _legacyUndefinedCheck: true,
/**
* Fired when the value is changed.
diff --git a/polygerrit-ui/app/elements/shared/gr-fixed-panel/gr-fixed-panel.js b/polygerrit-ui/app/elements/shared/gr-fixed-panel/gr-fixed-panel.js
index 87cd4b4..2c32709 100644
--- a/polygerrit-ui/app/elements/shared/gr-fixed-panel/gr-fixed-panel.js
+++ b/polygerrit-ui/app/elements/shared/gr-fixed-panel/gr-fixed-panel.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-fixed-panel',
- _legacyUndefinedCheck: true,
properties: {
floatingDisabled: Boolean,
diff --git a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.html b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.html
index b6ad1af..8aa5a00 100644
--- a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.html
+++ b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.html
@@ -29,7 +29,7 @@
ul,
blockquote,
gr-linked-text.pre {
- margin: 0 0 .8em 0;
+ margin: 0 0 var(--spacing-m) 0;
}
p,
ul,
@@ -44,11 +44,11 @@
}
blockquote {
border-left: 1px solid #aaa;
- padding: 0 .7em;
+ padding: 0 var(--spacing-m);
}
li {
list-style-type: disc;
- margin-left: 1.4em;
+ margin-left: var(--spacing-xl);
}
gr-linked-text.pre {
font-family: var(--monospace-font-family);
diff --git a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.js b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.js
index 8836574..4e68d42 100644
--- a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.js
+++ b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.js
@@ -22,7 +22,6 @@
Polymer({
is: 'gr-formatted-text',
- _legacyUndefinedCheck: true,
properties: {
content: {
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard.html b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard.html
index cd14139..c77ea81 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard.html
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard.html
@@ -37,7 +37,7 @@
#hovercard {
background: var(--dialog-background-color);
box-shadow: rgba(0, 0, 0, 0.3) 0 1px 3px;
- padding: 1em;
+ padding: var(--spacing-l);
}
</style>
<div id="hovercard" role="tooltip" tabindex="-1">
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard.js b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard.js
index 498c590..f9c1da1 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard.js
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard.js
@@ -27,7 +27,6 @@
Polymer({
is: 'gr-hovercard',
- _legacyUndefinedCheck: true,
properties: {
/**
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.js
index 7e7e927..3db7c63 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-api-utils.js
@@ -19,6 +19,7 @@
'use strict';
const PRELOADED_PROTOCOL = 'preloaded:';
+ const PLUGIN_LOADING_TIMEOUT_MS = 10000;
let _restAPI;
function getRestAPI() {
@@ -28,6 +29,10 @@
return _restAPI;
}
+ function getBaseUrl() {
+ return Gerrit.BaseUrlBehavior.getBaseUrl();
+ }
+
/**
* Retrieves the name of the plugin base on the url.
* @param {string|URL} url
@@ -96,6 +101,9 @@
getPluginNameFromUrl,
send,
getRestAPI,
+ getBaseUrl,
+ PRELOADED_PROTOCOL,
+ PLUGIN_LOADING_TIMEOUT_MS,
// TEST only methods
testOnly_resetInternalState,
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.html
index 0131912..7332877 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.html
@@ -58,13 +58,14 @@
Gerrit.install(p => { plugin = p; }, '0.1',
'http://test.com/plugins/testplugin/static/test.js');
// Mimic all plugins loaded.
- Gerrit._setPluginsPending([]);
+ Gerrit._loadPlugins([]);
changeActions = plugin.changeActions();
element = fixture('basic');
});
teardown(() => {
changeActions = null;
+ Gerrit._testOnly_resetPlugins();
});
test('does not throw', ()=> {
@@ -85,11 +86,12 @@
'http://test.com/plugins/testplugin/static/test.js');
changeActions = plugin.changeActions();
// Mimic all plugins loaded.
- Gerrit._setPluginsPending([]);
+ Gerrit._loadPlugins([]);
});
teardown(() => {
changeActions = null;
+ Gerrit._testOnly_resetPlugins();
});
test('property existence', () => {
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.js
index a567700..03eb2e8 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.js
@@ -23,42 +23,12 @@
(function(window) {
'use strict';
- /**
- * Hash of loaded and installed plugins, name to Plugin object.
- */
- const _plugins = {};
-
- /**
- * Array of plugin URLs to be loaded, name to url.
- */
- let _pluginsPending = {};
-
- let _pluginsInstalled = [];
-
- let _pluginsPendingCount = -1;
-
- const UNKNOWN_PLUGIN = 'unknown';
- const PRELOADED_PROTOCOL = 'preloaded:';
-
- const PLUGIN_LOADING_TIMEOUT_MS = 10000;
-
- let _reporting;
- const getReporting = () => {
- if (!_reporting) {
- _reporting = document.createElement('gr-reporting');
- }
- return _reporting;
- };
-
// Import utils methods
const {
- getPluginNameFromUrl,
send,
getRestAPI,
} = window._apiUtils;
- const API_VERSION = '0.1';
-
/**
* Trigger the preinstalls for bundled plugins.
* This needs to happen before Gerrit as plugin bundle overrides the Gerrit.
@@ -72,9 +42,7 @@
window.Gerrit = window.Gerrit || {};
const Gerrit = window.Gerrit;
-
- let _resolveAllPluginsLoaded = null;
- let _allPluginsPromise = null;
+ Gerrit._pluginLoader = new PluginLoader();
Gerrit._endpoints = new GrPluginEndpoints();
@@ -85,20 +53,13 @@
const {
testOnly_resetInternalState,
} = window._apiUtils;
- Gerrit._testOnly_installPreloadedPlugins = installPreloadedPlugins;
+ Gerrit._testOnly_installPreloadedPlugins = (...args) => Gerrit._pluginLoader
+ .installPreloadedPlugins(...args);
Gerrit._testOnly_flushPreinstalls = flushPreinstalls;
Gerrit._testOnly_resetPlugins = () => {
- _allPluginsPromise = null;
- _pluginsInstalled = [];
- _pluginsPending = {};
- _pluginsPendingCount = -1;
- _reporting = null;
- _resolveAllPluginsLoaded = null;
testOnly_resetInternalState();
Gerrit._endpoints = new GrPluginEndpoints();
- for (const k of Object.keys(_plugins)) {
- delete _plugins[k];
- }
+ Gerrit._pluginLoader = new PluginLoader();
};
}
@@ -122,36 +83,7 @@
};
Gerrit.install = function(callback, opt_version, opt_src) {
- // HTML import polyfill adds __importElement pointing to the import tag.
- const script = document.currentScript &&
- (document.currentScript.__importElement || document.currentScript);
-
- let src = opt_src || (script && script.src);
- if (!src || src.startsWith('data:')) {
- src = script && script.baseURI;
- }
- const name = getPluginNameFromUrl(src);
-
- if (opt_version && opt_version !== API_VERSION) {
- Gerrit._pluginInstallError(`Plugin ${name} install error: only version ` +
- API_VERSION + ' is supported in PolyGerrit. ' + opt_version +
- ' was given.');
- return;
- }
-
- const existingPlugin = _plugins[name];
- const plugin = existingPlugin || new Plugin(src);
- try {
- callback(plugin);
- if (name) {
- _plugins[name] = plugin;
- }
- if (!existingPlugin) {
- Gerrit._pluginInstalled(src);
- }
- } catch (e) {
- Gerrit._pluginInstallError(`${e.name}: ${e.message}`);
- }
+ Gerrit._pluginLoader.install(callback, opt_version, opt_src);
};
Gerrit.getLoggedIn = function() {
@@ -195,96 +127,33 @@
};
Gerrit.awaitPluginsLoaded = function() {
- if (!_allPluginsPromise) {
- if (Gerrit._arePluginsLoaded()) {
- _allPluginsPromise = Promise.resolve();
- } else {
- let timeoutId;
- _allPluginsPromise =
- Promise.race([
- new Promise(resolve => _resolveAllPluginsLoaded = resolve),
- new Promise(resolve => timeoutId = setTimeout(
- Gerrit._pluginLoadingTimeout, PLUGIN_LOADING_TIMEOUT_MS)),
- ]).then(() => clearTimeout(timeoutId));
- }
- }
- return _allPluginsPromise;
+ return Gerrit._pluginLoader.awaitPluginsLoaded();
};
- Gerrit._pluginLoadingTimeout = function() {
- console.error(`Failed to load plugins: ${Object.keys(_pluginsPending)}`);
- Gerrit._setPluginsPending([]);
- };
+ // TODO(taoalpha): consider removing these proxy methods
+ // and using _pluginLoader directly
- Gerrit._setPluginsPending = function(plugins) {
- _pluginsPending = plugins.reduce((o, url) => {
- // TODO(viktard): Remove guard (@see Issue 8962)
- o[getPluginNameFromUrl(url) || UNKNOWN_PLUGIN] = url;
- return o;
- }, {});
- Gerrit._setPluginsCount(Object.keys(_pluginsPending).length);
- };
-
- Gerrit._setPluginsCount = function(count) {
- _pluginsPendingCount = count;
- if (Gerrit._arePluginsLoaded()) {
- getReporting().pluginsLoaded(_pluginsInstalled);
- if (_resolveAllPluginsLoaded) {
- _resolveAllPluginsLoaded();
- }
- }
- };
-
- Gerrit._pluginInstallError = function(message) {
- document.dispatchEvent(new CustomEvent('show-alert', {
- detail: {
- message: `Plugin install error: ${message}`,
- },
- }));
- console.info(`Plugin install error: ${message}`);
- Gerrit._setPluginsCount(_pluginsPendingCount - 1);
- };
-
- Gerrit._pluginInstalled = function(url) {
- const name = getPluginNameFromUrl(url) || UNKNOWN_PLUGIN;
- if (!_pluginsPending[name]) {
- console.warn(`Unexpected plugin ${name} installed from ${url}.`);
- } else {
- delete _pluginsPending[name];
- _pluginsInstalled.push(name);
- Gerrit._setPluginsCount(_pluginsPendingCount - 1);
- getReporting().pluginLoaded(name);
- console.log(`Plugin ${name} installed.`);
- }
+ Gerrit._loadPlugins = function(plugins, opt_option) {
+ Gerrit._pluginLoader.loadPlugins(plugins, opt_option);
};
Gerrit._arePluginsLoaded = function() {
- return _pluginsPendingCount === 0;
- };
-
- Gerrit._getPluginScreenName = function(pluginName, screenName) {
- return `${pluginName}-screen-${screenName}`;
+ return Gerrit._pluginLoader.arePluginsLoaded;
};
Gerrit._isPluginPreloaded = function(url) {
- const name = getPluginNameFromUrl(url);
- if (name && Gerrit._preloadedPlugins) {
- return name in Gerrit._preloadedPlugins;
- } else {
- return false;
- }
+ return Gerrit._pluginLoader.isPluginPreloaded(url);
};
- function installPreloadedPlugins() {
- if (!Gerrit._preloadedPlugins) { return; }
- for (const name in Gerrit._preloadedPlugins) {
- if (!Gerrit._preloadedPlugins.hasOwnProperty(name)) { continue; }
- const callback = Gerrit._preloadedPlugins[name];
- Gerrit.install(callback, API_VERSION, PRELOADED_PROTOCOL + name);
- }
- }
+ Gerrit._isPluginEnabled = function(pathOrUrl) {
+ return Gerrit._pluginLoader.isPluginEnabled(pathOrUrl);
+ };
+
+ Gerrit._isPluginLoaded = function(pathOrUrl) {
+ return Gerrit._pluginLoader.isPluginLoaded(pathOrUrl);
+ };
// Preloaded plugins should be installed after Gerrit.install() is set,
// since plugin preloader substitutes Gerrit.install() temporarily.
- installPreloadedPlugins();
+ Gerrit._pluginLoader.installPreloadedPlugins();
})(window);
\ No newline at end of file
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit_test.html
index 9a05454..e81b8aa 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit_test.html
@@ -37,11 +37,11 @@
<script>
suite('gr-gerrit tests', () => {
let element;
- let plugin;
let sandbox;
let sendStub;
setup(() => {
+ this.clock = sinon.useFakeTimers();
sandbox = sinon.sandbox.create();
sendStub = sandbox.stub().returns(Promise.resolve({status: 200}));
stub('gr-rest-api-interface', {
@@ -53,136 +53,48 @@
},
});
element = fixture('basic');
- Gerrit.install(p => { plugin = p; }, '0.1',
- 'http://test.com/plugins/testplugin/static/test.js');
- Gerrit._setPluginsPending([]);
});
teardown(() => {
+ this.clock.restore();
sandbox.restore();
element._removeEventCallbacks();
- plugin = null;
+ Gerrit._testOnly_resetPlugins();
});
- test('reuse plugin for install calls', () => {
- let otherPlugin;
- Gerrit.install(p => { otherPlugin = p; }, '0.1',
- 'http://test.com/plugins/testplugin/static/test.js');
- assert.strictEqual(plugin, otherPlugin);
- });
-
- test('flushes preinstalls if provided', () => {
- assert.doesNotThrow(() => {
- Gerrit._testOnly_flushPreinstalls();
+ suite('proxy methods', () => {
+ test('Gerrit._isPluginEnabled proxy to pluginLoader', () => {
+ const stubFn = sandbox.stub();
+ sandbox.stub(
+ Gerrit._pluginLoader,
+ 'isPluginEnabled',
+ (...args) => stubFn(...args)
+ );
+ Gerrit._isPluginEnabled('test_plugin');
+ assert.isTrue(stubFn.calledWith('test_plugin'));
});
- window.Gerrit.flushPreinstalls = sandbox.stub();
- Gerrit._testOnly_flushPreinstalls();
- assert.isTrue(window.Gerrit.flushPreinstalls.calledOnce);
- delete window.Gerrit.flushPreinstalls;
- });
- test('versioning', () => {
- const callback = sandbox.spy();
- Gerrit.install(callback, '0.0pre-alpha');
- assert(callback.notCalled);
- });
-
- test('_setPluginsCount', done => {
- stub('gr-reporting', {
- pluginsLoaded() {
- done();
- },
+ test('Gerrit._isPluginLoaded proxy to pluginLoader', () => {
+ const stubFn = sandbox.stub();
+ sandbox.stub(
+ Gerrit._pluginLoader,
+ 'isPluginLoaded',
+ (...args) => stubFn(...args)
+ );
+ Gerrit._isPluginLoaded('test_plugin');
+ assert.isTrue(stubFn.calledWith('test_plugin'));
});
- Gerrit._setPluginsCount(0);
- });
- test('_arePluginsLoaded', () => {
- assert.isTrue(Gerrit._arePluginsLoaded());
- Gerrit._setPluginsCount(1);
- assert.isFalse(Gerrit._arePluginsLoaded());
- Gerrit._setPluginsCount(0);
- assert.isTrue(Gerrit._arePluginsLoaded());
- });
-
- test('_pluginInstalled', () => {
- const pluginsLoadedStub = sandbox.stub();
- stub('gr-reporting', {
- pluginsLoaded: (...args) => pluginsLoadedStub(...args),
+ test('Gerrit._isPluginPreloaded proxy to pluginLoader', () => {
+ const stubFn = sandbox.stub();
+ sandbox.stub(
+ Gerrit._pluginLoader,
+ 'isPluginPreloaded',
+ (...args) => stubFn(...args)
+ );
+ Gerrit._isPluginPreloaded('test_plugin');
+ assert.isTrue(stubFn.calledWith('test_plugin'));
});
- const plugins = [
- 'http://test.com/plugins/foo/static/test.js',
- 'http://test.com/plugins/bar/static/test.js',
- ];
- Gerrit._setPluginsPending(plugins);
- Gerrit._pluginInstalled(plugins[0]);
- Gerrit._pluginInstalled(plugins[1]);
- assert.isTrue(pluginsLoadedStub.calledWithExactly(['foo', 'bar']));
- });
-
- test('install calls _pluginInstalled', () => {
- sandbox.stub(Gerrit, '_pluginInstalled');
- Gerrit.install(p => { plugin = p; }, '0.1',
- 'http://test.com/plugins/testplugin/static/test.js');
-
- // testplugin has already been installed once (in setup).
- assert.isFalse(Gerrit._pluginInstalled.called);
-
- // testplugin2 plugin has not yet been installed.
- Gerrit.install(p => { plugin = p; }, '0.1',
- 'http://test.com/plugins/testplugin2/static/test.js');
- assert.isTrue(Gerrit._pluginInstalled.calledOnce);
- });
-
- test('plugin install errors mark plugins as loaded', () => {
- Gerrit._setPluginsCount(1);
- Gerrit.install(() => {}, '0.0pre-alpha');
- return Gerrit.awaitPluginsLoaded();
- });
-
- test('multiple ui plugins per java plugin', () => {
- const file1 = 'http://test.com/plugins/qaz/static/foo.nocache.js';
- const file2 = 'http://test.com/plugins/qaz/static/bar.js';
- Gerrit._setPluginsPending([file1, file2]);
- Gerrit.install(() => {}, '0.1', file1);
- Gerrit.install(() => {}, '0.1', file2);
- return Gerrit.awaitPluginsLoaded();
- });
-
- test('plugin install errors shows toasts', () => {
- const alertStub = sandbox.stub();
- document.addEventListener('show-alert', alertStub);
- Gerrit._setPluginsCount(1);
- Gerrit.install(() => {}, '0.0pre-alpha');
- return Gerrit.awaitPluginsLoaded().then(() => {
- assert.isTrue(alertStub.calledOnce);
- });
- });
-
- test('Gerrit._isPluginPreloaded', () => {
- Gerrit._preloadedPlugins = {baz: ()=>{}};
- assert.isFalse(Gerrit._isPluginPreloaded('plugins/foo/bar'));
- assert.isFalse(Gerrit._isPluginPreloaded('http://a.com/42'));
- assert.isTrue(Gerrit._isPluginPreloaded('preloaded:baz'));
- Gerrit._preloadedPlugins = null;
- });
-
- test('preloaded plugins are installed', () => {
- const installStub = sandbox.stub();
- Gerrit._preloadedPlugins = {foo: installStub};
- Gerrit._testOnly_installPreloadedPlugins();
- assert.isTrue(installStub.called);
- const pluginApi = installStub.lastCall.args[0];
- assert.strictEqual(pluginApi.getPluginName(), 'foo');
- });
-
- test('installing preloaded plugin', () => {
- let plugin;
- window.ASSETS_PATH = 'http://blips.com/chitz';
- Gerrit.install(p => { plugin = p; }, '0.1', 'preloaded:foo');
- assert.strictEqual(plugin.getPluginName(), 'foo');
- assert.strictEqual(plugin.url('/some/thing.html'),
- 'http://blips.com/chitz/plugins/foo/some/thing.html');
- delete window.ASSETS_PATH;
});
});
</script>
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.html
index 7fa2250..dc81545 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.html
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.html
@@ -31,6 +31,13 @@
<link rel="import" href="../gr-rest-api-interface/gr-rest-api-interface.html">
<dom-module id="gr-js-api-interface">
+ <!--
+ Note: the order matters as files depend on each other.
+ 1. gr-api-utils will be used in multiple files below.
+ 2. gr-gerrit depends on gr-plugin-loader, gr-public-js-api and
+ also gr-plugin-endpoints
+ 3. gr-public-js-api depends on gr-plugin-rest-api
+ -->
<script src="gr-api-utils.js"></script>
<script src="gr-annotation-actions-context.js"></script>
<script src="gr-annotation-actions-js-api.js"></script>
@@ -41,5 +48,6 @@
<script src="gr-plugin-action-context.js"></script>
<script src="gr-plugin-rest-api.js"></script>
<script src="gr-public-js-api.js"></script>
+ <script src="gr-plugin-loader.js"></script>
<script src="gr-gerrit.js"></script>
</dom-module>
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.js
index f907ad6..1bbb832 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface.js
@@ -38,7 +38,6 @@
Polymer({
is: 'gr-js-api-interface',
- _legacyUndefinedCheck: true,
properties: {
_elements: {
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html
index 330310f..ae12940 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html
@@ -35,6 +35,7 @@
</test-fixture>
<script>
+ const {PLUGIN_LOADING_TIMEOUT_MS} = window._apiUtils;
suite('gr-js-api-interface tests', () => {
let element;
let plugin;
@@ -48,6 +49,7 @@
};
setup(() => {
+ this.clock = sinon.useFakeTimers();
sandbox = sinon.sandbox.create();
getResponseObjectStub = sandbox.stub().returns(Promise.resolve());
sendStub = sandbox.stub().returns(Promise.resolve({status: 200}));
@@ -64,10 +66,11 @@
errorStub = sandbox.stub(console, 'error');
Gerrit.install(p => { plugin = p; }, '0.1',
'http://test.com/plugins/testplugin/static/test.js');
- Gerrit._setPluginsPending([]);
+ Gerrit._loadPlugins([]);
});
teardown(() => {
+ this.clock.restore();
sandbox.restore();
element._removeEventCallbacks();
plugin = null;
@@ -194,12 +197,15 @@
revisions: {def: {_number: 2}, abc: {_number: 1}},
};
const spy = sandbox.spy();
- Gerrit._setPluginsCount(1);
+ Gerrit._loadPlugins(['plugins/test.html']);
plugin.on(element.EventType.SHOW_CHANGE, spy);
element.handleEvent(element.EventType.SHOW_CHANGE,
{change: testChange, patchNum: 1});
assert.isFalse(spy.called);
- Gerrit._setPluginsCount(0);
+
+ // Timeout on loading plugins
+ this.clock.tick(PLUGIN_LOADING_TIMEOUT_MS * 2);
+
flush(() => {
assert.isTrue(spy.called);
done();
@@ -334,7 +340,6 @@
setup(() => {
sandbox.stub(Gerrit.BaseUrlBehavior, 'getBaseUrl').returns('/r');
- Gerrit._setPluginsCount(1);
Gerrit.install(p => { baseUrlPlugin = p; }, '0.1',
'http://test.com/r/plugins/baseurlplugin/static/test.js');
});
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-action-context_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-action-context_test.html
index 229c020..6da117f 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-action-context_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-action-context_test.html
@@ -42,7 +42,6 @@
setup(() => {
sandbox = sinon.sandbox.create();
- Gerrit._setPluginsCount(1);
Gerrit.install(p => { plugin = p; }, '0.1',
'http://test.com/plugins/testplugin/static/test.js');
instance = new GrPluginActionContext(plugin);
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.js
new file mode 100644
index 0000000..04caf6b
--- /dev/null
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.js
@@ -0,0 +1,393 @@
+/**
+ * @license
+ * Copyright (C) 2019 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.
+ */
+
+(function(window) {
+ 'use strict';
+
+ // Import utils methods
+ const {
+ PLUGIN_LOADING_TIMEOUT_MS,
+ PRELOADED_PROTOCOL,
+ getPluginNameFromUrl,
+ getBaseUrl,
+ } = window._apiUtils;
+
+ /**
+ * @enum {string}
+ */
+ const PluginState = {
+ /**
+ * State that indicates the plugin is pending to be loaded.
+ */
+ PENDING: 'PENDING',
+
+ /**
+ * State that indicates the plugin is already loaded.
+ */
+ LOADED: 'LOADED',
+
+ /**
+ * State that indicates the plugin is already loaded.
+ */
+ PRE_LOADED: 'PRE_LOADED',
+
+ /**
+ * State that indicates the plugin failed to load.
+ */
+ LOAD_FAILED: 'LOAD_FAILED',
+ };
+
+ // Prefix for any unrecognized plugin urls.
+ // Url should match following patterns:
+ // /plugins/PLUGINNAME/static/SCRIPTNAME.(html|js)
+ // /plugins/PLUGINNAME.(js|html)
+ const UNKNOWN_PLUGIN_PREFIX = '__$$__';
+
+ // Current API version for Plugin,
+ // plugins with incompatible version will not be laoded.
+ const API_VERSION = '0.1';
+
+ /**
+ * PluginLoader, responsible for:
+ *
+ * Loading all plugins and handling errors etc.
+ * Recording plugin state.
+ * Reporting on plugin loading status.
+ * Retrieve plugin.
+ * Check plugin status and if all plugins loaded.
+ */
+ class PluginLoader {
+ constructor() {
+ this._pluginListLoaded = false;
+
+ /** @type {Map<string,PluginLoader.PluginObject>} */
+ this._plugins = new Map();
+
+ this._reporting = null;
+
+ // Promise that resolves when all plugins loaded
+ this._loadingPromise = null;
+
+ // Resolver to resolve _loadingPromise once all plugins loaded
+ this._loadingResolver = null;
+ }
+
+ _getReporting() {
+ if (!this._reporting) {
+ this._reporting = document.createElement('gr-reporting');
+ }
+ return this._reporting;
+ }
+
+ /**
+ * Use the plugin name or use the full url if not recognized.
+ * @see gr-api-utils#getPluginNameFromUrl
+ * @param {string|URL} url
+ */
+ _getPluginKeyFromUrl(url) {
+ return getPluginNameFromUrl(url) ||
+ `${UNKNOWN_PLUGIN_PREFIX}${url}`;
+ }
+
+ /**
+ * Load multiple plugins with certain options.
+ *
+ * @param {Array<string>} plugins
+ * @param {Object<string, PluginLoader.PluginOption>} opts
+ */
+ loadPlugins(plugins = [], opts = {}) {
+ this._pluginListLoaded = true;
+
+ plugins.forEach(path => {
+ const url = this._urlFor(path);
+ // Skip if preloaded, for bundling.
+ if (this.isPluginPreloaded(url)) return;
+
+ const pluginKey = this._getPluginKeyFromUrl(url);
+ // Skip if already installed.
+ if (this._plugins.has(pluginKey)) return;
+ this._plugins.set(pluginKey, {
+ name: pluginKey,
+ url,
+ state: PluginState.PENDING,
+ plugin: null,
+ });
+
+ if (this._isPathEndsWith(url, '.html')) {
+ this._importHtmlPlugin(url, opts && opts[path]);
+ } else if (this._isPathEndsWith(url, '.js')) {
+ this._loadJsPlugin(url);
+ } else {
+ this._failToLoad(`Unrecognized plugin url ${url}`, url);
+ }
+ });
+
+ this.awaitPluginsLoaded().then(() => {
+ console.info('Plugins loaded');
+ this._getReporting().pluginsLoaded(this._getAllInstalledPluginNames());
+ });
+ }
+
+ _isPathEndsWith(url, suffix) {
+ if (!(url instanceof URL)) {
+ try {
+ url = new URL(url);
+ } catch (e) {
+ console.warn(e);
+ return false;
+ }
+ }
+
+ return url.pathname && url.pathname.endsWith(suffix);
+ }
+
+ _getAllInstalledPluginNames() {
+ const installedPlugins = [];
+ for (const plugin of this._plugins.values()) {
+ if (plugin.state === PluginState.LOADED) {
+ installedPlugins.push(plugin.name);
+ }
+ }
+ return installedPlugins;
+ }
+
+ install(callback, opt_version, opt_src) {
+ // HTML import polyfill adds __importElement pointing to the import tag.
+ const script = document.currentScript &&
+ (document.currentScript.__importElement || document.currentScript);
+ let src = opt_src || (script && script.src);
+ if (!src || src.startsWith('data:')) {
+ src = script && script.baseURI;
+ }
+
+ if (opt_version && opt_version !== API_VERSION) {
+ this._failToLoad(`Plugin ${src} install error: only version ` +
+ API_VERSION + ' is supported in PolyGerrit. ' + opt_version +
+ ' was given.', src);
+ return;
+ }
+
+ const pluginObject = this.getPlugin(src);
+ let plugin = pluginObject && pluginObject.plugin;
+ if (!plugin) {
+ plugin = new Plugin(src);
+ }
+ try {
+ callback(plugin);
+ this._pluginInstalled(src, plugin);
+ } catch (e) {
+ this._failToLoad(`${e.name}: ${e.message}`, src);
+ }
+ }
+
+ get arePluginsLoaded() {
+ // As the size of plugins is relatively small,
+ // so the performance of this check should be reasonable
+ if (!this._pluginListLoaded) return false;
+ for (const plugin of this._plugins.values()) {
+ if (plugin.state === PluginState.PENDING) return false;
+ }
+ return true;
+ }
+
+ _checkIfCompleted() {
+ if (this.arePluginsLoaded && this._loadingResolver) {
+ this._loadingResolver();
+ this._loadingResolver = null;
+ this._loadingPromise = null;
+ }
+ }
+
+ _timeout() {
+ const pendingPlugins = [];
+ for (const plugin of this._plugins.values()) {
+ if (plugin.state === PluginState.PENDING) {
+ this._updatePluginState(plugin.url, PluginState.LOAD_FAILED);
+ this._checkIfCompleted();
+ pendingPlugins.push(plugin.url);
+ }
+ }
+ return `Timeout when loading plugins: ${pendingPlugins.join(',')}`;
+ }
+
+ _failToLoad(message, pluginUrl) {
+ // Show an alert with the error
+ document.dispatchEvent(new CustomEvent('show-alert', {
+ detail: {
+ message: `Plugin install error: ${message} from ${pluginUrl}`,
+ },
+ }));
+ this._updatePluginState(pluginUrl, PluginState.LOAD_FAILED);
+ this._checkIfCompleted();
+ }
+
+ _updatePluginState(pluginUrl, state) {
+ const key = this._getPluginKeyFromUrl(pluginUrl);
+ if (this._plugins.has(key)) {
+ this._plugins.get(key).state = state;
+ } else {
+ // Plugin is not recorded for some reason.
+ console.warn(`Plugin loaded separately: ${pluginUrl}`);
+ this._plugins.set(key, {
+ name: key,
+ url: pluginUrl,
+ state,
+ plugin: null,
+ });
+ }
+ return this._plugins.get(key);
+ }
+
+ _pluginInstalled(url, plugin) {
+ const pluginObj = this._updatePluginState(url, PluginState.LOADED);
+ pluginObj.plugin = plugin;
+ this._getReporting().pluginLoaded(plugin.getPluginName() || url);
+ console.log(`Plugin ${plugin.getPluginName() || url} installed.`);
+ this._checkIfCompleted();
+ }
+
+ installPreloadedPlugins() {
+ if (!window.Gerrit || !window.Gerrit._preloadedPlugins) { return; }
+ const Gerrit = window.Gerrit;
+ for (const name in Gerrit._preloadedPlugins) {
+ if (!Gerrit._preloadedPlugins.hasOwnProperty(name)) { continue; }
+ const callback = Gerrit._preloadedPlugins[name];
+ this.install(callback, API_VERSION, PRELOADED_PROTOCOL + name);
+ }
+ }
+
+ isPluginPreloaded(pathOrUrl) {
+ const url = this._urlFor(pathOrUrl);
+ const name = getPluginNameFromUrl(url);
+ if (name && window.Gerrit._preloadedPlugins) {
+ return window.Gerrit._preloadedPlugins.hasOwnProperty(name);
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Checks if given plugin path/url is enabled or not.
+ * @param {string} pathOrUrl
+ */
+ isPluginEnabled(pathOrUrl) {
+ const url = this._urlFor(pathOrUrl);
+ if (this.isPluginPreloaded(url)) return true;
+ const key = this._getPluginKeyFromUrl(url);
+ return this._plugins.has(key);
+ }
+
+ /**
+ * Returns the plugin object with a given url.
+ * @param {string} pathOrUrl
+ */
+ getPlugin(pathOrUrl) {
+ const key = this._getPluginKeyFromUrl(this._urlFor(pathOrUrl));
+ return this._plugins.get(key);
+ }
+
+ /**
+ * Checks if given plugin path/url is loaded or not.
+ * @param {string} pathOrUrl
+ */
+ isPluginLoaded(pathOrUrl) {
+ const url = this._urlFor(pathOrUrl);
+ const key = this._getPluginKeyFromUrl(url);
+ return this._plugins.has(key) ?
+ this._plugins.get(key).state === PluginState.LOADED :
+ false;
+ }
+
+ _importHtmlPlugin(pluginUrl, opts = {}) {
+ // onload (second param) needs to be a function. When null or undefined
+ // were passed, plugins were not loaded correctly.
+ (Polymer.importHref || Polymer.Base.importHref)(
+ this._urlFor(pluginUrl), () => {},
+ () => this._failToLoad(`${pluginUrl} import error`, pluginUrl),
+ !opts.sync);
+ }
+
+ _loadJsPlugin(pluginUrl) {
+ this._createScriptTag(this._urlFor(pluginUrl));
+ }
+
+ _createScriptTag(url) {
+ const el = document.createElement('script');
+ el.defer = true;
+ el.setAttribute('src', url);
+ el.onerror = () => this._failToLoad(`${url} load error`, url);
+ return document.body.appendChild(el);
+ }
+
+ _urlFor(pathOrUrl) {
+ if (!pathOrUrl) {
+ return pathOrUrl;
+ }
+ if (pathOrUrl.startsWith(PRELOADED_PROTOCOL) ||
+ pathOrUrl.startsWith('http')) {
+ // Plugins are loaded from another domain or preloaded.
+ return pathOrUrl;
+ }
+ if (!pathOrUrl.startsWith('/')) {
+ pathOrUrl = '/' + pathOrUrl;
+ }
+ return window.location.origin + getBaseUrl() + pathOrUrl;
+ }
+
+ awaitPluginsLoaded() {
+ // Resolve if completed.
+ this._checkIfCompleted();
+
+ if (this.arePluginsLoaded) {
+ return Promise.resolve();
+ }
+ if (!this._loadingPromise) {
+ let timerId;
+ this._loadingPromise =
+ Promise.race([
+ new Promise(resolve => this._loadingResolver = resolve),
+ new Promise((_, reject) => timerId = setTimeout(
+ () => {
+ reject(this._timeout());
+ }, PLUGIN_LOADING_TIMEOUT_MS)),
+ ]).then(() => {
+ if (timerId) clearTimeout(timerId);
+ });
+ }
+ return this._loadingPromise;
+ }
+ }
+
+ /**
+ * @typedef {{
+ * name:string,
+ * url:string,
+ * state:PluginState,
+ * plugin:Object
+ * }}
+ */
+ PluginLoader.PluginObject;
+
+ /**
+ * @typedef {{
+ * sync:boolean,
+ * }}
+ */
+ PluginLoader.PluginOption;
+
+ window.PluginLoader = PluginLoader;
+})(window);
\ No newline at end of file
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.html
new file mode 100644
index 0000000..ee54319
--- /dev/null
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.html
@@ -0,0 +1,502 @@
+<!DOCTYPE html>
+<!--
+@license
+Copyright (C) 2017 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.
+-->
+
+<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
+<title>gr-plugin-host</title>
+<script src="/test/common-test-setup.js"></script>
+<script src="/bower_components/webcomponentsjs/custom-elements-es5-adapter.js"></script>
+
+<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
+<script src="/bower_components/web-component-tester/browser.js"></script>
+<link rel="import" href="../../../test/common-test-setup.html"/>
+<link rel="import" href="gr-js-api-interface.html">
+
+<script>void(0);</script>
+
+<test-fixture id="basic">
+ <template>
+ <gr-js-api-interface></gr-js-api-interface>
+ </template>
+</test-fixture>
+
+<script>
+ const {PRELOADED_PROTOCOL, PLUGIN_LOADING_TIMEOUT_MS} = window._apiUtils;
+ suite('gr-plugin-loader tests', () => {
+ let plugin;
+ let sandbox;
+ let url;
+ let sendStub;
+
+ setup(() => {
+ this.clock = sinon.useFakeTimers();
+ sandbox = sinon.sandbox.create();
+ sendStub = sandbox.stub().returns(Promise.resolve({status: 200}));
+ stub('gr-rest-api-interface', {
+ getAccount() {
+ return Promise.resolve({name: 'Judy Hopps'});
+ },
+ send(...args) {
+ return sendStub(...args);
+ },
+ });
+ sandbox.stub(document.body, 'appendChild');
+ fixture('basic');
+ url = window.location.origin;
+ });
+
+ teardown(() => {
+ sandbox.restore();
+ this.clock.restore();
+ Gerrit._testOnly_resetPlugins();
+ });
+
+ test('reuse plugin for install calls', () => {
+ Gerrit.install(p => { plugin = p; }, '0.1',
+ 'http://test.com/plugins/testplugin/static/test.js');
+
+ let otherPlugin;
+ Gerrit.install(p => { otherPlugin = p; }, '0.1',
+ 'http://test.com/plugins/testplugin/static/test.js');
+ assert.strictEqual(plugin, otherPlugin);
+ });
+
+ test('flushes preinstalls if provided', () => {
+ assert.doesNotThrow(() => {
+ Gerrit._testOnly_flushPreinstalls();
+ });
+ window.Gerrit.flushPreinstalls = sandbox.stub();
+ Gerrit._testOnly_flushPreinstalls();
+ assert.isTrue(window.Gerrit.flushPreinstalls.calledOnce);
+ delete window.Gerrit.flushPreinstalls;
+ });
+
+ test('versioning', () => {
+ const callback = sandbox.spy();
+ Gerrit.install(callback, '0.0pre-alpha');
+ assert(callback.notCalled);
+ });
+
+ test('report pluginsLoaded', done => {
+ stub('gr-reporting', {
+ pluginsLoaded() {
+ done();
+ },
+ });
+ Gerrit._loadPlugins([]);
+ });
+
+ test('arePluginsLoaded', done => {
+ assert.isFalse(Gerrit._arePluginsLoaded());
+ const plugins = [
+ 'http://test.com/plugins/foo/static/test.js',
+ 'http://test.com/plugins/bar/static/test.js',
+ ];
+
+ Gerrit._loadPlugins(plugins);
+ assert.isFalse(Gerrit._arePluginsLoaded());
+ // Timeout on loading plugins
+ this.clock.tick(PLUGIN_LOADING_TIMEOUT_MS * 2);
+
+ flush(() => {
+ assert.isTrue(Gerrit._arePluginsLoaded());
+ done();
+ });
+ });
+
+ test('plugins installed successfully', done => {
+ sandbox.stub(Gerrit._pluginLoader, '_loadJsPlugin', url => {
+ Gerrit.install(() => void 0, undefined, url);
+ });
+ const pluginsLoadedStub = sandbox.stub();
+ stub('gr-reporting', {
+ pluginsLoaded: (...args) => pluginsLoadedStub(...args),
+ });
+
+ const plugins = [
+ 'http://test.com/plugins/foo/static/test.js',
+ 'http://test.com/plugins/bar/static/test.js',
+ ];
+ Gerrit._loadPlugins(plugins);
+
+ flush(() => {
+ assert.isTrue(pluginsLoadedStub.calledWithExactly(['foo', 'bar']));
+ assert.isTrue(Gerrit._arePluginsLoaded());
+ done();
+ });
+ });
+
+ test('isPluginEnabled and isPluginLoaded', done => {
+ sandbox.stub(Gerrit._pluginLoader, '_loadJsPlugin', url => {
+ Gerrit.install(() => void 0, undefined, url);
+ });
+ const pluginsLoadedStub = sandbox.stub();
+ stub('gr-reporting', {
+ pluginsLoaded: (...args) => pluginsLoadedStub(...args),
+ });
+
+ const plugins = [
+ 'http://test.com/plugins/foo/static/test.js',
+ 'http://test.com/plugins/bar/static/test.js',
+ 'bar/static/test.js',
+ ];
+ Gerrit._loadPlugins(plugins);
+ assert.isTrue(
+ plugins.every(plugin => Gerrit._pluginLoader.isPluginEnabled(plugin))
+ );
+
+ flush(() => {
+ assert.isTrue(Gerrit._arePluginsLoaded());
+ assert.isTrue(
+ plugins.every(plugin => Gerrit._pluginLoader.isPluginLoaded(plugin))
+ );
+
+ done();
+ });
+ });
+
+ test('plugins installed mixed result, 1 fail 1 succeed', done => {
+ const plugins = [
+ 'http://test.com/plugins/foo/static/test.js',
+ 'http://test.com/plugins/bar/static/test.js',
+ ];
+
+ const alertStub = sandbox.stub();
+ document.addEventListener('show-alert', alertStub);
+
+ sandbox.stub(Gerrit._pluginLoader, '_loadJsPlugin', url => {
+ Gerrit.install(() => {
+ if (url === plugins[0]) {
+ throw new Error('failed');
+ }
+ }, undefined, url);
+ });
+
+ const pluginsLoadedStub = sandbox.stub();
+ stub('gr-reporting', {
+ pluginsLoaded: (...args) => pluginsLoadedStub(...args),
+ });
+
+ Gerrit._loadPlugins(plugins);
+
+ flush(() => {
+ assert.isTrue(pluginsLoadedStub.calledWithExactly(['bar']));
+ assert.isTrue(Gerrit._arePluginsLoaded());
+ assert.isTrue(alertStub.calledOnce);
+ done();
+ });
+ });
+
+ test('isPluginEnabled and isPluginLoaded for mixed results', done => {
+ const plugins = [
+ 'http://test.com/plugins/foo/static/test.js',
+ 'http://test.com/plugins/bar/static/test.js',
+ ];
+
+ const alertStub = sandbox.stub();
+ document.addEventListener('show-alert', alertStub);
+
+ sandbox.stub(Gerrit._pluginLoader, '_loadJsPlugin', url => {
+ Gerrit.install(() => {
+ if (url === plugins[0]) {
+ throw new Error('failed');
+ }
+ }, undefined, url);
+ });
+
+ const pluginsLoadedStub = sandbox.stub();
+ stub('gr-reporting', {
+ pluginsLoaded: (...args) => pluginsLoadedStub(...args),
+ });
+
+ Gerrit._loadPlugins(plugins);
+ assert.isTrue(
+ plugins.every(plugin => Gerrit._pluginLoader.isPluginEnabled(plugin))
+ );
+
+ flush(() => {
+ assert.isTrue(pluginsLoadedStub.calledWithExactly(['bar']));
+ assert.isTrue(Gerrit._arePluginsLoaded());
+ assert.isTrue(alertStub.calledOnce);
+ assert.isTrue(Gerrit._pluginLoader.isPluginLoaded(plugins[1]));
+ assert.isFalse(Gerrit._pluginLoader.isPluginLoaded(plugins[0]));
+ done();
+ });
+ });
+
+ test('plugins installed all failed', done => {
+ const plugins = [
+ 'http://test.com/plugins/foo/static/test.js',
+ 'http://test.com/plugins/bar/static/test.js',
+ ];
+
+ const alertStub = sandbox.stub();
+ document.addEventListener('show-alert', alertStub);
+
+ sandbox.stub(Gerrit._pluginLoader, '_loadJsPlugin', url => {
+ Gerrit.install(() => {
+ throw new Error('failed');
+ }, undefined, url);
+ });
+
+ const pluginsLoadedStub = sandbox.stub();
+ stub('gr-reporting', {
+ pluginsLoaded: (...args) => pluginsLoadedStub(...args),
+ });
+
+ Gerrit._loadPlugins(plugins);
+
+ flush(() => {
+ assert.isTrue(pluginsLoadedStub.calledWithExactly([]));
+ assert.isTrue(Gerrit._arePluginsLoaded());
+ assert.isTrue(alertStub.calledTwice);
+ done();
+ });
+ });
+
+ test('plugins installed failed becasue of wrong version', done => {
+ const plugins = [
+ 'http://test.com/plugins/foo/static/test.js',
+ 'http://test.com/plugins/bar/static/test.js',
+ ];
+
+ const alertStub = sandbox.stub();
+ document.addEventListener('show-alert', alertStub);
+
+ sandbox.stub(Gerrit._pluginLoader, '_loadJsPlugin', url => {
+ Gerrit.install(() => {
+ }, url === plugins[0] ? '' : 'alpha', url);
+ });
+
+ const pluginsLoadedStub = sandbox.stub();
+ stub('gr-reporting', {
+ pluginsLoaded: (...args) => pluginsLoadedStub(...args),
+ });
+
+ Gerrit._loadPlugins(plugins);
+
+ flush(() => {
+ assert.isTrue(pluginsLoadedStub.calledWithExactly(['foo']));
+ assert.isTrue(Gerrit._arePluginsLoaded());
+ assert.isTrue(alertStub.calledOnce);
+ done();
+ });
+ });
+
+ test('multiple assets for same plugin installed successfully', done => {
+ sandbox.stub(Gerrit._pluginLoader, '_loadJsPlugin', url => {
+ Gerrit.install(() => void 0, undefined, url);
+ });
+ const pluginsLoadedStub = sandbox.stub();
+ stub('gr-reporting', {
+ pluginsLoaded: (...args) => pluginsLoadedStub(...args),
+ });
+
+ const plugins = [
+ 'http://test.com/plugins/foo/static/test.js',
+ 'http://test.com/plugins/foo/static/test2.js',
+ 'http://test.com/plugins/bar/static/test.js',
+ ];
+ Gerrit._loadPlugins(plugins);
+
+ flush(() => {
+ assert.isTrue(pluginsLoadedStub.calledWithExactly(['foo', 'bar']));
+ assert.isTrue(Gerrit._arePluginsLoaded());
+ done();
+ });
+ });
+
+ suite('plugin path and url', () => {
+ let importHtmlPluginStub;
+ let loadJsPluginStub;
+ setup(() => {
+ importHtmlPluginStub = sandbox.stub();
+ sandbox.stub(Gerrit._pluginLoader, '_importHtmlPlugin', url => {
+ importHtmlPluginStub(url);
+ });
+ loadJsPluginStub = sandbox.stub();
+ sandbox.stub(Gerrit._pluginLoader, '_loadJsPlugin', url => {
+ loadJsPluginStub(url);
+ });
+ });
+
+ test('invalid plugin path', () => {
+ const failToLoadStub = sandbox.stub();
+ sandbox.stub(Gerrit._pluginLoader, '_failToLoad', (...args) => {
+ failToLoadStub(...args);
+ });
+
+ Gerrit._loadPlugins([
+ 'foo/bar',
+ ]);
+
+ assert.isTrue(failToLoadStub.calledOnce);
+ assert.isTrue(failToLoadStub.calledWithExactly(
+ `Unrecognized plugin url ${url}/foo/bar`,
+ `${url}/foo/bar`
+ ));
+ });
+
+ test('relative path for plugins', () => {
+ Gerrit._loadPlugins([
+ 'foo/bar.js',
+ 'foo/bar.html',
+ ]);
+
+ assert.isTrue(importHtmlPluginStub.calledOnce);
+ assert.isTrue(
+ importHtmlPluginStub.calledWithExactly(`${url}/foo/bar.html`)
+ );
+ assert.isTrue(loadJsPluginStub.calledOnce);
+ assert.isTrue(
+ loadJsPluginStub.calledWithExactly(`${url}/foo/bar.js`)
+ );
+ });
+
+
+ test('relative path should honor getBaseUrl', () => {
+ const testUrl = '/test';
+ sandbox.stub(Gerrit.BaseUrlBehavior, 'getBaseUrl', () => {
+ return testUrl;
+ });
+
+ Gerrit._loadPlugins([
+ 'foo/bar.js',
+ 'foo/bar.html',
+ ]);
+
+ assert.isTrue(importHtmlPluginStub.calledOnce);
+ assert.isTrue(loadJsPluginStub.calledOnce);
+ assert.isTrue(
+ importHtmlPluginStub.calledWithExactly(
+ `${url}${testUrl}/foo/bar.html`
+ )
+ );
+ assert.isTrue(
+ loadJsPluginStub.calledWithExactly(`${url}${testUrl}/foo/bar.js`)
+ );
+ });
+
+ test('absolute path for plugins', () => {
+ Gerrit._loadPlugins([
+ 'http://e.com/foo/bar.js',
+ 'http://e.com/foo/bar.html',
+ ]);
+
+ assert.isTrue(importHtmlPluginStub.calledOnce);
+ assert.isTrue(
+ importHtmlPluginStub.calledWithExactly(`http://e.com/foo/bar.html`)
+ );
+ assert.isTrue(loadJsPluginStub.calledOnce);
+ assert.isTrue(
+ loadJsPluginStub.calledWithExactly(`http://e.com/foo/bar.js`)
+ );
+ });
+ });
+
+ test('adds js plugins will call the body', () => {
+ Gerrit._loadPlugins([
+ 'http://e.com/foo/bar.js',
+ 'http://e.com/bar/foo.js',
+ ]);
+ assert.isTrue(document.body.appendChild.calledTwice);
+ });
+
+ test('can call awaitPluginsLoaded multiple times', done => {
+ const plugins = [
+ 'http://e.com/foo/bar.js',
+ 'http://e.com/bar/foo.js',
+ ];
+
+ let installed = false;
+ function pluginCallback(url) {
+ if (url === plugins[1]) {
+ installed = true;
+ }
+ }
+ sandbox.stub(Gerrit._pluginLoader, '_loadJsPlugin', url => {
+ Gerrit.install(() => pluginCallback(url), undefined, url);
+ });
+
+ Gerrit._loadPlugins(plugins);
+
+ Gerrit.awaitPluginsLoaded().then(() => {
+ assert.isTrue(installed);
+
+ Gerrit.awaitPluginsLoaded().then(() => {
+ done();
+ });
+ });
+ });
+
+ suite('preloaded plugins', () => {
+ test('skips preloaded plugins when load plugins', () => {
+ const importHtmlPluginStub = sandbox.stub();
+ sandbox.stub(Gerrit._pluginLoader, '_importHtmlPlugin', url => {
+ importHtmlPluginStub(url);
+ });
+ const loadJsPluginStub = sandbox.stub();
+ sandbox.stub(Gerrit._pluginLoader, '_loadJsPlugin', url => {
+ loadJsPluginStub(url);
+ });
+
+ Gerrit._preloadedPlugins = {
+ foo: () => void 0,
+ bar: () => void 0,
+ };
+
+ Gerrit._loadPlugins([
+ 'http://e.com/plugins/foo.js',
+ 'plugins/bar.html',
+ 'http://e.com/plugins/test/foo.js',
+ ]);
+
+ assert.isTrue(importHtmlPluginStub.notCalled);
+ assert.isTrue(loadJsPluginStub.calledOnce);
+ });
+
+ test('isPluginPreloaded', () => {
+ Gerrit._preloadedPlugins = {baz: ()=>{}};
+ assert.isFalse(Gerrit._pluginLoader.isPluginPreloaded('plugins/foo/bar'));
+ assert.isFalse(Gerrit._pluginLoader.isPluginPreloaded('http://a.com/42'));
+ assert.isTrue(
+ Gerrit._pluginLoader.isPluginPreloaded(PRELOADED_PROTOCOL + 'baz')
+ );
+ Gerrit._preloadedPlugins = null;
+ });
+
+ test('preloaded plugins are installed', () => {
+ const installStub = sandbox.stub();
+ Gerrit._preloadedPlugins = {foo: installStub};
+ Gerrit._pluginLoader.installPreloadedPlugins();
+ assert.isTrue(installStub.called);
+ const pluginApi = installStub.lastCall.args[0];
+ assert.strictEqual(pluginApi.getPluginName(), 'foo');
+ });
+
+ test('installing preloaded plugin', () => {
+ let plugin;
+ window.ASSETS_PATH = 'http://blips.com/chitz';
+ Gerrit.install(p => { plugin = p; }, '0.1', 'preloaded:foo');
+ assert.strictEqual(plugin.getPluginName(), 'foo');
+ assert.strictEqual(plugin.url('/some/thing.html'),
+ 'http://blips.com/chitz/plugins/foo/some/thing.html');
+ delete window.ASSETS_PATH;
+ });
+ });
+ });
+</script>
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api.js
index 984b870..af8bd9e 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api.js
@@ -38,6 +38,10 @@
return getRestApi().getVersion();
};
+ GrPluginRestApi.prototype.getConfig = function() {
+ return getRestApi().getConfig();
+ };
+
GrPluginRestApi.prototype.invalidateReposCache = function() {
getRestApi().invalidateReposCache();
};
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api_test.html
index 8626280..bcbd961 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-rest-api_test.html
@@ -44,12 +44,12 @@
send: sendStub,
getLoggedIn: sandbox.stub(),
getVersion: sandbox.stub(),
+ getConfig: sandbox.stub(),
};
stub('gr-rest-api-interface', Object.keys(restApiStub).reduce((a, k) => {
a[k] = (...args) => restApiStub[k](...args);
return a;
}, {}));
- Gerrit._setPluginsCount(1);
Gerrit.install(p => { plugin = p; }, '0.1',
'http://test.com/plugins/testplugin/static/test.js');
instance = new GrPluginRestApi();
@@ -135,12 +135,20 @@
});
});
- test('getConfig', () => {
+ test('getVersion', () => {
restApiStub.getVersion.returns(Promise.resolve('foo bar'));
return instance.getVersion().then(result => {
assert.isTrue(restApiStub.getVersion.calledOnce);
assert.equal(result, 'foo bar');
});
});
+
+ test('getConfig', () => {
+ restApiStub.getConfig.returns(Promise.resolve('foo bar'));
+ return instance.getConfig().then(result => {
+ assert.isTrue(restApiStub.getConfig.calledOnce);
+ assert.equal(result, 'foo bar');
+ });
+ });
});
</script>
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.js
index d44acea..d76c983 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.js
@@ -267,10 +267,14 @@
return;
}
return this.registerCustomComponent(
- Gerrit._getPluginScreenName(this.getPluginName(), screenName),
+ this._getScreenName(screenName),
opt_moduleName);
};
+ Plugin.prototype._getScreenName = function(screenName) {
+ return `${this.getPluginName()}-screen-${screenName}`;
+ };
+
const deprecatedAPI = {
_loadedGwt: ()=> {},
@@ -321,7 +325,7 @@
'Please use strings for patterns.');
return;
}
- this.hook(Gerrit._getPluginScreenName(this.getPluginName(), pattern))
+ this.hook(this._getScreenName(pattern))
.onAttached(el => {
el.style.display = 'none';
callback({
diff --git a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.html b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.html
index 54765df..4ff031a 100644
--- a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.html
+++ b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.html
@@ -31,7 +31,7 @@
<style include="shared-styles">
.placeholder {
color: var(--deemphasized-text-color);
- padding-top: .2em;
+ padding-top: var(--spacing-xs);
}
.hidden {
display: none;
@@ -39,8 +39,8 @@
.voteChip {
display: flex;
justify-content: center;
- margin-right: .3em;
- padding: .05em .85em;
+ margin-right: var(--spacing-s);
+ padding: var(--spacing-xxs) var(--spacing-m);
@apply --vote-chip-styles;
}
.max {
@@ -75,14 +75,14 @@
color: var(--border-color);
}
gr-account-chip {
- margin-right: .25em;
+ margin-right: var(--spacing-xs);
}
iron-icon {
height: 1.2em;
width: 1.2em;
}
.labelValueContainer:not(:first-of-type) td {
- padding-top: .3em;
+ padding-top: var(--spacing-s);
}
</style>
<table>
diff --git a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.js b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.js
index fa4a154..3eb44e6 100644
--- a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.js
+++ b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-label-info',
- _legacyUndefinedCheck: true,
properties: {
labelInfo: Object,
@@ -149,7 +148,7 @@
* order to trigger computation when a label is removed from the change.
*/
_computeShowPlaceholder(labelInfo, changeLabelsRecord) {
- if (labelInfo.all) {
+ if (labelInfo && labelInfo.all) {
for (const label of labelInfo.all) {
if (label.value && label.value != labelInfo.default_value) {
return 'hidden';
diff --git a/polygerrit-ui/app/elements/shared/gr-label/gr-label.js b/polygerrit-ui/app/elements/shared/gr-label/gr-label.js
index c437885..0de0881 100644
--- a/polygerrit-ui/app/elements/shared/gr-label/gr-label.js
+++ b/polygerrit-ui/app/elements/shared/gr-label/gr-label.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-label',
- _legacyUndefinedCheck: true,
behaviors: [
Gerrit.TooltipBehavior,
diff --git a/polygerrit-ui/app/elements/shared/gr-labeled-autocomplete/gr-labeled-autocomplete.html b/polygerrit-ui/app/elements/shared/gr-labeled-autocomplete/gr-labeled-autocomplete.html
index 986bce1..4eca569 100644
--- a/polygerrit-ui/app/elements/shared/gr-labeled-autocomplete/gr-labeled-autocomplete.html
+++ b/polygerrit-ui/app/elements/shared/gr-labeled-autocomplete/gr-labeled-autocomplete.html
@@ -28,7 +28,7 @@
#container {
background: var(--chip-background-color);
border-radius: 1em;
- padding: .5em;
+ padding: var(--spacing-m);
}
#header {
color: var(--deemphasized-text-color);
@@ -48,7 +48,7 @@
border-left: 1px solid var(--deemphasized-text-color);
color: var(--deemphasized-text-color);
cursor: pointer;
- padding-left: .4em;
+ padding-left: var(--spacing-s);
}
#trigger:hover {
color: var(--primary-text-color);
diff --git a/polygerrit-ui/app/elements/shared/gr-labeled-autocomplete/gr-labeled-autocomplete.js b/polygerrit-ui/app/elements/shared/gr-labeled-autocomplete/gr-labeled-autocomplete.js
index a892522..54b38eb 100644
--- a/polygerrit-ui/app/elements/shared/gr-labeled-autocomplete/gr-labeled-autocomplete.js
+++ b/polygerrit-ui/app/elements/shared/gr-labeled-autocomplete/gr-labeled-autocomplete.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-labeled-autocomplete',
- _legacyUndefinedCheck: true,
/**
* Fired when a value is chosen.
diff --git a/polygerrit-ui/app/elements/shared/gr-lib-loader/gr-lib-loader.js b/polygerrit-ui/app/elements/shared/gr-lib-loader/gr-lib-loader.js
index adc8619..08e668b 100644
--- a/polygerrit-ui/app/elements/shared/gr-lib-loader/gr-lib-loader.js
+++ b/polygerrit-ui/app/elements/shared/gr-lib-loader/gr-lib-loader.js
@@ -22,7 +22,6 @@
Polymer({
is: 'gr-lib-loader',
- _legacyUndefinedCheck: true,
properties: {
_hljsState: {
diff --git a/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text.js b/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text.js
index db13942..048e4f5 100644
--- a/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text.js
+++ b/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text.js
@@ -26,7 +26,6 @@
Polymer({
is: 'gr-limited-text',
- _legacyUndefinedCheck: true,
properties: {
/** The un-truncated text to display. */
diff --git a/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.html b/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.html
index de09cd4..f3e0906 100644
--- a/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.html
+++ b/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.html
@@ -35,17 +35,16 @@
background: var(--chip-background-color);
border-radius: .75em;
display: inline-flex;
- padding: 0 .5em;
+ padding: 0 var(--spacing-m);
}
gr-button.remove {
--gr-remove-button-style: {
border: 0;
color: var(--deemphasized-text-color);
- font-size: 1.7rem;
font-weight: normal;
height: .6em;
- line-height: .6;
- margin-left: .15em;
+ line-height: 10px;
+ margin-left: var(--spacing-xs);
padding: 0;
text-decoration: none;
}
diff --git a/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.js b/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.js
index ee8653f..33a9c25 100644
--- a/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.js
+++ b/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-linked-chip',
- _legacyUndefinedCheck: true,
properties: {
href: String,
diff --git a/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text.js b/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text.js
index e9d6e84..e7247b9 100644
--- a/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text.js
+++ b/polygerrit-ui/app/elements/shared/gr-linked-text/gr-linked-text.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-linked-text',
- _legacyUndefinedCheck: true,
properties: {
removeZeroWidthSpace: Boolean,
diff --git a/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.html b/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.html
index 63004c0..a4f75da 100644
--- a/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.html
+++ b/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.html
@@ -27,7 +27,6 @@
<template>
<style include="shared-styles">
#filter {
- font-size: var(--font-size-normal);
max-width: 25em;
}
#filter:focus {
@@ -38,7 +37,7 @@
display: flex;
height: 3rem;
justify-content: space-between;
- margin: 0 1em;
+ margin: 0 var(--spacing-l);
}
#createNewContainer:not(.show) {
display: none;
diff --git a/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.js b/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.js
index d70d753..8d81030 100644
--- a/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.js
+++ b/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.js
@@ -21,7 +21,6 @@
Polymer({
is: 'gr-list-view',
- _legacyUndefinedCheck: true,
properties: {
createNew: Boolean,
diff --git a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.js b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.js
index bba5a46..8623458 100644
--- a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.js
+++ b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.js
@@ -23,7 +23,6 @@
Polymer({
is: 'gr-overlay',
- _legacyUndefinedCheck: true,
/**
* Fired when a fullscreen overlay is closed
diff --git a/polygerrit-ui/app/elements/shared/gr-page-nav/gr-page-nav.js b/polygerrit-ui/app/elements/shared/gr-page-nav/gr-page-nav.js
index 0962540..9ccff600 100644
--- a/polygerrit-ui/app/elements/shared/gr-page-nav/gr-page-nav.js
+++ b/polygerrit-ui/app/elements/shared/gr-page-nav/gr-page-nav.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-page-nav',
- _legacyUndefinedCheck: true,
properties: {
_headerHeight: Number,
diff --git a/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.html b/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.html
index 416815b..ce596f8 100644
--- a/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.html
+++ b/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.html
@@ -33,7 +33,7 @@
display: inline-block;
}
iron-icon {
- margin-bottom: 1.2em;
+ margin-bottom: var(--spacing-l);
}
</style>
<div>
diff --git a/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.js b/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.js
index 2fccc8d..e2298c3 100644
--- a/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.js
+++ b/polygerrit-ui/app/elements/shared/gr-repo-branch-picker/gr-repo-branch-picker.js
@@ -22,7 +22,6 @@
Polymer({
is: 'gr-repo-branch-picker',
- _legacyUndefinedCheck: true,
properties: {
repo: {
diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
index 59f7d74..c84a113 100644
--- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
+++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
@@ -109,7 +109,6 @@
Polymer({
is: 'gr-rest-api-interface',
- _legacyUndefinedCheck: true,
behaviors: [
Gerrit.FireBehavior,
@@ -1267,6 +1266,7 @@
*/
getChangeFilePathsAsSpeciallySortedArray(changeNum, patchRange) {
return this.getChangeFiles(changeNum, patchRange).then(files => {
+ if (!files) return;
return Object.keys(files).sort(this.specialFilePathCompare);
});
},
diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/mock-diff-response_test.html b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/mock-diff-response_test.html
index 9a24ddc..015d71e 100644
--- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/mock-diff-response_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/mock-diff-response_test.html
@@ -153,7 +153,7 @@
Polymer({
is: 'mock-diff-response',
- _legacyUndefinedCheck: true,
+
properties: {
diffResponse: {
type: Object,
diff --git a/polygerrit-ui/app/elements/shared/gr-select/gr-select.js b/polygerrit-ui/app/elements/shared/gr-select/gr-select.js
index 333bede..05267ba 100644
--- a/polygerrit-ui/app/elements/shared/gr-select/gr-select.js
+++ b/polygerrit-ui/app/elements/shared/gr-select/gr-select.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-select',
- _legacyUndefinedCheck: true,
properties: {
bindValue: {
diff --git a/polygerrit-ui/app/elements/shared/gr-shell-command/gr-shell-command.html b/polygerrit-ui/app/elements/shared/gr-shell-command/gr-shell-command.html
index dbbf98b..15e282f 100644
--- a/polygerrit-ui/app/elements/shared/gr-shell-command/gr-shell-command.html
+++ b/polygerrit-ui/app/elements/shared/gr-shell-command/gr-shell-command.html
@@ -23,25 +23,30 @@
<template>
<style include="shared-styles">
.commandContainer {
- margin-bottom: .75em;
+ margin-bottom: var(--spacing-m);
}
.commandContainer {
background-color: var(--shell-command-background-color);
- padding: .5em .5em .5em 2.5em;
+ /* Should be spacing-m larger than the :before width. */
+ padding: var(--spacing-m) var(--spacing-m) var(--spacing-m) calc(3*var(--spacing-m) + 0.5em);
position: relative;
width: 100%;
}
.commandContainer:before {
- background: var(--shell-command-decoration-background-color);
- bottom: 0;
- box-sizing: border-box;
content: '$';
- display: block;
- left: 0;
- padding: .8em;
position: absolute;
+ display: block;
+ box-sizing: border-box;
+ background: var(--shell-command-decoration-background-color);
top: 0;
- width: 2em;
+ bottom: 0;
+ left: 0;
+ /* Should be spacing-m smaller than the .commandContainer padding-left. */
+ width: calc(2*var(--spacing-m) + 0.5em);
+ /* Should vertically match the padding of .commandContainer. */
+ padding: var(--spacing-m);
+ /* Should roughly match the height of .commandContainer without padding. */
+ line-height: 26px;
}
.commandContainer gr-copy-clipboard {
--text-container-style: {
diff --git a/polygerrit-ui/app/elements/shared/gr-shell-command/gr-shell-command.js b/polygerrit-ui/app/elements/shared/gr-shell-command/gr-shell-command.js
index 901b8ce..2c546cc 100644
--- a/polygerrit-ui/app/elements/shared/gr-shell-command/gr-shell-command.js
+++ b/polygerrit-ui/app/elements/shared/gr-shell-command/gr-shell-command.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-shell-command',
- _legacyUndefinedCheck: true,
properties: {
command: String,
diff --git a/polygerrit-ui/app/elements/shared/gr-storage/gr-storage.js b/polygerrit-ui/app/elements/shared/gr-storage/gr-storage.js
index 0690950..9ae77d9 100644
--- a/polygerrit-ui/app/elements/shared/gr-storage/gr-storage.js
+++ b/polygerrit-ui/app/elements/shared/gr-storage/gr-storage.js
@@ -30,7 +30,6 @@
Polymer({
is: 'gr-storage',
- _legacyUndefinedCheck: true,
properties: {
_lastCleanup: Number,
diff --git a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.html b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.html
index fa54dba..ad1a039 100644
--- a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.html
+++ b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.html
@@ -24,6 +24,7 @@
<link rel="import" href="/bower_components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
<link rel="import" href="/bower_components/iron-autogrow-textarea/iron-autogrow-textarea.html">
<link rel="import" href="../../../styles/shared-styles.html">
+<link rel="import" href="../../core/gr-reporting/gr-reporting.html">
<dom-module id="gr-textarea">
<template>
@@ -96,6 +97,7 @@
max-rows="[[maxRows]]"
value="{{text}}"
on-bind-value-changed="_onValueChanged"></iron-autogrow-textarea>
+ <gr-reporting id="reporting"></gr-reporting>
</template>
<script src="gr-textarea.js"></script>
</dom-module>
diff --git a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.js b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.js
index 1f90211..f751a0d 100644
--- a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.js
+++ b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.js
@@ -54,7 +54,6 @@
Polymer({
is: 'gr-textarea',
- _legacyUndefinedCheck: true,
/**
* @event bind-value-changed
@@ -83,7 +82,6 @@
_colonIndex: Number,
_currentSearchString: {
type: String,
- value: '',
observer: '_determineSuggestions',
},
_hideAutocomplete: {
@@ -114,7 +112,6 @@
},
ready() {
- this._resetEmojiDropdown();
if (this.monospace) {
this.classList.add('monospace');
}
@@ -154,6 +151,7 @@
e.stopPropagation();
this.$.emojiSuggestions.cursorUp();
this.$.textarea.textarea.focus();
+ this.disableEnterKeyForSelectingEmoji = false;
},
_handleDownKey(e) {
@@ -162,24 +160,34 @@
e.stopPropagation();
this.$.emojiSuggestions.cursorDown();
this.$.textarea.textarea.focus();
+ this.disableEnterKeyForSelectingEmoji = false;
},
_handleEnterByKey(e) {
- if (this._hideAutocomplete) { return; }
+ if (this._hideAutocomplete || this.disableEnterKeyForSelectingEmoji) {
+ return;
+ }
e.preventDefault();
e.stopPropagation();
- this.text = this._getText(this.$.emojiSuggestions.getCurrentText());
- this._resetEmojiDropdown();
+ this._setEmoji(this.$.emojiSuggestions.getCurrentText());
},
_handleEmojiSelect(e) {
- this.text = this._getText(e.detail.selected.dataset.value);
+ this._setEmoji(e.detail.selected.dataset.value);
+ },
+
+ _setEmoji(text) {
+ const colonIndex = this._colonIndex;
+ this.text = this._getText(text);
+ this.$.textarea.selectionStart = colonIndex + 1;
+ this.$.textarea.selectionEnd = colonIndex + 1;
+ this.$.reporting.reportInteraction('select-emoji');
this._resetEmojiDropdown();
},
_getText(value) {
return this.text.substr(0, this._colonIndex || 0) +
- value + this.text.substr(this.$.textarea.selectionStart) + ' ';
+ value + this.text.substr(this.$.textarea.selectionStart);
},
/**
* Uses a hidden element with the same width and styling of the textarea and
@@ -219,41 +227,41 @@
// If cursor is not in textarea (just opened with colon as last char),
// Don't do anything.
if (!e.currentTarget.focused) { return; }
- const newChar = e.detail.value[this.$.textarea.selectionStart - 1];
- // When a colon is detected, set a colon index, but don't do anything else
- // yet.
- if (newChar === ':') {
+ const charAtCursor = e.detail && e.detail.value ?
+ e.detail.value[this.$.textarea.selectionStart - 1] : '';
+ if (charAtCursor !== ':' && this._colonIndex == null) { return; }
+
+ // When a colon is detected, set a colon index.
+ if (charAtCursor === ':') {
this._colonIndex = this.$.textarea.selectionStart - 1;
- // If the colon index exists, continue to determine what needs to be done
- // with the dropdown. It may be open or closed at this point.
- } else if (this._colonIndex !== null) {
- // The search string is a substring of the textarea's value from (1
- // position after) the colon index to the cursor position.
- this._currentSearchString = e.detail.value.substr(this._colonIndex + 1,
- this.$.textarea.selectionStart);
- // Under the following conditions, close and reset the dropdown:
- // - The cursor is no longer at the end of the current search string
- // - The search string is an space or new line
- // - The colon has been removed
- // - There are no suggestions that match the search string
- if (this.$.textarea.selectionStart !==
- this._currentSearchString.length + this._colonIndex + 1 ||
- this._currentSearchString === ' ' ||
- this._currentSearchString === '\n' ||
- !(e.detail.value[this._colonIndex] === ':') ||
- !this._suggestions.length) {
- this._resetEmojiDropdown();
- // Otherwise open the dropdown and set the position to be just below the
- // cursor.
- } else if (this.$.emojiSuggestions.isHidden) {
- this._updateCaratPosition();
- }
- this.$.textarea.textarea.focus();
}
+
+ this._currentSearchString = e.detail.value.substr(this._colonIndex + 1,
+ this.$.textarea.selectionStart - this._colonIndex - 1);
+ // Under the following conditions, close and reset the dropdown:
+ // - The cursor is no longer at the end of the current search string
+ // - The search string is an space or new line
+ // - The colon has been removed
+ // - There are no suggestions that match the search string
+ if (this.$.textarea.selectionStart !==
+ this._currentSearchString.length + this._colonIndex + 1 ||
+ this._currentSearchString === ' ' ||
+ this._currentSearchString === '\n' ||
+ !(e.detail.value[this._colonIndex] === ':') ||
+ !this._suggestions.length) {
+ this._resetEmojiDropdown();
+ // Otherwise open the dropdown and set the position to be just below the
+ // cursor.
+ } else if (this.$.emojiSuggestions.isHidden) {
+ this._updateCaratPosition();
+ }
+ this.$.textarea.textarea.focus();
},
+
_openEmojiDropdown() {
this.$.emojiSuggestions.open();
+ this.$.reporting.reportInteraction('open-emoji-dropdown');
},
_formatSuggestions(matchedSuggestions) {
@@ -269,11 +277,14 @@
_determineSuggestions(emojiText) {
if (!emojiText.length) {
this._formatSuggestions(ALL_SUGGESTIONS);
+ this.disableEnterKeyForSelectingEmoji = true;
+ } else {
+ const matches = ALL_SUGGESTIONS.filter(suggestion => {
+ return suggestion.match.includes(emojiText);
+ }).slice(0, MAX_ITEMS_DROPDOWN);
+ this._formatSuggestions(matches);
+ this.disableEnterKeyForSelectingEmoji = false;
}
- const matches = ALL_SUGGESTIONS.filter(suggestion => {
- return suggestion.match.includes(emojiText);
- }).splice(0, MAX_ITEMS_DROPDOWN);
- this._formatSuggestions(matches);
},
_resetEmojiDropdown() {
diff --git a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea_test.html b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea_test.html
index 077f4b7..854dda9 100644
--- a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea_test.html
@@ -53,6 +53,7 @@
setup(() => {
sandbox = sinon.sandbox.create();
element = fixture('basic');
+ sandbox.stub(element.$.reporting, 'reportInteraction');
});
teardown(() => {
@@ -90,6 +91,21 @@
element.$.textarea.selectionStart = 1;
element.$.textarea.selectionEnd = 1;
element.text = ':';
+ flushAsynchronousOperations();
+ assert.isFalse(element.$.emojiSuggestions.isHidden);
+ assert.equal(element._colonIndex, 0);
+ assert.isFalse(element._hideAutocomplete);
+ assert.equal(element._currentSearchString, '');
+ });
+
+ test('emoji selector opens when a colon is typed and some substring',
+ () => {
+ MockInteractions.focus(element.$.textarea);
+ // Needed for Safari tests. selectionStart is not updated when text is
+ // updated.
+ element.$.textarea.selectionStart = 1;
+ element.$.textarea.selectionEnd = 1;
+ element.text = ':';
element.$.textarea.selectionStart = 2;
element.$.textarea.selectionEnd = 2;
element.text = ':t';
@@ -100,6 +116,30 @@
assert.equal(element._currentSearchString, 't');
});
+ test('emoji selector opens when a colon is typed in middle of text',
+ () => {
+ MockInteractions.focus(element.$.textarea);
+ // Needed for Safari tests. selectionStart is not updated when text is
+ // updated.
+ element.$.textarea.selectionStart = 1;
+ element.$.textarea.selectionEnd = 1;
+ // Since selectionStart is on Chrome set always on end of text, we
+ // stub it to 1
+ const text = ': hello';
+ sandbox.stub(element.$, 'textarea', {
+ selectionStart: 1,
+ value: text,
+ textarea: {
+ focus: () => {},
+ },
+ });
+ element.text = text;
+ flushAsynchronousOperations();
+ assert.isFalse(element.$.emojiSuggestions.isHidden);
+ assert.equal(element._colonIndex, 0);
+ assert.isFalse(element._hideAutocomplete);
+ assert.equal(element._currentSearchString, '');
+ });
test('emoji selector closes when text changes before the colon', () => {
const resetStub = sandbox.stub(element, '_resetEmojiDropdown');
MockInteractions.focus(element.$.textarea);
@@ -161,7 +201,7 @@
const selectedItem = {dataset: {value: '😂'}};
const event = {detail: {selected: selectedItem}};
element._handleEmojiSelect(event);
- assert.equal(element.text, 'test test 😂 ');
+ assert.equal(element.text, 'test test 😂');
});
test('_updateCaratPosition', () => {
@@ -236,8 +276,21 @@
MockInteractions.pressAndReleaseKeyOn(element.$.textarea, 13);
assert.isTrue(enterSpy.called);
flushAsynchronousOperations();
- // A space is automatically added at the end.
- assert.equal(element.text, '💯 ');
+ assert.equal(element.text, '💯');
+ });
+
+ test('enter key - ignored on just colon without more information', () => {
+ const enterSpy = sandbox.spy(element.$.emojiSuggestions,
+ 'getCursorTarget');
+ MockInteractions.pressAndReleaseKeyOn(element.$.textarea, 13);
+ assert.isFalse(enterSpy.called);
+ MockInteractions.focus(element.$.textarea);
+ element.$.textarea.selectionStart = 1;
+ element.$.textarea.selectionEnd = 1;
+ element.text = ':';
+ flushAsynchronousOperations();
+ MockInteractions.pressAndReleaseKeyOn(element.$.textarea, 13);
+ assert.isFalse(enterSpy.called);
});
});
});
diff --git a/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content.js b/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content.js
index b46cafb..c5de8f4 100644
--- a/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content.js
+++ b/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-tooltip-content',
- _legacyUndefinedCheck: true,
properties: {
title: {
diff --git a/polygerrit-ui/app/elements/shared/gr-tooltip/gr-tooltip.html b/polygerrit-ui/app/elements/shared/gr-tooltip/gr-tooltip.html
index 36378f6..1f608e5 100644
--- a/polygerrit-ui/app/elements/shared/gr-tooltip/gr-tooltip.html
+++ b/polygerrit-ui/app/elements/shared/gr-tooltip/gr-tooltip.html
@@ -34,7 +34,7 @@
max-width: var(--tooltip-max-width);
}
:host .tooltip {
- padding: .5em .85em;
+ padding: var(--spacing-m) var(--spacing-l);
}
:host .arrowPositionBelow,
:host([position-below]) .arrowPositionAbove {
diff --git a/polygerrit-ui/app/elements/shared/gr-tooltip/gr-tooltip.js b/polygerrit-ui/app/elements/shared/gr-tooltip/gr-tooltip.js
index 3e16beb..fb87b558 100644
--- a/polygerrit-ui/app/elements/shared/gr-tooltip/gr-tooltip.js
+++ b/polygerrit-ui/app/elements/shared/gr-tooltip/gr-tooltip.js
@@ -19,7 +19,6 @@
Polymer({
is: 'gr-tooltip',
- _legacyUndefinedCheck: true,
properties: {
text: String,
diff --git a/polygerrit-ui/app/samples/bind-parameters.html b/polygerrit-ui/app/samples/bind-parameters.html
index a7eb39a..a28c462 100644
--- a/polygerrit-ui/app/samples/bind-parameters.html
+++ b/polygerrit-ui/app/samples/bind-parameters.html
@@ -15,7 +15,7 @@
<script>
Polymer({
is: 'my-bind-sample',
- _legacyUndefinedCheck: true,
+
properties: {
computedExample: {
type: String,
diff --git a/polygerrit-ui/app/samples/repo-command.html b/polygerrit-ui/app/samples/repo-command.html
index 37aca04..526d350 100644
--- a/polygerrit-ui/app/samples/repo-command.html
+++ b/polygerrit-ui/app/samples/repo-command.html
@@ -29,7 +29,7 @@
<script>
Polymer({
is: 'repo-command-low',
- _legacyUndefinedCheck: true,
+
attached() {
console.log(this.repoName);
console.log(this.config);
diff --git a/polygerrit-ui/app/samples/some-screen.html b/polygerrit-ui/app/samples/some-screen.html
index 527ebce..da025a2 100644
--- a/polygerrit-ui/app/samples/some-screen.html
+++ b/polygerrit-ui/app/samples/some-screen.html
@@ -38,7 +38,7 @@
<script>
Polymer({
is: 'some-screen-main',
- _legacyUndefinedCheck: true,
+
properties: {
rootUrl: String,
},
diff --git a/polygerrit-ui/app/styles/dashboard-header-styles.html b/polygerrit-ui/app/styles/dashboard-header-styles.html
index ccc17b0..88d50c0 100644
--- a/polygerrit-ui/app/styles/dashboard-header-styles.html
+++ b/polygerrit-ui/app/styles/dashboard-header-styles.html
@@ -34,7 +34,7 @@
}
.info {
display: inline-block;
- padding: 1em;
+ padding: var(--spacing-l);
vertical-align: top;
}
.info > div > span {
diff --git a/polygerrit-ui/app/styles/gr-change-list-styles.html b/polygerrit-ui/app/styles/gr-change-list-styles.html
index 8f72216..a6b2497 100644
--- a/polygerrit-ui/app/styles/gr-change-list-styles.html
+++ b/polygerrit-ui/app/styles/gr-change-list-styles.html
@@ -17,9 +17,6 @@
<dom-module id="gr-change-list-styles">
<template>
<style>
- :host {
- font-size: var(--font-size-normal);
- }
gr-change-list-item,
tr {
border-top: 1px solid var(--border-color);
@@ -123,7 +120,7 @@
vertical-align: middle;
}
.leftPadding {
- width: var(--default-horizontal-margin);
+ width: var(--spacing-l);
}
.star {
width: 30px;
@@ -165,12 +162,12 @@
}
@media only screen and (max-width: 50em) {
:host {
- font-size: var(--font-size-large);
+ font-size: var(--font-size-h3);
}
gr-change-list-item {
flex-wrap: wrap;
justify-content: space-between;
- padding: .25em .5em;
+ padding: var(--spacing-xs) var(--spacing-m);
}
gr-change-list-item[selected],
gr-change-list-item:focus {
@@ -199,10 +196,10 @@
}
.groupHeader .cell,
.noChanges .cell {
- padding: 0 .5em;
+ padding: 0 var(--spacing-m);
}
.subject {
- margin-bottom: .25em;
+ margin-bottom: var(--spacing-xs);
width: calc(100% - 2em);
}
.owner,
@@ -214,11 +211,6 @@
height: auto;
}
}
- @media only screen and (min-width: 1450px) {
- :host {
- font-size: 14px;
- }
- }
</style>
</template>
</dom-module>
diff --git a/polygerrit-ui/app/styles/gr-change-metadata-shared-styles.html b/polygerrit-ui/app/styles/gr-change-metadata-shared-styles.html
index 591158e..d7bf975 100644
--- a/polygerrit-ui/app/styles/gr-change-metadata-shared-styles.html
+++ b/polygerrit-ui/app/styles/gr-change-metadata-shared-styles.html
@@ -23,11 +23,7 @@
section:not(:first-of-type) .title,
section:not(:first-of-type) .value {
- padding-top: .5em;
- }
-
- section:not(:first-of-type) {
- margin-top: 1em;
+ padding-top: var(--spacing-s);
}
.title,
@@ -40,7 +36,7 @@
font-weight: var(--font-weight-bold);
max-width: 20em;
padding-left: var(--metadata-horizontal-padding);
- padding-right: .5em;
+ padding-right: var(--spacing-m);
word-break: break-word;
}
@@ -49,4 +45,4 @@
}
</style>
</template>
-</dom-module>
\ No newline at end of file
+</dom-module>
diff --git a/polygerrit-ui/app/styles/gr-change-view-integration-shared-styles.html b/polygerrit-ui/app/styles/gr-change-view-integration-shared-styles.html
index bebb0bb..c9b84fb 100644
--- a/polygerrit-ui/app/styles/gr-change-view-integration-shared-styles.html
+++ b/polygerrit-ui/app/styles/gr-change-view-integration-shared-styles.html
@@ -26,18 +26,17 @@
<dom-module id="gr-change-view-integration-shared-styles">
<template>
<style>
- /* TODO(taoalpha): update spacings once change 241809 submitted */
.header {
color: var(--primary-text-color);
background-color: var(--table-header-background-color);
justify-content: space-between;
- padding: .5em var(--default-horizontal-margin, 1rem);
+ padding: var(--spacing-m) var(--spacing-l);
border-bottom: 1px solid var(--border-color);
}
.header .label {
font-weight: var(--font-weight-bold);
- font-size: 1.17em;
- margin: 0 1em 0 0;
+ font-size: var(--font-size-h3);
+ margin: 0 var(--spacing-l) 0 0;
}
.header .note {
color: var(--deemphasized-text-color);
diff --git a/polygerrit-ui/app/styles/gr-form-styles.html b/polygerrit-ui/app/styles/gr-form-styles.html
index 65c1ae3..d80dfa8 100644
--- a/polygerrit-ui/app/styles/gr-form-styles.html
+++ b/polygerrit-ui/app/styles/gr-form-styles.html
@@ -27,18 +27,18 @@
}
.gr-form-styles h1,
.gr-form-styles h2 {
- margin-bottom: .3em;
+ margin-bottom: var(--spacing-s);
}
.gr-form-styles h4 {
font-weight: var(--font-weight-bold);
}
.gr-form-styles fieldset {
border: none;
- margin-bottom: 2em;
+ margin-bottom: var(--spacing-xxl);
}
.gr-form-styles section {
display: flex;
- margin: .25em 0;
+ margin: var(--spacing-s) 0;
min-height: 2em;
}
.gr-form-styles section * {
@@ -51,12 +51,9 @@
.gr-form-styles .title {
color: var(--deemphasized-text-color);
font-weight: var(--font-weight-bold);
- padding-right: .5em;
+ padding-right: var(--spacing-m);
width: 15em;
}
- .gr-form-styles iron-autogrow-textarea {
- font-size: var(--font-size-normal);
- }
.gr-form-styles th {
color: var(--deemphasized-text-color);
text-align: left;
@@ -65,7 +62,7 @@
.gr-form-styles td,
.gr-form-styles tfoot th {
height: 2em;
- padding: .25em 0;
+ padding: var(--spacing-s) 0;
vertical-align: middle;
}
.gr-form-styles .emptyHeader {
@@ -87,9 +84,8 @@
.gr-form-styles textarea {
border: 1px solid var(--border-color);
border-radius: 2px;
- font-size: var(--font-size-normal);
height: 2em;
- padding: 0 .15em;
+ padding: 0 var(--spacing-xs);
}
.gr-form-styles td:last-child {
width: 5em;
@@ -106,8 +102,7 @@
border: 1px solid var(--border-color);
border-radius: 2px;
box-sizing: border-box;
- font-size: var(--font-size-normal);
- padding: .25em .15em 0 .15em;
+ padding: var(--spacing-s) var(--spacing-xs) 0 var(--spacing-xs);
}
}
.gr-form-styles gr-autocomplete {
@@ -115,15 +110,14 @@
--gr-autocomplete: {
border: 1px solid var(--border-color);
border-radius: 2px;
- font-size: var(--font-size-normal);
height: 2em;
- padding: 0 .15em;
+ padding: 0 var(--spacing-xs);
width: 14em;
}
}
@media only screen and (max-width: 40em) {
.gr-form-styles section {
- margin-bottom: 1em;
+ margin-bottom: var(--spacing-l);
}
.gr-form-styles .title,
.gr-form-styles .value {
diff --git a/polygerrit-ui/app/styles/gr-menu-page-styles.html b/polygerrit-ui/app/styles/gr-menu-page-styles.html
index 48ca396..d3b95b8 100644
--- a/polygerrit-ui/app/styles/gr-menu-page-styles.html
+++ b/polygerrit-ui/app/styles/gr-menu-page-styles.html
@@ -22,12 +22,12 @@
display: block;
}
main {
- margin: 2em auto;
+ margin: var(--spacing-xxl) auto;
max-width: 50em;
}
.mainHeader {
margin-left: 14em;
- padding: 1em 0 1em 2em;
+ padding: var(--spacing-l) 0 var(--spacing-l) var(--spacing-xxl);
}
main.table,
.mainHeader {
@@ -42,11 +42,11 @@
}
.loading {
color: var(--deemphasized-text-color);
- padding: 1em var(--default-horizontal-margin);
+ padding: var(--spacing-l);
}
@media only screen and (max-width: 67em) {
main {
- margin: 2em 0 2em 15em;
+ margin: var(--spacing-xxl) 0 var(--spacing-xxl) 15em;
}
main.table {
margin-left: 14em;
@@ -54,17 +54,17 @@
}
@media only screen and (max-width: 53em) {
.loading {
- padding: 0 var(--default-horizontal-margin);
+ padding: 0 var(--spacing-l);
}
main {
- margin: 2em 1em;
+ margin: var(--spacing-xxl) var(--spacing-l);
}
main.table {
margin: 0;
}
.mainHeader {
margin-left: 0;
- padding: .5em 0 .5em 1em;
+ padding: var(--spacing-m) 0 var(--spacing-m) var(--spacing-l);
}
}
</style>
diff --git a/polygerrit-ui/app/styles/gr-page-nav-styles.html b/polygerrit-ui/app/styles/gr-page-nav-styles.html
index 18ec143..ced6ecb 100644
--- a/polygerrit-ui/app/styles/gr-page-nav-styles.html
+++ b/polygerrit-ui/app/styles/gr-page-nav-styles.html
@@ -18,13 +18,13 @@
<template>
<style>
.navStyles ul {
- padding: 1em 0;
+ padding: var(--spacing-l) 0;
}
.navStyles li {
border-bottom: 1px solid transparent;
border-top: 1px solid transparent;
display: block;
- padding: 0 calc(var(--default-horizontal-margin) + 0.5em);
+ padding: 0 var(--spacing-xl);
}
.navStyles li a {
display: block;
@@ -33,20 +33,20 @@
white-space: nowrap;
}
.navStyles .subsectionItem {
- padding-left: calc(var(--default-horizontal-margin) + 1.5em);
+ padding-left: var(--spacing-xxl);
}
.navStyles .hideSubsection {
display: none;
}
.navStyles li.sectionTitle {
- padding: 0 2em 0 var(--default-horizontal-margin);
+ padding: 0 var(--spacing-xxl) 0 var(--spacing-l);
}
.navStyles li.sectionTitle:not(:first-child) {
- margin-top: 1em;
+ margin-top: var(--spacing-l);
}
.navStyles .title {
font-weight: var(--font-weight-bold);
- margin: .4em 0;
+ margin: var(--spacing-s) 0;
}
.navStyles .selected {
background-color: var(--view-background-color);
@@ -57,7 +57,7 @@
.navStyles a {
color: var(--primary-text-color);
display: inline-block;
- margin: .4em 0;
+ margin: var(--spacing-s) 0;
}
</style>
</template>
diff --git a/polygerrit-ui/app/styles/gr-subpage-styles.html b/polygerrit-ui/app/styles/gr-subpage-styles.html
index 098a604..222c38b 100644
--- a/polygerrit-ui/app/styles/gr-subpage-styles.html
+++ b/polygerrit-ui/app/styles/gr-subpage-styles.html
@@ -18,7 +18,7 @@
<template>
<style>
main {
- margin: 1em 1em;
+ margin: var(--spacing-l);
}
.loading {
display: none;
diff --git a/polygerrit-ui/app/styles/gr-table-styles.html b/polygerrit-ui/app/styles/gr-table-styles.html
index 1308952..d4e4bcf 100644
--- a/polygerrit-ui/app/styles/gr-table-styles.html
+++ b/polygerrit-ui/app/styles/gr-table-styles.html
@@ -24,7 +24,7 @@
}
.genericList td {
height: 2.25rem;
- padding: .3rem 0;
+ padding: var(--spacing-s) 0;
vertical-align: middle;
}
.genericList tr {
@@ -38,11 +38,11 @@
}
.genericList th,
.genericList td {
- padding-right: 1rem;
+ padding-right: var(--spacing-l);
}
.genericList tr th:first-of-type,
.genericList tr td:first-of-type {
- padding-left: 1rem;
+ padding-left: var(--spacing-l);
}
.genericList tr:first-of-type {
border-top: 1px solid var(--border-color);
@@ -51,7 +51,7 @@
.genericList tr td:last-of-type {
border-left: 1px solid var(--border-color);
text-align: center;
- padding: 0 1em;
+ padding: 0 var(--spacing-l);
}
.genericList tr th.delete,
.genericList tr td.delete,
@@ -78,7 +78,7 @@
}
.genericList .groupHeader {
background-color: var(--table-subheader-background-color);
- font-size: var(--font-size-large);
+ font-size: var(--font-size-h3);
}
.genericList a {
color: var(--primary-text-color);
@@ -93,7 +93,7 @@
.genericList .loadingMsg {
color: var(--deemphasized-text-color);
display: block;
- padding: .3em var(--default-horizontal-margin);
+ padding: var(--spacing-s) var(--spacing-l);
}
.genericList .loadingMsg:not(.loading) {
display: none;
diff --git a/polygerrit-ui/app/styles/main.css b/polygerrit-ui/app/styles/main.css
index 618a2d71..0d61b8a 100644
--- a/polygerrit-ui/app/styles/main.css
+++ b/polygerrit-ui/app/styles/main.css
@@ -42,6 +42,8 @@
* Work around this using font-size and font-family.
*/
-webkit-text-size-adjust: none;
- font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
- line-height: 1.4;
+ font-family: var(--font-family, ''), 'Roboto', Arial, sans-serif;
+ font-size: var(--font-size-normal, 1rem);
+ line-height: var(--line-height-normal, 1.4);
+ color: var(--primary-text-color, black);
}
diff --git a/polygerrit-ui/app/styles/shared-styles.html b/polygerrit-ui/app/styles/shared-styles.html
index 14fee4f..da424a5 100644
--- a/polygerrit-ui/app/styles/shared-styles.html
+++ b/polygerrit-ui/app/styles/shared-styles.html
@@ -17,7 +17,9 @@
<dom-module id="shared-styles">
<template>
<style>
+
/* CSS reset */
+
html, body, button, div, span, applet, object, iframe, h1, h2, h3,
h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite,
code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub,
@@ -55,9 +57,6 @@
button {
font: inherit;
}
- body {
- line-height: 1;
- }
ol, ul {
list-style: none;
}
@@ -73,25 +72,42 @@
border-collapse: collapse;
border-spacing: 0;
}
- /* Other Shared Styles*/
- h1 {
- font-size: 2rem;
- font-weight: var(--font-weight-bold);
+
+ /* Fonts */
+
+ .font-normal {
+ font-size: var(--font-size-normal);
+ font-weight: var(--font-weight-normal);
+ line-height: var(--line-height-normal);
}
- h2 {
- font-size: 1.5rem;
- font-weight: var(--font-weight-bold);
+ .font-small {
+ font-size: var(--font-size-small);
+ font-weight: var(--font-weight-normal);
+ line-height: var(--line-height-small);
}
- h3 {
- font-size: 1.17em;
+ h1, .font-h1 {
+ font-size: var(--font-size-h1);
font-weight: var(--font-weight-bold);
+ line-height: var(--line-height-h1);
+ }
+ h2, .font-h2 {
+ font-size: var(--font-size-h2);
+ font-weight: var(--font-weight-bold);
+ line-height: var(--line-height-h2);
+ }
+ h3, .font-h3 {
+ font-size: var(--font-size-h3);
+ font-weight: var(--font-weight-bold);
+ line-height: var(--line-height-h3);
}
iron-icon {
color: var(--deemphasized-text-color);
--iron-icon-height: 20px;
--iron-icon-width: 20px;
}
+
/* Stopgap solution until we remove hidden$ attributes. */
+
[hidden] {
display: none !important;
}
@@ -110,9 +126,6 @@
strong {
font-weight: var(--font-weight-bold);
}
- :host {
- color: var(--primary-text-color);
- }
</style>
</template>
</dom-module>
diff --git a/polygerrit-ui/app/styles/themes/app-theme.html b/polygerrit-ui/app/styles/themes/app-theme.html
index 91bcd69..6369096 100644
--- a/polygerrit-ui/app/styles/themes/app-theme.html
+++ b/polygerrit-ui/app/styles/themes/app-theme.html
@@ -30,7 +30,7 @@
--primary-text-color: black;
--link-color: #2a66d9;
--comment-text-color: black;
- --deemphasized-text-color: #757575;
+ --deemphasized-text-color: #616161;
--default-button-text-color: #2a66d9;
--error-text-color: red;
--primary-button-text-color: white;
@@ -74,15 +74,29 @@
/* fonts */
--font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
- --font-size-normal: 1rem;
- --font-size-small: .92rem;
- --font-size-large: 1.154rem;
- /* Used on text for change list that needs user's attention. */
- --font-weight-bold: 500;
--monospace-font-family: 'Roboto Mono', Menlo, 'Lucida Console', Monaco, monospace;
+ --font-size-small: .92rem; /* 12px */
+ --font-size-normal: 1rem; /* 13px */
+ --font-size-h3: 1.154rem; /* 15px */
+ --font-size-h2: 1.5rem; /* 19.5px */
+ --font-size-h1: 2rem; /* 26px */
+ --line-height-mono: 16px;
+ --line-height-small: 1.4; /* 16.8px */
+ --line-height-normal: 1.4; /* 18.2px */
+ --line-height-h3: 1.4; /* 21.0px */
+ --line-height-h2: 1.4; /* 27.3px */
+ --line-height-h1: 1.4; /* 36.4px */
+ --font-weight-normal: 400;
+ --font-weight-bold: 500;
/* spacing */
- --default-horizontal-margin: 1rem;
+ --spacing-xxs: 1px;
+ --spacing-xs: 2px;
+ --spacing-s: 4px;
+ --spacing-m: 8px;
+ --spacing-l: 12px;
+ --spacing-xl: 16px;
+ --spacing-xxl: 24px;
/* header and footer */
--footer-background-color: #eee;
@@ -150,7 +164,13 @@
}
@media screen and (max-width: 50em) {
html {
- --default-horizontal-margin: .7rem;
+ --spacing-xxs: 1px;
+ --spacing-xs: 1px;
+ --spacing-s: 2px;
+ --spacing-m: 4px;
+ --spacing-l: 8px;
+ --spacing-xl: 12px;
+ --spacing-xxl: 16px;
}
}
</style></custom-style>
diff --git a/polygerrit-ui/app/styles/themes/dark-theme.html b/polygerrit-ui/app/styles/themes/dark-theme.html
index 9027ddc..0097bb6 100644
--- a/polygerrit-ui/app/styles/themes/dark-theme.html
+++ b/polygerrit-ui/app/styles/themes/dark-theme.html
@@ -30,7 +30,7 @@
--primary-text-color: #e8eaed;
--link-color: #8ab4f8;
--comment-text-color: var(--primary-text-color);
- --deemphasized-text-color: #9aa0a6;
+ --deemphasized-text-color: #9e9e9e;
--default-button-text-color: #8ab4f8;
--error-text-color: red;
--primary-button-text-color: var(--primary-text-color);
@@ -59,7 +59,7 @@
--shell-command-background-color: #5f5f5f;
--shell-command-decoration-background-color: #999;
--table-header-background-color: #131416;
- --table-subheader-background-color: #3c4043;
+ --table-subheader-background-color: rgba(158, 158, 158, 0.24);
--tooltip-background-color: #111;
--unresolved-comment-background-color: #385a9a;
--view-background-color: #131416;
@@ -73,7 +73,6 @@
--border-color: #5f6368;
/* fonts */
- /* Used on text for change list that needs user's attention. */
--font-weight-bold: 900;
/* spacing */
diff --git a/polygerrit-ui/app/test/common-test-setup.html b/polygerrit-ui/app/test/common-test-setup.html
index 65c66b5..17dc05e 100644
--- a/polygerrit-ui/app/test/common-test-setup.html
+++ b/polygerrit-ui/app/test/common-test-setup.html
@@ -62,6 +62,5 @@
</script>
<link rel="import"
href="/bower_components/iron-test-helpers/iron-test-helpers.html" />
-<link rel="import" href="/bower_components/polymer/lib/legacy/legacy-data-mixin.html">
<link rel="import" href="test-router.html" />
<script src="/bower_components/moment/moment.js"></script>
diff --git a/polygerrit-ui/app/test/index.html b/polygerrit-ui/app/test/index.html
index a1c3ae6..cb1fcef 100644
--- a/polygerrit-ui/app/test/index.html
+++ b/polygerrit-ui/app/test/index.html
@@ -188,6 +188,7 @@
'shared/gr-js-api-interface/gr-js-api-interface_test.html',
'shared/gr-js-api-interface/gr-gerrit_test.html',
'shared/gr-js-api-interface/gr-plugin-action-context_test.html',
+ 'shared/gr-js-api-interface/gr-plugin-loader_test.html',
'shared/gr-js-api-interface/gr-plugin-endpoints_test.html',
'shared/gr-js-api-interface/gr-plugin-rest-api_test.html',
'shared/gr-fixed-panel/gr-fixed-panel_test.html',