Search in sources :

Example 1 with ActionInfo

use of com.google.gerrit.client.info.ActionInfo 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 ActionInfo

use of com.google.gerrit.client.info.ActionInfo 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 ActionInfo

use of com.google.gerrit.client.info.ActionInfo in project gerrit by GerritCodeReview.

the class ChangeScreen method loadRevisionInfo.

void loadRevisionInfo() {
    RestApi call = ChangeApi.actions(changeId.get(), revision);
    call.background();
    call.get(new GerritCallback<NativeMap<ActionInfo>>() {

        @Override
        public void onSuccess(NativeMap<ActionInfo> actionMap) {
            actionMap.copyKeysIntoChildren("id");
            renderRevisionInfo(changeInfo, actionMap);
        }
    });
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) ActionInfo(com.google.gerrit.client.info.ActionInfo) NativeMap(com.google.gerrit.client.rpc.NativeMap)

Example 4 with ActionInfo

use of com.google.gerrit.client.info.ActionInfo 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)

Example 5 with ActionInfo

use of com.google.gerrit.client.info.ActionInfo in project gerrit by GerritCodeReview.

the class ProjectInfoScreen method initProjectActions.

private void initProjectActions(ConfigInfo info) {
    actionsGrid.clear(true);
    actionsGrid.removeAllRows();
    boolean showCreateChange = Gerrit.isSignedIn();
    NativeMap<ActionInfo> actions = info.actions();
    if (actions == null) {
        actions = NativeMap.create().cast();
    }
    if (actions.isEmpty() && !showCreateChange) {
        return;
    }
    actions.copyKeysIntoChildren("id");
    actionsGrid.addHeader(new SmallHeading(AdminConstants.I.headingProjectCommands()));
    FlowPanel actionsPanel = new FlowPanel();
    actionsPanel.setStyleName(Gerrit.RESOURCES.css().projectActions());
    actionsPanel.setVisible(true);
    actionsGrid.add(AdminConstants.I.headingCommands(), actionsPanel);
    for (String id : actions.keySet()) {
        actionsPanel.add(new ActionButton(getProjectKey(), actions.get(id)));
    }
    // HEAD. This would have to happen on the server side.
    if (showCreateChange) {
        actionsPanel.add(createChangeAction());
    }
    if (isOwner && configVisible) {
        actionsPanel.add(createEditConfigAction());
    }
}
Also used : SmallHeading(com.google.gerrit.client.ui.SmallHeading) ActionButton(com.google.gerrit.client.actions.ActionButton) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) ActionInfo(com.google.gerrit.client.info.ActionInfo)

Aggregations

ActionInfo (com.google.gerrit.client.info.ActionInfo)7 ActionButton (com.google.gerrit.client.actions.ActionButton)3 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)3 CommitInfo (com.google.gerrit.client.info.ChangeInfo.CommitInfo)1 NativeMap (com.google.gerrit.client.rpc.NativeMap)1 RestApi (com.google.gerrit.client.rpc.RestApi)1 SmallHeading (com.google.gerrit.client.ui.SmallHeading)1 Status (com.google.gerrit.reviewdb.client.Change.Status)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 SafeHtmlBuilder (com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)1