Warn user in submit dialog about unresolved comments

Change-Id: I5cbc470686f7a80155ecbda2640eb63bef9ac259
This commit is contained in:
Milutin Kristofic
2020-02-04 14:49:04 +01:00
parent 6734cce159
commit 9dae035d10
3 changed files with 35 additions and 1 deletions

View File

@@ -16,12 +16,15 @@ limitations under the License.
-->
<link rel="import" href="/bower_components/polymer/polymer.html">
<link rel="import" href="/bower_components/iron-icon/iron-icon.html">
<link rel="import" href="../../shared/gr-icons/gr-icons.html">
<link rel="import" href="../../core/gr-navigation/gr-navigation.html">
<link rel="import" href="../../shared/gr-dialog/gr-dialog.html">
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
<link rel="import" href="../../plugins/gr-endpoint-decorator/gr-endpoint-decorator.html">
<link rel="import" href="../../plugins/gr-endpoint-param/gr-endpoint-param.html">
<link rel="import" href="../../../styles/shared-styles.html">
<dom-module id="gr-confirm-submit-dialog">
@@ -33,6 +36,11 @@ limitations under the License.
p {
margin-bottom: var(--spacing-l);
}
.warningBeforeSubmit {
color: var(--error-text-color);
vertical-align: top;
margin-right: var(--spacing-s);
}
@media screen and (max-width: 50em) {
#dialog {
min-width: inherit;
@@ -53,7 +61,17 @@ limitations under the License.
<gr-endpoint-decorator name="confirm-submit-change">
<p>Ready to submit &ldquo;<strong>[[change.subject]]</strong>&rdquo;?</p>
<template is="dom-if" if="[[change.is_private]]">
<p><strong>Heads Up!</strong> Submitting this private change will also make it public.</p>
<p>
<iron-icon icon="gr-icons:error" class="warningBeforeSubmit"></iron-icon>
<strong>Heads Up!</strong>
Submitting this private change will also make it public.
</p>
</template>
<template is="dom-if" if="[[change.unresolved_comment_count]]">
<p>
<iron-icon icon="gr-icons:error" class="warningBeforeSubmit"></iron-icon>
[[_computeUnresolvedCommentsWarning(change)]]
</p>
</template>
<gr-endpoint-param name="change" value="[[change]]"></gr-endpoint-param>
<gr-endpoint-param name="action" value="[[action]]"></gr-endpoint-param>

View File

@@ -57,6 +57,12 @@
this.$.dialog.resetFocus();
}
_computeUnresolvedCommentsWarning(change) {
const unresolvedCount = change.unresolved_comment_count;
const plural = unresolvedCount > 1 ? 's' : '';
return `Heads Up! ${unresolvedCount} unresolved comment${plural}.`;
}
_handleConfirmTap(e) {
e.preventDefault();
e.stopPropagation();

View File

@@ -61,5 +61,15 @@ limitations under the License.
assert.notEqual(message.textContent.length, 0);
assert.notEqual(message.textContent.indexOf('my-subject'), -1);
});
test('_computeUnresolvedCommentsWarning', () => {
const change = {unresolved_comment_count: 1};
assert.equal(element._computeUnresolvedCommentsWarning(change),
'Heads Up! 1 unresolved comment.');
const change2 = {unresolved_comment_count: 2};
assert.equal(element._computeUnresolvedCommentsWarning(change2),
'Heads Up! 2 unresolved comments.');
});
});
</script>