Merge "Change the long comment threshold from 5 to 10."
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/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/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..5305cea 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) {
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/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..e02b337 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
@@ -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-view/gr-change-view.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
index 304939c..3d7646f 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
@@ -2313,6 +2313,7 @@
return response;
});
}
+ // TODO: use returned Promise
this.getRelatedChangesListExperimental()?.reload(
relatedChangesPromise
);
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 11f0fd3..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
@@ -16,9 +16,12 @@
*/
import {html, nothing} from 'lit-html';
import './gr-related-change';
+import '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator';
+import '../../plugins/gr-endpoint-param/gr-endpoint-param';
+import '../../plugins/gr-endpoint-slot/gr-endpoint-slot';
import {classMap} from 'lit-html/directives/class-map';
import {GrLitElement} from '../../lit/gr-lit-element';
-import {customElement, property, css} from 'lit-element';
+import {customElement, property, css, internalProperty} from 'lit-element';
import {sharedStyles} from '../../../styles/shared-styles';
import {
SubmittedTogetherInfo,
@@ -32,7 +35,11 @@
import {ParsedChangeInfo} from '../../../types/types';
import {GerritNav} from '../../core/gr-navigation/gr-navigation';
import {pluralize} from '../../../utils/string-util';
-import {getRevisionKey, isChangeInfo} from '../../../utils/change-util';
+import {
+ changeIsOpen,
+ getRevisionKey,
+ isChangeInfo,
+} from '../../../utils/change-util';
/** What is the maximum number of shown changes in collapsed list? */
const MAX_CHANGES_WHEN_COLLAPSED = 3;
@@ -46,13 +53,25 @@
patchNum?: PatchSetNum;
@property()
- _submittedTogether?: SubmittedTogetherInfo = {
+ mergeable?: boolean;
+
+ @internalProperty()
+ submittedTogether?: SubmittedTogetherInfo = {
changes: [],
non_visible_changes: 0,
};
- @property()
- _relatedResponse?: RelatedChangesInfo = {changes: []};
+ @internalProperty()
+ relatedChanges: RelatedChangeAndCommitInfo[] = [];
+
+ @internalProperty()
+ conflictingChanges: ChangeInfo[] = [];
+
+ @internalProperty()
+ cherryPickChanges: ChangeInfo[] = [];
+
+ @internalProperty()
+ sameTopicChanges: ChangeInfo[] = [];
private readonly restApiService = appContext.restApiService;
@@ -62,6 +81,7 @@
css`
.note {
color: var(--error-text-color);
+ margin-left: 1.2em;
}
section {
margin-bottom: var(--spacing-m);
@@ -71,27 +91,26 @@
}
render() {
- const relatedChanges = this._relatedResponse?.changes ?? [];
let showWhenCollapsedPredicate = this.showWhenCollapsedPredicateFactory(
- relatedChanges.length,
- relatedChanges.findIndex(relatedChange =>
+ this.relatedChanges.length,
+ this.relatedChanges.findIndex(relatedChange =>
this._changesEqual(relatedChange, this.change)
)
);
const connectedRevisions = this._computeConnectedRevisions(
this.change,
this.patchNum,
- relatedChanges
+ this.relatedChanges
);
const relatedChangeSection = html` <section
class="relatedChanges"
- ?hidden=${!relatedChanges.length}
+ ?hidden=${!this.relatedChanges.length}
>
<gr-related-collapse
title="Relation chain"
- .length=${relatedChanges.length}
+ .length=${this.relatedChanges.length}
>
- ${relatedChanges.map(
+ ${this.relatedChanges.map(
(change, index) =>
html`<gr-related-change
class="${classMap({
@@ -114,9 +133,9 @@
</gr-related-collapse>
</section>`;
- const submittedTogetherChanges = this._submittedTogether?.changes ?? [];
+ const submittedTogetherChanges = this.submittedTogether?.changes ?? [];
const countNonVisibleChanges =
- this._submittedTogether?.non_visible_changes ?? 0;
+ this.submittedTogether?.non_visible_changes ?? 0;
showWhenCollapsedPredicate = this.showWhenCollapsedPredicateFactory(
submittedTogetherChanges.length,
submittedTogetherChanges.findIndex(relatedChange =>
@@ -126,7 +145,7 @@
const submittedTogetherSection = html`<section
id="submittedTogether"
?hidden=${!submittedTogetherChanges?.length &&
- !this._submittedTogether?.non_visible_changes}
+ !this.submittedTogether?.non_visible_changes}
>
<gr-related-collapse
title="Submitted together"
@@ -155,11 +174,106 @@
</div>
</section>`;
- return html`${relatedChangeSection}${submittedTogetherSection}`;
+ showWhenCollapsedPredicate = this.showWhenCollapsedPredicateFactory(
+ this.sameTopicChanges.length,
+ -1
+ );
+ const sameTopicSection = html`<section
+ id="sameTopic"
+ ?hidden=${!this.sameTopicChanges?.length}
+ >
+ <gr-related-collapse
+ title="Same topic"
+ .length=${this.sameTopicChanges.length}
+ >
+ ${this.sameTopicChanges.map(
+ (change, index) =>
+ html`<gr-related-change
+ class="${classMap({
+ ['show-when-collapsed']: showWhenCollapsedPredicate(index),
+ })}"
+ .change="${change}"
+ .href="${GerritNav.getUrlForChangeById(
+ change._number,
+ change.project
+ )}"
+ >${change.project}: ${change.branch}:
+ ${change.subject}</gr-related-change
+ >`
+ )}
+ </gr-related-collapse>
+ </section>`;
+
+ showWhenCollapsedPredicate = this.showWhenCollapsedPredicateFactory(
+ this.conflictingChanges.length,
+ -1
+ );
+ const mergeConflictsSection = html`<section
+ id="mergeConflicts"
+ ?hidden=${!this.conflictingChanges?.length}
+ >
+ <gr-related-collapse
+ title="Merge conflicts"
+ .length=${this.conflictingChanges.length}
+ >
+ ${this.conflictingChanges.map(
+ (change, index) =>
+ html`<gr-related-change
+ class="${classMap({
+ ['show-when-collapsed']: showWhenCollapsedPredicate(index),
+ })}"
+ .change="${change}"
+ .href="${GerritNav.getUrlForChangeById(
+ change._number,
+ change.project
+ )}"
+ >${change.subject}</gr-related-change
+ >`
+ )}
+ </gr-related-collapse>
+ </section>`;
+
+ showWhenCollapsedPredicate = this.showWhenCollapsedPredicateFactory(
+ this.cherryPickChanges.length,
+ -1
+ );
+ const cherryPicksSection = html`<section
+ id="cherryPicks"
+ ?hidden=${!this.cherryPickChanges?.length}
+ >
+ <gr-related-collapse
+ title="Cherry picks"
+ .length=${this.cherryPickChanges.length}
+ >
+ ${this.cherryPickChanges.map(
+ (change, index) =>
+ html`<gr-related-change
+ class="${classMap({
+ ['show-when-collapsed']: showWhenCollapsedPredicate(index),
+ })}"
+ .change="${change}"
+ .href="${GerritNav.getUrlForChangeById(
+ change._number,
+ change.project
+ )}"
+ >${change.branch}: ${change.subject}</gr-related-change
+ >`
+ )}
+ </gr-related-collapse>
+ </section>`;
+
+ return html`<gr-endpoint-decorator name="related-changes-section">
+ <gr-endpoint-param name="change" value="[[change]]"></gr-endpoint-param>
+ <gr-endpoint-slot name="top"></gr-endpoint-slot>
+ ${relatedChangeSection} ${submittedTogetherSection} ${sameTopicSection}
+ ${mergeConflictsSection} ${cherryPicksSection}
+ <gr-endpoint-slot name="bottom"></gr-endpoint-slot>
+ </gr-endpoint-decorator>`;
}
showWhenCollapsedPredicateFactory(length: number, highlightIndex: number) {
return (index: number) => {
+ if (highlightIndex === -1) return index < MAX_CHANGES_WHEN_COLLAPSED;
if (highlightIndex === 0) return index <= MAX_CHANGES_WHEN_COLLAPSED - 1;
if (highlightIndex === length - 1)
return index >= length - MAX_CHANGES_WHEN_COLLAPSED;
@@ -171,21 +285,60 @@
}
reload(getRelatedChanges?: Promise<RelatedChangesInfo | undefined>) {
- if (!this.change) return Promise.reject(new Error('change missing'));
+ const change = this.change;
+ if (!change) return Promise.reject(new Error('change missing'));
+ if (!this.patchNum) return Promise.reject(new Error('patchNum missing'));
+ if (!getRelatedChanges) {
+ getRelatedChanges = this.restApiService.getRelatedChanges(
+ change._number,
+ this.patchNum
+ );
+ }
const promises: Array<Promise<void>> = [
+ getRelatedChanges.then(response => {
+ if (!response) {
+ throw new Error('getRelatedChanges returned undefined response');
+ }
+ this.relatedChanges = response?.changes ?? [];
+ }),
this.restApiService
- .getChangesSubmittedTogether(this.change._number)
+ .getChangesSubmittedTogether(change._number)
.then(response => {
- this._submittedTogether = response;
+ this.submittedTogether = response;
+ }),
+ this.restApiService
+ .getChangeCherryPicks(change.project, change.change_id, change._number)
+ .then(response => {
+ this.cherryPickChanges = response || [];
}),
];
- if (getRelatedChanges) {
+
+ // Get conflicts if change is open and is mergeable.
+ // Mergeable is output of restApiServict.getMergeable from gr-change-view
+ if (changeIsOpen(change) && this.mergeable) {
promises.push(
- getRelatedChanges.then(response => {
- if (!response) {
- throw new Error('getRelatedChanges returned undefined response');
+ this.restApiService
+ .getChangeConflicts(change._number)
+ .then(response => {
+ this.conflictingChanges = response ?? [];
+ })
+ );
+ }
+ if (change.topic) {
+ const changeTopic = change.topic;
+ promises.push(
+ this.restApiService.getConfig().then(config => {
+ if (config && !config.change.submit_whole_topic) {
+ return this.restApiService
+ .getChangesWithSameTopic(changeTopic, change._number)
+ .then(response => {
+ if (changeTopic === this.change?.topic) {
+ this.sameTopicChanges = response ?? [];
+ }
+ });
}
- this._relatedResponse = response;
+ this.sameTopicChanges = [];
+ return Promise.resolve();
})
);
}
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 8cb0638..9941fa9 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
@@ -193,6 +193,7 @@
href$="[[_computeChangeURL(change._number, change.project)]]"
class$="[[_computeLinkClass(change)]]"
title$="[[change.subject]]"
+ on-click="_reportClick"
>
[[change.subject]]
</a>
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-results.ts b/polygerrit-ui/app/elements/checks/gr-checks-results.ts
index 34945a9..e448374 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,6 +286,12 @@
@customElement('gr-checks-results')
export class GrChecksResults extends GrLitElement {
+ @query('#filterInput')
+ filterInput?: HTMLInputElement;
+
+ @internalProperty()
+ filterRegExp = new RegExp('');
+
@property()
runs: CheckRun[] = [];
@@ -267,6 +303,11 @@
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);
@@ -310,12 +351,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()}
`;
}
+ 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';
@@ -358,6 +417,11 @@
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>`
@@ -365,7 +429,9 @@
}
renderSuccess() {
- const runs = this.runs.filter(hasCompletedWithoutResults);
+ const runs = this.runs
+ .filter(hasCompletedWithoutResults)
+ .filter(r => this.filterRegExp.test(r.checkName));
if (runs.length === 0) return;
return html`
<h3 class="categoryHeader heading-3">
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-runs.ts b/polygerrit-ui/app/elements/checks/gr-checks-runs.ts
index 5b7428b..71ad041 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, toggleSetMembership} 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,
})
);
}
@@ -124,9 +129,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 +156,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,6 +227,12 @@
@customElement('gr-checks-runs')
export class GrChecksRuns extends GrLitElement {
+ @query('#filterInput')
+ filterInput?: HTMLInputElement;
+
+ @internalProperty()
+ filterRegExp = new RegExp('');
+
@property()
runs: CheckRun[] = [];
@@ -207,6 +255,11 @@
padding-top: var(--spacing-l);
text-transform: capitalize;
}
+ input#filterInput {
+ margin-top: var(--spacing-s);
+ padding: var(--spacing-s) var(--spacing-m);
+ width: 100%;
+ }
.testing {
margin-top: var(--spacing-xxl);
color: var(--deemphasized-text-color);
@@ -227,6 +280,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 +312,11 @@
`;
}
+ onInput() {
+ assertIsDefined(this.filterInput, 'filter <input> element');
+ this.filterRegExp = new RegExp(this.filterInput.value, 'i');
+ }
+
none() {
updateStateSetResults('f0', []);
updateStateSetResults('f1', []);
@@ -277,6 +341,7 @@
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;
return html`
@@ -289,20 +354,17 @@
renderRun(run: CheckRun) {
const selected = this.selectedRuns.has(run.checkName);
+ const deselected = !selected && this.selectedRuns.size > 0;
return html`<gr-checks-run
.run="${run}"
.selected="${selected}"
+ .deselected="${deselected}"
@run-selected="${this.handleRunSelected}"
></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);
- }
+ toggleSetMembership(this.selectedRuns, e.detail.checkName);
this.requestUpdate();
}
}
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-tab.ts b/polygerrit-ui/app/elements/checks/gr-checks-tab.ts
index 61f8bd1..0ce81ed 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-tab.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-tab.ts
@@ -32,7 +32,11 @@
ActionTriggeredEvent,
fireActionTriggered,
} from '../../services/checks/checks-util';
-import {checkRequiredProperty} from '../../utils/common-util';
+import {
+ checkRequiredProperty,
+ toggleSetMembership,
+} from '../../utils/common-util';
+import {RunSelectedEvent} from './gr-checks-runs';
/**
* The "Checks" tab on the Gerrit change page. Gets its data from plugins that
@@ -53,6 +57,8 @@
@property()
changeNum: NumericChangeId | undefined = undefined;
+ private selectedRuns = new Set<string>();
+
constructor() {
super();
this.subscribe('runs', allRuns$);
@@ -100,6 +106,9 @@
render() {
const ps = `Patchset ${this.currentPatchNum} (Latest)`;
+ const filteredRuns = this.runs.filter(
+ r => this.selectedRuns.size === 0 || this.selectedRuns.has(r.checkName)
+ );
return html`
<div class="header">
<div class="left">
@@ -118,10 +127,14 @@
</div>
</div>
<div class="container">
- <gr-checks-runs class="runs" .runs="${this.runs}"></gr-checks-runs>
+ <gr-checks-runs
+ class="runs"
+ .runs="${this.runs}"
+ @run-selected="${this.handleRunSelected}"
+ ></gr-checks-runs>
<gr-checks-results
class="results"
- .runs="${this.runs}"
+ .runs="${filteredRuns}"
></gr-checks-results>
</div>
`;
@@ -148,6 +161,11 @@
action.name
);
}
+
+ handleRunSelected(e: RunSelectedEvent) {
+ toggleSetMembership(this.selectedRuns, e.detail.checkName);
+ this.requestUpdate();
+ }
}
@customElement('gr-checks-top-level-action')
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..829038b 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
@@ -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/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/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-annotation-actions-js-api.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api.ts
index 95252cf..a3d038d 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api.ts
@@ -120,12 +120,8 @@
* Don't forget to also call disposeLayer().
*/
createLayer(path: string, changeNum: number) {
- if (!this.annotationCallback) return undefined;
- const annotationLayer = new AnnotationLayer(
- path,
- changeNum,
- this.annotationCallback
- );
+ const callbackFn = this.annotationCallback || (() => {});
+ const annotationLayer = new AnnotationLayer(path, changeNum, callbackFn);
this.annotationLayers.push(annotationLayer);
return annotationLayer;
}
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-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-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-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..68f15dc 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 = {
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/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/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_impl.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
index f80cb75..af06450 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();
}
@@ -765,7 +765,7 @@
true
);
if (elapsed >= SLOW_RPC_THRESHOLD) {
- this._slowRpcList.push({anonymizedUrl, elapsed});
+ this.slowRpcList.push({anonymizedUrl, elapsed});
}
}
@@ -812,10 +812,10 @@
// 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/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/dom-util.ts b/polygerrit-ui/app/utils/dom-util.ts
index aa83173..32014d7 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.
@@ -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);
+}