Search in sources :

Example 1 with GroupInfo

use of com.google.gerrit.common.data.GroupInfo in project gerrit by GerritCodeReview.

the class PermissionRuleEditor method setValue.

@Override
public void setValue(PermissionRule value) {
    if (clickHandler != null) {
        clickHandler.removeHandler();
        clickHandler = null;
    }
    GroupReference ref = value.getGroup();
    GroupInfo info = groupInfo != null && ref.getUUID() != null ? groupInfo.get(ref.getUUID()) : null;
    boolean link;
    if (ref.getUUID() != null && AccountGroup.isInternalGroup(ref.getUUID())) {
        final String token = Dispatcher.toGroup(ref.getUUID());
        groupNameLink.setText(ref.getName());
        groupNameLink.setHref("#" + token);
        groupNameLink.setTitle(info != null ? info.getDescription() : null);
        groupNameLink.setTarget(null);
        clickHandler = groupNameLink.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                event.preventDefault();
                event.stopPropagation();
                Gerrit.display(token);
            }
        });
        link = true;
    } else if (info != null && info.getUrl() != null) {
        groupNameLink.setText(ref.getName());
        groupNameLink.setHref(info.getUrl());
        groupNameLink.setTitle(info.getDescription());
        groupNameLink.setTarget("_blank");
        link = true;
    } else {
        groupNameSpan.setInnerText(ref.getName());
        groupNameSpan.setTitle(ref.getUUID() != null ? ref.getUUID().get() : "");
        link = false;
    }
    deletedGroupName.setInnerText(ref.getName());
    groupNameLink.setVisible(link);
    UIObject.setVisible(groupNameSpan, !link);
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) GroupInfo(com.google.gerrit.common.data.GroupInfo) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) GroupReference(com.google.gerrit.common.data.GroupReference)

Example 2 with GroupInfo

use of com.google.gerrit.common.data.GroupInfo in project gerrit by GerritCodeReview.

the class ProjectAccessFactory method buildGroupInfo.

private Map<AccountGroup.UUID, GroupInfo> buildGroupInfo(List<AccessSection> local) {
    Map<AccountGroup.UUID, GroupInfo> infos = new HashMap<>();
    for (AccessSection section : local) {
        for (Permission permission : section.getPermissions()) {
            for (PermissionRule rule : permission.getRules()) {
                if (rule.getGroup() != null) {
                    AccountGroup.UUID uuid = rule.getGroup().getUUID();
                    if (uuid != null && !infos.containsKey(uuid)) {
                        GroupDescription.Basic group = groupBackend.get(uuid);
                        infos.put(uuid, group != null ? new GroupInfo(group) : null);
                    }
                }
            }
        }
    }
    return Maps.filterEntries(infos, in -> in.getValue() != null);
}
Also used : GroupDescription(com.google.gerrit.common.data.GroupDescription) AccountGroup(com.google.gerrit.reviewdb.client.AccountGroup) HashMap(java.util.HashMap) GroupInfo(com.google.gerrit.common.data.GroupInfo) PermissionRule(com.google.gerrit.common.data.PermissionRule) Permission(com.google.gerrit.common.data.Permission) ProjectPermission(com.google.gerrit.server.permissions.ProjectPermission) AccessSection(com.google.gerrit.common.data.AccessSection)

Aggregations

GroupInfo (com.google.gerrit.common.data.GroupInfo)2 AccessSection (com.google.gerrit.common.data.AccessSection)1 GroupDescription (com.google.gerrit.common.data.GroupDescription)1 GroupReference (com.google.gerrit.common.data.GroupReference)1 Permission (com.google.gerrit.common.data.Permission)1 PermissionRule (com.google.gerrit.common.data.PermissionRule)1 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)1 ProjectPermission (com.google.gerrit.server.permissions.ProjectPermission)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 HashMap (java.util.HashMap)1