Search in sources :

Example 1 with RevisionInfo

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)));
    }
}
Also used : ActionButton(com.google.gerrit.client.actions.ActionButton) RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) ActionInfo(com.google.gerrit.client.info.ActionInfo) SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)

Example 2 with RevisionInfo

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);
}
Also used : RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) ActionInfo(com.google.gerrit.client.info.ActionInfo) CommitInfo(com.google.gerrit.client.info.ChangeInfo.CommitInfo)

Example 3 with RevisionInfo

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);
}
Also used : RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo)

Example 4 with RevisionInfo

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;
        }
    }
}
Also used : RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) GerritUiExtensionPoint(com.google.gerrit.client.GerritUiExtensionPoint)

Example 5 with RevisionInfo

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);
    }
}
Also used : Status(com.google.gerrit.reviewdb.client.Change.Status) RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) ActionInfo(com.google.gerrit.client.info.ActionInfo)

Aggregations

RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)14 GerritUiExtensionPoint (com.google.gerrit.client.GerritUiExtensionPoint)3 ActionInfo (com.google.gerrit.client.info.ActionInfo)3 CommitInfo (com.google.gerrit.client.info.ChangeInfo.CommitInfo)3 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)3 ChangeInfo (com.google.gerrit.client.info.ChangeInfo)2 EditInfo (com.google.gerrit.client.info.ChangeInfo.EditInfo)2 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 SafeHtmlBuilder (com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)2 ErrorDialog (com.google.gerrit.client.ErrorDialog)1 NotFoundScreen (com.google.gerrit.client.NotFoundScreen)1 ActionButton (com.google.gerrit.client.actions.ActionButton)1 ChangeList (com.google.gerrit.client.changes.ChangeList)1 CommentInfo (com.google.gerrit.client.changes.CommentInfo)1 WebLinkInfo (com.google.gerrit.client.info.WebLinkInfo)1 NativeMap (com.google.gerrit.client.rpc.NativeMap)1 RestApi (com.google.gerrit.client.rpc.RestApi)1 InlineHyperlink (com.google.gerrit.client.ui.InlineHyperlink)1 Status (com.google.gerrit.reviewdb.client.Change.Status)1