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