Search in sources :

Example 36 with RestApi

use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.

the class AccountApi method deleteSshKeys.

/**
   * Delete SSH keys. For each key to be deleted a separate DELETE request is fired to the server.
   * The {@code onSuccess} method of the provided callback is invoked once after all requests
   * succeeded. If any request fails the callbacks' {@code onFailure} method is invoked. In a
   * failure case it can be that still some of the keys were successfully deleted.
   */
public static void deleteSshKeys(String account, Set<Integer> sequenceNumbers, AsyncCallback<VoidResult> cb) {
    CallbackGroup group = new CallbackGroup();
    for (int seq : sequenceNumbers) {
        new RestApi("/accounts/").id(account).view("sshkeys").id(seq).delete(group.add(cb));
        cb = CallbackGroup.emptyCallback();
    }
    group.done();
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup)

Example 37 with RestApi

use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.

the class AvatarImage method loadAvatar.

private void loadAvatar(AccountInfo account, int size, boolean addPopup) {
    if (!Gerrit.info().plugin().hasAvatars()) {
        setVisible(false);
        return;
    }
    // TODO Kill /accounts/*/avatar URL.
    String u = account.email();
    if (Gerrit.isSignedIn() && u.equals(Gerrit.getUserAccount().email())) {
        u = "self";
    }
    RestApi api = new RestApi("/accounts/").id(u).view("avatar");
    if (size > 0) {
        api.addParameter("s", size);
        setSize("", size + "px");
    }
    setVisible(false);
    setUrl(api.url());
    popup(account, addPopup);
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi)

Example 38 with RestApi

use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.

the class ChangeScreen method loadChangeInfo.

void loadChangeInfo(boolean fg, AsyncCallback<ChangeInfo> cb) {
    RestApi call = ChangeApi.detail(changeId.get());
    EnumSet<ListChangesOption> opts = EnumSet.of(ListChangesOption.ALL_REVISIONS, ListChangesOption.CHANGE_ACTIONS);
    if (enableSignedPush()) {
        opts.add(ListChangesOption.PUSH_CERTIFICATES);
    }
    ChangeList.addOptions(call, opts);
    if (!fg) {
        call.background();
    }
    call.get(cb);
}
Also used : ListChangesOption(com.google.gerrit.extensions.client.ListChangesOption) RestApi(com.google.gerrit.client.rpc.RestApi)

Example 39 with RestApi

use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.

the class ChangeGlue method onAction.

public static void onAction(ChangeInfo change, ActionInfo action, ActionButton button) {
    RestApi api = ChangeApi.change(change.legacyId().get()).view(action.id());
    JavaScriptObject f = get(action.id());
    if (f != null) {
        ActionContext c = ActionContext.create(api);
        c.set(action);
        c.set(change);
        c.button(button);
        ApiGlue.invoke(f, c);
    } else {
        DefaultActions.invoke(change, action, api);
    }
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject)

Example 40 with RestApi

use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.

the class EditGlue method onAction.

public static void onAction(ChangeInfo change, EditInfo edit, ActionInfo action, ActionButton button) {
    RestApi api = ChangeApi.edit(change.legacyId().get()).view(action.id());
    JavaScriptObject f = get(action.id());
    if (f != null) {
        ActionContext c = ActionContext.create(api);
        c.set(action);
        c.set(change);
        c.set(edit);
        c.button(button);
        ApiGlue.invoke(f, c);
    } else {
        DefaultActions.invoke(change, action, api);
    }
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject)

Aggregations

RestApi (com.google.gerrit.client.rpc.RestApi)42 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)8 ChangeInfo (com.google.gerrit.client.info.ChangeInfo)3 EditInfo (com.google.gerrit.client.info.ChangeInfo.EditInfo)2 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 Anchor (com.google.gwt.user.client.ui.Anchor)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)2 InlineLabel (com.google.gwt.user.client.ui.InlineLabel)2 ArrayList (java.util.ArrayList)2 GerritUiExtensionPoint (com.google.gerrit.client.GerritUiExtensionPoint)1 ActionInfo (com.google.gerrit.client.info.ActionInfo)1 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)1 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)1 NativeMap (com.google.gerrit.client.rpc.NativeMap)1 NativeString (com.google.gerrit.client.rpc.NativeString)1 ListChangesOption (com.google.gerrit.extensions.client.ListChangesOption)1 Change (com.google.gerrit.reviewdb.client.Change)1 Project (com.google.gerrit.reviewdb.client.Project)1 JsArray (com.google.gwt.core.client.JsArray)1