use of com.google.gerrit.client.info.ChangeInfo.RevisionInfo in project gerrit by GerritCodeReview.
the class Actions method reloadRevisionActions.
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);
a2b(actions, "cherrypick", cherrypick);
a2b(actions, "rebase", rebase);
// The rebase button on change screen is always enabled.
// It is the "Rebase" button in the RebaseDialog that might be disabled.
rebaseParentNotCurrent = rebase.isEnabled();
if (rebase.isVisible()) {
rebase.setEnabled(true);
}
RevisionInfo revInfo = changeInfo.revision(revision);
for (String id : filterNonCore(actions)) {
add(new ActionButton(changeInfo, revInfo, actions.get(id)));
}
}
use of com.google.gerrit.client.info.ChangeInfo.RevisionInfo in project gerrit by GerritCodeReview.
the class Actions method display.
void display(ChangeInfo info, String revision) {
this.revision = revision;
boolean hasUser = Gerrit.isSignedIn();
RevisionInfo revInfo = info.revision(revision);
CommitInfo commit = revInfo.commit();
changeId = info.legacyId();
project = info.project();
topic = info.topic();
subject = commit.subject();
message = commit.message();
branch = info.branch();
key = info.changeId();
changeInfo = info;
initChangeActions(info, hasUser);
NativeMap<ActionInfo> actionMap = revInfo.hasActions() ? revInfo.actions() : NativeMap.<ActionInfo>create();
actionMap.copyKeysIntoChildren("id");
reloadRevisionActions(actionMap);
}
use of com.google.gerrit.client.info.ChangeInfo.RevisionInfo in project gerrit by GerritCodeReview.
the class ChangeScreen method initCurrentRevision.
private RevisionInfo initCurrentRevision(ChangeInfo info) {
info.revisions().copyKeysIntoChildren("name");
if (edit != null) {
edit.setName(edit.commit().commit());
info.setEdit(edit);
if (edit.hasFiles()) {
edit.files().copyKeysIntoChildren("path");
}
info.revisions().put(edit.name(), RevisionInfo.fromEdit(edit));
JsArray<RevisionInfo> list = info.revisions().values();
// use the edit regardless of which patch set it is based on
if (revision == null) {
RevisionInfo.sortRevisionInfoByNumber(list);
RevisionInfo rev = list.get(list.length() - 1);
if (rev.isEdit()) {
info.setCurrentRevision(rev.name());
}
} else if (revision.equals("edit") || revision.equals("0")) {
for (int i = 0; i < list.length(); i++) {
RevisionInfo r = list.get(i);
if (r.isEdit()) {
info.setCurrentRevision(r.name());
break;
}
}
}
}
return resolveRevisionToDisplay(info);
}
use of com.google.gerrit.client.info.ChangeInfo.RevisionInfo in project gerrit by GerritCodeReview.
the class ChangeScreen method gotoSibling.
private void gotoSibling(int offset) {
if (offset > 0 && changeInfo.currentRevision() != null && changeInfo.currentRevision().equals(revision)) {
return;
}
if (offset < 0 && changeInfo.revision(revision)._number() == 1) {
return;
}
JsArray<RevisionInfo> revisions = changeInfo.revisions().values();
RevisionInfo.sortRevisionInfoByNumber(revisions);
for (int i = 0; i < revisions.length(); i++) {
if (revision.equals(revisions.get(i).name())) {
if (0 <= i + offset && i + offset < revisions.length()) {
Gerrit.display(PageLinks.toChange(new PatchSet.Id(changeInfo.legacyId(), revisions.get(i + offset)._number())));
return;
}
return;
}
}
}
use of com.google.gerrit.client.info.ChangeInfo.RevisionInfo in project gerrit by GerritCodeReview.
the class ChangeScreen method renderChangeInfo.
private void renderChangeInfo(ChangeInfo info) {
RevisionInfo revisionInfo = info.revision(revision);
changeInfo = info;
lastDisplayedUpdate = info.updated();
labels.set(info);
renderOwner(info);
renderUploader(info, revisionInfo);
renderActionTextDate(info);
renderDiffBaseListBox(info);
initReplyButton(info, revision);
initIncludedInAction(info);
initDownloadAction(info, revision);
initProjectLinks(info);
initBranchLink(info);
initEditMode(info, revision);
actions.display(info, revision);
star.setValue(info.starred());
permalink.setHref(ChangeLink.permalink(changeId));
permalink.setText(String.valueOf(info.legacyId()));
topic.set(info, revision);
commit.set(commentLinkProcessor, info, revision);
related.set(info, revision);
reviewers.set(info);
assignee.set(info);
if (Gerrit.isNoteDbEnabled()) {
hashtags.set(info, revision);
} else {
setVisible(hashtagTableRow, false);
}
StringBuilder sb = new StringBuilder();
sb.append(Util.M.changeScreenTitleId(info.idAbbreviated()));
if (info.subject() != null) {
sb.append(": ");
sb.append(info.subject());
}
setWindowTitle(sb.toString());
// render it faster.
if (!info.status().isOpen() || !revision.equals(info.currentRevision()) || revisionInfo.isEdit()) {
setVisible(strategy, false);
}
// Properly render revision actions initially while waiting for
// the callback to populate them correctly.
NativeMap<ActionInfo> emptyMap = NativeMap.<ActionInfo>create();
initRevisionsAction(info, revision, emptyMap);
quickApprove.setVisible(false);
actions.reloadRevisionActions(emptyMap);
boolean current = revision.equals(info.currentRevision()) && !revisionInfo.isEdit();
if (revisionInfo.isEdit()) {
statusText.setInnerText(Util.C.changeEdit());
} else if (!current) {
statusText.setInnerText(Util.C.notCurrent());
labels.setVisible(false);
} else {
Status s = info.revision(revision).draft() ? Status.DRAFT : info.status();
statusText.setInnerText(Util.toLongString(s));
}
if (info.isPrivate()) {
privateText.setInnerText(Util.C.isPrivate());
}
if (info.isWorkInProgress()) {
wipText.setInnerText(Util.C.isWorkInProgress());
}
if (Gerrit.isSignedIn()) {
replyAction = new ReplyAction(info, revision, hasDraftComments, style, commentLinkProcessor, reply, quickApprove);
}
history.set(commentLinkProcessor, replyAction, changeId, info);
if (current && info.status().isOpen()) {
quickApprove.set(info, revision, replyAction);
renderSubmitType(info.status(), isSubmittable(info), info.submitType());
} else {
quickApprove.setVisible(false);
}
}
Aggregations