Skip to content

Commit

Permalink
Merge changes from topic "warning-submitting" into stable-3.0
Browse files Browse the repository at this point in the history
* changes:
  Use strict equality
  Add a warning if submitting a change with an open change edit
  • Loading branch information
David Ostrovsky authored and Gerrit Code Review committed Nov 24, 2020
2 parents 928f83d + 5d6ca05 commit 6bc2968
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
<template is="dom-if" if="[[change.is_private]]">
<p><strong>Heads Up!</strong> Submitting this private change will also make it public.</p>
</template>
<template is="dom-if" if="[[_computeHasChangeEdit(change)]]">
<iron-icon icon="gr-icons:error" class="warningBeforeSubmit"></iron-icon>
Your unpublished edit will not be submitted. Did you
forget to click <b>PUBLISH</b>?
</template>
<gr-endpoint-param name="change" value="[[change]]"></gr-endpoint-param>
<gr-endpoint-param name="action" value="[[action]]"></gr-endpoint-param>
</gr-endpoint-decorator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
this.$.dialog.resetFocus();
},

_computeHasChangeEdit(change) {
return !!change.revisions &&
Object.values(change.revisions).some(rev => rev._number === 'edit');
},

_handleConfirmTap(e) {
e.preventDefault();
this.dispatchEvent(new CustomEvent('confirm', {bubbles: false}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@

test('display', () => {
element.action = {label: 'my-label'};
element.change = {subject: 'my-subject'};
element.change = {
subject: 'my-subject',
revisions: {},
};
flushAsynchronousOperations();
const header = element.$$('.header');
assert.equal(header.textContent.trim(), 'my-label');
Expand All @@ -59,5 +62,27 @@
assert.notEqual(message.textContent.length, 0);
assert.notEqual(message.textContent.indexOf('my-subject'), -1);
});

test('_computeHasChangeEdit', () => {
const change = {
revisions: {
d442ff05d6c4f2a3af0eeca1f67374b39f9dc3d8: {
_number: 'edit',
},
},
unresolved_comment_count: 0,
};

assert.equal(element._computeHasChangeEdit(change), true);

const change2 = {
revisions: {
d442ff05d6c4f2a3af0eeca1f67374b39f9dc3d8: {
_number: 2,
},
},
};
assert.equal(element._computeHasChangeEdit(change2), false);
});
});
</script>

0 comments on commit 6bc2968

Please sign in to comment.