Merge "Fix delete button again"

This commit is contained in:
Wyatt Allen 2017-05-19 23:09:03 +00:00 committed by Gerrit Code Review
commit 2b37d9363f
5 changed files with 18 additions and 10 deletions

View File

@ -56,7 +56,7 @@ limitations under the License.
robot-button-disabled="[[_hideActions(_showActions, _lastComment)]]"
change-num="[[changeNum]]"
patch-num="[[patchNum]]"
draft="[[comment.__draft]]"
draft="[[_isDraft(comment)]]"
show-actions="[[_showActions]]"
comment-side="[[comment.__commentSide]]"
side="[[comment.side]]"

View File

@ -205,6 +205,10 @@
}
},
_isDraft(comment) {
return !!comment.__draft;
},
_processCommentReply(opt_quote) {
const comment = this._lastComment;
let quoteStr;

View File

@ -54,9 +54,6 @@ limitations under the License.
margin-bottom: 0.7em;
padding-bottom: 0;
}
.hidden {
display: none;
}
.container.collapsed .header {
margin: 0;
}
@ -192,8 +189,12 @@ limitations under the License.
width: 100%;
}
#deleteBtn {
display: none;
margin-top: .5em;
}
#deleteBtn.showDeleteButtons {
display: block;
}
</style>
<div id="container"
class="container"
@ -275,7 +276,7 @@ limitations under the License.
</div>
<gr-button
id="deleteBtn"
class$="action delete [[_maybeAddHidden(_isAdmin, draft)]]"
class$="action delete [[_computeDeleteButtonClass(_isAdmin, draft)]]"
on-tap="_handleCommentDelete">
Delete
</gr-button>

View File

@ -253,8 +253,8 @@
return '#' + comment.line;
},
_maybeAddHidden(isAdmin, draft) {
return isAdmin && !draft ? '' : 'hidden';
_computeDeleteButtonClass(isAdmin, draft) {
return isAdmin && !draft ? 'showDeleteButtons' : '';
},
_computeSaveDisabled(draft) {

View File

@ -248,13 +248,15 @@ limitations under the License.
});
test('delete comment button for non-admins is hidden', () => {
element._isAdmin = false;
assert.isTrue(element.$$('.action.delete').classList.contains('hidden'));
assert.isFalse(element.$$('.action.delete')
.classList.contains('showDeleteButtons'));
});
test('delete comment button for admins with draft is hidden', () => {
element._isAdmin = false;
element.draft = true;
assert.isTrue(element.$$('.action.delete').classList.contains('hidden'));
assert.isFalse(element.$$('.action.delete')
.classList.contains('showDeleteButtons'));
});
test('delete comment', done => {
@ -264,7 +266,8 @@ limitations under the License.
element.changeNum = 42;
element.patchNum = 0xDEADBEEF;
element._isAdmin = true;
assert.isFalse(element.$$('.action.delete').classList.contains('hidden'));
assert.isTrue(element.$$('.action.delete')
.classList.contains('showDeleteButtons'));
MockInteractions.tap(element.$$('.action.delete'));
element.$.overlay.open.lastCall.returnValue.then(() => {
element.$.confirmDeleteComment.message = 'removal reason';