PolyGerrit: Add support for creating annotated tags
Change-Id: I614ba3b3b848a052cb30cb5ac3b184b65de6d4dd
This commit is contained in:
@@ -35,8 +35,10 @@ limitations under the License.
|
||||
input {
|
||||
width: 20em;
|
||||
}
|
||||
.hideItem {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="gr-form-styles">
|
||||
<div id="form">
|
||||
<section>
|
||||
@@ -55,6 +57,14 @@ limitations under the License.
|
||||
placeholder="Revision (Branch or SHA-1)"
|
||||
bind-value="{{_itemRevision}}">
|
||||
</section>
|
||||
<section class$="[[_computeHideItemClass(itemDetail)]]">
|
||||
<span class="title">Annotation</span>
|
||||
<input
|
||||
is="iron-input"
|
||||
id="itemAnnotationInput"
|
||||
placeholder="Annotation (Optional)"
|
||||
bind-value="{{_itemAnnotation}}">
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
itemDetail: String,
|
||||
_itemName: String,
|
||||
_itemRevision: String,
|
||||
_itemAnnotation: String,
|
||||
},
|
||||
|
||||
behaviors: [
|
||||
@@ -70,7 +71,8 @@
|
||||
});
|
||||
} else if (this.itemDetail === DETAIL_TYPES.tags) {
|
||||
return this.$.restAPI.createProjectTag(this.projectName,
|
||||
this._itemName, {revision: USE_HEAD})
|
||||
this._itemName,
|
||||
{revision: USE_HEAD, message: this._itemAnnotation || null})
|
||||
.then(itemRegistered => {
|
||||
if (itemRegistered.status === 201) {
|
||||
page.show(this._computeItemUrl(this.itemDetail));
|
||||
@@ -78,5 +80,9 @@
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
_computeHideItemClass(type) {
|
||||
return type === DETAIL_TYPES.branches ? 'hideItem' : '';
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -87,5 +87,37 @@ limitations under the License.
|
||||
|
||||
assert.equal(element._itemRevision, 'HEAD');
|
||||
});
|
||||
|
||||
test('tag created with annotations', () => {
|
||||
sandbox.stub(element.$.restAPI, 'createProjectTag', () => {
|
||||
return Promise.resolve({});
|
||||
});
|
||||
|
||||
assert.isFalse(element.hasNewItemName);
|
||||
|
||||
element._itemName = 'test-tag';
|
||||
element._itemAnnotation = 'test-message';
|
||||
element.itemDetail = 'tags';
|
||||
|
||||
element.$.itemNameInput.bindValue = 'test-tag2';
|
||||
element.$.itemAnnotationInput.bindValue = 'test-message2';
|
||||
element.$.itemRevisionInput.bindValue = 'HEAD';
|
||||
|
||||
assert.isTrue(element.hasNewItemName);
|
||||
|
||||
assert.equal(element._itemName, 'test-tag2');
|
||||
|
||||
assert.equal(element._itemAnnotation, 'test-message2');
|
||||
|
||||
assert.equal(element._itemRevision, 'HEAD');
|
||||
});
|
||||
|
||||
test('_computeHideItemClass returns hideItem if type is branches', () => {
|
||||
assert.equal(element._computeHideItemClass('branches'), 'hideItem');
|
||||
});
|
||||
|
||||
test('_computeHideItemClass returns strings if not branches', () => {
|
||||
assert.equal(element._computeHideItemClass('tags'), '');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user