Merge "Fix caching for SubmitRecords in ChangeData"
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index 91fe24b..23720460 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -5189,6 +5189,13 @@
+
By default 50.
+[[suggest.skipServiceUsers]]suggest.skipServiceUsers::
++
+If link:access-control.html#service_users[service users] should be skipped when
+suggesting reviewers.
++
+By default true.
+
[[tracing]]
=== Section tracing
diff --git a/Documentation/js_licenses.txt b/Documentation/js_licenses.txt
index 48e729f..7ef9473 100644
--- a/Documentation/js_licenses.txt
+++ b/Documentation/js_licenses.txt
@@ -247,6 +247,38 @@
----
+[[DefinitelyTyped]]
+DefinitelyTyped
+
+* @types/resize-observer-browser
+
+[[DefinitelyTyped_license]]
+----
+ MIT License
+
+ Copyright (c) Microsoft Corporation.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE
+
+----
+
+
[[Polymer-2014]]
Polymer-2014
diff --git a/Documentation/licenses.txt b/Documentation/licenses.txt
index b7cdf8a..5f0fb65 100644
--- a/Documentation/licenses.txt
+++ b/Documentation/licenses.txt
@@ -3204,6 +3204,38 @@
----
+[[DefinitelyTyped]]
+DefinitelyTyped
+
+* @types/resize-observer-browser
+
+[[DefinitelyTyped_license]]
+----
+ MIT License
+
+ Copyright (c) Microsoft Corporation.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE
+
+----
+
+
[[Polymer-2014]]
Polymer-2014
diff --git a/Documentation/rest-api-config.txt b/Documentation/rest-api-config.txt
index 9764c8a..a8d9b3d 100644
--- a/Documentation/rest-api-config.txt
+++ b/Documentation/rest-api-config.txt
@@ -1839,6 +1839,8 @@
Whether to enable the web UI for editing GPG keys.
|`report_bug_url` |optional|
link:config-gerrit.html#gerrit.reportBugUrl[URL to report bugs].
+|`instance_id` |optional|
+link:config-gerrit.html#gerrit.instanceId[Short identifier for this Gerrit installation].
|=================================
[[index-config-info]]
diff --git a/Documentation/user-search.txt b/Documentation/user-search.txt
index e02dc21..52c282e 100644
--- a/Documentation/user-search.txt
+++ b/Documentation/user-search.txt
@@ -190,6 +190,13 @@
+
Changes occurring in projects starting with 'PREFIX'.
+[[parentof]]
+parentof:'ID'::
+Changes which are parent to the change specified by 'ID'. Change 'ID' can be
+specified as a legacy numerical 'ID' such as 15183, or a Change-Id that can be
+picked from the commit message. This operator will return immediate parents
+and will not return grand parents or higher level ancestors of the given change.
+
[[parentproject]]
parentproject:'PROJECT'::
+
diff --git a/java/com/google/gerrit/extensions/common/ActionInfo.java b/java/com/google/gerrit/extensions/common/ActionInfo.java
index 6ab80b2..2144ed5 100644
--- a/java/com/google/gerrit/extensions/common/ActionInfo.java
+++ b/java/com/google/gerrit/extensions/common/ActionInfo.java
@@ -15,6 +15,7 @@
package com.google.gerrit.extensions.common;
import com.google.gerrit.extensions.webui.UiAction;
+import java.util.Objects;
/**
* Representation of an action in the REST API.
@@ -55,4 +56,23 @@
title = d.getTitle();
enabled = d.isEnabled() ? true : null;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof ActionInfo) {
+ ActionInfo actionInfo = (ActionInfo) o;
+ return Objects.equals(method, actionInfo.method)
+ && Objects.equals(label, actionInfo.label)
+ && Objects.equals(title, actionInfo.title)
+ && Objects.equals(enabled, actionInfo.enabled);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(method, label, title, enabled);
+ }
+
+ protected ActionInfo() {}
}
diff --git a/java/com/google/gerrit/extensions/common/ApprovalInfo.java b/java/com/google/gerrit/extensions/common/ApprovalInfo.java
index f95ddff..bf72e83 100644
--- a/java/com/google/gerrit/extensions/common/ApprovalInfo.java
+++ b/java/com/google/gerrit/extensions/common/ApprovalInfo.java
@@ -16,6 +16,7 @@
import com.google.gerrit.common.Nullable;
import java.sql.Timestamp;
+import java.util.Objects;
/**
* Representation of an approval in the REST API.
@@ -71,4 +72,23 @@
this.date = date;
this.tag = tag;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof ApprovalInfo) {
+ ApprovalInfo approvalInfo = (ApprovalInfo) o;
+ return super.equals(o)
+ && Objects.equals(tag, approvalInfo.tag)
+ && Objects.equals(value, approvalInfo.value)
+ && Objects.equals(date, approvalInfo.date)
+ && Objects.equals(postSubmit, approvalInfo.postSubmit)
+ && Objects.equals(permittedVotingRange, approvalInfo.permittedVotingRange);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), tag, value, date, postSubmit, permittedVotingRange);
+ }
}
diff --git a/java/com/google/gerrit/extensions/common/AttentionSetInfo.java b/java/com/google/gerrit/extensions/common/AttentionSetInfo.java
index f29d32b..ba865fb 100644
--- a/java/com/google/gerrit/extensions/common/AttentionSetInfo.java
+++ b/java/com/google/gerrit/extensions/common/AttentionSetInfo.java
@@ -15,6 +15,7 @@
package com.google.gerrit.extensions.common;
import java.sql.Timestamp;
+import java.util.Objects;
/**
* Represents a single user included in the attention set. Used in the API. See {@link
@@ -36,4 +37,22 @@
this.lastUpdate = lastUpdate;
this.reason = reason;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof AttentionSetInfo) {
+ AttentionSetInfo attentionSetInfo = (AttentionSetInfo) o;
+ return Objects.equals(account, attentionSetInfo.account)
+ && Objects.equals(lastUpdate, attentionSetInfo.lastUpdate)
+ && Objects.equals(reason, attentionSetInfo.reason);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(account, lastUpdate, reason);
+ }
+
+ protected AttentionSetInfo() {}
}
diff --git a/java/com/google/gerrit/extensions/common/AvatarInfo.java b/java/com/google/gerrit/extensions/common/AvatarInfo.java
index 75665a8..b620ac2 100644
--- a/java/com/google/gerrit/extensions/common/AvatarInfo.java
+++ b/java/com/google/gerrit/extensions/common/AvatarInfo.java
@@ -14,6 +14,8 @@
package com.google.gerrit.extensions.common;
+import java.util.Objects;
+
/**
* Representation of an avatar in the REST API.
*
@@ -38,4 +40,20 @@
/** The width of the avatar image in pixels. */
public Integer width;
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof AvatarInfo) {
+ AvatarInfo avatarInfo = (AvatarInfo) o;
+ return Objects.equals(url, avatarInfo.url)
+ && Objects.equals(height, avatarInfo.height)
+ && Objects.equals(width, avatarInfo.width);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(url, height, width);
+ }
}
diff --git a/java/com/google/gerrit/extensions/common/FetchInfo.java b/java/com/google/gerrit/extensions/common/FetchInfo.java
index eda84b1..4b1e941 100644
--- a/java/com/google/gerrit/extensions/common/FetchInfo.java
+++ b/java/com/google/gerrit/extensions/common/FetchInfo.java
@@ -15,6 +15,7 @@
package com.google.gerrit.extensions.common;
import java.util.Map;
+import java.util.Objects;
public class FetchInfo {
public String url;
@@ -25,4 +26,22 @@
this.url = url;
this.ref = ref;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof FetchInfo) {
+ FetchInfo fetchInfo = (FetchInfo) o;
+ return Objects.equals(url, fetchInfo.url)
+ && Objects.equals(ref, fetchInfo.ref)
+ && Objects.equals(commands, fetchInfo.commands);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(url, ref, commands);
+ }
+
+ protected FetchInfo() {}
}
diff --git a/java/com/google/gerrit/extensions/common/GerritInfo.java b/java/com/google/gerrit/extensions/common/GerritInfo.java
index 2ae6703..3265a00 100644
--- a/java/com/google/gerrit/extensions/common/GerritInfo.java
+++ b/java/com/google/gerrit/extensions/common/GerritInfo.java
@@ -23,4 +23,5 @@
public Boolean editGpgKeys;
public String reportBugUrl;
public String primaryWeblinkName;
+ public String instanceId;
}
diff --git a/java/com/google/gerrit/extensions/common/GpgKeyInfo.java b/java/com/google/gerrit/extensions/common/GpgKeyInfo.java
index 7a5c15b..d656f22 100644
--- a/java/com/google/gerrit/extensions/common/GpgKeyInfo.java
+++ b/java/com/google/gerrit/extensions/common/GpgKeyInfo.java
@@ -15,6 +15,7 @@
package com.google.gerrit.extensions.common;
import java.util.List;
+import java.util.Objects;
public class GpgKeyInfo {
/**
@@ -43,4 +44,22 @@
public Status status;
public List<String> problems;
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof GpgKeyInfo) {
+ GpgKeyInfo gpgKeyInfo = (GpgKeyInfo) o;
+ return Objects.equals(id, gpgKeyInfo.id)
+ && Objects.equals(fingerprint, gpgKeyInfo.fingerprint)
+ && Objects.equals(userIds, gpgKeyInfo.userIds)
+ && Objects.equals(status, gpgKeyInfo.status)
+ && Objects.equals(problems, gpgKeyInfo.problems);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, fingerprint, userIds, status, problems);
+ }
}
diff --git a/java/com/google/gerrit/extensions/common/LabelInfo.java b/java/com/google/gerrit/extensions/common/LabelInfo.java
index 76dd93d..44bcdaf 100644
--- a/java/com/google/gerrit/extensions/common/LabelInfo.java
+++ b/java/com/google/gerrit/extensions/common/LabelInfo.java
@@ -16,6 +16,7 @@
import java.util.List;
import java.util.Map;
+import java.util.Objects;
public class LabelInfo {
public AccountInfo approved;
@@ -30,4 +31,37 @@
public Short defaultValue;
public Boolean optional;
public Boolean blocking;
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof LabelInfo) {
+ LabelInfo labelInfo = (LabelInfo) o;
+ return Objects.equals(approved, labelInfo.approved)
+ && Objects.equals(rejected, labelInfo.rejected)
+ && Objects.equals(recommended, labelInfo.recommended)
+ && Objects.equals(disliked, labelInfo.disliked)
+ && Objects.equals(all, labelInfo.all)
+ && Objects.equals(values, labelInfo.values)
+ && Objects.equals(value, labelInfo.value)
+ && Objects.equals(defaultValue, labelInfo.defaultValue)
+ && Objects.equals(optional, labelInfo.optional)
+ && Objects.equals(blocking, labelInfo.blocking);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ approved,
+ rejected,
+ recommended,
+ disliked,
+ all,
+ values,
+ value,
+ defaultValue,
+ optional,
+ blocking);
+ }
}
diff --git a/java/com/google/gerrit/extensions/common/PluginDefinedInfo.java b/java/com/google/gerrit/extensions/common/PluginDefinedInfo.java
index 69bfa2c..e2b1c36 100644
--- a/java/com/google/gerrit/extensions/common/PluginDefinedInfo.java
+++ b/java/com/google/gerrit/extensions/common/PluginDefinedInfo.java
@@ -14,7 +14,24 @@
package com.google.gerrit.extensions.common;
+import java.util.Objects;
+
public class PluginDefinedInfo {
public String name;
public String message;
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof PluginDefinedInfo) {
+ PluginDefinedInfo pluginDefinedInfo = (PluginDefinedInfo) o;
+ return Objects.equals(name, pluginDefinedInfo.name)
+ && Objects.equals(message, pluginDefinedInfo.message);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, message);
+ }
}
diff --git a/java/com/google/gerrit/extensions/common/PushCertificateInfo.java b/java/com/google/gerrit/extensions/common/PushCertificateInfo.java
index 9eed808..199dbd1 100644
--- a/java/com/google/gerrit/extensions/common/PushCertificateInfo.java
+++ b/java/com/google/gerrit/extensions/common/PushCertificateInfo.java
@@ -14,7 +14,24 @@
package com.google.gerrit.extensions.common;
+import java.util.Objects;
+
public class PushCertificateInfo {
public String certificate;
public GpgKeyInfo key;
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof PushCertificateInfo) {
+ PushCertificateInfo pushCertificateInfo = (PushCertificateInfo) o;
+ return Objects.equals(certificate, pushCertificateInfo.certificate)
+ && Objects.equals(key, pushCertificateInfo.key);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(certificate, key);
+ }
}
diff --git a/java/com/google/gerrit/extensions/common/ReviewerUpdateInfo.java b/java/com/google/gerrit/extensions/common/ReviewerUpdateInfo.java
index eccdc64..37e1ceb 100644
--- a/java/com/google/gerrit/extensions/common/ReviewerUpdateInfo.java
+++ b/java/com/google/gerrit/extensions/common/ReviewerUpdateInfo.java
@@ -16,10 +16,28 @@
import com.google.gerrit.extensions.client.ReviewerState;
import java.sql.Timestamp;
+import java.util.Objects;
public class ReviewerUpdateInfo {
public Timestamp updated;
public AccountInfo updatedBy;
public AccountInfo reviewer;
public ReviewerState state;
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof ReviewerUpdateInfo) {
+ ReviewerUpdateInfo reviewerUpdateInfo = (ReviewerUpdateInfo) o;
+ return Objects.equals(updated, reviewerUpdateInfo.updated)
+ && Objects.equals(updatedBy, reviewerUpdateInfo.updatedBy)
+ && Objects.equals(reviewer, reviewerUpdateInfo.reviewer)
+ && Objects.equals(state, reviewerUpdateInfo.state);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(updated, updatedBy, reviewer, state);
+ }
}
diff --git a/java/com/google/gerrit/extensions/common/RevisionInfo.java b/java/com/google/gerrit/extensions/common/RevisionInfo.java
index f262901..ea61f31 100644
--- a/java/com/google/gerrit/extensions/common/RevisionInfo.java
+++ b/java/com/google/gerrit/extensions/common/RevisionInfo.java
@@ -17,6 +17,7 @@
import com.google.gerrit.extensions.client.ChangeKind;
import java.sql.Timestamp;
import java.util.Map;
+import java.util.Objects;
public class RevisionInfo {
// ActionJson#copy(List, RevisionInfo) must be adapted if new fields are added that are not
@@ -34,4 +35,43 @@
public String commitWithFooters;
public PushCertificateInfo pushCertificate;
public String description;
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof RevisionInfo) {
+ RevisionInfo revisionInfo = (RevisionInfo) o;
+ return isCurrent == revisionInfo.isCurrent
+ && Objects.equals(kind, revisionInfo.kind)
+ && _number == revisionInfo._number
+ && Objects.equals(created, revisionInfo.created)
+ && Objects.equals(uploader, revisionInfo.uploader)
+ && Objects.equals(ref, revisionInfo.ref)
+ && Objects.equals(fetch, revisionInfo.fetch)
+ && Objects.equals(commit, revisionInfo.commit)
+ && Objects.equals(files, revisionInfo.files)
+ && Objects.equals(actions, revisionInfo.actions)
+ && Objects.equals(commitWithFooters, revisionInfo.commitWithFooters)
+ && Objects.equals(pushCertificate, revisionInfo.pushCertificate)
+ && Objects.equals(description, revisionInfo.description);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ isCurrent,
+ kind,
+ _number,
+ created,
+ uploader,
+ ref,
+ fetch,
+ commit,
+ files,
+ actions,
+ commitWithFooters,
+ pushCertificate,
+ description);
+ }
}
diff --git a/java/com/google/gerrit/extensions/common/SubmitRequirementInfo.java b/java/com/google/gerrit/extensions/common/SubmitRequirementInfo.java
index 3483de5..a13e645 100644
--- a/java/com/google/gerrit/extensions/common/SubmitRequirementInfo.java
+++ b/java/com/google/gerrit/extensions/common/SubmitRequirementInfo.java
@@ -18,9 +18,9 @@
import java.util.Objects;
public class SubmitRequirementInfo {
- public final String status;
- public final String fallbackText;
- public final String type;
+ public String status;
+ public String fallbackText;
+ public String type;
public SubmitRequirementInfo(String status, String fallbackText, String type) {
this.status = status;
@@ -55,4 +55,6 @@
.add("type", type)
.toString();
}
+
+ protected SubmitRequirementInfo() {}
}
diff --git a/java/com/google/gerrit/extensions/common/TrackingIdInfo.java b/java/com/google/gerrit/extensions/common/TrackingIdInfo.java
index 0c5ed68..3d35e08 100644
--- a/java/com/google/gerrit/extensions/common/TrackingIdInfo.java
+++ b/java/com/google/gerrit/extensions/common/TrackingIdInfo.java
@@ -14,6 +14,8 @@
package com.google.gerrit.extensions.common;
+import java.util.Objects;
+
public class TrackingIdInfo {
public String system;
public String id;
@@ -22,4 +24,20 @@
this.system = system;
this.id = id;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof TrackingIdInfo) {
+ TrackingIdInfo trackingIdInfo = (TrackingIdInfo) o;
+ return Objects.equals(system, trackingIdInfo.system) && Objects.equals(id, trackingIdInfo.id);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(system, id);
+ }
+
+ protected TrackingIdInfo() {}
}
diff --git a/java/com/google/gerrit/extensions/common/VotingRangeInfo.java b/java/com/google/gerrit/extensions/common/VotingRangeInfo.java
index 5c35a49..2f7e9e4 100644
--- a/java/com/google/gerrit/extensions/common/VotingRangeInfo.java
+++ b/java/com/google/gerrit/extensions/common/VotingRangeInfo.java
@@ -14,6 +14,8 @@
package com.google.gerrit.extensions.common;
+import java.util.Objects;
+
public class VotingRangeInfo {
public int min;
public int max;
@@ -22,4 +24,18 @@
this.min = min;
this.max = max;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof VotingRangeInfo) {
+ VotingRangeInfo votingRangeInfo = (VotingRangeInfo) o;
+ return min == votingRangeInfo.min && max == votingRangeInfo.max;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(min, max);
+ }
}
diff --git a/java/com/google/gerrit/extensions/common/WebLinkInfo.java b/java/com/google/gerrit/extensions/common/WebLinkInfo.java
index 84fd970..ba12be0 100644
--- a/java/com/google/gerrit/extensions/common/WebLinkInfo.java
+++ b/java/com/google/gerrit/extensions/common/WebLinkInfo.java
@@ -64,4 +64,6 @@
+ target
+ "}";
}
+
+ protected WebLinkInfo() {}
}
diff --git a/java/com/google/gerrit/server/patch/AutoMerger.java b/java/com/google/gerrit/server/patch/AutoMerger.java
index fe915c5..ac37411 100644
--- a/java/com/google/gerrit/server/patch/AutoMerger.java
+++ b/java/com/google/gerrit/server/patch/AutoMerger.java
@@ -109,6 +109,7 @@
ActionType.GIT_UPDATE,
"createAutoMerge",
() -> createAutoMergeCommit(repo, rw, ins, merge, mergeStrategy))
+ .defaultTimeoutMultiplier(2)
.call();
} catch (Exception e) {
Throwables.throwIfUnchecked(e);
diff --git a/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java b/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java
index 68a90d2..4e3edcd 100644
--- a/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java
+++ b/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java
@@ -173,6 +173,7 @@
public static final String FIELD_MESSAGE = "message";
public static final String FIELD_OWNER = "owner";
public static final String FIELD_OWNERIN = "ownerin";
+ public static final String FIELD_PARENTOF = "parentof";
public static final String FIELD_PARENTPROJECT = "parentproject";
public static final String FIELD_PATH = "path";
public static final String FIELD_PENDING_REVIEWER = "pendingreviewer";
@@ -735,6 +736,16 @@
}
@Operator
+ public Predicate<ChangeData> parentof(String value) throws QueryParseException {
+ List<ChangeData> changes = parseChangeData(value);
+ List<Predicate<ChangeData>> or = new ArrayList<>(changes.size());
+ for (ChangeData c : changes) {
+ or.add(new ParentOfPredicate(value, c, args.repoManager));
+ }
+ return Predicate.or(or);
+ }
+
+ @Operator
public Predicate<ChangeData> parentproject(String name) {
return new ParentProjectPredicate(args.projectCache, args.childProjects, name);
}
@@ -1560,14 +1571,18 @@
}
private List<Change> parseChange(String value) throws QueryParseException {
+ return asChanges(parseChangeData(value));
+ }
+
+ private List<ChangeData> parseChangeData(String value) throws QueryParseException {
if (PAT_LEGACY_ID.matcher(value).matches()) {
Optional<Change.Id> id = Change.Id.tryParse(value);
if (!id.isPresent()) {
throw error("Invalid change id " + value);
}
- return asChanges(args.queryProvider.get().byLegacyChangeId(id.get()));
+ return args.queryProvider.get().byLegacyChangeId(id.get());
} else if (PAT_CHANGE_ID.matcher(value).matches()) {
- List<Change> changes = asChanges(args.queryProvider.get().byKeyPrefix(parseChangeId(value)));
+ List<ChangeData> changes = args.queryProvider.get().byKeyPrefix(parseChangeId(value));
if (changes.isEmpty()) {
throw error("Change " + value + " not found");
}
diff --git a/java/com/google/gerrit/server/query/change/ParentOfPredicate.java b/java/com/google/gerrit/server/query/change/ParentOfPredicate.java
new file mode 100644
index 0000000..e48d586
--- /dev/null
+++ b/java/com/google/gerrit/server/query/change/ParentOfPredicate.java
@@ -0,0 +1,62 @@
+// Copyright (C) 2021 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.server.query.change;
+
+import com.google.common.collect.Sets;
+import com.google.gerrit.entities.PatchSet;
+import com.google.gerrit.exceptions.StorageException;
+import com.google.gerrit.index.query.Matchable;
+import com.google.gerrit.index.query.OperatorPredicate;
+import com.google.gerrit.server.git.GitRepositoryManager;
+import java.io.IOException;
+import java.util.Set;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevWalk;
+
+public class ParentOfPredicate extends OperatorPredicate<ChangeData>
+ implements Matchable<ChangeData> {
+ protected final Set<RevCommit> parents;
+
+ public ParentOfPredicate(String value, ChangeData change, GitRepositoryManager repoManager) {
+ super(ChangeQueryBuilder.FIELD_PARENTOF, value);
+ this.parents = getParents(change, repoManager);
+ }
+
+ @Override
+ public boolean match(ChangeData changeData) {
+ return changeData.patchSets().stream().anyMatch(ps -> parents.contains(ps.commitId()));
+ }
+
+ @Override
+ public int getCost() {
+ return 1;
+ }
+
+ protected Set<RevCommit> getParents(ChangeData change, GitRepositoryManager repoManager) {
+ PatchSet ps = change.currentPatchSet();
+ try (Repository repo = repoManager.openRepository(change.project());
+ RevWalk walk = new RevWalk(repo)) {
+ RevCommit c = walk.parseCommit(ps.commitId());
+ return Sets.newHashSet(c.getParents());
+ } catch (IOException e) {
+ throw new StorageException(
+ String.format(
+ "Loading commit %s for ps %d of change %d failed.",
+ ps.commitId(), ps.id().get(), ps.id().changeId().get()),
+ e);
+ }
+ }
+}
diff --git a/java/com/google/gerrit/server/restapi/change/ReviewersUtil.java b/java/com/google/gerrit/server/restapi/change/ReviewersUtil.java
index 2a55e41..38be27e 100644
--- a/java/com/google/gerrit/server/restapi/change/ReviewersUtil.java
+++ b/java/com/google/gerrit/server/restapi/change/ReviewersUtil.java
@@ -51,6 +51,7 @@
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.account.GroupMembers;
+import com.google.gerrit.server.account.ServiceUserClassifier;
import com.google.gerrit.server.change.ReviewerAdder;
import com.google.gerrit.server.index.account.AccountField;
import com.google.gerrit.server.index.account.AccountIndexCollection;
@@ -130,6 +131,7 @@
private final IndexConfig indexConfig;
private final AccountControl.Factory accountControlFactory;
private final Provider<CurrentUser> self;
+ private final ServiceUserClassifier serviceUserClassifier;
@Inject
ReviewersUtil(
@@ -143,7 +145,8 @@
AccountIndexCollection accountIndexes,
IndexConfig indexConfig,
AccountControl.Factory accountControlFactory,
- Provider<CurrentUser> self) {
+ Provider<CurrentUser> self,
+ ServiceUserClassifier serviceUserClassifier) {
this.accountLoaderFactory = accountLoaderFactory;
this.accountQueryBuilder = accountQueryBuilder;
this.accountIndexRewriter = accountIndexRewriter;
@@ -155,6 +158,7 @@
this.indexConfig = indexConfig;
this.accountControlFactory = accountControlFactory;
this.self = self;
+ this.serviceUserClassifier = serviceUserClassifier;
}
public interface VisibilityControl {
@@ -200,13 +204,17 @@
reviewerState, changeNotes, suggestReviewers, projectState, candidateList);
logger.atFine().log("Sorted recommendations: %s", sortedRecommendations);
- // Filter accounts by visibility and enforce limit
+ // Filter accounts by visibility, skip service users and enforce limit
List<Account.Id> filteredRecommendations = new ArrayList<>();
try (Timer0.Context ctx = metrics.filterVisibility.start()) {
for (Account.Id reviewer : sortedRecommendations) {
if (filteredRecommendations.size() >= limit) {
break;
}
+ if (suggestReviewers.isSkipServiceUsers()
+ && serviceUserClassifier.isServiceUser(reviewer)) {
+ continue;
+ }
// Check if change is visible to reviewer and if the current user can see reviewer
if (visibilityControl.isVisibleTo(reviewer)
&& accountControlFactory.get().canSee(reviewer)) {
diff --git a/java/com/google/gerrit/server/restapi/change/SuggestReviewers.java b/java/com/google/gerrit/server/restapi/change/SuggestReviewers.java
index e071c89..71ff493 100644
--- a/java/com/google/gerrit/server/restapi/change/SuggestReviewers.java
+++ b/java/com/google/gerrit/server/restapi/change/SuggestReviewers.java
@@ -31,6 +31,8 @@
private static final int DEFAULT_MAX_SUGGESTED = 10;
+ private static final boolean DEFAULT_SKIP_SERVICE_USERS = true;
+
protected final ReviewersUtil reviewersUtil;
private final boolean suggestAccounts;
@@ -39,6 +41,7 @@
protected int limit;
protected String query;
protected final int maxSuggestedReviewers;
+ protected boolean skipServiceUsers;
@Option(
name = "--limit",
@@ -78,6 +81,10 @@
return maxAllowedWithoutConfirmation;
}
+ public boolean isSkipServiceUsers() {
+ return skipServiceUsers;
+ }
+
@Inject
public SuggestReviewers(
AccountVisibility av, @GerritServerConfig Config cfg, ReviewersUtil reviewersUtil) {
@@ -100,6 +107,9 @@
ReviewerAdder.DEFAULT_MAX_REVIEWERS_WITHOUT_CHECK);
logger.atFine().log("AccountVisibility: %s", av.name());
+
+ this.skipServiceUsers =
+ cfg.getBoolean("suggest", "skipServiceUsers", DEFAULT_SKIP_SERVICE_USERS);
}
public static GerritConfigListener configListener() {
diff --git a/java/com/google/gerrit/server/restapi/config/GetServerInfo.java b/java/com/google/gerrit/server/restapi/config/GetServerInfo.java
index 5459ede..0a5692e 100644
--- a/java/com/google/gerrit/server/restapi/config/GetServerInfo.java
+++ b/java/com/google/gerrit/server/restapi/config/GetServerInfo.java
@@ -304,6 +304,7 @@
info.editGpgKeys =
toBoolean(enableSignedPush && config.getBoolean("gerrit", null, "editGpgKeys", true));
info.primaryWeblinkName = config.getString("gerrit", null, "primaryWeblinkName");
+ info.instanceId = config.getString("gerrit", null, "instanceId");
return info;
}
diff --git a/java/com/google/gerrit/server/submit/MergeOp.java b/java/com/google/gerrit/server/submit/MergeOp.java
index b12a5b5..f486650 100644
--- a/java/com/google/gerrit/server/submit/MergeOp.java
+++ b/java/com/google/gerrit/server/submit/MergeOp.java
@@ -549,8 +549,8 @@
.listener(retryTracker)
// Up to the entire submit operation is retried, including possibly many projects.
// Multiply the timeout by the number of projects we're actually attempting to
- // submit.
- .defaultTimeoutMultiplier(filteredNoteDbChangeSet.projects().size())
+ // submit. Times 2 to retry more persistently, to increase success rate.
+ .defaultTimeoutMultiplier(filteredNoteDbChangeSet.projects().size() * 2)
// By default, we only retry lock failures. Here it's better to also retry unexpected
// runtime exceptions.
.retryOn(t -> t instanceof RuntimeException)
diff --git a/javatests/com/google/gerrit/acceptance/rest/change/SuggestReviewersIT.java b/javatests/com/google/gerrit/acceptance/rest/change/SuggestReviewersIT.java
index 888878f..ffde622 100644
--- a/javatests/com/google/gerrit/acceptance/rest/change/SuggestReviewersIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/change/SuggestReviewersIT.java
@@ -450,6 +450,23 @@
}
@Test
+ public void suggestNoServiceAccounts() throws Exception {
+ requestScopeOperations.setApiUser(user.id());
+ String changeIdReviewed = createChangeFromApi();
+ String changeId = createChangeFromApi();
+
+ String name = name("foo");
+ TestAccount foo = accountCreator.create(name);
+ reviewChange(changeIdReviewed, foo);
+
+ assertReviewers(suggestReviewers(changeId, name), ImmutableList.of(foo), ImmutableList.of());
+
+ groupOperations.group(serviceUsersUUID()).forUpdate().addMember(foo.id()).update();
+
+ assertReviewers(suggestReviewers(changeId, name), ImmutableList.of(), ImmutableList.of());
+ }
+
+ @Test
public void suggestNoExistingReviewers() throws Exception {
requestScopeOperations.setApiUser(user.id());
String changeId = createChangeFromApi();
@@ -608,6 +625,13 @@
return user(name, fullName, name);
}
+ private AccountGroup.UUID serviceUsersUUID() {
+ return groupCache
+ .get(AccountGroup.nameKey("Service Users"))
+ .orElseThrow(() -> new IllegalStateException("unable to find 'Service Users'"))
+ .getGroupUUID();
+ }
+
private void reviewChange(String changeId, TestAccount reviewer) throws RestApiException {
gApi.changes().id(changeId).addReviewer(reviewer.id().toString());
}
diff --git a/javatests/com/google/gerrit/acceptance/rest/config/ServerInfoIT.java b/javatests/com/google/gerrit/acceptance/rest/config/ServerInfoIT.java
index 0a84db4..4738f64 100644
--- a/javatests/com/google/gerrit/acceptance/rest/config/ServerInfoIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/config/ServerInfoIT.java
@@ -74,6 +74,7 @@
@GerritConfig(name = "gerrit.allProjects", value = "Root")
@GerritConfig(name = "gerrit.allUsers", value = "Users")
@GerritConfig(name = "gerrit.reportBugUrl", value = "https://example.com/report")
+ @GerritConfig(name = "gerrit.instanceId", value = "devops-instance")
// suggest
@GerritConfig(name = "suggest.from", value = "3")
@@ -116,6 +117,7 @@
assertThat(i.gerrit.allProjects).isEqualTo("Root");
assertThat(i.gerrit.allUsers).isEqualTo("Users");
assertThat(i.gerrit.reportBugUrl).isEqualTo("https://example.com/report");
+ assertThat(i.gerrit.instanceId).isEqualTo("devops-instance");
// plugin
assertThat(i.plugin.jsResourcePaths).isEmpty();
@@ -184,6 +186,7 @@
assertThat(i.gerrit.allProjects).isEqualTo(AllProjectsNameProvider.DEFAULT);
assertThat(i.gerrit.allUsers).isEqualTo(AllUsersNameProvider.DEFAULT);
assertThat(i.gerrit.reportBugUrl).isNull();
+ assertThat(i.gerrit.instanceId).isNull();
// plugin
assertThat(i.plugin.jsResourcePaths).isEmpty();
diff --git a/javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java b/javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
index 7efcb4b..48bd321 100644
--- a/javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
+++ b/javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
@@ -705,6 +705,24 @@
}
@Test
+ public void byParentOf() throws Exception {
+ TestRepository<Repo> repo1 = createProject("repo1");
+ RevCommit commit1 = repo1.parseBody(repo1.commit().message("message").create());
+ Change change1 = insert(repo1, newChangeForCommit(repo1, commit1));
+ RevCommit commit2 = repo1.parseBody(repo1.commit(commit1));
+ Change change2 = insert(repo1, newChangeForCommit(repo1, commit2));
+ RevCommit commit3 = repo1.parseBody(repo1.commit(commit1, commit2));
+ Change change3 = insert(repo1, newChangeForCommit(repo1, commit3));
+
+ assertQuery("parentof:" + change1.getId().get());
+ assertQuery("parentof:" + change1.getKey().get());
+ assertQuery("parentof:" + change2.getId().get(), change1);
+ assertQuery("parentof:" + change2.getKey().get(), change1);
+ assertQuery("parentof:" + change3.getId().get(), change2, change1);
+ assertQuery("parentof:" + change3.getKey().get(), change2, change1);
+ }
+
+ @Test
public void byParentProject() throws Exception {
TestRepository<Repo> repo1 = createProject("repo1");
TestRepository<Repo> repo2 = createProject("repo2", "repo1");
diff --git a/modules/jgit b/modules/jgit
index 4560bdf..9bfb0f3 160000
--- a/modules/jgit
+++ b/modules/jgit
@@ -1 +1 @@
-Subproject commit 4560bdf7e2e3c16a7c7bb3f2fcf067bb1eee26fb
+Subproject commit 9bfb0f3a4ec856dcbebb477a1ee8803a3c47c194
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.ts b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.ts
index bd2781f..f2b4c89 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.ts
+++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.ts
@@ -99,7 +99,7 @@
return htmlTemplate;
}
- private _account?: AccountDetailInfo;
+ private account?: AccountDetailInfo;
@property({type: Object})
params?: AdminViewParams;
@@ -189,7 +189,7 @@
getPluginLoader().awaitPluginsLoaded(),
];
return Promise.all(promises).then(result => {
- this._account = result[0];
+ this.account = result[0];
let options: AdminNavLinksOption | undefined = undefined;
if (this._repoName) {
options = {repoName: this._repoName};
@@ -204,7 +204,7 @@
}
return getAdminLinks(
- this._account,
+ this.account,
() =>
this.restApiService.getAccountCapabilities().then(capabilities => {
if (!capabilities) {
@@ -400,7 +400,7 @@
}
return '';
}
- // TODO(TS): The following condtion seems always false, because params
+ // TODO(TS): The following condition seems always false, because params
// never has detailType property. Remove it.
if (
((params as unknown) as AdminSubsectionLink).detailType &&
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.ts b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.ts
index 26ff799..56c5733 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-access/gr-repo-access.ts
@@ -118,7 +118,7 @@
@property({type: Boolean})
_loading = true;
- private _originalInheritsFrom?: ProjectInfo | null;
+ private originalInheritsFrom?: ProjectInfo | null;
private readonly restApiService = appContext.restApiService;
@@ -173,7 +173,7 @@
...res.inherits_from,
}
: null;
- this._originalInheritsFrom = res.inherits_from
+ this.originalInheritsFrom = res.inherits_from
? {
...res.inherits_from,
}
@@ -306,7 +306,7 @@
}
// Restore inheritFrom.
if (this._inheritsFrom) {
- this._inheritsFrom = {...this._originalInheritsFrom};
+ this._inheritsFrom = {...this.originalInheritsFrom};
this._inheritFromFilter =
'name' in this._inheritsFrom ? this._inheritsFrom.name : undefined;
}
@@ -446,8 +446,8 @@
remove: {},
};
- const originalInheritsFromId = this._originalInheritsFrom
- ? singleDecodeURL(this._originalInheritsFrom.id)
+ const originalInheritsFromId = this.originalInheritsFrom
+ ? singleDecodeURL(this.originalInheritsFrom.id)
: null;
// TODO(TS): this._inheritsFrom as ProjectInfo might be a mistake.
// _inheritsFrom can be {}
diff --git a/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor_test.js b/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor_test.js
index b0065d9..9cc6357 100644
--- a/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor_test.js
+++ b/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor_test.js
@@ -192,7 +192,7 @@
};
element.section = 'refs/*';
- // Typically called on ready since elements will have properies defined
+ // Typically called on ready since elements will have properties defined
// by the parent element.
element._setupValues(element.rule);
flush();
diff --git a/polygerrit-ui/app/elements/change-list/gr-create-change-help/gr-create-change-help_html.ts b/polygerrit-ui/app/elements/change-list/gr-create-change-help/gr-create-change-help_html.ts
index 9812933..add7ca5 100644
--- a/polygerrit-ui/app/elements/change-list/gr-create-change-help/gr-create-change-help_html.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-create-change-help/gr-create-change-help_html.ts
@@ -36,7 +36,7 @@
width: 10em;
}
#graphic iron-icon {
- color: #9e9e9e;
+ color: var(--gray-foreground);
height: 5em;
width: 5em;
}
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts
index 9240905..816c8ef 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts
@@ -58,7 +58,7 @@
import {firePageError, fireTitleChange} from '../../../utils/event-util';
import {GerritView} from '../../../services/router/router-model';
-const PROJECT_PLACEHOLDER_PATTERN = /\$\{project\}/g;
+const PROJECT_PLACEHOLDER_PATTERN = /\${project}/g;
const RELOAD_DASHBOARD_INTERVAL_MS = 10 * 1000;
export interface GrDashboardView {
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.ts b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.ts
index c3858d8..87b09c7 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.ts
@@ -2068,10 +2068,10 @@
*
*/
_waitForChangeReachable(changeNum: NumericChangeId) {
- let attempsRemaining = AWAIT_CHANGE_ATTEMPTS;
+ let attemptsRemaining = AWAIT_CHANGE_ATTEMPTS;
return new Promise(resolve => {
const check = () => {
- attempsRemaining--;
+ attemptsRemaining--;
// Pass a no-op error handler to avoid the "not found" error toast.
this.restApiService
.getChange(changeNum, () => {})
@@ -2082,7 +2082,7 @@
return;
}
- if (attempsRemaining) {
+ if (attemptsRemaining) {
this.async(check, AWAIT_CHANGE_TIMEOUT_MS);
} else {
resolve(false);
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.js
index 6c9a27d..fbb70b7 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.js
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.js
@@ -2110,7 +2110,7 @@
element = basicFixture.instantiate();
// getChangeRevisionActions is not called without
- // set the following properies
+ // set the following properties
element.change = {};
element.changeNum = '42';
element.latestPatchNum = '2';
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_html.ts b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_html.ts
index c5c73c5..59bf8ad 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_html.ts
@@ -78,7 +78,7 @@
}
.icon.help,
.icon.notTrusted {
- color: #ffa62f;
+ color: var(--warning-foreground);
}
.icon.invalid {
color: var(--negative-red-text-color);
@@ -87,7 +87,7 @@
color: var(--positive-green-text-color);
}
.parentList.notCurrent.nonMerge #parentNotCurrentMessage {
- --arrow-color: #ffa62f;
+ --arrow-color: var(--warning-foreground);
display: inline-block;
}
.separatedSection {
diff --git a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.ts b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.ts
index c0e87f3..adc7fd3 100644
--- a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.ts
@@ -37,6 +37,7 @@
import {PolymerDeepPropertyChange} from '@polymer/polymer/interfaces';
import {appContext} from '../../../services/app-context';
import {KnownExperimentId} from '../../../services/flags/flags';
+import {labelCompare} from '../../../utils/label-util';
interface ChangeRequirement extends Requirement {
satisfied: boolean;
@@ -136,7 +137,7 @@
const labels = labelsRecord.base || {};
const allLabels: Label[] = [];
- for (const label of Object.keys(labels).sort()) {
+ for (const label of Object.keys(labels).sort(labelCompare)) {
allLabels.push({
labelName: label,
icon: this._computeLabelIcon(labels[label]),
diff --git a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements_html.ts b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements_html.ts
index f172ccc..a502949 100644
--- a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements_html.ts
@@ -23,7 +23,7 @@
width: 100%;
}
.status {
- color: #ffa62f;
+ color: var(--warning-foreground);
display: inline-block;
text-align: center;
vertical-align: top;
@@ -99,6 +99,9 @@
padding-left: 0;
}
</style>
+ <template is="dom-if" if="[[_isNewChangeSummaryUiEnabled]]">
+ <h3 class="metadata-title">Submit requirements</h3>
+ </template>
<template is="dom-repeat" items="[[_requirements]]">
<gr-endpoint-decorator
class="submit-requirement-endpoints"
@@ -126,9 +129,6 @@
</div>
</gr-endpoint-decorator>
</template>
- <template is="dom-if" if="[[_isNewChangeSummaryUiEnabled]]">
- <h3 class="metadata-title">Submit requirements</h3>
- </template>
<template is="dom-repeat" items="[[_requiredLabels]]">
<section>
<div class="title">
diff --git a/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts b/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts
index 4af51a9..beec0a4 100644
--- a/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts
@@ -56,7 +56,7 @@
import {notUndefined} from '../../../types/types';
import {uniqueDefinedAvatar} from '../../../utils/account-util';
import {PrimaryTab} from '../../../constants/constants';
-import {CommentTabState} from '../../../types/events';
+import {ChecksTabState, CommentTabState} from '../../../types/events';
export enum SummaryChipStyles {
INFO = 'info',
@@ -229,19 +229,13 @@
const chipClass = `checksChip font-small ${this.icon}`;
const grIcon = `gr-icons:${this.icon}`;
return html`
- <div class="${chipClass}" role="button" @click="${this.handleClick}">
+ <div class="${chipClass}" role="button">
<iron-icon icon="${grIcon}"></iron-icon>
<div class="text">${this.text}</div>
<slot></slot>
</div>
`;
}
-
- private handleClick(e: MouseEvent) {
- e.stopPropagation();
- e.preventDefault();
- fireShowPrimaryTab(this, PrimaryTab.CHECKS);
- }
}
/** What is the maximum number of expanded checks chips? */
@@ -325,7 +319,7 @@
const icon = iconForCategory(category);
const runs = this.runs.filter(run => hasResultsOf(run, category));
const count = (run: CheckRun) => getResultsOf(run, category);
- return this.renderChecksChip(icon, runs, count);
+ return this.renderChecksChip(icon, runs, category, count);
}
renderChecksChipForStatus(
@@ -334,12 +328,13 @@
) {
const icon = iconForStatus(status);
const runs = this.runs.filter(filter);
- return this.renderChecksChip(icon, runs, () => []);
+ return this.renderChecksChip(icon, runs, status, () => []);
}
renderChecksChip(
icon: string,
runs: CheckRun[],
+ statusOrCategory: RunStatus | Category,
resultFilter: (run: CheckRun) => CheckResult[]
) {
if (runs.length === 0) {
@@ -359,9 +354,10 @@
class="${icon}"
.icon="${icon}"
.text="${text}"
+ @click="${() => this.onChipClick({checkName: run.checkName})}"
>${links.map(
link => html`
- <a href="${link.url}" target="_blank" @click="${this.onClick}"
+ <a href="${link.url}" target="_blank" @click="${this.onLinkClick}"
><iron-icon class="launch" icon="gr-icons:launch"></iron-icon
></a>
`
@@ -380,11 +376,18 @@
class="${icon}"
.icon="${icon}"
.text="${sum}"
+ @click="${() => this.onChipClick({statusOrCategory})}"
></gr-checks-chip>`;
}
- private onClick(e: MouseEvent) {
- // Prevents handleClick() from reacting to <a> link clicks.
+ private onChipClick(state: ChecksTabState) {
+ fireShowPrimaryTab(this, PrimaryTab.CHECKS, true, {
+ checksTab: state,
+ });
+ }
+
+ private onLinkClick(e: MouseEvent) {
+ // Prevents onChipClick() from reacting to <a> link clicks.
e.stopPropagation();
}
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts
index f3fb860..08c04e8 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts
@@ -690,7 +690,10 @@
is="dom-if"
if="[[_isTabActive(_constants.PrimaryTab.CHECKS, _activeTabs)]]"
>
- <gr-checks-tab id="checksTab"></gr-checks-tab>
+ <gr-checks-tab
+ id="checksTab"
+ tab-state="[[_tabState.checksTab]]"
+ ></gr-checks-tab>
</template>
<template
is="dom-if"
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
index a5c0624..c2947a6 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
@@ -803,7 +803,7 @@
}
/**
- * Handle all events from the file list dom-repeat so event handleers don't
+ * Handle all events from the file list dom-repeat so event handlers don't
* have to get registered for potentially very long lists.
*/
_handleFileListClick(e: MouseEvent) {
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.ts
index 23718fa..c57a2d5 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.ts
@@ -154,7 +154,7 @@
padding-left: var(--spacing-s);
}
.drafts {
- color: #c62828;
+ color: var(--error-foreground);
font-weight: var(--font-weight-bold);
}
.show-hide-icon:focus {
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js
index 285b73f..80d8729 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js
@@ -1244,7 +1244,7 @@
// are no deletions.
assert.equal(element._computeBarAdditionWidth(file, stats), 30);
- // If there are no insetions, there is no width.
+ // If there are no insertions, there is no width.
stats.maxInserted = 0;
assert.equal(element._computeBarAdditionWidth(file, stats), 0);
diff --git a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.ts b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.ts
index a966186..661cd1a 100644
--- a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.ts
+++ b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.ts
@@ -37,6 +37,7 @@
} from '../gr-label-score-row/gr-label-score-row';
import {PolymerDeepPropertyChange} from '@polymer/polymer/interfaces';
import {appContext} from '../../../services/app-context';
+import {labelCompare} from '../../../utils/label-util';
@customElement('gr-label-scores')
export class GrLabelScores extends GestureEventListeners(
@@ -147,7 +148,7 @@
if (!labelRecord?.base) return [];
const labelsObj = labelRecord.base;
return Object.keys(labelsObj)
- .sort()
+ .sort(labelCompare)
.map(key => {
return {
name: key,
diff --git a/polygerrit-ui/app/elements/change/gr-message/gr-message.ts b/polygerrit-ui/app/elements/change/gr-message/gr-message.ts
index 2fe409a..f913459 100644
--- a/polygerrit-ui/app/elements/change/gr-message/gr-message.ts
+++ b/polygerrit-ui/app/elements/change/gr-message/gr-message.ts
@@ -54,7 +54,7 @@
} from '../../../utils/patch-set-util';
import {isServiceUser} from '../../../utils/account-util';
-const PATCH_SET_PREFIX_PATTERN = /^(?:Uploaded\s*)?(?:P|p)atch (?:S|s)et \d+:\s*(.*)/;
+const PATCH_SET_PREFIX_PATTERN = /^(?:Uploaded\s*)?[Pp]atch [Ss]et \d+:\s*(.*)/;
const LABEL_TITLE_SCORE_PATTERN = /^(-?)([A-Za-z0-9-]+?)([+-]\d+)?[.]?$/;
const UPLOADED_NEW_PATCHSET_PATTERN = /Uploaded patch set (\d+)./;
const MERGED_PATCHSET_PATTERN = /(\d+) is the latest approved patch-set/;
@@ -484,7 +484,7 @@
_handleAnchorClick(e: Event) {
e.preventDefault();
// The element which triggers _handleAnchorClick is rendered only if
- // message.id defined: the elemenet is wrapped in dom-if if="[[message.id]]"
+ // message.id defined: the element is wrapped in dom-if if="[[message.id]]"
const detail: MessageAnchorTapDetail = {
id: this.message!.id,
};
diff --git a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.ts b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.ts
index 9877a95..bc3f167 100644
--- a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.ts
@@ -118,7 +118,7 @@
/**
* If messages have the same tag, then that influences grouping and whether
- * a message is initally hidden or not, see isImportant(). So we are applying
+ * a message is initially hidden or not, see isImportant(). So we are applying
* some "magic" rules here in order to hide exactly the right messages.
*
* 1. If a message does not have a tag, but is associated with robot comments,
@@ -263,7 +263,7 @@
_combinedMessages: CombinedMessage[] = [];
@property({type: Object, computed: '_computeLabelExtremes(labels.*)'})
- _labelExtremes: {[lableName: string]: VotingRangeInfo} = {};
+ _labelExtremes: {[labelName: string]: VotingRangeInfo} = {};
private readonly reporting = appContext.reportingService;
@@ -466,7 +466,7 @@
LabelNameToInfoMap
>
) {
- const extremes: {[lableName: string]: VotingRangeInfo} = {};
+ const extremes: {[labelName: string]: VotingRangeInfo} = {};
const labels = labelRecord.base;
if (!labels) {
return extremes;
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list-experimental/gr-related-change.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list-experimental/gr-related-change.ts
index 3ed545e..7b698f1 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list-experimental/gr-related-change.ts
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list-experimental/gr-related-change.ts
@@ -77,10 +77,10 @@
margin-left: var(--spacing-xs);
}
.notCurrent {
- color: #e65100;
+ color: var(--warning-foreground);
}
.indirectAncestor {
- color: #33691e;
+ color: var(--indirect-ancestor-text-color);
}
.submittableCheck {
padding-left: var(--spacing-s);
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list-experimental/gr-related-changes-list-experimental.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list-experimental/gr-related-changes-list-experimental.ts
index c4b1917..e921979 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list-experimental/gr-related-changes-list-experimental.ts
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list-experimental/gr-related-changes-list-experimental.ts
@@ -81,6 +81,7 @@
css`
.note {
color: var(--error-text-color);
+ margin-left: 1.2em;
}
section {
margin-bottom: var(--spacing-m);
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_html.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_html.ts
index 9941fa9..2f53319 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_html.ts
@@ -66,10 +66,10 @@
margin-left: var(--spacing-xs);
}
.notCurrent {
- color: #e65100;
+ color: var(--warning-foreground);
}
.indirectAncestor {
- color: #33691e;
+ color: var(--indirect-ancestor-text-color);
}
.submittableCheck {
padding-left: var(--spacing-s);
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
index 705a402..a8e89b6 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
@@ -784,7 +784,7 @@
}
_handle400Error(r?: Response | null) {
- if (!r) throw new Error('Reponse is empty.');
+ if (!r) throw new Error('Response is empty.');
let response: Response = r;
// A call to _saveReview could fail with a server error if erroneous
// reviewers were requested. This is signalled with a 400 Bad Request
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.js b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.js
index 6682bfb..0575239 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.js
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.js
@@ -1276,7 +1276,7 @@
'Send and Start review');
});
- test('_handle400Error reviewrs and CCs', done => {
+ test('_handle400Error reviewers and CCs', done => {
const error1 = 'error 1';
const error2 = 'error 2';
const error3 = 'error 3';
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-results.ts b/polygerrit-ui/app/elements/checks/gr-checks-results.ts
index 34945a9..002c8c3 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-results.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-results.ts
@@ -15,7 +15,14 @@
* limitations under the License.
*/
import {html} from 'lit-html';
-import {css, customElement, property, PropertyValues} from 'lit-element';
+import {
+ css,
+ customElement,
+ internalProperty,
+ property,
+ PropertyValues,
+ query,
+} from 'lit-element';
import {GrLitElement} from '../lit/gr-lit-element';
import {Category, CheckRun, Link, RunStatus, Tag} from '../../api/checks';
import {sharedStyles} from '../../styles/shared-styles';
@@ -26,6 +33,8 @@
iconForCategory,
isRunning,
} from '../../services/checks/checks-util';
+import {assertIsDefined} from '../../utils/common-util';
+import {whenVisible} from '../../utils/dom-util';
@customElement('gr-result-row')
class GrResultRow extends GrLitElement {
@@ -38,6 +47,9 @@
@property({type: Boolean, reflect: true})
isExpandable = false;
+ @property()
+ shouldRender = false;
+
static get styles() {
return [
sharedStyles,
@@ -126,8 +138,26 @@
super.update(changedProperties);
}
+ firstUpdated() {
+ const loading = this.shadowRoot?.querySelector('.container');
+ assertIsDefined(loading, '"Loading" element');
+ whenVisible(loading, () => this.setAttribute('shouldRender', 'true'), 200);
+ }
+
render() {
if (!this.result) return '';
+ if (!this.shouldRender) {
+ return html`
+ <tr class="container">
+ <td class="iconCol"></td>
+ <td class="nameCol">
+ <div><span class="loading">Loading...</span></div>
+ </td>
+ <td class="summaryCol"></td>
+ <td class="expanderCol"></td>
+ </tr>
+ `;
+ }
return html`
<tr class="container" @click="${this.toggleExpanded}">
<td class="iconCol">
@@ -256,9 +286,17 @@
@customElement('gr-checks-results')
export class GrChecksResults extends GrLitElement {
+ @query('#filterInput')
+ filterInput?: HTMLInputElement;
+
+ @internalProperty()
+ filterRegExp = new RegExp('');
+
@property()
runs: CheckRun[] = [];
+ private isSectionExpanded = new Map<Category | 'SUCCESS', boolean>();
+
static get styles() {
return [
sharedStyles,
@@ -267,27 +305,45 @@
display: block;
padding: var(--spacing-xl);
}
+ input#filterInput {
+ margin-top: var(--spacing-s);
+ padding: var(--spacing-s) var(--spacing-m);
+ min-width: 400px;
+ }
.categoryHeader {
margin-top: var(--spacing-l);
margin-left: var(--spacing-l);
text-transform: capitalize;
+ cursor: default;
}
- .categoryHeader iron-icon {
+ .categoryHeader .expandIcon {
+ width: var(--line-height-h3);
+ height: var(--line-height-h3);
+ margin-right: var(--spacing-s);
+ }
+ .categoryHeader .statusIcon {
position: relative;
- top: 1px;
+ top: 2px;
}
- .categoryHeader iron-icon.error {
+ .categoryHeader .statusIcon.error {
color: var(--error-foreground);
}
- .categoryHeader iron-icon.warning {
+ .categoryHeader .statusIcon.warning {
color: var(--warning-foreground);
}
- .categoryHeader iron-icon.info {
+ .categoryHeader .statusIcon.info {
color: var(--info-foreground);
}
- .categoryHeader iron-icon.success {
+ .categoryHeader .statusIcon.success {
color: var(--success-foreground);
}
+ .collapsed table {
+ display: none;
+ }
+ .collapsed {
+ border-bottom: 1px solid var(--border-color);
+ padding-bottom: var(--spacing-m);
+ }
.noCompleted {
margin-top: var(--spacing-l);
}
@@ -310,12 +366,30 @@
render() {
return html`
<div><h2 class="heading-2">Results</h2></div>
- ${this.renderNoCompleted()} ${this.renderSection(Category.ERROR)}
+ ${this.renderFilter()} ${this.renderNoCompleted()}
+ ${this.renderSection(Category.ERROR)}
${this.renderSection(Category.WARNING)}
- ${this.renderSection(Category.INFO)} ${this.renderSuccess()}
+ ${this.renderSection(Category.INFO)} ${this.renderSection('SUCCESS')}
`;
}
+ renderFilter() {
+ if (this.runs.length === 0) return;
+ return html`
+ <input
+ id="filterInput"
+ type="text"
+ placeholder="Filter results by regular expression"
+ @input="${this.onInput}"
+ />
+ `;
+ }
+
+ onInput() {
+ assertIsDefined(this.filterInput, 'filter <input> element');
+ this.filterRegExp = new RegExp(this.filterInput.value, 'i');
+ }
+
renderNoCompleted() {
if (this.runs.some(hasCompleted)) return;
let text = 'No results';
@@ -325,68 +399,76 @@
return html`<div class="noCompleted">${text}</div>`;
}
- renderSection(category: Category) {
+ renderSection(category: Category | 'SUCCESS') {
const catString = category.toString().toLowerCase();
- const runs = this.runs.filter(r =>
- (r.results ?? []).some(res => res.category === category)
- );
+ let runs = this.runs;
+ if (category === 'SUCCESS') {
+ runs = runs
+ .filter(hasCompletedWithoutResults)
+ .filter(r => this.filterRegExp.test(r.checkName));
+ } else {
+ runs = runs.filter(r =>
+ (r.results ?? []).some(res => res.category === category)
+ );
+ }
if (runs.length === 0) return;
+ const expanded = this.isSectionExpanded.get(category) ?? true;
+ const expandedClass = expanded ? 'expanded' : 'collapsed';
+ const icon = expanded ? 'gr-icons:expand-more' : 'gr-icons:expand-less';
return html`
- <h3 class="categoryHeader heading-3">
- <iron-icon
- icon="gr-icons:${iconForCategory(category)}"
- class="${catString}"
- ></iron-icon>
- ${catString}
- </h3>
- <table class="resultsTable">
- <thead>
- <tr class="headerRow">
- <th class="iconCol"></th>
- <th class="nameCol">Run</th>
- <th class="summaryCol">Summary</th>
- <th class="expanderCol"></th>
- </tr>
- </thead>
- <tbody>
- ${runs.map(run => this.renderRun(category, run))}
- </tbody>
- </table>
+ <div class="${expandedClass}">
+ <h3
+ class="categoryHeader heading-3"
+ @click="${() => this.toggleExpanded(category)}"
+ >
+ <iron-icon class="expandIcon" icon="${icon}"></iron-icon>
+ <iron-icon
+ icon="gr-icons:${iconForCategory(category)}"
+ class="statusIcon ${catString}"
+ ></iron-icon>
+ ${catString}
+ </h3>
+ <table class="resultsTable">
+ <thead>
+ <tr class="headerRow">
+ <th class="iconCol"></th>
+ <th class="nameCol">Run</th>
+ <th class="summaryCol">Summary</th>
+ <th class="expanderCol"></th>
+ </tr>
+ </thead>
+ <tbody>
+ ${runs.map(run =>
+ category === 'SUCCESS'
+ ? this.renderSuccessfulRun(run)
+ : this.renderRun(category, run)
+ )}
+ </tbody>
+ </table>
+ </div>
`;
}
+ toggleExpanded(category: Category | 'SUCCESS') {
+ const expanded = this.isSectionExpanded.get(category) ?? true;
+ this.isSectionExpanded.set(category, !expanded);
+ this.requestUpdate();
+ }
+
renderRun(category: Category, run: CheckRun) {
return html`${run.results
?.filter(result => result.category === category)
+ .filter(
+ result =>
+ this.filterRegExp.test(run.checkName) ||
+ this.filterRegExp.test(result.summary)
+ )
.map(
result =>
html`<gr-result-row .result="${{...run, ...result}}"></gr-result-row>`
)}`;
}
- renderSuccess() {
- const runs = this.runs.filter(hasCompletedWithoutResults);
- if (runs.length === 0) return;
- return html`
- <h3 class="categoryHeader heading-3">
- <iron-icon
- icon="gr-icons:check-circle-outline"
- class="success"
- ></iron-icon>
- Success
- </h3>
- <table class="resultsTable">
- <tr class="headerRow">
- <th class="iconCol"></th>
- <th class="nameCol">Run</th>
- <th class="summaryCol">Summary</th>
- <th class="expanderCol"></th>
- </tr>
- ${runs.map(run => this.renderSuccessfulRun(run))}
- </table>
- `;
- }
-
renderSuccessfulRun(run: CheckRun) {
const adaptedRun: RunResult = {
category: Category.INFO, // will not be used, but is required
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-runs.ts b/polygerrit-ui/app/elements/checks/gr-checks-runs.ts
index 5b7428b..1b49f8a 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-runs.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-runs.ts
@@ -16,7 +16,13 @@
*/
import {html} from 'lit-html';
import {classMap} from 'lit-html/directives/class-map';
-import {css, customElement, property} from 'lit-element';
+import {
+ css,
+ customElement,
+ internalProperty,
+ property,
+ query,
+} from 'lit-element';
import {GrLitElement} from '../lit/gr-lit-element';
import {Action, CheckRun, RunStatus} from '../../api/checks';
import {sharedStyles} from '../../styles/shared-styles';
@@ -35,15 +41,14 @@
fakeRun4,
updateStateSetResults,
} from '../../services/checks/checks-model';
+import {assertIsDefined} from '../../utils/common-util';
+import {whenVisible} from '../../utils/dom-util';
-/* The RunSelectedEvent is only used locally to communicate from <gr-checks-run>
- to its <gr-checks-runs> parent. */
-
-interface RunSelectedEventDetail {
+export interface RunSelectedEventDetail {
checkName: string;
}
-type RunSelectedEvent = CustomEvent<RunSelectedEventDetail>;
+export type RunSelectedEvent = CustomEvent<RunSelectedEventDetail>;
declare global {
interface HTMLElementEventMap {
@@ -55,8 +60,8 @@
target.dispatchEvent(
new CustomEvent('run-selected', {
detail: {checkName},
- composed: false,
- bubbles: false,
+ composed: true,
+ bubbles: true,
})
);
}
@@ -106,6 +111,9 @@
.chip.placeholder {
border-left: var(--thick-border) solid var(--border-color);
}
+ .chip.placeholder iron-icon {
+ display: none;
+ }
.chip.error iron-icon {
color: var(--error-foreground);
}
@@ -124,9 +132,21 @@
background-color: var(--selected-background);
padding-left: calc(var(--spacing-m) + var(--thick-border) - 1px);
}
+ div.chip.deselected {
+ border: 1px solid var(--gray-foreground);
+ background-color: transparent;
+ padding-left: calc(var(--spacing-m) + var(--thick-border) - 1px);
+ }
div.chip.selected iron-icon {
color: var(--selected-foreground);
}
+ div.chip.deselected iron-icon {
+ color: var(--gray-foreground);
+ }
+ .chip.selected gr-button.action,
+ .chip.deselected gr-button.action {
+ display: none;
+ }
gr-button.action {
--padding: var(--spacing-xs) var(--spacing-m);
/* The button should fit into the 20px line-height. The negative
@@ -139,15 +159,40 @@
];
}
+ @query('.chip')
+ chipElement?: HTMLElement;
+
@property()
run!: CheckRun;
@property()
selected = false;
+ @property()
+ deselected = false;
+
+ @property()
+ shouldRender = false;
+
+ firstUpdated() {
+ assertIsDefined(this.chipElement, 'chip element');
+ whenVisible(
+ this.chipElement,
+ () => this.setAttribute('shouldRender', 'true'),
+ 200
+ );
+ }
+
render() {
- const icon = this.selected ? 'check-circle' : iconForRun(this.run);
- const classes = {chip: true, [icon]: true, selected: this.selected};
+ if (!this.shouldRender) return html`<div class="chip">Loading ...</div>`;
+
+ const icon = this.selected ? 'filter' : iconForRun(this.run);
+ const classes = {
+ chip: true,
+ [icon]: true,
+ selected: this.selected,
+ deselected: this.deselected,
+ };
const action = primaryRunAction(this.run);
return html`
@@ -185,10 +230,19 @@
@customElement('gr-checks-runs')
export class GrChecksRuns extends GrLitElement {
+ @query('#filterInput')
+ filterInput?: HTMLInputElement;
+
+ @internalProperty()
+ filterRegExp = new RegExp('');
+
@property()
runs: CheckRun[] = [];
- private selectedRuns = new Set<string>();
+ @property()
+ selectedRuns: string[] = [];
+
+ private isSectionExpanded = new Map<RunStatus, boolean>();
constructor() {
super();
@@ -203,9 +257,29 @@
display: block;
padding: var(--spacing-xl);
}
- .statusHeader {
+ .expandIcon {
+ width: var(--line-height-h3);
+ height: var(--line-height-h3);
+ }
+ .sectionHeader {
padding-top: var(--spacing-l);
text-transform: capitalize;
+ cursor: default;
+ }
+ .sectionHeader h3 {
+ display: inline-block;
+ }
+ .collapsed .sectionRuns {
+ display: none;
+ }
+ .collapsed {
+ border-bottom: 1px solid var(--border-color);
+ padding-bottom: var(--spacing-m);
+ }
+ input#filterInput {
+ margin-top: var(--spacing-s);
+ padding: var(--spacing-s) var(--spacing-m);
+ width: 100%;
}
.testing {
margin-top: var(--spacing-xxl);
@@ -227,6 +301,12 @@
render() {
return html`
<h2 class="heading-2">Runs</h2>
+ <input
+ id="filterInput"
+ type="text"
+ placeholder="Filter runs by regular expression"
+ @input="${this.onInput}"
+ />
${this.renderSection(RunStatus.COMPLETED)}
${this.renderSection(RunStatus.RUNNING)}
${this.renderSection(RunStatus.RUNNABLE)}
@@ -253,6 +333,11 @@
`;
}
+ onInput() {
+ assertIsDefined(this.filterInput, 'filter <input> element');
+ this.filterRegExp = new RegExp(this.filterInput.value, 'i');
+ }
+
none() {
updateStateSetResults('f0', []);
updateStateSetResults('f1', []);
@@ -277,34 +362,43 @@
renderSection(status: RunStatus) {
const runs = this.runs
.filter(r => r.status === status)
+ .filter(r => this.filterRegExp.test(r.checkName))
.sort(compareByWorstCategory);
if (runs.length === 0) return;
+ const expanded = this.isSectionExpanded.get(status) ?? true;
+ const expandedClass = expanded ? 'expanded' : 'collapsed';
+ const icon = expanded ? 'gr-icons:expand-more' : 'gr-icons:expand-less';
return html`
- <div class="${status.toLowerCase()}">
- <h3 class="statusHeader heading-3">${status.toLowerCase()}</h3>
- ${runs.map(run => this.renderRun(run))}
+ <div class="${status.toLowerCase()} ${expandedClass}">
+ <div
+ class="sectionHeader"
+ @click="${() => this.toggleExpanded(status)}"
+ >
+ <iron-icon class="expandIcon" icon="${icon}"></iron-icon>
+ <h3 class="heading-3">${status.toLowerCase()}</h3>
+ </div>
+ <div class="sectionRuns">
+ ${runs.map(run => this.renderRun(run))}
+ </div>
</div>
`;
}
+ toggleExpanded(status: RunStatus) {
+ const expanded = this.isSectionExpanded.get(status) ?? true;
+ this.isSectionExpanded.set(status, !expanded);
+ this.requestUpdate();
+ }
+
renderRun(run: CheckRun) {
- const selected = this.selectedRuns.has(run.checkName);
+ const selected = this.selectedRuns.includes(run.checkName);
+ const deselected = !selected && this.selectedRuns.length > 0;
return html`<gr-checks-run
.run="${run}"
.selected="${selected}"
- @run-selected="${this.handleRunSelected}"
+ .deselected="${deselected}"
></gr-checks-run>`;
}
-
- handleRunSelected(e: RunSelectedEvent) {
- const checkName = e.detail.checkName;
- if (this.selectedRuns.has(checkName)) {
- this.selectedRuns.delete(checkName);
- } else {
- this.selectedRuns.add(checkName);
- }
- this.requestUpdate();
- }
}
declare global {
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-tab.ts b/polygerrit-ui/app/elements/checks/gr-checks-tab.ts
index 61f8bd1..ad4f2ae 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-tab.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-tab.ts
@@ -15,7 +15,13 @@
* limitations under the License.
*/
import {html} from 'lit-html';
-import {css, customElement, property} from 'lit-element';
+import {
+ css,
+ customElement,
+ internalProperty,
+ property,
+ PropertyValues,
+} from 'lit-element';
import {GrLitElement} from '../lit/gr-lit-element';
import {Action, CheckResult, CheckRun} from '../../api/checks';
import {
@@ -33,6 +39,8 @@
fireActionTriggered,
} from '../../services/checks/checks-util';
import {checkRequiredProperty} from '../../utils/common-util';
+import {RunSelectedEvent} from './gr-checks-runs';
+import {ChecksTabState} from '../../types/events';
/**
* The "Checks" tab on the Gerrit change page. Gets its data from plugins that
@@ -48,11 +56,17 @@
actions: Action[] = [];
@property()
+ tabState?: ChecksTabState;
+
+ @property()
currentPatchNum: PatchSetNum | undefined = undefined;
@property()
changeNum: NumericChangeId | undefined = undefined;
+ @internalProperty()
+ selectedRuns: string[] = [];
+
constructor() {
super();
this.subscribe('runs', allRuns$);
@@ -100,6 +114,11 @@
render() {
const ps = `Patchset ${this.currentPatchNum} (Latest)`;
+ const filteredRuns = this.runs.filter(
+ r =>
+ this.selectedRuns.length === 0 ||
+ this.selectedRuns.includes(r.checkName)
+ );
return html`
<div class="header">
<div class="left">
@@ -118,15 +137,30 @@
</div>
</div>
<div class="container">
- <gr-checks-runs class="runs" .runs="${this.runs}"></gr-checks-runs>
+ <gr-checks-runs
+ class="runs"
+ .runs="${this.runs}"
+ .selectedRuns="${this.selectedRuns}"
+ @run-selected="${this.handleRunSelected}"
+ ></gr-checks-runs>
<gr-checks-results
class="results"
- .runs="${this.runs}"
+ .runs="${filteredRuns}"
></gr-checks-results>
</div>
`;
}
+ protected updated(changedProperties: PropertyValues) {
+ super.updated(changedProperties);
+ if (changedProperties.has('tabState')) {
+ const check = this.tabState?.checkName;
+ if (check) {
+ this.selectedRuns = [check];
+ }
+ }
+ }
+
renderAction(action: Action) {
return html`<gr-checks-top-level-action
.action="${action}"
@@ -148,6 +182,18 @@
action.name
);
}
+
+ handleRunSelected(e: RunSelectedEvent) {
+ this.toggleSelected(e.detail.checkName);
+ }
+
+ toggleSelected(checkName: string) {
+ if (this.selectedRuns.includes(checkName)) {
+ this.selectedRuns = this.selectedRuns.filter(r => r !== checkName);
+ } else {
+ this.selectedRuns = [...this.selectedRuns, checkName];
+ }
+ }
}
@customElement('gr-checks-top-level-action')
diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.ts b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.ts
index b43b3b0..bed07a6 100644
--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.ts
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.ts
@@ -304,7 +304,7 @@
if (!config) {
throw new Error('getConfig returned undefined');
}
- this._retreiveFeedbackURL(config);
+ this._retrieveFeedbackURL(config);
this._retrieveRegisterURL(config);
return getDocsBaseUrl(config, this.restApiService);
})
@@ -325,7 +325,7 @@
});
}
- _retreiveFeedbackURL(config: ServerInfo) {
+ _retrieveFeedbackURL(config: ServerInfo) {
if (config.gerrit?.report_bug_url) {
this._feedbackURL = config.gerrit.report_bug_url;
}
diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.ts b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.ts
index 7430cc0..d9c43d6 100644
--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.ts
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header_test.ts
@@ -488,7 +488,7 @@
report_bug_url: url,
},
};
- element._retreiveFeedbackURL(config);
+ element._retrieveFeedbackURL(config);
await flush();
assert.equal(element._feedbackURL, url);
diff --git a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.ts b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.ts
index f2ee838..632ce4c 100644
--- a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.ts
+++ b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.ts
@@ -249,7 +249,7 @@
export interface GenerateUrlChangeViewParameters {
view: GerritView.CHANGE;
- // TODO(TS): NumericChangeId - not sure about it, may be it can be removeds
+ // TODO(TS): NumericChangeId - not sure about it, may be it can be removed
changeNum: NumericChangeId;
project: RepoName;
patchNum?: PatchSetNum;
diff --git a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.ts b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.ts
index 43f8a2b..97d5271 100644
--- a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.ts
+++ b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.ts
@@ -93,6 +93,7 @@
'onlyextensions:',
'owner:',
'ownerin:',
+ 'parentof:',
'parentproject:',
'project:',
'projects:',
diff --git a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.ts b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.ts
index 19f43c2..b60a585 100644
--- a/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.ts
+++ b/polygerrit-ui/app/elements/diff/gr-comment-api/gr-comment-api.ts
@@ -611,7 +611,7 @@
private readonly flagsService = appContext.flagsService;
- private _isPortingCommentsExperimentEnabled = false;
+ private isPortingCommentsExperimentEnabled = false;
/** @override */
created() {
@@ -620,7 +620,7 @@
constructor() {
super();
- this._isPortingCommentsExperimentEnabled = this.flagsService.isEnabled(
+ this.isPortingCommentsExperimentEnabled = this.flagsService.isEnabled(
KnownExperimentId.PORTING_COMMENTS
);
}
@@ -636,10 +636,10 @@
this.restApiService.getDiffComments(changeNum),
this.restApiService.getDiffRobotComments(changeNum),
this.restApiService.getDiffDrafts(changeNum),
- this._isPortingCommentsExperimentEnabled
+ this.isPortingCommentsExperimentEnabled
? this.restApiService.getPortedComments(changeNum, revision)
: Promise.resolve({}),
- this._isPortingCommentsExperimentEnabled
+ this.isPortingCommentsExperimentEnabled
? this.restApiService.getPortedDrafts(changeNum, revision)
: Promise.resolve({}),
];
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.ts b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.ts
index da1b928..4943298 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.ts
@@ -33,7 +33,7 @@
/**
* In JS, unicode code points above 0xFFFF occupy two elements of a string.
- * For example '𐀏'.length is 2. An occurence of such a code point is called a
+ * For example '𐀏'.length is 2. An occurrence of such a code point is called a
* surrogate pair.
*
* This regex segments a string along tabs ('\t') and surrogate pairs, since
@@ -80,7 +80,7 @@
readonly groups: GrDiffGroup[];
- private _blameInfo: BlameInfo[] | null;
+ private blameInfo: BlameInfo[] | null;
private readonly _layerUpdateListener: (
start: LineNumber,
@@ -104,7 +104,7 @@
this._prefs = prefs;
this._outputEl = outputEl;
this.groups = [];
- this._blameInfo = null;
+ this.blameInfo = null;
if (isNaN(prefs.tab_size) || prefs.tab_size <= 0) {
throw Error('Invalid tab size from preferences.');
@@ -765,7 +765,7 @@
* re-render its blame cell content.
*/
setBlame(blame: BlameInfo[] | null) {
- this._blameInfo = blame;
+ this.blameInfo = blame;
if (!blame) return;
// TODO(wyatta): make this loop asynchronous.
@@ -890,11 +890,11 @@
* @return The commit information.
*/
_getBlameCommitForBaseLine(lineNum: LineNumber) {
- if (!this._blameInfo) {
+ if (!this.blameInfo) {
return null;
}
- for (const blameCommit of this._blameInfo) {
+ for (const blameCommit of this.blameInfo) {
for (const range of blameCommit.ranges) {
if (range.start <= lineNum && range.end >= lineNum) {
return blameCommit;
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.ts b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.ts
index 5ac37dc..cc3be07 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-cursor/gr-diff-cursor.ts
@@ -61,7 +61,7 @@
return htmlTemplate;
}
- private _preventAutoScrollOnManualScroll = false;
+ private preventAutoScrollOnManualScroll = false;
private lastDisplayedNavigateToNextFileToast: number | null = null;
@@ -338,10 +338,10 @@
}
private _boundHandleWindowScroll = () => {
- if (this._preventAutoScrollOnManualScroll) {
+ if (this.preventAutoScrollOnManualScroll) {
this._scrollMode = ScrollMode.NEVER;
this._focusOnMove = false;
- this._preventAutoScrollOnManualScroll = false;
+ this.preventAutoScrollOnManualScroll = false;
}
};
@@ -360,14 +360,14 @@
};
private _boundHandleDiffRenderStart = () => {
- this._preventAutoScrollOnManualScroll = true;
+ this.preventAutoScrollOnManualScroll = true;
};
private _boundHandleDiffRenderContent = () => {
this._updateStops();
// When done rendering, turn focus on move and automatic scrolling back on
this._focusOnMove = true;
- this._preventAutoScrollOnManualScroll = false;
+ this.preventAutoScrollOnManualScroll = false;
};
private _boundHandleDiffLineSelected = (event: Event) => {
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/gr-overview-image.ts b/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/gr-overview-image.ts
new file mode 100644
index 0000000..42268e9
--- /dev/null
+++ b/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/gr-overview-image.ts
@@ -0,0 +1,304 @@
+/**
+ * @license
+ * Copyright (C) 2021 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.
+ */
+import {
+ css,
+ customElement,
+ html,
+ internalProperty,
+ LitElement,
+ property,
+ PropertyValues,
+ query,
+} from 'lit-element';
+import {StyleInfo, styleMap} from 'lit-html/directives/style-map';
+
+import {Dimensions, fitToFrame, Point, Rect} from './util';
+
+/**
+ * Displays a scaled-down version of an image with a draggable frame for
+ * choosing a portion of the image to be magnified by other components.
+ *
+ * Slotted content can be arbitrary elements, but should be limited to images or
+ * stacks of image-like elements (e.g. for overlays) with limited interactivity,
+ * to prevent confusion, as the component only captures a limited set of events.
+ * Slotted content is scaled to fit the bounds of the component, with
+ * letterboxing if aspect ratios differ. For slotted content smaller than the
+ * component, it will cap the scale at 1x and also apply letterboxing.
+ */
+@customElement('gr-overview-image')
+export class GrOverviewImage extends LitElement {
+ @property({type: Object})
+ frameRect: Rect = {origin: {x: 0, y: 0}, dimensions: {width: 0, height: 0}};
+
+ @internalProperty() protected contentStyle: StyleInfo = {};
+
+ @internalProperty() protected contentTransformStyle: StyleInfo = {};
+
+ @internalProperty() protected frameStyle: StyleInfo = {};
+
+ @internalProperty() protected overlayStyle: StyleInfo = {};
+
+ @internalProperty() protected dragging = false;
+
+ @query('.content-box') protected contentBox!: HTMLDivElement;
+
+ @query('.content') protected content!: HTMLDivElement;
+
+ @query('.content-transform') protected contentTransform!: HTMLDivElement;
+
+ @query('.frame') protected frame!: HTMLDivElement;
+
+ private contentBounds: Dimensions = {width: 0, height: 0};
+
+ private imageBounds: Dimensions = {width: 0, height: 0};
+
+ private scale = 1;
+
+ // When grabbing the frame to drag it around, this stores the offset of the
+ // cursor from the center of the frame at the start of the drag.
+ private grabOffset: Point = {x: 0, y: 0};
+
+ private readonly resizeObserver = new ResizeObserver(
+ (entries: ResizeObserverEntry[]) => {
+ for (const entry of entries) {
+ if (entry.target === this.contentBox) {
+ this.contentBounds = {
+ width: entry.contentRect.width,
+ height: entry.contentRect.height,
+ };
+ }
+ if (entry.target === this.contentTransform) {
+ this.imageBounds = {
+ width: entry.contentRect.width,
+ height: entry.contentRect.height,
+ };
+ }
+ this.updateScale();
+ }
+ }
+ );
+
+ static styles = css`
+ :host {
+ --overview-image-background-color: #000;
+ --overview-image-frame-color: #f00;
+ display: flex;
+ }
+ * {
+ box-sizing: border-box;
+ }
+ ::slotted(*) {
+ display: block;
+ }
+ .content-box {
+ border: 1px solid var(--overview-image-background-color);
+ background-color: var(--overview-iamge-background-color);
+ width: 100%;
+ position: relative;
+ }
+ .content {
+ position: absolute;
+ cursor: pointer;
+ }
+ .content-transform {
+ position: absolute;
+ transform-origin: top left;
+ will-change: transform;
+ }
+ .frame {
+ border: 1px solid var(--overview-image-frame-color);
+ position: absolute;
+ will-change: transform;
+ }
+ .overlay {
+ position: absolute;
+ z-index: 10000;
+ cursor: grabbing;
+ }
+ `;
+
+ render() {
+ return html`
+ <div class="content-box">
+ <div
+ class="content"
+ style="${styleMap({
+ ...this.contentStyle,
+ })}"
+ @mousemove="${this.maybeDragFrame}"
+ @mousedown=${this.clickOverview}
+ @mouseup="${this.releaseFrame}"
+ >
+ <div
+ class="content-transform"
+ style="${styleMap(this.contentTransformStyle)}"
+ >
+ <slot></slot>
+ </div>
+ <div
+ class="frame"
+ style="${styleMap({
+ ...this.frameStyle,
+ cursor: this.dragging ? 'grabbing' : 'grab',
+ })}"
+ @mousedown="${this.grabFrame}"
+ ></div>
+ </div>
+ <div
+ class="overlay"
+ style="${styleMap({
+ ...this.overlayStyle,
+ display: this.dragging ? 'block' : 'none',
+ })}"
+ @mousemove="${this.overlayMouseMove}"
+ @mouseleave="${this.releaseFrame}"
+ @mouseup="${this.releaseFrame}"
+ ></div>
+ </div>
+ `;
+ }
+
+ firstUpdated() {
+ this.resizeObserver.observe(this.contentBox);
+ this.resizeObserver.observe(this.contentTransform);
+ }
+
+ updated(changedProperties: PropertyValues) {
+ if (changedProperties.has('frameRect')) {
+ this.updateFrameStyle();
+ }
+ }
+
+ clickOverview(event: MouseEvent) {
+ event.preventDefault();
+
+ this.updateOverlaySize();
+
+ this.dragging = true;
+ const rect = this.content.getBoundingClientRect();
+ this.notifyNewCenter({
+ x: (event.clientX - rect.left) / this.scale,
+ y: (event.clientY - rect.top) / this.scale,
+ });
+ }
+
+ grabFrame(event: MouseEvent) {
+ event.preventDefault();
+ // Do not bubble up into clickOverview().
+ event.stopPropagation();
+
+ this.updateOverlaySize();
+
+ this.dragging = true;
+ const rect = this.frame.getBoundingClientRect();
+ const frameCenterX = rect.x + rect.width / 2;
+ const frameCenterY = rect.y + rect.height / 2;
+ this.grabOffset = {
+ x: event.clientX - frameCenterX,
+ y: event.clientY - frameCenterY,
+ };
+ }
+
+ maybeDragFrame(event: MouseEvent) {
+ event.preventDefault();
+ if (!this.dragging) return;
+ const rect = this.content.getBoundingClientRect();
+ const center = {
+ x: (event.clientX - rect.left - this.grabOffset.x) / this.scale,
+ y: (event.clientY - rect.top - this.grabOffset.y) / this.scale,
+ };
+ this.notifyNewCenter(center);
+ }
+
+ releaseFrame(event: MouseEvent) {
+ event.preventDefault();
+ this.dragging = false;
+ this.grabOffset = {x: 0, y: 0};
+ }
+
+ overlayMouseMove(event: MouseEvent) {
+ event.preventDefault();
+ this.maybeDragFrame(event);
+ }
+
+ private updateScale() {
+ const fitted = fitToFrame(this.imageBounds, this.contentBounds);
+ this.scale = fitted.scale;
+
+ this.contentStyle = {
+ ...this.contentStyle,
+ top: `${fitted.top}px`,
+ left: `${fitted.left}px`,
+ width: `${fitted.width}px`,
+ height: `${fitted.height}px`,
+ };
+
+ this.contentTransformStyle = {
+ transform: `scale(${this.scale})`,
+ };
+
+ this.updateFrameStyle();
+ }
+
+ private updateFrameStyle() {
+ const x = this.frameRect.origin.x * this.scale;
+ const y = this.frameRect.origin.y * this.scale;
+ const width = this.frameRect.dimensions.width * this.scale;
+ const height = this.frameRect.dimensions.height * this.scale;
+ this.frameStyle = {
+ ...this.frameStyle,
+ transform: `translate(${x}px, ${y}px)`,
+ width: `${width}px`,
+ height: `${height}px`,
+ };
+ }
+
+ private updateOverlaySize() {
+ const rect = this.contentBox.getBoundingClientRect();
+ // Create a whole-page overlay to capture mouse events, so that the drag
+ // interaction continues until the user releases the mouse button. Since
+ // innerWidth and innerHeight include scrollbars, we subtract 20 pixels each
+ // to prevent the overlay from extending offscreen under any existing
+ // scrollbar and causing the scrollbar for the other dimension to show up
+ // unnecessarily.
+ const width = window.innerWidth - 20;
+ const height = window.innerHeight - 20;
+ this.overlayStyle = {
+ ...this.overlayStyle,
+ top: `-${rect.top + 1}px`,
+ left: `-${rect.left + 1}px`,
+ width: `${width}px`,
+ height: `${height}px`,
+ };
+ }
+
+ private notifyNewCenter(center: Point) {
+ this.dispatchEvent(
+ new CustomEvent('center-updated', {
+ detail: {...center},
+ bubbles: true,
+ composed: true,
+ })
+ );
+ }
+}
+
+declare global {
+ interface HTMLElementTagNameMap {
+ 'gr-overview-image': GrOverviewImage;
+ }
+}
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/gr-zoomed-image.ts b/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/gr-zoomed-image.ts
new file mode 100644
index 0000000..a14a9cc
--- /dev/null
+++ b/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/gr-zoomed-image.ts
@@ -0,0 +1,95 @@
+/**
+ * @license
+ * Copyright (C) 2021 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.
+ */
+import {
+ css,
+ customElement,
+ html,
+ internalProperty,
+ LitElement,
+ property,
+ PropertyValues,
+} from 'lit-element';
+import {StyleInfo, styleMap} from 'lit-html/directives/style-map';
+import {Rect} from './util';
+
+/**
+ * Displays its slotted content at a given scale, centered over a given point,
+ * while ensuring the content always fills the container. The content does not
+ * have to be a single image, it can be arbitrary HTML. To prevent user
+ * confusion, it should ideally be image-like, i.e. have limited or no
+ * interactivity, as the component does not prevent events or focus from
+ * reaching the slotted content.
+ */
+@customElement('gr-zoomed-image')
+export class GrZoomedImage extends LitElement {
+ @property({type: Number}) scale = 1;
+
+ @property({type: Object})
+ frameRect: Rect = {origin: {x: 0, y: 0}, dimensions: {width: 0, height: 0}};
+
+ @internalProperty() protected imageStyles: StyleInfo = {};
+
+ static styles = css`
+ :host {
+ display: block;
+ }
+ ::slotted(*) {
+ display: block;
+ }
+ #clip {
+ position: relative;
+ width: 100%;
+ height: 100%;
+ overflow: hidden;
+ }
+ #transform {
+ position: absolute;
+ transform-origin: top left;
+ will-change: transform;
+ }
+ `;
+
+ render() {
+ return html`
+ <div id="clip">
+ <div id="transform" style="${styleMap(this.imageStyles)}">
+ <slot></slot>
+ </div>
+ </div>
+ `;
+ }
+
+ updated(changedProperties: PropertyValues) {
+ if (changedProperties.has('scale') || changedProperties.has('frameRect')) {
+ this.updateImageStyles();
+ }
+ }
+
+ private updateImageStyles() {
+ const {x, y} = this.frameRect.origin;
+ this.imageStyles = {
+ 'image-rendering': this.scale >= 1 ? 'pixelated' : 'auto',
+ transform: `translate(${-x}px, ${-y}px) scale(${this.scale})`,
+ };
+ }
+}
+
+declare global {
+ interface HTMLElementTagNameMap {
+ 'gr-zoomed-image': GrZoomedImage;
+ }
+}
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/util.ts b/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/util.ts
new file mode 100644
index 0000000..b42eea9
--- /dev/null
+++ b/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/util.ts
@@ -0,0 +1,236 @@
+/**
+ * @license
+ * Copyright (C) 2021 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.
+ */
+
+export interface Point {
+ x: number;
+ y: number;
+}
+
+export interface Dimensions {
+ width: number;
+ height: number;
+}
+
+export interface Rect {
+ origin: Point;
+ dimensions: Dimensions;
+}
+
+export interface FittedContent {
+ top: number;
+ left: number;
+ width: number;
+ height: number;
+ scale: number;
+}
+
+function clamp(value: number, min: number, max: number) {
+ return Math.max(min, Math.min(value, max));
+}
+
+/**
+ * Fits content of the given dimensions into the given frame, maintaining the
+ * aspect ratio of the content and applying letterboxing / pillarboxing as
+ * needed.
+ */
+export function fitToFrame(
+ content: Dimensions,
+ frame: Dimensions
+): FittedContent {
+ const contentAspectRatio = content.width / content.height;
+ const frameAspectRatio = frame.width / frame.height;
+ // If the content is wider than the frame, it will be letterboxed, otherwise
+ // it will be pillarboxed. When letterboxed, content and frame width will
+ // match exactly, when pillarboxed, content and frame height will match
+ // exactly.
+ const isLetterboxed = contentAspectRatio > frameAspectRatio;
+ let width: number;
+ let height: number;
+ if (isLetterboxed) {
+ width = Math.min(frame.width, content.width);
+ height = content.height * (width / content.width);
+ } else {
+ height = Math.min(frame.height, content.height);
+ width = content.width * (height / content.height);
+ }
+ const top = (frame.height - height) / 2;
+ const left = (frame.width - width) / 2;
+ const scale = width / content.width;
+ return {top, left, width, height, scale};
+}
+
+function ensureInBounds(part: Rect, bounds: Dimensions): Rect {
+ const x =
+ part.dimensions.width <= bounds.width
+ ? clamp(part.origin.x, 0, bounds.width - part.dimensions.width)
+ : (bounds.width - part.dimensions.width) / 2;
+ const y =
+ part.dimensions.height <= bounds.height
+ ? clamp(part.origin.y, 0, bounds.height - part.dimensions.height)
+ : (bounds.height - part.dimensions.height) / 2;
+ return {origin: {x, y}, dimensions: part.dimensions};
+}
+
+/**
+ * Maintains a given frame inside given bounds, adjusting requested positions
+ * for the frame as needed. This supports the non-destructive application of a
+ * scaling factor, so that e.g. the magnification of an image can be changed
+ * easily while keeping the frame centered over the same spot. Changing bounds
+ * or frame size also keeps the frame position when possible.
+ */
+export class FrameConstrainer {
+ private center: Point = {x: 0, y: 0};
+
+ private frameSize: Dimensions = {width: 0, height: 0};
+
+ private bounds: Dimensions = {width: 0, height: 0};
+
+ private scale = 1;
+
+ private unscaledFrame: Rect = {
+ origin: {x: 0, y: 0},
+ dimensions: {width: 0, height: 0},
+ };
+
+ private scaledFrame: Rect = {
+ origin: {x: 0, y: 0},
+ dimensions: {width: 0, height: 0},
+ };
+
+ getCenter(): Point {
+ return {...this.center};
+ }
+
+ /**
+ * Returns the frame at its original size, positioned within the given bounds
+ * at the given scale; its origin will be in scaled bounds coordinates.
+ *
+ * Ex: for given bounds 100x50 and frame size 30x20, centered over (50, 25),
+ * all at 1x scale, when setting scale to 2, this will return a frame of size
+ * 30x20, centered over (100, 50), within bounds 200x100.
+ *
+ * Useful for positioning a viewport of fixed size over a magnified image.
+ */
+ getUnscaledFrame(): Rect {
+ return {
+ origin: {...this.unscaledFrame.origin},
+ dimensions: {...this.unscaledFrame.dimensions},
+ };
+ }
+
+ /**
+ * Returns the scaled down frame–a scale of 2 will result in frame dimensions
+ * being halved—position within the given bounds at 1x scale; its origin will
+ * be in unscaled bounds coordinates.
+ *
+ * Ex: for given bounds 100x50 and frame size 30x20, centered over (50, 25),
+ * all at 1x scale, when setting scale to 2, this will return a frame of size
+ * 15x10, centered over (50, 25), within bounds 100x50.
+ *
+ * Useful for highlighting the magnified portion of an image as determined by
+ * getUnscaledFrame() in an overview image of fixed size.
+ */
+ getScaledFrame(): Rect {
+ return {
+ origin: {...this.scaledFrame.origin},
+ dimensions: {...this.scaledFrame.dimensions},
+ };
+ }
+
+ /**
+ * Requests the frame to be centered over the given point, in unscaled bounds
+ * coordinates. This will keep the frame within the given bounds, also when
+ * requesting a center point fully outside the given bounds.
+ */
+ requestCenter(center: Point) {
+ this.center = {...center};
+
+ this.ensureFrameInBounds();
+ }
+
+ /**
+ * Sets the frame size, while keeping the frame within the given bounds, and
+ * maintaining the current center if possible.
+ */
+ setFrameSize(frameSize: Dimensions) {
+ if (frameSize.width <= 0 || frameSize.height <= 0) return;
+ this.frameSize = {...frameSize};
+
+ this.ensureFrameInBounds();
+ }
+
+ /**
+ * Sets the bounds, while keeping the frame within them, and maintaining the
+ * current center if possible.
+ */
+ setBounds(bounds: Dimensions) {
+ if (bounds.width <= 0 || bounds.height <= 0) return;
+ this.bounds = {...bounds};
+
+ this.ensureFrameInBounds();
+ }
+
+ /**
+ * Sets the applied scale, while keeping the frame within the given bounds,
+ * and maintaining the current center if possible (both relevant moving from
+ * a larger scale to a smaller scale).
+ */
+ setScale(scale: number) {
+ if (!scale || scale <= 0) return;
+ this.scale = scale;
+
+ this.ensureFrameInBounds();
+ }
+
+ private ensureFrameInBounds() {
+ const scaledCenter = {
+ x: this.center.x * this.scale,
+ y: this.center.y * this.scale,
+ };
+ const scaledBounds = {
+ width: this.bounds.width * this.scale,
+ height: this.bounds.height * this.scale,
+ };
+ const scaledFrameSize = {
+ width: this.frameSize.width / this.scale,
+ height: this.frameSize.height / this.scale,
+ };
+
+ const requestedUnscaledFrame = {
+ origin: {
+ x: scaledCenter.x - this.frameSize.width / 2,
+ y: scaledCenter.y - this.frameSize.height / 2,
+ },
+ dimensions: this.frameSize,
+ };
+ const requestedScaledFrame = {
+ origin: {
+ x: this.center.x - scaledFrameSize.width / 2,
+ y: this.center.y - scaledFrameSize.height / 2,
+ },
+ dimensions: scaledFrameSize,
+ };
+
+ this.unscaledFrame = ensureInBounds(requestedUnscaledFrame, scaledBounds);
+ this.scaledFrame = ensureInBounds(requestedScaledFrame, this.bounds);
+
+ this.center = {
+ x: this.scaledFrame.origin.x + this.scaledFrame.dimensions.width / 2,
+ y: this.scaledFrame.origin.y + this.scaledFrame.dimensions.height / 2,
+ };
+ }
+}
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/util_test.js b/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/util_test.js
new file mode 100644
index 0000000..80cfa36
--- /dev/null
+++ b/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/util_test.js
@@ -0,0 +1,171 @@
+/**
+ * @license
+ * Copyright (C) 2021 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.
+ */
+import '../../../test/common-test-setup-karma.js';
+import {FrameConstrainer} from './util.js';
+
+suite('FrameConstrainer tests', () => {
+ let constrainer;
+
+ setup(() => {
+ constrainer = new FrameConstrainer();
+ constrainer.setBounds({width: 100, height: 100});
+ constrainer.setFrameSize({width: 50, height: 50});
+ constrainer.requestCenter({x: 50, y: 50});
+ });
+
+ suite('changing center', () => {
+ test('moves frame to requested position', () => {
+ constrainer.requestCenter({x: 30, y: 30});
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 5, y: 5}, dimensions: {width: 50, height: 50}});
+ });
+
+ test('keeps frame in bounds for top left corner', () => {
+ constrainer.requestCenter({x: 5, y: 5});
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 0, y: 0}, dimensions: {width: 50, height: 50}});
+ });
+
+ test('keeps frame in bounds for bottom right corner', () => {
+ constrainer.requestCenter({x: 95, y: 95});
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 50, y: 50}, dimensions: {width: 50, height: 50}});
+ });
+
+ test('handles out-of-bounds center left', () => {
+ constrainer.requestCenter({x: -5, y: 50});
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 0, y: 25}, dimensions: {width: 50, height: 50}});
+ });
+
+ test('handles out-of-bounds center right', () => {
+ constrainer.requestCenter({x: 105, y: 50});
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 50, y: 25}, dimensions: {width: 50, height: 50}});
+ });
+
+ test('handles out-of-bounds center top', () => {
+ constrainer.requestCenter({x: 50, y: -5});
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 25, y: 0}, dimensions: {width: 50, height: 50}});
+ });
+
+ test('handles out-of-bounds center bottom', () => {
+ constrainer.requestCenter({x: 50, y: 105});
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 25, y: 50}, dimensions: {width: 50, height: 50}});
+ });
+ });
+
+ suite('changing frame size', () => {
+ test('maintains center when decreased', () => {
+ constrainer.setFrameSize({width: 10, height: 10});
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 45, y: 45}, dimensions: {width: 10, height: 10}});
+ });
+
+ test('maintains center when increased', () => {
+ constrainer.setFrameSize({width: 80, height: 80});
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 10, y: 10}, dimensions: {width: 80, height: 80}});
+ });
+
+ test('updates center to remain in bounds when increased', () => {
+ constrainer.setFrameSize({width: 10, height: 10});
+ constrainer.requestCenter({x: 95, y: 95});
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 90, y: 90}, dimensions: {width: 10, height: 10}});
+
+ constrainer.setFrameSize({width: 20, height: 20});
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 80, y: 80}, dimensions: {width: 20, height: 20}});
+ });
+ });
+
+ suite('changing scale', () => {
+ suite('for unscaled frame', () => {
+ test('adjusts origin to maintain center when zooming in', () => {
+ constrainer.setScale(2);
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 75, y: 75}, dimensions: {width: 50, height: 50}});
+ });
+
+ test('adjusts origin to maintain center when zooming out', () => {
+ constrainer.setFrameSize({width: 20, height: 20});
+ constrainer.setScale(0.5);
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 15, y: 15}, dimensions: {width: 20, height: 20}});
+ });
+
+ test('keeps frame in bounds when zooming out', () => {
+ constrainer.setScale(5);
+ constrainer.requestCenter({x: 100, y: 100});
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 450, y: 450}, dimensions: {width: 50, height: 50}});
+
+ constrainer.setScale(1);
+ assert.deepEqual(
+ constrainer.getUnscaledFrame(),
+ {origin: {x: 50, y: 50}, dimensions: {width: 50, height: 50}});
+ });
+ });
+
+ suite('for scaled frame', () => {
+ test('decreases frame size and maintains center when zooming in', () => {
+ constrainer.setScale(2);
+ assert.deepEqual(
+ constrainer.getScaledFrame(),
+ {origin: {x: 37.5, y: 37.5}, dimensions: {width: 25, height: 25}});
+ });
+
+ test('increases frame size and maintains center when zooming out', () => {
+ constrainer.setFrameSize({width: 20, height: 20});
+ constrainer.setScale(0.5);
+ assert.deepEqual(
+ constrainer.getScaledFrame(),
+ {origin: {x: 30, y: 30}, dimensions: {width: 40, height: 40}});
+ });
+
+ test('keeps frame in bounds when zooming out', () => {
+ constrainer.setScale(5);
+ constrainer.requestCenter({x: 100, y: 100});
+ assert.deepEqual(
+ constrainer.getScaledFrame(),
+ {origin: {x: 90, y: 90}, dimensions: {width: 10, height: 10}});
+
+ constrainer.setScale(1);
+ assert.deepEqual(
+ constrainer.getScaledFrame(),
+ {origin: {x: 50, y: 50}, dimensions: {width: 50, height: 50}});
+ });
+ });
+ });
+});
\ No newline at end of file
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector.ts b/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector.ts
index cfe2cfe..60f2853 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector.ts
@@ -60,17 +60,17 @@
this.restApiService.savePreferences({diff_view: newMode});
}
this.mode = newMode;
- let annoucement;
+ let announcement;
if (this.isUnifiedSelected(newMode)) {
- annoucement = 'Changed diff view to unified';
+ announcement = 'Changed diff view to unified';
} else if (this.isSideBySideSelected(newMode)) {
- annoucement = 'Changed diff view to side by side';
+ announcement = 'Changed diff view to side by side';
}
- if (annoucement) {
+ if (announcement) {
this.fire(
'iron-announce',
{
- text: annoucement,
+ text: announcement,
},
{bubbles: true}
);
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.ts b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.ts
index 088d9cf..2c4b8f6 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.ts
@@ -1465,9 +1465,9 @@
) {
let patchNum = patchRange.patchNum;
- const comparedAgainsParent = patchRange.basePatchNum === 'PARENT';
+ const comparedAgainstParent = patchRange.basePatchNum === 'PARENT';
- if (isBase && !comparedAgainsParent) {
+ if (isBase && !comparedAgainstParent) {
patchNum = patchRange.basePatchNum;
}
@@ -1475,7 +1475,7 @@
changeBaseURL(project, changeNum, patchNum) +
`/files/${encodeURIComponent(path)}/download`;
- if (isBase && comparedAgainsParent) {
+ if (isBase && comparedAgainstParent) {
url += '?parent=1';
}
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff-utils.ts b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff-utils.ts
index 5edd353..0ca929a 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff-utils.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff-utils.ts
@@ -40,7 +40,7 @@
}
export function isLongCommentRange(range: CommentRange): boolean {
- return range.end_line - range.start_line > 5;
+ return range.end_line - range.start_line > 10;
}
export function getLineNumber(lineEl?: Element | null): LineNumber | null {
@@ -88,7 +88,7 @@
// TODO: This type should be exposed to gr-diff clients in a separate type file.
// For Gerrit these are instances of GrCommentThread, but other gr-diff users
// have different HTML elements in use for comment threads.
-// TODO: Also document the required HTML attritbutes that thread elements must
+// TODO: Also document the required HTML attributes that thread elements must
// have, e.g. 'diff-side', 'range', 'line-num', 'data-value'.
export interface GrDiffThreadElement extends HTMLElement {
rootId: string;
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_test.js b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_test.js
index 6fef223..49eac72 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff_test.js
@@ -558,7 +558,7 @@
test('adds long range comment chip', async () => {
const range = {
start_line: 1,
- end_line: 7,
+ end_line: 12,
start_character: 0,
end_character: 0,
};
@@ -572,7 +572,7 @@
a: [],
b: [],
}, {
- ab: Array(8).fill('text'),
+ ab: Array(13).fill('text'),
}];
setupSampleDiff({content});
@@ -586,7 +586,7 @@
test('no duplicate range chip for same thread', async () => {
const range = {
start_line: 1,
- end_line: 7,
+ end_line: 12,
start_character: 0,
end_character: 0,
};
@@ -604,7 +604,7 @@
a: [],
b: [],
}, {
- ab: Array(8).fill('text'),
+ ab: Array(13).fill('text'),
}];
setupSampleDiff({content});
diff --git a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_html.ts b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_html.ts
index 52465b3..5ab8449 100644
--- a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_html.ts
+++ b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_html.ts
@@ -35,7 +35,6 @@
text-transform: none;
font-family: var(--font-family);
}
- --trigger-hover-color: rgba(0, 0, 0, 0.6);
}
@media screen and (max-width: 50em) {
.filesWeblinks {
diff --git a/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer_test.js b/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer_test.js
index fad717d..8279ab1 100644
--- a/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer_test.js
@@ -72,7 +72,7 @@
side: 'right',
range: {
end_character: 1,
- end_line: 70,
+ end_line: 71,
start_character: 1,
start_line: 60,
},
@@ -314,10 +314,10 @@
assert.equal(element._rangesMap.left[39][0].start, 0);
assert.equal(element._rangesMap.left[39][0].end, 9);
- // The right has four ranged comments: 10-12, 55-55, 60-70, 100-100
+ // The right has four ranged comments: 10-12, 55-55, 60-71, 100-100
const rightKeys = [];
for (let i = 10; i <= 12; i++) { rightKeys.push('' + i); }
- for (let i = 60; i <= 70; i++) { rightKeys.push('' + i); }
+ for (let i = 60; i <= 71; i++) { rightKeys.push('' + i); }
rightKeys.push('55', '100');
assert.deepEqual(Object.keys(element._rangesMap.right).sort(),
rightKeys.sort());
diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts
index da29b85..1150674 100644
--- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts
+++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts
@@ -492,7 +492,7 @@
* with code it shouldn't AND to avoid executing regexes as much as
* possible.
* * These tests should document the issue clearly enough that the test can
- * be condidently removed when the issue is solved in HLJS.
+ * be confidently removed when the issue is solved in HLJS.
* * These tests should rewrite the line of code to have the same number of
* characters. This method rewrites the string that gets parsed, but NOT
* the string that gets displayed and highlighted. Thus, the positions
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.ts b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.ts
index b36edd4..bc153ee 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.ts
+++ b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.ts
@@ -277,7 +277,8 @@
return this.restApiService
.queryChangeFiles(this.change._number, this.patchNum, input)
.then(res => {
- if (!res) throw new Error('Failed to retrieve files. Reponse not set.');
+ if (!res)
+ throw new Error('Failed to retrieve files. Response not set.');
return res.map(file => {
return {name: file};
});
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.js b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.js
index be6ffc4..bbf4790 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.js
+++ b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.js
@@ -50,14 +50,14 @@
suite('edit button CUJ', () => {
let navStubs;
- let openAutoCcmplete;
+ let openAutoComplete;
setup(() => {
navStubs = [
sinon.stub(GerritNav, 'getEditUrlForDiff'),
sinon.stub(GerritNav, 'navigateToRelativeUrl'),
];
- openAutoCcmplete = element.$.openDialog.querySelector('gr-autocomplete');
+ openAutoComplete = element.$.openDialog.querySelector('gr-autocomplete');
});
test('_isValidPath', () => {
@@ -77,9 +77,9 @@
assert.isFalse(queryStub.called);
// Setup _focused manually - in headless mode Chrome sometimes don't
// setup focus. flush and/or flushAsynchronousOperations don't help
- openAutoCcmplete._focused = true;
- openAutoCcmplete.noDebounce = true;
- openAutoCcmplete.text = 'src/test.cpp';
+ openAutoComplete._focused = true;
+ openAutoComplete.noDebounce = true;
+ openAutoComplete.text = 'src/test.cpp';
assert.isTrue(queryStub.called);
assert.isFalse(element.$.openDialog.disabled);
MockInteractions.tap(element.$.openDialog.shadowRoot
@@ -95,8 +95,8 @@
MockInteractions.tap(element.shadowRoot.querySelector('#open'));
return showDialogSpy.lastCall.returnValue.then(() => {
assert.isTrue(element.$.openDialog.disabled);
- openAutoCcmplete.noDebounce = true;
- openAutoCcmplete.text = 'src/test.cpp';
+ openAutoComplete.noDebounce = true;
+ openAutoComplete.text = 'src/test.cpp';
assert.isFalse(element.$.openDialog.disabled);
MockInteractions.tap(element.$.openDialog.shadowRoot
.querySelector('gr-button'));
diff --git a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts
index 1864598..1e08a5c 100644
--- a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts
+++ b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts
@@ -200,7 +200,7 @@
}
_handlePathChanged(e: CustomEvent<string>) {
- // TODO(TS) could be cleand up, it was added for type requirements
+ // TODO(TS) could be cleaned up, it was added for type requirements
if (this._changeNum === undefined || !this._path) {
return Promise.reject(new Error('changeNum or path undefined'));
}
diff --git a/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.js b/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.js
index ea7bdc3..7ea3be3 100644
--- a/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.js
+++ b/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.js
@@ -20,7 +20,7 @@
import {GrAttributeHelper} from './gr-attribute-helper.js';
Polymer({
- is: 'gr-attrubute-helper-some-element',
+ is: 'gr-attribute-helper-some-element',
properties: {
fooBar: {
type: Object,
@@ -29,7 +29,7 @@
},
});
-const basicFixture = fixtureFromElement('gr-attrubute-helper-some-element');
+const basicFixture = fixtureFromElement('gr-attribute-helper-some-element');
suite('gr-attribute-helper tests', () => {
let element;
diff --git a/polygerrit-ui/app/elements/plugins/gr-change-metadata-api/gr-change-metadata-api.ts b/polygerrit-ui/app/elements/plugins/gr-change-metadata-api/gr-change-metadata-api.ts
index 3a61bce..a03c5dc 100644
--- a/polygerrit-ui/app/elements/plugins/gr-change-metadata-api/gr-change-metadata-api.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-change-metadata-api/gr-change-metadata-api.ts
@@ -19,24 +19,24 @@
import {HookApi} from '../../../api/hook';
export class GrChangeMetadataApi implements ChangeMetadataPluginApi {
- private _hook: HookApi | null;
+ private hook: HookApi | null;
public plugin: PluginApi;
constructor(plugin: PluginApi) {
this.plugin = plugin;
- this._hook = null;
+ this.hook = null;
}
_createHook() {
- this._hook = this.plugin.hook('change-metadata-item');
+ this.hook = this.plugin.hook('change-metadata-item');
}
onLabelsChanged(callback: (value: unknown) => void) {
- if (!this._hook) {
+ if (!this.hook) {
this._createHook();
}
- this._hook!.onAttached((element: Element) =>
+ this.hook!.onAttached((element: Element) =>
this.plugin.attributeHelper(element).bind('labels', callback)
);
return this;
diff --git a/polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks.ts b/polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks.ts
index d2568ad..3e8f0a4 100644
--- a/polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks.ts
@@ -19,13 +19,13 @@
import {HookApi, HookCallback} from '../../../api/hook';
export class GrDomHooksManager {
- private _hooks: Record<string, GrDomHook>;
+ private hooks: Record<string, GrDomHook>;
- private _plugin: PluginApi;
+ private plugin: PluginApi;
constructor(plugin: PluginApi) {
- this._plugin = plugin;
- this._hooks = {};
+ this.plugin = plugin;
+ this.hooks = {};
}
_getHookName(endpointName: string, moduleName?: string) {
@@ -36,37 +36,36 @@
// TODO: this still can not prevent if plugin has invalid char
// other than uppercase, but is the first step
// https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
- const pluginName: string =
- this._plugin.getPluginName() || 'unknown_plugin';
+ const pluginName: string = this.plugin.getPluginName() || 'unknownplugin';
return pluginName.toLowerCase() + '-autogenerated-' + endpointName;
}
}
getDomHook(endpointName: string, moduleName?: string) {
const hookName = this._getHookName(endpointName, moduleName);
- if (!this._hooks[hookName]) {
- this._hooks[hookName] = new GrDomHook(hookName, moduleName);
+ if (!this.hooks[hookName]) {
+ this.hooks[hookName] = new GrDomHook(hookName, moduleName);
}
- return this._hooks[hookName];
+ return this.hooks[hookName];
}
}
export class GrDomHook implements HookApi {
- private _instances: HTMLElement[] = [];
+ private instances: HTMLElement[] = [];
- private _attachCallbacks: HookCallback[] = [];
+ private attachCallbacks: HookCallback[] = [];
- private _detachCallbacks: HookCallback[] = [];
+ private detachCallbacks: HookCallback[] = [];
- private _moduleName: string;
+ private moduleName: string;
- private _lastAttachedPromise: Promise<HTMLElement> | null = null;
+ private lastAttachedPromise: Promise<HTMLElement> | null = null;
constructor(hookName: string, moduleName?: string) {
if (moduleName) {
- this._moduleName = moduleName;
+ this.moduleName = moduleName;
} else {
- this._moduleName = hookName;
+ this.moduleName = hookName;
this._createPlaceholder(hookName);
}
}
@@ -89,16 +88,16 @@
}
handleInstanceDetached(instance: HTMLElement) {
- const index = this._instances.indexOf(instance);
+ const index = this.instances.indexOf(instance);
if (index !== -1) {
- this._instances.splice(index, 1);
+ this.instances.splice(index, 1);
}
- this._detachCallbacks.forEach(callback => callback(instance));
+ this.detachCallbacks.forEach(callback => callback(instance));
}
handleInstanceAttached(instance: HTMLElement) {
- this._instances.push(instance);
- this._attachCallbacks.forEach(callback => callback(instance));
+ this.instances.push(instance);
+ this.attachCallbacks.forEach(callback => callback(instance));
}
/**
@@ -106,32 +105,32 @@
* Returns a Promise, that's resolved when attachment is done.
*/
getLastAttached(): Promise<HTMLElement> {
- if (this._instances.length) {
- return Promise.resolve(this._instances.slice(-1)[0]);
+ if (this.instances.length) {
+ return Promise.resolve(this.instances.slice(-1)[0]);
}
- if (!this._lastAttachedPromise) {
+ if (!this.lastAttachedPromise) {
let resolve: HookCallback;
const promise = new Promise<HTMLElement>(r => {
resolve = r;
- this._attachCallbacks.push(resolve);
+ this.attachCallbacks.push(resolve);
});
- this._lastAttachedPromise = promise.then((element: HTMLElement) => {
- this._lastAttachedPromise = null;
- const index = this._attachCallbacks.indexOf(resolve);
+ this.lastAttachedPromise = promise.then((element: HTMLElement) => {
+ this.lastAttachedPromise = null;
+ const index = this.attachCallbacks.indexOf(resolve);
if (index !== -1) {
- this._attachCallbacks.splice(index, 1);
+ this.attachCallbacks.splice(index, 1);
}
return element;
});
}
- return this._lastAttachedPromise;
+ return this.lastAttachedPromise;
}
/**
* Get all DOM hook elements.
*/
getAllAttached() {
- return this._instances;
+ return this.instances;
}
/**
@@ -139,7 +138,7 @@
* is attached.
*/
onAttached(callback: HookCallback) {
- this._attachCallbacks.push(callback);
+ this.attachCallbacks.push(callback);
return this;
}
@@ -149,7 +148,7 @@
*
*/
onDetached(callback: HookCallback) {
- this._detachCallbacks.push(callback);
+ this.detachCallbacks.push(callback);
return this;
}
@@ -157,6 +156,6 @@
* Name of DOM hook element that will be installed into the endpoint.
*/
getModuleName() {
- return this._moduleName;
+ return this.moduleName;
}
}
diff --git a/polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks_test.js b/polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks_test.js
index 49223b9..883f2a6 100644
--- a/polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks_test.js
+++ b/polygerrit-ui/app/elements/plugins/gr-dom-hooks/gr-dom-hooks_test.js
@@ -45,7 +45,7 @@
});
test('getModuleName()', () => {
- const hookName = Object.keys(instance._hooks).pop();
+ const hookName = Object.keys(instance.hooks).pop();
assert.equal(hookName, 'testplugin-autogenerated-foo-bar');
assert.equal(hook.getModuleName(), 'testplugin-autogenerated-foo-bar');
});
@@ -57,7 +57,7 @@
});
test('getModuleName()', () => {
- const hookName = Object.keys(instance._hooks).pop();
+ const hookName = Object.keys(instance.hooks).pop();
assert.equal(hookName, 'foo-bar my-el');
assert.equal(hook.getModuleName(), 'my-el');
});
diff --git a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface.ts b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface.ts
index 07d11ec..dcabc80 100644
--- a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface.ts
@@ -27,23 +27,23 @@
/**
* Plugin popup API.
* Provides method for opening and closing popups from plugin.
- * opt_moduleName is a name of custom element that will be automatically
+ * optmoduleName is a name of custom element that will be automatically
* inserted on popup opening.
*/
export class GrPopupInterface implements PopupPluginApi {
- private _openingPromise: Promise<GrPopupInterface> | null = null;
+ private openingPromise: Promise<GrPopupInterface> | null = null;
- private _popup: GrPluginPopup | null = null;
+ private popup: GrPluginPopup | null = null;
constructor(
readonly plugin: PluginApi,
- private _moduleName: string | null = null
+ private moduleName: string | null = null
) {}
_getElement() {
// TODO(TS): maybe consider removing this if no one is using
// anything other than native methods on the return
- return (dom(this._popup) as unknown) as HTMLElement;
+ return (dom(this.popup) as unknown) as HTMLElement;
}
/**
@@ -52,34 +52,34 @@
* if it was provided with constructor.
*/
open(): Promise<PopupPluginApi> {
- if (!this._openingPromise) {
- this._openingPromise = this.plugin
+ if (!this.openingPromise) {
+ this.openingPromise = this.plugin
.hook('plugin-overlay')
.getLastAttached()
.then(hookEl => {
const popup = document.createElement('gr-plugin-popup');
- if (this._moduleName) {
+ if (this.moduleName) {
const el = popup.appendChild(
- document.createElement(this._moduleName) as CustomPolymerPluginEl
+ document.createElement(this.moduleName) as CustomPolymerPluginEl
);
el.plugin = this.plugin;
}
- this._popup = hookEl.appendChild(popup);
+ this.popup = hookEl.appendChild(popup);
flush();
- return this._popup.open().then(() => this);
+ return this.popup.open().then(() => this);
});
}
- return this._openingPromise;
+ return this.openingPromise;
}
/**
* Hides the popup.
*/
close() {
- if (!this._popup) {
+ if (!this.popup) {
return;
}
- this._popup.close();
- this._openingPromise = null;
+ this.popup.close();
+ this.openingPromise = null;
}
}
diff --git a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api.ts b/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api.ts
index e42ca08..0418edb 100644
--- a/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-repo-api/gr-repo-api.ts
@@ -29,7 +29,7 @@
}
export class GrRepoApi implements RepoPluginApi {
- private _hook?: HookApi;
+ private hook?: HookApi;
constructor(readonly plugin: PluginApi) {}
@@ -43,12 +43,12 @@
}
createCommand(title: string, callback: RepoCommandCallback) {
- if (this._hook) {
+ if (this.hook) {
console.warn('Already set up.');
return this;
}
- this._hook = this._createHook(title);
- this._hook.onAttached(element => {
+ this.hook = this._createHook(title);
+ this.hook.onAttached(element => {
if (callback(element.repoName, element.config) === false) {
element.hidden = true;
}
@@ -57,11 +57,11 @@
}
onTap(callback: (event: Event) => boolean) {
- if (!this._hook) {
+ if (!this.hook) {
console.warn('Call createCommand first.');
return this;
}
- this._hook.onAttached(element => {
+ this.hook.onAttached(element => {
this.plugin.eventHelper(element).on('command-tap', callback);
});
return this;
diff --git a/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view_html.ts b/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view_html.ts
index 91ca402..59203d3 100644
--- a/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view_html.ts
+++ b/polygerrit-ui/app/elements/settings/gr-cla-view/gr-cla-view_html.ts
@@ -25,7 +25,7 @@
margin-bottom: var(--spacing-m);
}
.agreementsUrl {
- border: 1px solid #b0bdcc;
+ border: 1px solid var(--border-color);
margin-bottom: var(--spacing-xl);
margin-left: var(--spacing-xl);
margin-right: var(--spacing-xl);
diff --git a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip_html.ts b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip_html.ts
index 3bb1458..4e6dd1a 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip_html.ts
@@ -58,7 +58,6 @@
gr-button.remove:focus {
--gr-button: {
@apply --gr-remove-button-style;
- color: #333;
}
}
gr-button.remove {
diff --git a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_html.ts b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_html.ts
index d105c5d..e55c8f1 100644
--- a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_html.ts
@@ -22,7 +22,7 @@
display: inline-block;
border-radius: 50%;
background-size: cover;
- background-color: var(--avatar-background-color, #f1f2f3);
+ background-color: var(--avatar-background-color, var(--gray-background));
}
</style>
`;
diff --git a/polygerrit-ui/app/elements/shared/gr-button/gr-button.ts b/polygerrit-ui/app/elements/shared/gr-button/gr-button.ts
index 7a6ce2c..60b891e 100644
--- a/polygerrit-ui/app/elements/shared/gr-button/gr-button.ts
+++ b/polygerrit-ui/app/elements/shared/gr-button/gr-button.ts
@@ -61,7 +61,7 @@
tooltip = '';
// Note: don't assign a value to this, since constructor is called
- // after created, the initial value maybe overriden by this
+ // after created, the initial value maybe overridden by this
@property({type: String})
_initialTabindex?: string;
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts
index 76bbd67..55408c0 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts
@@ -23,12 +23,12 @@
font-size: var(--font-size-normal);
font-weight: var(--font-weight-normal);
line-height: var(--line-height-normal);
- /* Explicitly set the background color of the diff to be white. We
+ /* Explicitly set the background color of the diff. We
* cannot use the diff content type ab because of the skip chunk preceding
* it, diff processor assumes the chunk of type skip/ab can be collapsed
* and hides our diff behind context control buttons.
* */
- --dark-add-highlight-color: white;
+ --dark-add-highlight-color: var(--background-color-primary);
}
gr-button {
margin-left: var(--spacing-m);
diff --git a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts
index 2fbbd7c..119ed20 100644
--- a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts
+++ b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts
@@ -54,8 +54,8 @@
export type Stop = HTMLElement | AbortStop;
/**
- * Type guard and checker to check if a stop can be targetted.
- * Abort stops cannot be targetted.
+ * Type guard and checker to check if a stop can be targeted.
+ * Abort stops cannot be targeted.
*/
export function isTargetable(stop: Stop): stop is HTMLElement {
return !(stop instanceof AbortStop);
diff --git a/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.ts b/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.ts
index d2f003b..4c2a417 100644
--- a/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.ts
+++ b/polygerrit-ui/app/elements/shared/gr-download-commands/gr-download-commands.ts
@@ -52,7 +52,7 @@
// TODO(TS): maybe default to [] as only used in dom-repeat
@property({type: Array})
- comamnds?: Command[];
+ commands?: Command[];
@property({type: Boolean})
_loggedIn = false;
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts
index 3fce16e..888f34f 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts
@@ -32,7 +32,7 @@
import {NormalizedFileInfo} from '../../change/gr-file-list/gr-file-list';
/**
- * Requred values are text and value. mobileText and triggerText will
+ * Required values are text and value. mobileText and triggerText will
* fall back to text if not provided.
*
* If bottomText is not provided, nothing will display on the second
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.ts b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.ts
index e67e1f6..b8f0161 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.ts
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.ts
@@ -110,13 +110,13 @@
@property({type: String})
containerId = 'gr-hovercard-container';
- private _hideDebouncer: Debouncer | null = null;
+ private hideDebouncer: Debouncer | null = null;
- private _showDebouncer: Debouncer | null = null;
+ private showDebouncer: Debouncer | null = null;
- private _isScheduledToShow?: boolean;
+ private isScheduledToShow?: boolean;
- private _isScheduledToHide?: boolean;
+ private isScheduledToHide?: boolean;
/** @override */
attached() {
@@ -174,24 +174,24 @@
debounceHide() {
this.cancelShowDebouncer();
- if (!this._isShowing || this._isScheduledToHide) return;
- this._isScheduledToHide = true;
- this._hideDebouncer = Debouncer.debounce(
- this._hideDebouncer,
+ if (!this._isShowing || this.isScheduledToHide) return;
+ this.isScheduledToHide = true;
+ this.hideDebouncer = Debouncer.debounce(
+ this.hideDebouncer,
timeOut.after(HIDE_DELAY_MS),
() => {
// This happens when hide immediately through click or mouse leave
// on the hovercard
- if (!this._isScheduledToHide) return;
+ if (!this.isScheduledToHide) return;
this.hide();
}
);
}
cancelHideDebouncer() {
- if (this._hideDebouncer) {
- this._hideDebouncer.cancel();
- this._isScheduledToHide = false;
+ if (this.hideDebouncer) {
+ this.hideDebouncer.cancel();
+ this.isScheduledToHide = false;
}
}
@@ -305,23 +305,23 @@
*/
debounceShowBy(delayMs: number) {
this.cancelHideDebouncer();
- if (this._isShowing || this._isScheduledToShow) return;
- this._isScheduledToShow = true;
- this._showDebouncer = Debouncer.debounce(
- this._showDebouncer,
+ if (this._isShowing || this.isScheduledToShow) return;
+ this.isScheduledToShow = true;
+ this.showDebouncer = Debouncer.debounce(
+ this.showDebouncer,
timeOut.after(delayMs),
() => {
// This happens when the mouse leaves the target before the delay is over.
- if (!this._isScheduledToShow) return;
+ if (!this.isScheduledToShow) return;
this.show();
}
);
}
cancelShowDebouncer() {
- if (this._showDebouncer) {
- this._showDebouncer.cancel();
- this._isScheduledToShow = false;
+ if (this.showDebouncer) {
+ this.showDebouncer.cancel();
+ this.isScheduledToShow = false;
}
}
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard_test.js b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard_test.js
index 6b2e620..628b1e9 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard_test.js
@@ -120,18 +120,18 @@
button.dispatchEvent(new CustomEvent('mouseenter'));
await enterPromise;
- assert.isTrue(element._isScheduledToShow);
- element._showDebouncer.flush();
+ assert.isTrue(element.isScheduledToShow);
+ element.showDebouncer.flush();
assert.isTrue(element._isShowing);
- assert.isFalse(element._isScheduledToShow);
+ assert.isFalse(element.isScheduledToShow);
button.dispatchEvent(new CustomEvent('mouseleave'));
await leavePromise;
- assert.isTrue(element._isScheduledToHide);
+ assert.isTrue(element.isScheduledToHide);
assert.isTrue(element._isShowing);
- element._hideDebouncer.flush();
- assert.isFalse(element._isScheduledToShow);
+ element.hideDebouncer.flush();
+ assert.isFalse(element.isScheduledToShow);
assert.isFalse(element._isShowing);
button.removeEventListener('mouseenter', enterResolve);
@@ -152,11 +152,11 @@
button.dispatchEvent(new CustomEvent('mouseenter'));
await enterPromise;
- assert.isTrue(element._isScheduledToShow);
+ assert.isTrue(element.isScheduledToShow);
MockInteractions.tap(button);
await clickPromise;
- assert.isFalse(element._isScheduledToShow);
+ assert.isFalse(element.isScheduledToShow);
assert.isFalse(element._isShowing);
button.removeEventListener('mouseenter', enterResolve);
diff --git a/polygerrit-ui/app/elements/shared/gr-icons/gr-icons.ts b/polygerrit-ui/app/elements/shared/gr-icons/gr-icons.ts
index 0a3ef5b..7745da8 100644
--- a/polygerrit-ui/app/elements/shared/gr-icons/gr-icons.ts
+++ b/polygerrit-ui/app/elements/shared/gr-icons/gr-icons.ts
@@ -128,6 +128,8 @@
<g id="message"><path d="M0 0h24v24H0z" fill="none"/><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z"/></g>
<!-- This SVG is a copy from material.io https://material.io/icons/#launch-->
<g id="launch"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"/></g>
+ <!-- This SVG is a copy from material.io https://material.io/icons/#filter-->
+ <g id="filter"><path d="M0,0h24 M24,24H0" fill="none"/><path d="M4.25,5.61C6.27,8.2,10,13,10,13v6c0,0.55,0.45,1,1,1h2c0.55,0,1-0.45,1-1v-6c0,0,3.72-4.8,5.74-7.39 C20.25,4.95,19.78,4,18.95,4H5.04C4.21,4,3.74,4.95,4.25,5.61z"/><path d="M0,0h24v24H0V0z" fill="none"/></g>
<!-- This is just a placeholder, i.e. an empty icon that has the same size as a normal icon. -->
<g id="placeholder"><path d="M0 0h24v24H0z" fill="none"/></g>
</defs>
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api.ts
index 2f2b5ce..a4c6974 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api.ts
@@ -60,7 +60,7 @@
}
export class GrChangeActionsInterface implements ChangeActionsPluginApi {
- private _el?: GrChangeActionsElement;
+ private el?: GrChangeActionsElement;
RevisionActions = RevisionActions;
@@ -80,7 +80,7 @@
console.warn('changeActions() is not ready');
return;
}
- this._el = el;
+ this.el = el;
}
/**
@@ -88,7 +88,7 @@
* element and retrieve if the interface was created before element.
*/
private ensureEl(): GrChangeActionsElement {
- if (!this._el) {
+ if (!this.el) {
const sharedApiElement = appContext.jsApiService;
this.setEl(
(sharedApiElement.getElement(
@@ -96,7 +96,7 @@
) as unknown) as GrChangeActionsElement
);
}
- return this._el!;
+ return this.el!;
}
addPrimaryActionKey(key: PrimaryActionKey) {
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts
index 27bc591..7f9218a 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts
@@ -250,7 +250,7 @@
* });
* });
*
- * // Listen on your-special-event from pluignB
+ * // Listen on your-special-event from pluginB
* Gerrit.install(pluginB => {
* Gerrit.on("your-special-event", ({plugin}) => {
* // do something, plugin is pluginA
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js
index 6a8a0dd..12a4056 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js
@@ -426,7 +426,7 @@
// eslint-disable-next-line no-invalid-this
const grPopupInterface = this;
assert.equal(grPopupInterface.plugin, plugin);
- assert.equal(grPopupInterface._moduleName, 'some-name');
+ assert.equal(grPopupInterface.moduleName, 'some-name');
});
plugin.popup('some-name');
assert.isTrue(openStub.calledOnce);
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-action-context.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-action-context.ts
index 21e4876..2135c30 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-action-context.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-action-context.ts
@@ -28,7 +28,7 @@
}
export class GrPluginActionContext {
- private _popups: PopupPluginApi[] = [];
+ private popups: PopupPluginApi[] = [];
constructor(
public readonly plugin: PluginApi,
@@ -44,15 +44,15 @@
throw new Error('Popup element not found');
}
popupEl.appendChild(element);
- this._popups.push(popApi);
+ this.popups.push(popApi);
});
}
hide() {
- for (const popupApi of this._popups) {
+ for (const popupApi of this.popups) {
popupApi.close();
}
- this._popups.splice(0);
+ this.popups.splice(0);
}
refresh() {
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts
index 2752c74..82df2fa 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts
@@ -51,10 +51,10 @@
private readonly _importedUrls = new Set<string>();
- private _pluginLoaded = false;
+ private pluginLoaded = false;
setPluginsReady() {
- this._pluginLoaded = true;
+ this.pluginLoaded = true;
}
onNewEndpoint(endpoint: string, callback: Callback) {
@@ -125,7 +125,7 @@
// one register before plugins ready
// the other done after, then only the later one will have the callbacks
// invoked.
- if (this._pluginLoaded && this._callbacks.has(endpoint)) {
+ if (this.pluginLoaded && this._callbacks.has(endpoint)) {
this._callbacks.get(endpoint)!.forEach(callback => callback(moduleInfo));
}
}
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
index 8c0fce26..db34e5a 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
@@ -74,7 +74,7 @@
const UNKNOWN_PLUGIN_PREFIX = '__$$__';
// Current API version for Plugin,
-// plugins with incompatible version will not be laoded.
+// plugins with incompatible version will not be loaded.
const API_VERSION = '0.1';
/**
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.js
index 6b62291..f5b1fca 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.js
@@ -225,7 +225,7 @@
assert.isTrue(alertStub.calledTwice);
});
- test('plugins installed failed becasue of wrong version', async () => {
+ test('plugins installed failed because of wrong version', async () => {
const plugins = [
'http://test.com/plugins/foo/static/test.js',
'http://test.com/plugins/bar/static/test.js',
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.ts
index 45ffdcd9..e7843af 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.ts
@@ -78,14 +78,14 @@
export class Plugin implements PluginApi {
readonly _url?: URL;
- private _domHooks: GrDomHooksManager;
+ private domHooks: GrDomHooksManager;
private readonly _name: string = PLUGIN_NAME_NOT_SET;
private readonly jsApi = appContext.jsApiService;
constructor(url?: string) {
- this._domHooks = new GrDomHooksManager(this);
+ this.domHooks = new GrDomHooksManager(this);
if (!url) {
console.warn(
@@ -151,7 +151,7 @@
const type =
options && options.replace ? EndpointType.REPLACE : EndpointType.DECORATE;
const slot = (options && options.slot) || '';
- const domHook = this._domHooks.getDomHook(endpoint, moduleName);
+ const domHook = this.domHooks.getDomHook(endpoint, moduleName);
moduleName = moduleName || domHook.getModuleName();
getPluginEndpoints().registerModule(this, {
slot,
diff --git a/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip_html.ts b/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip_html.ts
index a335db7..8581a0c 100644
--- a/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip_html.ts
@@ -46,7 +46,6 @@
gr-button.remove:focus {
--gr-button: {
@apply --gr-remove-button-style;
- color: #333;
}
}
gr-button.remove {
diff --git a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts
index d29cba7..20e5296 100644
--- a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts
+++ b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts
@@ -56,7 +56,7 @@
* @event fullscreen-overlay-opened
*/
- private _fullScreenOpen = false;
+ private fullScreenOpen = false;
private _boundHandleClose: () => void = () => super.close();
@@ -99,7 +99,7 @@
super.open.apply(this);
if (this._isMobile()) {
fireEvent(this, 'fullscreen-overlay-opened');
- this._fullScreenOpen = true;
+ this.fullScreenOpen = true;
}
this._awaitOpen(resolve, reject);
});
@@ -112,9 +112,9 @@
// called after iron-overlay is closed. Does not actually close the overlay
_overlayClosed() {
window.removeEventListener('popstate', this._boundHandleClose);
- if (this._fullScreenOpen) {
+ if (this.fullScreenOpen) {
fireEvent(this, 'fullscreen-overlay-closed');
- this._fullScreenOpen = false;
+ this.fullScreenOpen = false;
}
if (this.returnFocusTo) {
this.returnFocusTo.focus();
diff --git a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay_test.js b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay_test.js
index 4b6ae34..72c3399 100644
--- a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay_test.js
@@ -57,11 +57,11 @@
await element.open();
assert.isTrue(element._isMobile.called);
- assert.isTrue(element._fullScreenOpen);
+ assert.isTrue(element.fullScreenOpen);
assert.isTrue(openHandler.called);
element._overlayClosed();
- assert.isFalse(element._fullScreenOpen);
+ assert.isFalse(element.fullScreenOpen);
assert.isTrue(closeHandler.called);
});
@@ -75,11 +75,11 @@
await element.open();
assert.isTrue(element._isMobile.called);
- assert.isFalse(element._fullScreenOpen);
+ assert.isFalse(element.fullScreenOpen);
assert.isFalse(openHandler.called);
element._overlayClosed();
- assert.isFalse(element._fullScreenOpen);
+ assert.isFalse(element.fullScreenOpen);
assert.isFalse(closeHandler.called);
});
});
diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper.ts b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper.ts
index fa2a28e..89abd57 100644
--- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper.ts
+++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-apis/gr-rest-api-helper.ts
@@ -75,7 +75,7 @@
export class SiteBasedCache {
// TODO(TS): Type looks unusual. Fix it.
// Container of per-canonical-path caches.
- private readonly _data = new Map<
+ private readonly data = new Map<
string | undefined,
unknown | Map<string, ParsedJSON | null>
>();
@@ -93,13 +93,13 @@
// Returns the cache for the current canonical path.
_cache(): Map<string, unknown> {
- if (!this._data.has(window.CANONICAL_PATH)) {
- this._data.set(
+ if (!this.data.has(window.CANONICAL_PATH)) {
+ this.data.set(
window.CANONICAL_PATH,
new Map<string, ParsedJSON | null>()
);
}
- return this._data.get(window.CANONICAL_PATH) as Map<
+ return this.data.get(window.CANONICAL_PATH) as Map<
string,
ParsedJSON | null
>;
@@ -140,7 +140,7 @@
newMap.set(key, value);
}
}
- this._data.set(window.CANONICAL_PATH, newMap);
+ this.data.set(window.CANONICAL_PATH, newMap);
}
}
@@ -149,25 +149,25 @@
};
export class FetchPromisesCache {
- private _data: FetchPromisesCacheData;
+ private data: FetchPromisesCacheData;
constructor() {
- this._data = {};
+ this.data = {};
}
public testOnlyGetData() {
- return this._data;
+ return this.data;
}
/**
* @return true only if a value for a key sets and it is not undefined
*/
has(key: string): boolean {
- return !!this._data[key];
+ return !!this.data[key];
}
get(key: string) {
- return this._data[key];
+ return this.data[key];
}
/**
@@ -175,17 +175,17 @@
* mark key as deleted.
*/
set(key: string, value: Promise<ParsedJSON | undefined> | undefined) {
- this._data[key] = value;
+ this.data[key] = value;
}
invalidatePrefix(prefix: string) {
const newData: FetchPromisesCacheData = {};
- Object.entries(this._data).forEach(([key, value]) => {
+ Object.entries(this.data).forEach(([key, value]) => {
if (!key.startsWith(prefix)) {
newData[key] = value;
}
});
- this._data = newData;
+ this.data = newData;
}
}
export type FetchParams = {
@@ -457,7 +457,7 @@
* Send an XHR.
*
* @return Promise resolves to Response/ParsedJSON only if the request is successful
- * (i.e. no exception and response.ok is trsue). If response fails then
+ * (i.e. no exception and response.ok is true). If response fails then
* promise resolves either to void if errFn is set or rejects if errFn
* is not set */
send(req: SendRequest): Promise<Response | ParsedJSON | undefined> {
diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser.ts b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser.ts
index 1a1062c..95e06c0 100644
--- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser.ts
+++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser.ts
@@ -81,9 +81,9 @@
// type. This class should be refactored to avoid reassignment.
private readonly result: ChangeInfoParserInput;
- private _batch: ParserBatch | null = null;
+ private batch: ParserBatch | null = null;
- private _updateItems: {[accountId: string]: UpdateItem} | null = null;
+ private updateItems: {[accountId: string]: UpdateItem} | null = null;
private readonly _lastState: {[accountId: string]: ReviewerState} = {};
@@ -105,7 +105,7 @@
* Is a part of _groupUpdates(). Creates a new batch of updates.
*/
private _startBatch(update: ReviewerUpdateInfo): ParserBatch {
- this._updateItems = {};
+ this.updateItems = {};
return {
author: update.updated_by,
date: update.updated,
@@ -121,7 +121,7 @@
*/
private _completeBatch(batch: ParserBatch) {
const items = [];
- for (const [accountId, item] of Object.entries(this._updateItems ?? {})) {
+ for (const [accountId, item] of Object.entries(this.updateItems ?? {})) {
if (this._lastState[accountId] !== item.state) {
this._lastState[accountId] = item.state;
items.push(item);
@@ -142,27 +142,27 @@
_groupUpdates(): ParserBatchWithNonEmptyUpdates[] {
const updates = this.result.reviewer_updates;
const newUpdates = updates.reduce((newUpdates, update) => {
- if (!this._batch) {
- this._batch = this._startBatch(update);
+ if (!this.batch) {
+ this.batch = this._startBatch(update);
}
const updateDate = parseDate(update.updated).getTime();
- const batchUpdateDate = parseDate(this._batch.date).getTime();
+ const batchUpdateDate = parseDate(this.batch.date).getTime();
const reviewerId = accountKey(update.reviewer);
if (
updateDate - batchUpdateDate > REVIEWER_UPDATE_THRESHOLD_MILLIS ||
- update.updated_by._account_id !== this._batch.author._account_id
+ update.updated_by._account_id !== this.batch.author._account_id
) {
// Next sequential update should form new group.
- this._completeBatch(this._batch);
- if (isParserBatchWithNonEmptyUpdates(this._batch)) {
- newUpdates.push(this._batch);
+ this._completeBatch(this.batch);
+ if (isParserBatchWithNonEmptyUpdates(this.batch)) {
+ newUpdates.push(this.batch);
}
- this._batch = this._startBatch(update);
+ this.batch = this._startBatch(update);
}
- // _startBatch assigns _updateItems. When _groupUpdates is calling,
- // _batch and _updateItems are not set => _startBatch is called. The
- // _startBatch method assigns _updateItems
- const updateItems = this._updateItems!;
+ // _startBatch assigns updateItems. When _groupUpdates is calling,
+ // batch and updateItems are not set => _startBatch is called. The
+ // _startBatch method assigns updateItems
+ const updateItems = this.updateItems!;
updateItems[reviewerId] = {
reviewer: update.reviewer,
state: update.state,
@@ -174,8 +174,8 @@
}, [] as ParserBatchWithNonEmptyUpdates[]);
// reviewer_updates always has at least 1 item
// (otherwise parse is not created) => updates.reduce calls callback
- // at least once and callback assigns this._batch
- const batch = this._batch!;
+ // at least once and callback assigns this.batch
+ const batch = this.batch!;
this._completeBatch(batch);
if (isParserBatchWithNonEmptyUpdates(batch)) {
newUpdates.push(batch);
diff --git a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts
index b0b40dd..885db2a 100644
--- a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts
+++ b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts
@@ -112,7 +112,7 @@
@property({type: Boolean})
hideBorder = false;
- /** Text input should be rendered in monspace font. */
+ /** Text input should be rendered in monospace font. */
@property({type: Boolean})
monospace = false;
diff --git a/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin.ts b/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin.ts
index 77d2d00..75ad608 100644
--- a/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin.ts
+++ b/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin.ts
@@ -69,13 +69,13 @@
// Handler for mouseenter event
private mouseenterHandler?: (e: MouseEvent) => void;
- // Hanlder for scrolling on window
+ // Handler for scrolling on window
private readonly windowScrollHandler: () => void;
- // Hanlder for showing the tooltip, will be attached to certain events
+ // Handler for showing the tooltip, will be attached to certain events
private readonly showHandler: () => void;
- // Hanlder for hiding the tooltip, will be attached to certain events
+ // Handler for hiding the tooltip, will be attached to certain events
private readonly hideHandler: () => void;
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
diff --git a/polygerrit-ui/app/mixins/iron-fit-mixin/iron-fit-mixin.ts b/polygerrit-ui/app/mixins/iron-fit-mixin/iron-fit-mixin.ts
index 662d6bf..57e034f 100644
--- a/polygerrit-ui/app/mixins/iron-fit-mixin/iron-fit-mixin.ts
+++ b/polygerrit-ui/app/mixins/iron-fit-mixin/iron-fit-mixin.ts
@@ -29,7 +29,7 @@
// is used. To ensure that this import can't be avoided, the second parameter
// is added. Usage example:
// class Element extends IronFitMixin(PolymerElement, IronFitBehavior as IronFitBehavior)
-// The code 'IronFitBehavior as IronFitBehavior' required, becuase IronFitBehavior
+// The code 'IronFitBehavior as IronFitBehavior' required, because IronFitBehavior
// defined as an object, not as IronFitBehavior instance.
export const IronFitMixin = <T extends Constructor<PolymerElement>>(
diff --git a/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts b/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts
index 63a05aa..ab85b87 100644
--- a/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts
+++ b/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts
@@ -544,7 +544,7 @@
}
/**
- * Shortcut manager, holds all hosts, bindings and listners.
+ * Shortcut manager, holds all hosts, bindings and listeners.
*/
export class ShortcutManager {
private readonly activeHosts = new Map<PolymerElement, Map<string, string>>();
diff --git a/polygerrit-ui/app/node_modules_licenses/licenses.ts b/polygerrit-ui/app/node_modules_licenses/licenses.ts
index 7a6253b..f03c7e6 100644
--- a/polygerrit-ui/app/node_modules_licenses/licenses.ts
+++ b/polygerrit-ui/app/node_modules_licenses/licenses.ts
@@ -254,6 +254,14 @@
license: SharedLicenses.Polymer2017
},
{
+ name: "@types/resize-observer-browser",
+ license: {
+ name: 'DefinitelyTyped',
+ type: LicenseTypes.Mit,
+ packageLicenseFile: "LICENSE"
+ }
+ },
+ {
name: "@webcomponents/shadycss",
license: SharedLicenses.Polymer2017
},
diff --git a/polygerrit-ui/app/package.json b/polygerrit-ui/app/package.json
index 3351386..5e15990 100644
--- a/polygerrit-ui/app/package.json
+++ b/polygerrit-ui/app/package.json
@@ -25,6 +25,7 @@
"@polymer/paper-tabs": "^3.1.0",
"@polymer/paper-toggle-button": "^3.0.1",
"@polymer/polymer": "^3.4.1",
+ "@types/resize-observer-browser": "^0.1.5",
"@webcomponents/shadycss": "^1.9.2",
"@webcomponents/webcomponentsjs": "^1.3.3",
"ba-linkify": "file:../../lib/ba-linkify/src/",
diff --git a/polygerrit-ui/app/scripts/gr-email-suggestions-provider/gr-email-suggestions-provider.ts b/polygerrit-ui/app/scripts/gr-email-suggestions-provider/gr-email-suggestions-provider.ts
index 7969b84..5818003 100644
--- a/polygerrit-ui/app/scripts/gr-email-suggestions-provider/gr-email-suggestions-provider.ts
+++ b/polygerrit-ui/app/scripts/gr-email-suggestions-provider/gr-email-suggestions-provider.ts
@@ -19,10 +19,10 @@
import {AccountInfo} from '../../types/common';
export class GrEmailSuggestionsProvider {
- constructor(private _restAPI: RestApiService) {}
+ constructor(private restAPI: RestApiService) {}
getSuggestions(input: string) {
- return this._restAPI.getSuggestedAccounts(`${input}`).then(accounts => {
+ return this.restAPI.getSuggestedAccounts(`${input}`).then(accounts => {
if (!accounts) {
return [];
}
diff --git a/polygerrit-ui/app/scripts/gr-group-suggestions-provider/gr-group-suggestions-provider.ts b/polygerrit-ui/app/scripts/gr-group-suggestions-provider/gr-group-suggestions-provider.ts
index 1cf1c39..ff113fb 100644
--- a/polygerrit-ui/app/scripts/gr-group-suggestions-provider/gr-group-suggestions-provider.ts
+++ b/polygerrit-ui/app/scripts/gr-group-suggestions-provider/gr-group-suggestions-provider.ts
@@ -19,10 +19,10 @@
import {GroupBaseInfo} from '../../types/common';
export class GrGroupSuggestionsProvider {
- constructor(private _restAPI: RestApiService) {}
+ constructor(private restAPI: RestApiService) {}
getSuggestions(input: string) {
- return this._restAPI.getSuggestedGroups(`${input}`).then(groups => {
+ return this.restAPI.getSuggestedGroups(`${input}`).then(groups => {
if (!groups) {
return [];
}
diff --git a/polygerrit-ui/app/scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider.ts b/polygerrit-ui/app/scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider.ts
index 1572ba1..45116aa 100644
--- a/polygerrit-ui/app/scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider.ts
+++ b/polygerrit-ui/app/scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider.ts
@@ -73,13 +73,13 @@
}
}
- private _initPromise?: Promise<void>;
+ private initPromise?: Promise<void>;
- private _config?: ServerInfo;
+ private config?: ServerInfo;
- private _loggedIn = false;
+ private loggedIn = false;
- private _initialized = false;
+ private initialized = false;
private constructor(
private readonly _restAPI: RestApiService,
@@ -87,26 +87,25 @@
) {}
init() {
- if (this._initPromise) {
- return this._initPromise;
+ if (this.initPromise) {
+ return this.initPromise;
}
const getConfigPromise = this._restAPI.getConfig().then(cfg => {
- this._config = cfg;
+ this.config = cfg;
});
const getLoggedInPromise = this._restAPI.getLoggedIn().then(loggedIn => {
- this._loggedIn = loggedIn;
+ this.loggedIn = loggedIn;
});
- this._initPromise = Promise.all([
- getConfigPromise,
- getLoggedInPromise,
- ]).then(() => {
- this._initialized = true;
- });
- return this._initPromise;
+ this.initPromise = Promise.all([getConfigPromise, getLoggedInPromise]).then(
+ () => {
+ this.initialized = true;
+ }
+ );
+ return this.initPromise;
}
getSuggestions(input: string): Promise<Suggestion[]> {
- if (!this._initialized || !this._loggedIn) {
+ if (!this.initialized || !this.loggedIn) {
return Promise.resolve([]);
}
@@ -117,7 +116,7 @@
if (isReviewerAccountSuggestion(suggestion)) {
// Reviewer is an account suggestion from getChangeSuggestedReviewers.
return {
- name: getAccountDisplayName(this._config, suggestion.account),
+ name: getAccountDisplayName(this.config, suggestion.account),
value: suggestion,
};
}
@@ -133,7 +132,7 @@
if (isAccountSuggestions(suggestion)) {
// Reviewer is an account suggestion from getSuggestedAccounts.
return {
- name: getAccountDisplayName(this._config, suggestion),
+ name: getAccountDisplayName(this.config, suggestion),
value: {account: suggestion, count: 1},
};
}
diff --git a/polygerrit-ui/app/scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider_test.js b/polygerrit-ui/app/scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider_test.js
index c7de24a..d3cad45 100644
--- a/polygerrit-ui/app/scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider_test.js
+++ b/polygerrit-ui/app/scripts/gr-reviewer-suggestions-provider/gr-reviewer-suggestions-provider_test.js
@@ -130,7 +130,7 @@
value: {account: {}},
});
- provider._config = {
+ provider.config = {
user: {
anonymous_coward_name: 'Anonymous Coward Name',
},
@@ -179,10 +179,10 @@
});
test('getSuggestions short circuits when logged out', () => {
- provider._loggedIn = false;
+ provider.loggedIn = false;
return provider.getSuggestions('').then(() => {
assert.isFalse(getChangeSuggestedReviewersStub.called);
- provider._loggedIn = true;
+ provider.loggedIn = true;
return provider.getSuggestions('').then(() => {
assert.isTrue(getChangeSuggestedReviewersStub.called);
});
diff --git a/polygerrit-ui/app/services/checks/checks-util.ts b/polygerrit-ui/app/services/checks/checks-util.ts
index 176464f..1613359 100644
--- a/polygerrit-ui/app/services/checks/checks-util.ts
+++ b/polygerrit-ui/app/services/checks/checks-util.ts
@@ -24,7 +24,7 @@
return undefined;
}
-export function iconForCategory(category: Category) {
+export function iconForCategory(category: Category | 'SUCCESS') {
switch (category) {
case Category.ERROR:
return 'error';
@@ -32,6 +32,8 @@
return 'info-outline';
case Category.WARNING:
return 'warning';
+ case 'SUCCESS':
+ return 'check-circle-outline';
default:
assertNever(category, `Unsupported category: ${category}`);
}
diff --git a/polygerrit-ui/app/services/gr-auth/gr-auth_impl.ts b/polygerrit-ui/app/services/gr-auth/gr-auth_impl.ts
index 8fe7c35..6fadfde 100644
--- a/polygerrit-ui/app/services/gr-auth/gr-auth_impl.ts
+++ b/polygerrit-ui/app/services/gr-auth/gr-auth_impl.ts
@@ -61,26 +61,26 @@
static CREDS_EXPIRED_MSG = 'Credentials expired.';
- private _authCheckPromise?: Promise<Response>;
+ private authCheckPromise?: Promise<Response>;
private _last_auth_check_time: number = Date.now();
private _status = AuthStatus.UNDETERMINED;
- private _retriesLeft = MAX_GET_TOKEN_RETRIES;
+ private retriesLeft = MAX_GET_TOKEN_RETRIES;
- private _cachedTokenPromise: Promise<Token | null> | null = null;
+ private cachedTokenPromise: Promise<Token | null> | null = null;
- private _type?: AuthType;
+ private type?: AuthType;
- private _defaultOptions: AuthRequestInit = {};
+ private defaultOptions: AuthRequestInit = {};
- private _getToken: GetTokenCallback;
+ private getToken: GetTokenCallback;
public eventEmitter: EventEmitterService;
constructor(eventEmitter: EventEmitterService) {
- this._getToken = () => Promise.resolve(this._cachedTokenPromise);
+ this.getToken = () => Promise.resolve(this.cachedTokenPromise);
this.eventEmitter = eventEmitter;
}
@@ -93,15 +93,15 @@
*/
authCheck(): Promise<boolean> {
if (
- !this._authCheckPromise ||
+ !this.authCheckPromise ||
Date.now() - this._last_auth_check_time > MAX_AUTH_CHECK_WAIT_TIME_MS
) {
// Refetch after last check expired
- this._authCheckPromise = fetch(`${this.baseUrl}/auth-check`);
+ this.authCheckPromise = fetch(`${this.baseUrl}/auth-check`);
this._last_auth_check_time = Date.now();
}
- return this._authCheckPromise
+ return this.authCheckPromise
.then(res => {
// auth-check will return 204 if authed
// treat the rest as unauthed
@@ -115,14 +115,14 @@
})
.catch(() => {
this._setStatus(AuthStatus.ERROR);
- // Reset _authCheckPromise to avoid caching the failed promise
- this._authCheckPromise = undefined;
+ // Reset authCheckPromise to avoid caching the failed promise
+ this.authCheckPromise = undefined;
return false;
});
}
clearCache() {
- this._authCheckPromise = undefined;
+ this.authCheckPromise = undefined;
}
private _setStatus(status: AuthStatus) {
@@ -149,15 +149,15 @@
* Enable cross-domain authentication using OAuth access token.
*/
setup(getToken: GetTokenCallback, defaultOptions: DefaultAuthOptions) {
- this._retriesLeft = MAX_GET_TOKEN_RETRIES;
+ this.retriesLeft = MAX_GET_TOKEN_RETRIES;
if (getToken) {
- this._type = AuthType.ACCESS_TOKEN;
- this._cachedTokenPromise = null;
- this._getToken = getToken;
+ this.type = AuthType.ACCESS_TOKEN;
+ this.cachedTokenPromise = null;
+ this.getToken = getToken;
}
- this._defaultOptions = {};
+ this.defaultOptions = {};
if (defaultOptions) {
- this._defaultOptions.credentials = defaultOptions.credentials;
+ this.defaultOptions.credentials = defaultOptions.credentials;
}
}
@@ -167,10 +167,10 @@
fetch(url: string, opt_options?: AuthRequestInit): Promise<Response> {
const options: AuthRequestInitWithHeaders = {
headers: new Headers(),
- ...this._defaultOptions,
+ ...this.defaultOptions,
...opt_options,
};
- if (this._type === AuthType.ACCESS_TOKEN) {
+ if (this.type === AuthType.ACCESS_TOKEN) {
return this._getAccessToken().then(accessToken =>
this._fetchWithAccessToken(url, options, accessToken)
);
@@ -224,17 +224,17 @@
}
private _getAccessToken(): Promise<string | null> {
- if (!this._cachedTokenPromise) {
- this._cachedTokenPromise = this._getToken();
+ if (!this.cachedTokenPromise) {
+ this.cachedTokenPromise = this.getToken();
}
- return this._cachedTokenPromise.then(token => {
+ return this.cachedTokenPromise.then(token => {
if (this._isTokenValid(token)) {
- this._retriesLeft = MAX_GET_TOKEN_RETRIES;
+ this.retriesLeft = MAX_GET_TOKEN_RETRIES;
return token.access_token;
}
- if (this._retriesLeft > 0) {
- this._retriesLeft--;
- this._cachedTokenPromise = null;
+ if (this.retriesLeft > 0) {
+ this.retriesLeft--;
+ this.cachedTokenPromise = null;
return this._getAccessToken();
}
// Fall back to anonymous access.
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
index 4ca983a..4196513 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
@@ -61,7 +61,7 @@
timeEnd(name: string, eventDetails?: EventDetails): void;
/**
* Reports just line timeEnd, but additionally reports an average given a
- * denominator and a separate reporiting name for the average.
+ * denominator and a separate reporting name for the average.
*
* @param name Timing name.
* @param averageName Average timing name.
@@ -74,7 +74,7 @@
denominator: number
): void;
/**
- * Get a timer object to for reporing a user timing. The start time will be
+ * Get a timer object for reporting a user timing. The start time will be
* the time that the object has been created, and the end time will be the
* time that the "end" method is called on the object.
*/
@@ -99,7 +99,7 @@
reportExecution(id: string, details: EventDetails): void;
reportInteraction(eventName: string, details?: EventDetails): void;
/**
- * A draft interaction was started. Update the time-betweeen-draft-actions
+ * A draft interaction was started. Update the time-between-draft-actions
* timer.
*/
recordDraftInteraction(): void;
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
index f80cb75..631a4e0 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
@@ -292,17 +292,17 @@
private readonly _baselines = STARTUP_TIMERS;
- private _reportRepoName: string | undefined;
+ private reportRepoName: string | undefined;
- private _reportChangeId: NumericChangeId | undefined;
+ private reportChangeId: NumericChangeId | undefined;
- private _timers: {timeBetweenDraftActions: Timer | null} = {
+ private timers: {timeBetweenDraftActions: Timer | null} = {
timeBetweenDraftActions: null,
};
- private _pending: PendingReportInfo[] = [];
+ private pending: PendingReportInfo[] = [];
- private _slowRpcList: SlowRpcCall[] = [];
+ private slowRpcList: SlowRpcCall[] = [];
/**
* Keeps track of which ids were already reported to have been executed.
@@ -321,7 +321,7 @@
}
private get slowRpcSnapshot() {
- return (this._slowRpcList || []).slice();
+ return (this.slowRpcList || []).slice();
}
private _arePluginsLoaded() {
@@ -366,16 +366,16 @@
}
// We report events immediately when metrics plugin is loaded
- if (this._isMetricsPluginLoaded() && !this._pending.length) {
+ if (this._isMetricsPluginLoaded() && !this.pending.length) {
this._reportEvent(eventInfo, noLog);
} else {
// We cache until metrics plugin is loaded
- this._pending.push([eventInfo, noLog]);
+ this.pending.push([eventInfo, noLog]);
if (this._isMetricsPluginLoaded()) {
- this._pending.forEach(([eventInfo, opt_noLog]) => {
+ this.pending.forEach(([eventInfo, opt_noLog]) => {
this._reportEvent(eventInfo, opt_noLog);
});
- this._pending = [];
+ this.pending = [];
}
}
}
@@ -417,11 +417,11 @@
eventInfo.eventDetails = JSON.stringify(eventDetails);
}
- if (this._reportRepoName) {
- eventInfo.repoName = this._reportRepoName;
+ if (this.reportRepoName) {
+ eventInfo.repoName = this.reportRepoName;
}
- if (this._reportChangeId) {
- eventInfo.changeId = `${this._reportChangeId}`;
+ if (this.reportChangeId) {
+ eventInfo.changeId = `${this.reportChangeId}`;
}
const isInBackgroundTab = document.visibilityState === 'hidden';
@@ -501,10 +501,10 @@
this.time(TIMER.DIFF_VIEW_DISPLAYED);
this.time(TIMER.DIFF_VIEW_LOAD_FULL);
this.time(TIMER.FILE_LIST_DISPLAYED);
- this._reportRepoName = undefined;
- this._reportChangeId = undefined;
+ this.reportRepoName = undefined;
+ this.reportChangeId = undefined;
// reset slow rpc list since here start page loads which report these rpcs
- this._slowRpcList = [];
+ this.slowRpcList = [];
this.hiddenDurationTimer.reset();
}
@@ -651,7 +651,7 @@
if (baseTime !== 0) {
window.performance.measure(name, `${name}-start`);
} else {
- // Microsft Edge does not handle the 2nd param correctly
+ // Microsoft Edge does not handle the 2nd param correctly
// (if undefined).
window.performance.measure(name);
}
@@ -659,7 +659,7 @@
/**
* Reports just line timeEnd, but additionally reports an average given a
- * denominator and a separate reporiting name for the average.
+ * denominator and a separate reporting name for the average.
*
* @param name Timing name.
* @param averageName Average timing name.
@@ -703,7 +703,7 @@
}
/**
- * Get a timer object to for reporing a user timing. The start time will be
+ * Get a timer object to for reporting a user timing. The start time will be
* the time that the object has been created, and the end time will be the
* time that the "end" method is called on the object.
*/
@@ -765,7 +765,7 @@
true
);
if (elapsed >= SLOW_RPC_THRESHOLD) {
- this._slowRpcList.push({anonymizedUrl, elapsed});
+ this.slowRpcList.push({anonymizedUrl, elapsed});
}
}
@@ -805,17 +805,17 @@
}
/**
- * A draft interaction was started. Update the time-betweeen-draft-actions
+ * A draft interaction was started. Update the time-between-draft-actions
* timer.
*/
recordDraftInteraction() {
// If there is no timer defined, then this is the first interaction.
// Set up the timer so that it's ready to record the intervening time when
// called again.
- const timer = this._timers.timeBetweenDraftActions;
+ const timer = this.timers.timeBetweenDraftActions;
if (!timer) {
// Create a timer with a maximum length.
- this._timers.timeBetweenDraftActions = this.getTimer(
+ this.timers.timeBetweenDraftActions = this.getTimer(
DRAFT_ACTION_TIMER
).withMaximum(DRAFT_ACTION_TIMER_MAX);
return;
@@ -848,11 +848,11 @@
}
setRepoName(repoName: string) {
- this._reportRepoName = repoName;
+ this.reportRepoName = repoName;
}
setChangeId(changeId: NumericChangeId) {
- this._reportChangeId = changeId;
+ this.reportChangeId = changeId;
}
}
diff --git a/polygerrit-ui/app/styles/gr-voting-styles.ts b/polygerrit-ui/app/styles/gr-voting-styles.ts
index d4e6d52..c1989de 100644
--- a/polygerrit-ui/app/styles/gr-voting-styles.ts
+++ b/polygerrit-ui/app/styles/gr-voting-styles.ts
@@ -27,7 +27,7 @@
<style>
:host {
--vote-chip-styles: {
- border: 1px solid rgba(0,0,0,.12);
+ border: 1px solid var(--border-color);
border-radius: 1em;
box-shadow: none;
box-sizing: border-box;
diff --git a/polygerrit-ui/app/styles/themes/app-theme.ts b/polygerrit-ui/app/styles/themes/app-theme.ts
index c3b0681..2d83cf5 100644
--- a/polygerrit-ui/app/styles/themes/app-theme.ts
+++ b/polygerrit-ui/app/styles/themes/app-theme.ts
@@ -101,6 +101,7 @@
--tooltip-text-color: white;
--negative-red-text-color: #d93025;
--positive-green-text-color: #188038;
+ --indirect-ancestor-text-color: var(--green-700);
/* background colors */
/* primary background colors */
@@ -171,7 +172,7 @@
--line-height-mono: 1.286rem; /* 18px */
--line-height-small: 1.143rem; /* 16px */
--line-height-normal: 1.429rem; /* 20px */
- --line-height-h3: 1.714rem; /* 24px */
+ --line-height-h3: 1.715rem; /* 24px */
--line-height-h2: 2rem; /* 28px */
--line-height-h1: 2.286rem; /* 32px */
--font-weight-normal: 400; /* 400 is the same as 'normal' */
diff --git a/polygerrit-ui/app/styles/themes/dark-theme.ts b/polygerrit-ui/app/styles/themes/dark-theme.ts
index 4057f7f..072ca8f 100644
--- a/polygerrit-ui/app/styles/themes/dark-theme.ts
+++ b/polygerrit-ui/app/styles/themes/dark-theme.ts
@@ -44,9 +44,12 @@
--warning-background: var(--orange-900);
--info-foreground: var(--blue-200);
--info-background: var(--blue-900);
+ --selected-foreground: var(--blue-200);
+ --selected-background: var(--blue-900);
--info-deemphasized-foreground: var(--gray-700);
--info-deemphasized-background: var(--primary-text-color);
--success-foreground: var(--green-200);
+ --success-background: var(--green-900);
--gray-foreground: var(--gray-100);
--gray-background: var(--gray-900);
--tag-background: var(--cyan-900);
diff --git a/polygerrit-ui/app/tsconfig.json b/polygerrit-ui/app/tsconfig.json
index 0d751ab..46d0173d 100644
--- a/polygerrit-ui/app/tsconfig.json
+++ b/polygerrit-ui/app/tsconfig.json
@@ -48,7 +48,7 @@
"include": [
// Items below must be in sync with the src_dirs list in the BUILD file
// Also items must be in sync with tsconfig_bazel.json, tsconfig_bazel_test.json
- // (include and exclude arrays are overriden when extends)
+ // (include and exclude arrays are overridden when extends)
"api/**/*",
"constants/**/*",
"elements/**/*",
diff --git a/polygerrit-ui/app/tsconfig_bazel.json b/polygerrit-ui/app/tsconfig_bazel.json
index 46bd926..dfd2078 100644
--- a/polygerrit-ui/app/tsconfig_bazel.json
+++ b/polygerrit-ui/app/tsconfig_bazel.json
@@ -9,7 +9,7 @@
"include": [
// Items below must be in sync with the src_dirs list in the BUILD file
// Also items must be in sync with tsconfig.json, tsconfig_bazel_test.json
- // (include and exclude arrays are overriden when extends)
+ // (include and exclude arrays are overridden when extends)
"api/**/*",
"constants/**/*",
"elements/**/*",
diff --git a/polygerrit-ui/app/tsconfig_bazel_test.json b/polygerrit-ui/app/tsconfig_bazel_test.json
index 1b6c226..9c2ff93 100644
--- a/polygerrit-ui/app/tsconfig_bazel_test.json
+++ b/polygerrit-ui/app/tsconfig_bazel_test.json
@@ -14,7 +14,7 @@
"include": [
// Items below must be in sync with the src_dirs list in the BUILD file
// Also items must be in sync with tsconfig.json, tsconfig_test.json
- // (include and exclude arrays are overriden when extends)
+ // (include and exclude arrays are overridden when extends)
"api/**/*",
"constants/**/*",
"elements/**/*",
diff --git a/polygerrit-ui/app/types/common.ts b/polygerrit-ui/app/types/common.ts
index 95801e7..711b11b 100644
--- a/polygerrit-ui/app/types/common.ts
+++ b/polygerrit-ui/app/types/common.ts
@@ -1021,7 +1021,7 @@
*/
export interface PluginConfigInfo {
has_avatars: boolean;
- // The following 2 properies exists in Java class, but don't mention in docs
+ // The following 2 properties exists in Java class, but don't mention in docs
js_resource_paths: string[];
html_resource_paths: string[];
}
diff --git a/polygerrit-ui/app/types/events.ts b/polygerrit-ui/app/types/events.ts
index 6b05fad..5965453 100644
--- a/polygerrit-ui/app/types/events.ts
+++ b/polygerrit-ui/app/types/events.ts
@@ -19,6 +19,7 @@
import {UIComment} from '../utils/comment-util';
import {FetchRequest} from './types';
import {MovedLinkClickedEventDetail} from '../api/diff';
+import {Category, RunStatus} from '../api/checks';
export interface TitleChangeEventDetail {
title: string;
@@ -152,6 +153,7 @@
export interface TabState {
commentTab?: CommentTabState;
+ checksTab?: ChecksTabState;
}
export enum CommentTabState {
@@ -160,6 +162,11 @@
SHOW_ALL = 'show all',
}
+export interface ChecksTabState {
+ statusOrCategory?: RunStatus | Category;
+ checkName?: string;
+}
+
export type SwitchTabEvent = CustomEvent<SwitchTabEventDetail>;
declare global {
diff --git a/polygerrit-ui/app/utils/change-util.ts b/polygerrit-ui/app/utils/change-util.ts
index 1228863..a7f8b49 100644
--- a/polygerrit-ui/app/utils/change-util.ts
+++ b/polygerrit-ui/app/utils/change-util.ts
@@ -173,28 +173,44 @@
return states;
}
-export function isOwner(change?: ChangeInfo, account?: AccountInfo) {
+export function isOwner(change?: ChangeInfo, account?: AccountInfo): boolean {
if (!change || !account) return false;
return change.owner?._account_id === account._account_id;
}
-export function isReviewer(change?: ChangeInfo, account?: AccountInfo) {
+export function isReviewer(
+ change?: ChangeInfo,
+ account?: AccountInfo
+): boolean {
if (!change || !account) return false;
const reviewers = change.reviewers.REVIEWER ?? [];
return reviewers.some(r => r._account_id === account._account_id);
}
-export function isUploader(change?: ChangeInfo, account?: AccountInfo) {
+export function isCc(change?: ChangeInfo, account?: AccountInfo): boolean {
+ if (!change || !account) return false;
+ const ccs = change.reviewers.CC ?? [];
+ return ccs.some(r => r._account_id === account._account_id);
+}
+
+export function isUploader(
+ change?: ChangeInfo,
+ account?: AccountInfo
+): boolean {
if (!change || !account) return false;
const rev = getCurrentRevision(change);
return rev?.uploader?._account_id === account._account_id;
}
-export function isInvolved(change?: ChangeInfo, account?: AccountInfo) {
+export function isInvolved(
+ change?: ChangeInfo,
+ account?: AccountInfo
+): boolean {
const owner = isOwner(change, account);
const uploader = isUploader(change, account);
const reviewer = isReviewer(change, account);
- return owner || uploader || reviewer;
+ const cc = isCc(change, account);
+ return owner || uploader || reviewer || cc;
}
export function getCurrentRevision(change?: ChangeInfo) {
diff --git a/polygerrit-ui/app/utils/common-util.ts b/polygerrit-ui/app/utils/common-util.ts
index 2246251..f4d6d51 100644
--- a/polygerrit-ui/app/utils/common-util.ts
+++ b/polygerrit-ui/app/utils/common-util.ts
@@ -111,3 +111,14 @@
}
return true;
}
+
+/**
+ * Add value, if the set does not contain it. Otherwise remove it.
+ */
+export function toggleSetMembership<T>(set: Set<T>, value: T): void {
+ if (set.has(value)) {
+ set.delete(value);
+ } else {
+ set.add(value);
+ }
+}
diff --git a/polygerrit-ui/app/utils/common-util_test.js b/polygerrit-ui/app/utils/common-util_test.js
index 917d652b..d6d66d7 100644
--- a/polygerrit-ui/app/utils/common-util_test.js
+++ b/polygerrit-ui/app/utils/common-util_test.js
@@ -29,7 +29,7 @@
assert.isTrue(hasOwnProperty(obj, 'name with spaces'));
assert.isFalse(hasOwnProperty(obj, 'def'));
});
- test('object prototype has overriden hasOwnProperty', () => {
+ test('object prototype has overridden hasOwnProperty', () => {
const F = function() {
this.abc = 23;
};
diff --git a/polygerrit-ui/app/utils/dom-util.ts b/polygerrit-ui/app/utils/dom-util.ts
index aa83173..7f9ef72 100644
--- a/polygerrit-ui/app/utils/dom-util.ts
+++ b/polygerrit-ui/app/utils/dom-util.ts
@@ -16,6 +16,7 @@
*/
import {EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
+import {check} from './common-util';
/**
* Event emitted from polymer elements.
@@ -155,7 +156,7 @@
export function windowLocationReload() {
const e = new Error();
- console.info(`Calling window.location.realod(): ${e.stack}`);
+ console.info(`Calling window.location.reload(): ${e.stack}`);
window.location.reload();
}
@@ -258,3 +259,22 @@
(/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream)
);
}
+
+export function whenVisible(
+ element: Element,
+ callback: () => void,
+ marginPx = 0
+) {
+ const observer = new IntersectionObserver(
+ (entries: IntersectionObserverEntry[]) => {
+ check(entries.length === 1, 'Expected one intersection observer entry.');
+ const entry = entries[0];
+ if (entry.isIntersecting) {
+ observer.unobserve(entry.target);
+ callback();
+ }
+ },
+ {rootMargin: `${marginPx}px`}
+ );
+ observer.observe(element);
+}
diff --git a/polygerrit-ui/app/utils/label-util.ts b/polygerrit-ui/app/utils/label-util.ts
index 60ac4d8..4eed0a0 100644
--- a/polygerrit-ui/app/utils/label-util.ts
+++ b/polygerrit-ui/app/utils/label-util.ts
@@ -51,3 +51,11 @@
): ApprovalInfo | undefined {
return label.all?.filter(x => x._account_id === account._account_id)[0];
}
+
+export function labelCompare(labelName1: string, labelName2: string) {
+ if (labelName1 === CODE_REVIEW && labelName2 === CODE_REVIEW) return 0;
+ if (labelName1 === CODE_REVIEW) return -1;
+ if (labelName2 === CODE_REVIEW) return 1;
+
+ return labelName1.localeCompare(labelName2);
+}
diff --git a/polygerrit-ui/app/utils/label-util_test.js b/polygerrit-ui/app/utils/label-util_test.js
index 6a2f768..f9a30df 100644
--- a/polygerrit-ui/app/utils/label-util_test.js
+++ b/polygerrit-ui/app/utils/label-util_test.js
@@ -21,6 +21,7 @@
getVotingRangeOrDefault,
getMaxAccounts,
getApprovalInfo,
+ labelCompare,
} from './label-util.js';
const VALUES_1 = {
@@ -113,4 +114,11 @@
};
assert.isUndefined(getApprovalInfo(label, myAccountInfo));
});
+
+ test('labelCompare', () => {
+ let sorted = ['c', 'b', 'a'].sort(labelCompare);
+ assert.sameOrderedMembers(sorted, ['a', 'b', 'c']);
+ sorted = ['b', 'a', 'Code-Review'].sort(labelCompare);
+ assert.sameOrderedMembers(sorted, ['Code-Review', 'a', 'b']);
+ });
});
diff --git a/polygerrit-ui/app/utils/url-util_test.js b/polygerrit-ui/app/utils/url-util_test.js
index 0658be3..b1b17f4 100644
--- a/polygerrit-ui/app/utils/url-util_test.js
+++ b/polygerrit-ui/app/utils/url-util_test.js
@@ -25,15 +25,15 @@
suite('url-util tests', () => {
suite('getBaseUrl tests', () => {
- let originialCanonicalPath;
+ let originalCanonicalPath;
suiteSetup(() => {
- originialCanonicalPath = window.CANONICAL_PATH;
+ originalCanonicalPath = window.CANONICAL_PATH;
window.CANONICAL_PATH = '/r';
});
suiteTeardown(() => {
- window.CANONICAL_PATH = originialCanonicalPath;
+ window.CANONICAL_PATH = originalCanonicalPath;
});
test('getBaseUrl', () => {
diff --git a/polygerrit-ui/app/yarn.lock b/polygerrit-ui/app/yarn.lock
index e544dbc..ec3b7a0 100644
--- a/polygerrit-ui/app/yarn.lock
+++ b/polygerrit-ui/app/yarn.lock
@@ -324,6 +324,11 @@
dependencies:
"@webcomponents/shadycss" "^1.9.1"
+"@types/resize-observer-browser@^0.1.5":
+ version "0.1.5"
+ resolved "https://registry.yarnpkg.com/@types/resize-observer-browser/-/resize-observer-browser-0.1.5.tgz#36d897708172ac2380cd486da7a3daf1161c1e23"
+ integrity sha512-8k/67Z95Goa6Lznuykxkfhq9YU3l1Qe6LNZmwde1u7802a3x8v44oq0j91DICclxatTr0rNnhXx7+VTIetSrSQ==
+
"@webcomponents/shadycss@^1.9.1", "@webcomponents/shadycss@^1.9.2":
version "1.9.4"
resolved "https://registry.yarnpkg.com/@webcomponents/shadycss/-/shadycss-1.9.4.tgz#4f9d8ea1526bab084c60b53d4854dc39fdb2bb48"