GWT UI: Add support for creating annotated tags
Change-Id: Iaa1a7293ae4861177152ed8172e02e91d0b1a2dd
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.java
index cc6a136..14e7abc 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.java
@@ -31,6 +31,8 @@
String defaultRevisionSpec();
+ String annotation();
+
String buttonDeleteIncludedGroup();
String buttonAddIncludedGroup();
@@ -177,6 +179,8 @@
String columnTagRevision();
+ String columnTagAnnotation();
+
String initialRevision();
String revision();
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.properties
index 1588ea6..ef4ae5f 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.properties
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.properties
@@ -3,6 +3,7 @@
defaultBranchName = Branch Name
defaultTagName = Tag Name
defaultRevisionSpec = Revision (Branch or SHA-1)
+annotation = Annotation (optional)
buttonDeleteIncludedGroup = Delete
buttonAddIncludedGroup = Add
@@ -84,6 +85,7 @@
columnBranchRevision = Revision
columnTagName = Tag Name
columnTagRevision = Revision
+columnTagAnnotation = Annotation
initialRevision = Initial Revision
revision = Revision
buttonAddBranch = Create Branch
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectTagsScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectTagsScreen.java
index 45d0fdb..6829555 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectTagsScreen.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectTagsScreen.java
@@ -71,6 +71,7 @@
private Button addTag;
private HintTextBox nameTxtBox;
private HintTextBox irevTxtBox;
+ private HintTextBox annotationTxtBox;
private FlowPanel addPanel;
private NpTextBox filterTxt;
private Query query;
@@ -105,6 +106,7 @@
addTag.setEnabled(true);
nameTxtBox.setEnabled(true);
irevTxtBox.setEnabled(true);
+ annotationTxtBox.setEnabled(true);
}
@Override
@@ -120,14 +122,11 @@
addPanel = new FlowPanel();
- Grid addGrid = new Grid(2, 2);
+ Grid addGrid = new Grid(3, 2);
addGrid.setStyleName(Gerrit.RESOURCES.css().addBranch());
int texBoxLength = 50;
- nameTxtBox = new HintTextBox();
- nameTxtBox.setVisibleLength(texBoxLength);
- nameTxtBox.setHintText(AdminConstants.I.defaultTagName());
- nameTxtBox.addKeyPressHandler(
+ KeyPressHandler onKeyPress =
new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
@@ -135,25 +134,29 @@
doAddNewTag();
}
}
- });
+ };
+
+ nameTxtBox = new HintTextBox();
+ nameTxtBox.setVisibleLength(texBoxLength);
+ nameTxtBox.setHintText(AdminConstants.I.defaultTagName());
+ nameTxtBox.addKeyPressHandler(onKeyPress);
addGrid.setText(0, 0, AdminConstants.I.columnTagName() + ":");
addGrid.setWidget(0, 1, nameTxtBox);
irevTxtBox = new HintTextBox();
irevTxtBox.setVisibleLength(texBoxLength);
irevTxtBox.setHintText(AdminConstants.I.defaultRevisionSpec());
- irevTxtBox.addKeyPressHandler(
- new KeyPressHandler() {
- @Override
- public void onKeyPress(KeyPressEvent event) {
- if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
- doAddNewTag();
- }
- }
- });
+ irevTxtBox.addKeyPressHandler(onKeyPress);
addGrid.setText(1, 0, AdminConstants.I.revision() + ":");
addGrid.setWidget(1, 1, irevTxtBox);
+ annotationTxtBox = new HintTextBox();
+ annotationTxtBox.setVisibleLength(texBoxLength);
+ annotationTxtBox.setHintText(AdminConstants.I.annotation());
+ annotationTxtBox.addKeyPressHandler(onKeyPress);
+ addGrid.setText(2, 0, AdminConstants.I.columnTagAnnotation() + ":");
+ addGrid.setWidget(2, 1, annotationTxtBox);
+
addTag = new Button(AdminConstants.I.buttonAddTag());
addTag.addClickHandler(
new ClickHandler() {
@@ -237,17 +240,24 @@
return;
}
+ String annotation = annotationTxtBox.getText().trim();
+ if (annotation.isEmpty()) {
+ annotation = null;
+ }
+
addTag.setEnabled(false);
ProjectApi.createTag(
getProjectKey(),
tagName,
rev,
+ annotation,
new GerritCallback<TagInfo>() {
@Override
public void onSuccess(TagInfo tag) {
showAddedTag(tag);
nameTxtBox.setText("");
irevTxtBox.setText("");
+ annotationTxtBox.setText("");
query = new Query(match).start(start).run();
}
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/projects/ProjectApi.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/projects/ProjectApi.java
index 2efab8e..ff4c810 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/projects/ProjectApi.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/projects/ProjectApi.java
@@ -62,9 +62,14 @@
/** Create a new tag */
public static void createTag(
- Project.NameKey name, String ref, String revision, AsyncCallback<TagInfo> cb) {
+ Project.NameKey name,
+ String ref,
+ String revision,
+ String annotation,
+ AsyncCallback<TagInfo> cb) {
TagInput input = TagInput.create();
input.setRevision(revision);
+ input.setMessage(annotation);
project(name).view("tags").id(ref).ifNoneMatch().put(input, cb);
}
@@ -355,6 +360,8 @@
protected TagInput() {}
final native void setRevision(String r) /*-{ if(r)this.revision=r; }-*/;
+
+ final native void setMessage(String m) /*-{ if(m)this.message=m; }-*/;
}
private static class BranchInput extends JavaScriptObject {