GWT UI: Add support for creating annotated tags

Change-Id: Iaa1a7293ae4861177152ed8172e02e91d0b1a2dd
This commit is contained in:
David Pursehouse 2017-09-05 09:55:28 +09:00
parent 1e2ead0a12
commit 89efb88fe1
4 changed files with 39 additions and 16 deletions

View File

@ -31,6 +31,8 @@ public interface AdminConstants extends Constants {
String defaultRevisionSpec(); String defaultRevisionSpec();
String annotation();
String buttonDeleteIncludedGroup(); String buttonDeleteIncludedGroup();
String buttonAddIncludedGroup(); String buttonAddIncludedGroup();
@ -177,6 +179,8 @@ public interface AdminConstants extends Constants {
String columnTagRevision(); String columnTagRevision();
String columnTagAnnotation();
String initialRevision(); String initialRevision();
String revision(); String revision();

View File

@ -3,6 +3,7 @@ defaultAccountGroupName = Group Name
defaultBranchName = Branch Name defaultBranchName = Branch Name
defaultTagName = Tag Name defaultTagName = Tag Name
defaultRevisionSpec = Revision (Branch or SHA-1) defaultRevisionSpec = Revision (Branch or SHA-1)
annotation = Annotation (optional)
buttonDeleteIncludedGroup = Delete buttonDeleteIncludedGroup = Delete
buttonAddIncludedGroup = Add buttonAddIncludedGroup = Add
@ -84,6 +85,7 @@ columnBranchName = Branch Name
columnBranchRevision = Revision columnBranchRevision = Revision
columnTagName = Tag Name columnTagName = Tag Name
columnTagRevision = Revision columnTagRevision = Revision
columnTagAnnotation = Annotation
initialRevision = Initial Revision initialRevision = Initial Revision
revision = Revision revision = Revision
buttonAddBranch = Create Branch buttonAddBranch = Create Branch

View File

@ -71,6 +71,7 @@ public class ProjectTagsScreen extends PaginatedProjectScreen {
private Button addTag; private Button addTag;
private HintTextBox nameTxtBox; private HintTextBox nameTxtBox;
private HintTextBox irevTxtBox; private HintTextBox irevTxtBox;
private HintTextBox annotationTxtBox;
private FlowPanel addPanel; private FlowPanel addPanel;
private NpTextBox filterTxt; private NpTextBox filterTxt;
private Query query; private Query query;
@ -105,6 +106,7 @@ public class ProjectTagsScreen extends PaginatedProjectScreen {
addTag.setEnabled(true); addTag.setEnabled(true);
nameTxtBox.setEnabled(true); nameTxtBox.setEnabled(true);
irevTxtBox.setEnabled(true); irevTxtBox.setEnabled(true);
annotationTxtBox.setEnabled(true);
} }
@Override @Override
@ -120,14 +122,11 @@ public class ProjectTagsScreen extends PaginatedProjectScreen {
addPanel = new FlowPanel(); addPanel = new FlowPanel();
Grid addGrid = new Grid(2, 2); Grid addGrid = new Grid(3, 2);
addGrid.setStyleName(Gerrit.RESOURCES.css().addBranch()); addGrid.setStyleName(Gerrit.RESOURCES.css().addBranch());
int texBoxLength = 50; int texBoxLength = 50;
nameTxtBox = new HintTextBox(); KeyPressHandler onKeyPress =
nameTxtBox.setVisibleLength(texBoxLength);
nameTxtBox.setHintText(AdminConstants.I.defaultTagName());
nameTxtBox.addKeyPressHandler(
new KeyPressHandler() { new KeyPressHandler() {
@Override @Override
public void onKeyPress(KeyPressEvent event) { public void onKeyPress(KeyPressEvent event) {
@ -135,25 +134,29 @@ public class ProjectTagsScreen extends PaginatedProjectScreen {
doAddNewTag(); doAddNewTag();
} }
} }
}); };
nameTxtBox = new HintTextBox();
nameTxtBox.setVisibleLength(texBoxLength);
nameTxtBox.setHintText(AdminConstants.I.defaultTagName());
nameTxtBox.addKeyPressHandler(onKeyPress);
addGrid.setText(0, 0, AdminConstants.I.columnTagName() + ":"); addGrid.setText(0, 0, AdminConstants.I.columnTagName() + ":");
addGrid.setWidget(0, 1, nameTxtBox); addGrid.setWidget(0, 1, nameTxtBox);
irevTxtBox = new HintTextBox(); irevTxtBox = new HintTextBox();
irevTxtBox.setVisibleLength(texBoxLength); irevTxtBox.setVisibleLength(texBoxLength);
irevTxtBox.setHintText(AdminConstants.I.defaultRevisionSpec()); irevTxtBox.setHintText(AdminConstants.I.defaultRevisionSpec());
irevTxtBox.addKeyPressHandler( irevTxtBox.addKeyPressHandler(onKeyPress);
new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
doAddNewTag();
}
}
});
addGrid.setText(1, 0, AdminConstants.I.revision() + ":"); addGrid.setText(1, 0, AdminConstants.I.revision() + ":");
addGrid.setWidget(1, 1, irevTxtBox); 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 = new Button(AdminConstants.I.buttonAddTag());
addTag.addClickHandler( addTag.addClickHandler(
new ClickHandler() { new ClickHandler() {
@ -237,17 +240,24 @@ public class ProjectTagsScreen extends PaginatedProjectScreen {
return; return;
} }
String annotation = annotationTxtBox.getText().trim();
if (annotation.isEmpty()) {
annotation = null;
}
addTag.setEnabled(false); addTag.setEnabled(false);
ProjectApi.createTag( ProjectApi.createTag(
getProjectKey(), getProjectKey(),
tagName, tagName,
rev, rev,
annotation,
new GerritCallback<TagInfo>() { new GerritCallback<TagInfo>() {
@Override @Override
public void onSuccess(TagInfo tag) { public void onSuccess(TagInfo tag) {
showAddedTag(tag); showAddedTag(tag);
nameTxtBox.setText(""); nameTxtBox.setText("");
irevTxtBox.setText(""); irevTxtBox.setText("");
annotationTxtBox.setText("");
query = new Query(match).start(start).run(); query = new Query(match).start(start).run();
} }

View File

@ -62,9 +62,14 @@ public class ProjectApi {
/** Create a new tag */ /** Create a new tag */
public static void createTag( 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(); TagInput input = TagInput.create();
input.setRevision(revision); input.setRevision(revision);
input.setMessage(annotation);
project(name).view("tags").id(ref).ifNoneMatch().put(input, cb); project(name).view("tags").id(ref).ifNoneMatch().put(input, cb);
} }
@ -355,6 +360,8 @@ public class ProjectApi {
protected TagInput() {} protected TagInput() {}
final native void setRevision(String r) /*-{ if(r)this.revision=r; }-*/; 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 { private static class BranchInput extends JavaScriptObject {