Merge "Fix delete button again"
This commit is contained in:
@@ -56,7 +56,7 @@ limitations under the License.
|
|||||||
robot-button-disabled="[[_hideActions(_showActions, _lastComment)]]"
|
robot-button-disabled="[[_hideActions(_showActions, _lastComment)]]"
|
||||||
change-num="[[changeNum]]"
|
change-num="[[changeNum]]"
|
||||||
patch-num="[[patchNum]]"
|
patch-num="[[patchNum]]"
|
||||||
draft="[[comment.__draft]]"
|
draft="[[_isDraft(comment)]]"
|
||||||
show-actions="[[_showActions]]"
|
show-actions="[[_showActions]]"
|
||||||
comment-side="[[comment.__commentSide]]"
|
comment-side="[[comment.__commentSide]]"
|
||||||
side="[[comment.side]]"
|
side="[[comment.side]]"
|
||||||
|
@@ -205,6 +205,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_isDraft(comment) {
|
||||||
|
return !!comment.__draft;
|
||||||
|
},
|
||||||
|
|
||||||
_processCommentReply(opt_quote) {
|
_processCommentReply(opt_quote) {
|
||||||
const comment = this._lastComment;
|
const comment = this._lastComment;
|
||||||
let quoteStr;
|
let quoteStr;
|
||||||
|
@@ -54,9 +54,6 @@ limitations under the License.
|
|||||||
margin-bottom: 0.7em;
|
margin-bottom: 0.7em;
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
.hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.container.collapsed .header {
|
.container.collapsed .header {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
@@ -192,8 +189,12 @@ limitations under the License.
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
#deleteBtn {
|
#deleteBtn {
|
||||||
|
display: none;
|
||||||
margin-top: .5em;
|
margin-top: .5em;
|
||||||
}
|
}
|
||||||
|
#deleteBtn.showDeleteButtons {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<div id="container"
|
<div id="container"
|
||||||
class="container"
|
class="container"
|
||||||
@@ -275,7 +276,7 @@ limitations under the License.
|
|||||||
</div>
|
</div>
|
||||||
<gr-button
|
<gr-button
|
||||||
id="deleteBtn"
|
id="deleteBtn"
|
||||||
class$="action delete [[_maybeAddHidden(_isAdmin, draft)]]"
|
class$="action delete [[_computeDeleteButtonClass(_isAdmin, draft)]]"
|
||||||
on-tap="_handleCommentDelete">
|
on-tap="_handleCommentDelete">
|
||||||
Delete
|
Delete
|
||||||
</gr-button>
|
</gr-button>
|
||||||
|
@@ -253,8 +253,8 @@
|
|||||||
return '#' + comment.line;
|
return '#' + comment.line;
|
||||||
},
|
},
|
||||||
|
|
||||||
_maybeAddHidden(isAdmin, draft) {
|
_computeDeleteButtonClass(isAdmin, draft) {
|
||||||
return isAdmin && !draft ? '' : 'hidden';
|
return isAdmin && !draft ? 'showDeleteButtons' : '';
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeSaveDisabled(draft) {
|
_computeSaveDisabled(draft) {
|
||||||
|
@@ -248,13 +248,15 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
test('delete comment button for non-admins is hidden', () => {
|
test('delete comment button for non-admins is hidden', () => {
|
||||||
element._isAdmin = false;
|
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', () => {
|
test('delete comment button for admins with draft is hidden', () => {
|
||||||
element._isAdmin = false;
|
element._isAdmin = false;
|
||||||
element.draft = true;
|
element.draft = true;
|
||||||
assert.isTrue(element.$$('.action.delete').classList.contains('hidden'));
|
assert.isFalse(element.$$('.action.delete')
|
||||||
|
.classList.contains('showDeleteButtons'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('delete comment', done => {
|
test('delete comment', done => {
|
||||||
@@ -264,7 +266,8 @@ limitations under the License.
|
|||||||
element.changeNum = 42;
|
element.changeNum = 42;
|
||||||
element.patchNum = 0xDEADBEEF;
|
element.patchNum = 0xDEADBEEF;
|
||||||
element._isAdmin = true;
|
element._isAdmin = true;
|
||||||
assert.isFalse(element.$$('.action.delete').classList.contains('hidden'));
|
assert.isTrue(element.$$('.action.delete')
|
||||||
|
.classList.contains('showDeleteButtons'));
|
||||||
MockInteractions.tap(element.$$('.action.delete'));
|
MockInteractions.tap(element.$$('.action.delete'));
|
||||||
element.$.overlay.open.lastCall.returnValue.then(() => {
|
element.$.overlay.open.lastCall.returnValue.then(() => {
|
||||||
element.$.confirmDeleteComment.message = 'removal reason';
|
element.$.confirmDeleteComment.message = 'removal reason';
|
||||||
|
Reference in New Issue
Block a user