Actions: reloadRevisionActions determines submit button visibility
Change-Id: I07e64c2a536b407dc7f566051a15727183583c99
This commit is contained in:
@@ -65,7 +65,6 @@ class Actions extends Composite {
|
|||||||
private String message;
|
private String message;
|
||||||
private String branch;
|
private String branch;
|
||||||
private String key;
|
private String key;
|
||||||
private boolean canSubmit;
|
|
||||||
|
|
||||||
Actions() {
|
Actions() {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
@@ -87,7 +86,12 @@ class Actions extends Composite {
|
|||||||
changeInfo = info;
|
changeInfo = info;
|
||||||
|
|
||||||
initChangeActions(info, hasUser);
|
initChangeActions(info, hasUser);
|
||||||
initRevisionActions(info, revInfo, hasUser);
|
|
||||||
|
NativeMap<ActionInfo> actionMap = revInfo.has_actions()
|
||||||
|
? revInfo.actions()
|
||||||
|
: NativeMap.<ActionInfo> create();
|
||||||
|
actionMap.copyKeysIntoChildren("id");
|
||||||
|
reloadRevisionActions(actionMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initChangeActions(ChangeInfo info, boolean hasUser) {
|
private void initChangeActions(ChangeInfo info, boolean hasUser) {
|
||||||
@@ -107,30 +111,29 @@ class Actions extends Composite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initRevisionActions(ChangeInfo info, RevisionInfo revInfo,
|
void reloadRevisionActions(NativeMap<ActionInfo> actions) {
|
||||||
boolean hasUser) {
|
if (!Gerrit.isSignedIn()) {
|
||||||
NativeMap<ActionInfo> actions = revInfo.has_actions()
|
return;
|
||||||
? revInfo.actions()
|
}
|
||||||
: NativeMap.<ActionInfo> create();
|
boolean canSubmit = actions.containsKey("submit");
|
||||||
actions.copyKeysIntoChildren("id");
|
if (canSubmit) {
|
||||||
|
ActionInfo action = actions.get("submit");
|
||||||
|
submit.setTitle(action.title());
|
||||||
|
submit.setEnabled(action.enabled());
|
||||||
|
submit.setHTML(new SafeHtmlBuilder()
|
||||||
|
.openDiv()
|
||||||
|
.append(action.label())
|
||||||
|
.closeDiv());
|
||||||
|
submit.setEnabled(action.enabled());
|
||||||
|
}
|
||||||
|
submit.setVisible(canSubmit);
|
||||||
|
|
||||||
canSubmit = false;
|
a2b(actions, "cherrypick", cherrypick);
|
||||||
if (hasUser) {
|
a2b(actions, "rebase", rebase);
|
||||||
canSubmit = actions.containsKey("submit");
|
|
||||||
if (canSubmit) {
|
RevisionInfo revInfo = changeInfo.revision(revision);
|
||||||
ActionInfo action = actions.get("submit");
|
for (String id : filterNonCore(actions)) {
|
||||||
submit.setTitle(action.title());
|
add(new ActionButton(changeInfo, revInfo, actions.get(id)));
|
||||||
submit.setEnabled(action.enabled());
|
|
||||||
submit.setHTML(new SafeHtmlBuilder()
|
|
||||||
.openDiv()
|
|
||||||
.append(action.label())
|
|
||||||
.closeDiv());
|
|
||||||
}
|
|
||||||
a2b(actions, "cherrypick", cherrypick);
|
|
||||||
a2b(actions, "rebase", rebase);
|
|
||||||
for (String id : filterNonCore(actions)) {
|
|
||||||
add(new ActionButton(info, revInfo, actions.get(id)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,10 +149,6 @@ class Actions extends Composite {
|
|||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSubmitEnabled() {
|
|
||||||
submit.setVisible(canSubmit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@UiHandler("followUp")
|
@UiHandler("followUp")
|
||||||
void onFollowUp(@SuppressWarnings("unused") ClickEvent e) {
|
void onFollowUp(@SuppressWarnings("unused") ClickEvent e) {
|
||||||
if (followUpAction == null) {
|
if (followUpAction == null) {
|
||||||
|
|||||||
@@ -929,7 +929,6 @@ public class ChangeScreen extends Screen {
|
|||||||
|
|
||||||
private void loadSubmitType(final Change.Status status, final boolean canSubmit) {
|
private void loadSubmitType(final Change.Status status, final boolean canSubmit) {
|
||||||
if (canSubmit) {
|
if (canSubmit) {
|
||||||
actions.setSubmitEnabled();
|
|
||||||
if (status == Change.Status.NEW) {
|
if (status == Change.Status.NEW) {
|
||||||
statusText.setInnerText(Util.C.readyToSubmit());
|
statusText.setInnerText(Util.C.readyToSubmit());
|
||||||
}
|
}
|
||||||
@@ -1122,6 +1121,7 @@ public class ChangeScreen extends Screen {
|
|||||||
quickApprove.setVisible(false);
|
quickApprove.setVisible(false);
|
||||||
setVisible(strategy, false);
|
setVisible(strategy, false);
|
||||||
}
|
}
|
||||||
|
actions.reloadRevisionActions(actionMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderOwner(ChangeInfo info) {
|
private void renderOwner(ChangeInfo info) {
|
||||||
|
|||||||
Reference in New Issue
Block a user