Move 'Publish' and 'Delete Change/Revision' buttons into header
If a change/revision is a draft the natural next step is to publish (or delete) it, hence these buttons should be displayed in a more prominent place. Change-Id: I4aa756152548ef78cd9dc9a67ecc397a3af12ff7 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -27,7 +27,6 @@ import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
@@ -45,9 +44,6 @@ class Actions extends Composite {
|
||||
private static final Binder uiBinder = GWT.create(Binder.class);
|
||||
|
||||
@UiField Button cherrypick;
|
||||
@UiField Button deleteChange;
|
||||
@UiField Button deleteRevision;
|
||||
@UiField Button publish;
|
||||
@UiField Button rebase;
|
||||
@UiField Button revert;
|
||||
@UiField Button submit;
|
||||
@@ -101,7 +97,6 @@ class Actions extends Composite {
|
||||
actions.copyKeysIntoChildren("id");
|
||||
|
||||
if (hasUser) {
|
||||
a2b(actions, "/", deleteChange);
|
||||
a2b(actions, "abandon", abandon);
|
||||
a2b(actions, "restore", restore);
|
||||
a2b(actions, "revert", revert);
|
||||
@@ -130,9 +125,7 @@ class Actions extends Composite {
|
||||
.append(action.label())
|
||||
.closeDiv());
|
||||
}
|
||||
a2b(actions, "/", deleteRevision);
|
||||
a2b(actions, "cherrypick", cherrypick);
|
||||
a2b(actions, "publish", publish);
|
||||
a2b(actions, "rebase", rebase);
|
||||
for (String id : filterNonCore(actions)) {
|
||||
add(new ActionButton(info, revInfo, actions.get(id)));
|
||||
@@ -177,25 +170,6 @@ class Actions extends Composite {
|
||||
abandonAction.show();
|
||||
}
|
||||
|
||||
@UiHandler("publish")
|
||||
void onPublish(@SuppressWarnings("unused") ClickEvent e) {
|
||||
DraftActions.publish(changeId, revision);
|
||||
}
|
||||
|
||||
@UiHandler("deleteRevision")
|
||||
void onDeleteRevision(@SuppressWarnings("unused") ClickEvent e) {
|
||||
if (Window.confirm(Resources.C.deleteDraftRevision())) {
|
||||
DraftActions.delete(changeId, revision);
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("deleteChange")
|
||||
void onDeleteChange(@SuppressWarnings("unused") ClickEvent e) {
|
||||
if (Window.confirm(Resources.C.deleteDraftChange())) {
|
||||
DraftActions.delete(changeId);
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("restore")
|
||||
void onRestore(@SuppressWarnings("unused") ClickEvent e) {
|
||||
if (restoreAction == null) {
|
||||
|
||||
@@ -69,16 +69,6 @@ limitations under the License.
|
||||
<g:Button ui:field='revert' styleName='' visible='false'>
|
||||
<div><ui:msg>Revert</ui:msg></div>
|
||||
</g:Button>
|
||||
<g:Button ui:field='deleteChange' styleName='' visible='false'>
|
||||
<div><ui:msg>Delete Change</ui:msg></div>
|
||||
</g:Button>
|
||||
<g:Button ui:field='deleteRevision' styleName='' visible='false'>
|
||||
<div><ui:msg>Delete Revision</ui:msg></div>
|
||||
</g:Button>
|
||||
<g:Button ui:field='publish' styleName='' visible='false'>
|
||||
<div><ui:msg>Publish</ui:msg></div>
|
||||
</g:Button>
|
||||
|
||||
<g:Button ui:field='abandon' styleName='' visible='false'>
|
||||
<div><ui:msg>Abandon</ui:msg></div>
|
||||
</g:Button>
|
||||
|
||||
@@ -183,6 +183,9 @@ public class ChangeScreen2 extends Screen {
|
||||
@UiField Button publishEdit;
|
||||
@UiField Button rebaseEdit;
|
||||
@UiField Button deleteEdit;
|
||||
@UiField Button publish;
|
||||
@UiField Button deleteChange;
|
||||
@UiField Button deleteRevision;
|
||||
@UiField Button openAll;
|
||||
@UiField Button editMode;
|
||||
@UiField Button reviewMode;
|
||||
@@ -385,6 +388,19 @@ public class ChangeScreen2 extends Screen {
|
||||
}
|
||||
}
|
||||
|
||||
private void initChangeAction(ChangeInfo info) {
|
||||
if (info.status() == Status.DRAFT) {
|
||||
NativeMap<ActionInfo> actions = info.has_actions()
|
||||
? info.actions()
|
||||
: NativeMap.<ActionInfo> create();
|
||||
actions.copyKeysIntoChildren("id");
|
||||
if (actions.containsKey("/")) {
|
||||
deleteChange.setVisible(true);
|
||||
deleteChange.setTitle(actions.get("/").title());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initRevisionsAction(ChangeInfo info, String revision) {
|
||||
int currentPatchSet;
|
||||
if (info.current_revision() != null
|
||||
@@ -410,6 +426,23 @@ public class ChangeScreen2 extends Screen {
|
||||
patchSetsAction = new PatchSetsAction(
|
||||
info.legacy_id(), revision,
|
||||
style, headerLine, patchSets);
|
||||
|
||||
RevisionInfo revInfo = info.revision(revision);
|
||||
if (revInfo.draft()) {
|
||||
NativeMap<ActionInfo> actions = revInfo.has_actions()
|
||||
? revInfo.actions()
|
||||
: NativeMap.<ActionInfo> create();
|
||||
actions.copyKeysIntoChildren("id");
|
||||
|
||||
if (actions.containsKey("publish")) {
|
||||
publish.setVisible(true);
|
||||
publish.setTitle(actions.get("publish").title());
|
||||
}
|
||||
if (actions.containsKey("/")) {
|
||||
deleteRevision.setVisible(true);
|
||||
deleteRevision.setTitle(actions.get("/").title());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initDownloadAction(ChangeInfo info, String revision) {
|
||||
@@ -533,6 +566,25 @@ public class ChangeScreen2 extends Screen {
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("publish")
|
||||
void onPublish(@SuppressWarnings("unused") ClickEvent e) {
|
||||
DraftActions.publish(changeId, revision);
|
||||
}
|
||||
|
||||
@UiHandler("deleteRevision")
|
||||
void onDeleteRevision(@SuppressWarnings("unused") ClickEvent e) {
|
||||
if (Window.confirm(Resources.C.deleteDraftRevision())) {
|
||||
DraftActions.delete(changeId, revision);
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("deleteChange")
|
||||
void onDeleteChange(@SuppressWarnings("unused") ClickEvent e) {
|
||||
if (Window.confirm(Resources.C.deleteDraftChange())) {
|
||||
DraftActions.delete(changeId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerKeys() {
|
||||
super.registerKeys();
|
||||
@@ -1023,6 +1075,7 @@ public class ChangeScreen2 extends Screen {
|
||||
renderDiffBaseListBox(info);
|
||||
initReplyButton(info, revision);
|
||||
initIncludedInAction(info);
|
||||
initChangeAction(info);
|
||||
initRevisionsAction(info, revision);
|
||||
initDownloadAction(info, revision);
|
||||
initProjectLinks(info);
|
||||
|
||||
@@ -375,6 +375,15 @@ limitations under the License.
|
||||
<g:Button ui:field='deleteEdit' styleName='' visible='false'>
|
||||
<div><ui:msg>Delete Edit</ui:msg></div>
|
||||
</g:Button>
|
||||
<g:Button ui:field='publish' styleName='' visible='false'>
|
||||
<div><ui:msg>Publish</ui:msg></div>
|
||||
</g:Button>
|
||||
<g:Button ui:field='deleteChange' styleName='' visible='false'>
|
||||
<div><ui:msg>Delete Change</ui:msg></div>
|
||||
</g:Button>
|
||||
<g:Button ui:field='deleteRevision' styleName='' visible='false'>
|
||||
<div><ui:msg>Delete Revision</ui:msg></div>
|
||||
</g:Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user