Expand robot comments by default

Change-Id: I6c55c0dad4cc0bd96013c77ad75b3cd6c6d34cdd
This commit is contained in:
Viktar Donich
2017-12-08 11:01:26 -08:00
parent 7ba85c0c82
commit a671085c3c
2 changed files with 18 additions and 8 deletions

View File

@@ -156,18 +156,21 @@
},
/**
* Sets the initial state of the comment thread to have the last
* {UNRESOLVED_EXPAND_COUNT} comments expanded by default if the
* thread is unresolved.
* Sets the initial state of the comment thread.
* Expands the thread if one of the following is true:
* - last {UNRESOLVED_EXPAND_COUNT} comments expanded by default if the
* thread is unresolved,
* - it's a robot comment.
*/
_setInitialExpandedState() {
let comment;
if (this._orderedComments) {
for (let i = 0; i < this._orderedComments.length; i++) {
comment = this._orderedComments[i];
comment.collapsed =
this._orderedComments.length - i - 1 >= UNRESOLVED_EXPAND_COUNT ||
!this._unresolved;
const comment = this._orderedComments[i];
const isRobotComment = !!comment.robot_id;
// False if it's an unresolved comment under UNRESOLVED_EXPAND_COUNT.
const resolvedThread = !this._unresolved ||
this._orderedComments.length - i - 1 >= UNRESOLVED_EXPAND_COUNT;
comment.collapsed = !isRobotComment && resolvedThread;
}
}
},

View File

@@ -510,6 +510,13 @@ limitations under the License.
for (let i = 0; i < element.comments.length; i++) {
assert.isTrue(element.comments[i].collapsed);
}
for (let i = 0; i < element.comments.length; i++) {
element.comments[i].robot_id = 123;
}
element._setInitialExpandedState();
for (let i = 0; i < element.comments.length; i++) {
assert.isFalse(element.comments[i].collapsed);
}
});
});