GWT UI: Add support for creating annotated tags
Change-Id: Iaa1a7293ae4861177152ed8172e02e91d0b1a2dd
This commit is contained in:
parent
1e2ead0a12
commit
89efb88fe1
@ -31,6 +31,8 @@ public interface AdminConstants extends Constants {
|
||||
|
||||
String defaultRevisionSpec();
|
||||
|
||||
String annotation();
|
||||
|
||||
String buttonDeleteIncludedGroup();
|
||||
|
||||
String buttonAddIncludedGroup();
|
||||
@ -177,6 +179,8 @@ public interface AdminConstants extends Constants {
|
||||
|
||||
String columnTagRevision();
|
||||
|
||||
String columnTagAnnotation();
|
||||
|
||||
String initialRevision();
|
||||
|
||||
String revision();
|
||||
|
@ -3,6 +3,7 @@ defaultAccountGroupName = Group Name
|
||||
defaultBranchName = Branch Name
|
||||
defaultTagName = Tag Name
|
||||
defaultRevisionSpec = Revision (Branch or SHA-1)
|
||||
annotation = Annotation (optional)
|
||||
|
||||
buttonDeleteIncludedGroup = Delete
|
||||
buttonAddIncludedGroup = Add
|
||||
@ -84,6 +85,7 @@ columnBranchName = Branch Name
|
||||
columnBranchRevision = Revision
|
||||
columnTagName = Tag Name
|
||||
columnTagRevision = Revision
|
||||
columnTagAnnotation = Annotation
|
||||
initialRevision = Initial Revision
|
||||
revision = Revision
|
||||
buttonAddBranch = Create Branch
|
||||
|
@ -71,6 +71,7 @@ public class ProjectTagsScreen extends PaginatedProjectScreen {
|
||||
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 @@ public class ProjectTagsScreen extends PaginatedProjectScreen {
|
||||
addTag.setEnabled(true);
|
||||
nameTxtBox.setEnabled(true);
|
||||
irevTxtBox.setEnabled(true);
|
||||
annotationTxtBox.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -120,14 +122,11 @@ public class ProjectTagsScreen extends PaginatedProjectScreen {
|
||||
|
||||
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 @@ public class ProjectTagsScreen extends PaginatedProjectScreen {
|
||||
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 @@ public class ProjectTagsScreen extends PaginatedProjectScreen {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -62,9 +62,14 @@ public class ProjectApi {
|
||||
|
||||
/** 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 @@ public class ProjectApi {
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user