Merge "PolyGerrit: Add support for creating annotated tags"
diff --git a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.html b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.html
index 465ecb7..dcc23e1 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.html
+++ b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.html
@@ -35,8 +35,10 @@
input {
width: 20em;
}
+ .hideItem {
+ display: none;
+ }
</style>
-
<div class="gr-form-styles">
<div id="form">
<section>
@@ -55,6 +57,14 @@
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>
diff --git a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.js b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.js
index de1d0f8..4d552f4 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.js
+++ b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.js
@@ -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' : '';
+ },
});
})();
diff --git a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.html b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.html
index 1ce6d8a..dd74574 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.html
+++ b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.html
@@ -87,5 +87,37 @@
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>