Merge changes Id0f7deac,I27b6be10,Id24991b4,Ibcac4ab0,I8c8d581f, ...
* changes:
Remove errFn from save(|Diff|Edit)Preferences
Remove errFn from getGroupMembers
Remove errFn from createRepoBranch and createRepoTag
Remove errFn from deleteRepoTags
Remove errFn from deleteRepoBranches
Remove errFn from createGroup
Remove errFn from createRepo
Remove errFn from saveRepoConfig and runRepoGC
Create proper event and util for network-error
Create proper event and util for server-error
diff --git a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.ts b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.ts
index 6a32834..dc04e38 100644
--- a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.ts
@@ -399,7 +399,7 @@
hasRobotComment,
hasHumanReplyToRobotComment,
unresolved: !!lastComment && !!lastComment.unresolved,
- isEditing: !!lastComment && !!lastComment.__editing,
+ isEditing: isDraft(lastComment) && !!lastComment.__editing,
hasDraft: !!lastComment && isDraft(lastComment),
updated,
};
diff --git a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.js b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.js
index 945cca9..622e1a2 100644
--- a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.js
+++ b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.js
@@ -568,6 +568,7 @@
modifiedThreads[5].comments.push({
...modifiedThreads[5].comments[0],
__editing: true,
+ __draft: true,
});
element.threads = modifiedThreads;
MockInteractions.tap(element.shadowRoot.querySelector('#draftToggle'));
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
index b5efff6..0e0ee0c 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
@@ -400,15 +400,6 @@
if (!id) throw new Error('Cannot reply to comment without id.');
const reply = this._newReply(id, content, unresolved);
- // If there is currently a comment in an editing state, add an attribute
- // so that the gr-comment knows not to populate the draft text.
- for (let i = 0; i < this.comments.length; i++) {
- if (this.comments[i].__editing) {
- reply.__otherEditing = true;
- break;
- }
- }
-
if (isEditing) {
reply.__editing = true;
}
@@ -565,7 +556,7 @@
// Check to see if there are any other open comments getting edited and
// set the local storage value to its message value.
for (const changeComment of this.comments) {
- if (changeComment.__editing) {
+ if (isDraft(changeComment) && changeComment.__editing) {
const commentLocation: StorageLocation = {
changeNum: this.changeNum,
patchNum: this.patchNum,
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
index 175311e..c1367a6 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
@@ -605,31 +605,6 @@
);
});
- test('first editing comment does not add __otherEditing attribute', () => {
- element.comments = [
- {
- author: {
- name: 'Mr. Peanutbutter',
- email: ('tenn1sballchaser@aol.com' as EmailAddress) as EmailAddress,
- },
- id: 'baf0414d_60047215' as UrlEncodedCommentId,
- line: 5,
- path: 'test',
- message: 'is this a crossover episode!?',
- updated: '2015-12-08 19:48:33.843000000' as Timestamp,
- __draft: true,
- },
- ];
-
- const replyBtn = element.$.replyBtn;
- tap(replyBtn);
- flush();
-
- const editing = element._orderedComments.filter(c => c.__editing === true);
- assert.equal(editing.length, 1);
- assert.equal(!!editing[0].__otherEditing, false);
- });
-
test(
'When not editing other comments, local storage not set' + ' after discard',
done => {
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
index 73f3614..1401208 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -155,10 +155,10 @@
changeNum?: NumericChangeId;
@property({type: Object, notify: true, observer: '_commentChanged'})
- comment?: UIComment | UIRobot;
+ comment?: UIComment;
@property({type: Array})
- comments?: (UIComment | UIRobot)[];
+ comments?: UIComment[];
@property({type: Boolean, reflectToAttribute: true})
isRobotComment = false;
@@ -477,7 +477,7 @@
}
_commentChanged(comment: UIComment) {
- this.editing = !!comment.__editing;
+ this.editing = isDraft(comment) && !!comment.__editing;
this.resolved = !comment.unresolved;
if (this.editing) {
// It's a new draft/reply, notify.
@@ -547,7 +547,7 @@
cancelButton.hidden = !editing;
}
}
- if (this.comment) {
+ if (isDraft(this.comment)) {
this.comment.__editing = this.editing;
}
if (!!editing !== !!previousValue) {
@@ -921,17 +921,7 @@
// Only apply local drafts to comments that haven't been saved
// remotely, and haven't been given a default message already.
- //
- // Don't get local draft if there is another comment that is currently
- // in an editing state.
- if (
- !comment ||
- comment.id ||
- comment.message ||
- comment.__otherEditing ||
- !comment.path
- ) {
- if (comment) delete comment.__otherEditing;
+ if (!comment || comment.id || comment.message || !comment.path) {
return;
}
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.js b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.js
index 3026f4a..1c85523 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.js
@@ -129,7 +129,6 @@
email: 'tenn1sballchaser@aol.com',
},
line: 5,
- __otherEditing: true,
};
flush(() => {
assert.isTrue(loadSpy.called);
@@ -1264,7 +1263,7 @@
element = draftFixture.instantiate();
// fake random
element.getRandomNum = () => 0;
- element.comment = {__editing: true};
+ element.comment = {__editing: true, __draft: true};
flush(() => {
assert.isTrue(respectfulGetStub.called);
assert.isTrue(respectfulSetStub.called);
@@ -1287,7 +1286,7 @@
element = draftFixture.instantiate();
// fake random
element.getRandomNum = () => 0;
- element.comment = {__editing: true};
+ element.comment = {__editing: true, __draft: true};
flush(() => {
assert.isTrue(respectfulGetStub.called);
assert.isTrue(respectfulSetStub.called);
@@ -1316,7 +1315,7 @@
element = draftFixture.instantiate();
// fake random
element.getRandomNum = () => 3;
- element.comment = {__editing: true};
+ element.comment = {__editing: true, __draft: true};
flush(() => {
assert.isTrue(respectfulGetStub.called);
assert.isFalse(respectfulSetStub.called);
@@ -1371,7 +1370,7 @@
element = draftFixture.instantiate();
// fake random
element.getRandomNum = () => 0;
- element.comment = {__editing: true};
+ element.comment = {__editing: true, __draft: true};
flush(() => {
assert.isTrue(respectfulGetStub.called);
assert.isFalse(respectfulSetStub.called);
diff --git a/polygerrit-ui/app/utils/comment-util.ts b/polygerrit-ui/app/utils/comment-util.ts
index 3340820..0726f67 100644
--- a/polygerrit-ui/app/utils/comment-util.ts
+++ b/polygerrit-ui/app/utils/comment-util.ts
@@ -46,12 +46,13 @@
export interface UIStateCommentProps {
collapsed?: boolean;
- // TODO(TS): Consider allowing this only for drafts.
- __editing?: boolean;
- __otherEditing?: boolean;
}
-export type UIDraft = DraftInfo & UIStateCommentProps;
+export interface UIStateDraftProps {
+ __editing?: boolean;
+}
+
+export type UIDraft = DraftInfo & UIStateCommentProps & UIStateDraftProps;
export type UIHuman = CommentInfo & UIStateCommentProps;