Search in sources :

Example 1 with GroupInfo

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

the class Dispatcher method admin.

private static void admin(String token) {
    GWT.runAsync(new AsyncSplit(token) {

        @Override
        public void onSuccess() {
            if (matchExact(ADMIN_GROUPS, token) || matchExact("/admin/groups", token)) {
                Gerrit.display(token, new GroupListScreen());
            } else if (matchPrefix(ADMIN_GROUPS, token)) {
                String rest = skip(token);
                if (rest.startsWith("?")) {
                    Gerrit.display(token, new GroupListScreen(rest.substring(1)));
                } else {
                    group();
                }
            } else if (matchPrefix("/admin/groups", token)) {
                String rest = skip(token);
                if (rest.startsWith("?")) {
                    Gerrit.display(token, new GroupListScreen(rest.substring(1)));
                }
            } else if (matchExact(ADMIN_PROJECTS, token) || matchExact("/admin/projects", token)) {
                Gerrit.display(token, new ProjectListScreen());
            } else if (matchPrefix(ADMIN_PROJECTS, token)) {
                String rest = skip(token);
                if (rest.startsWith("?")) {
                    Gerrit.display(token, new ProjectListScreen(rest.substring(1)));
                } else {
                    Gerrit.display(token, selectProject());
                }
            } else if (matchPrefix("/admin/projects", token)) {
                String rest = skip(token);
                if (rest.startsWith("?")) {
                    Gerrit.display(token, new ProjectListScreen(rest.substring(1)));
                }
            } else if (matchPrefix(ADMIN_PLUGINS, token) || matchExact("/admin/plugins", token)) {
                Gerrit.display(token, new PluginListScreen());
            } else if (matchExact(ADMIN_CREATE_PROJECT, token) || matchExact("/admin/create-project", token)) {
                Gerrit.display(token, new CreateProjectScreen());
            } else if (matchExact(ADMIN_CREATE_GROUP, token) || matchExact("/admin/create-group", token)) {
                Gerrit.display(token, new CreateGroupScreen());
            } else {
                Gerrit.display(token, new NotFoundScreen());
            }
        }

        private void group() {
            final String panel;
            final String group;
            if (matchPrefix("/admin/groups/uuid-", token)) {
                String p = skip(token);
                int c = p.indexOf(',');
                if (c < 0) {
                    group = p;
                    panel = null;
                } else {
                    group = p.substring(0, c);
                    panel = p.substring(c + 1);
                }
            } else if (matchPrefix(ADMIN_GROUPS, token)) {
                String p = skip(token);
                int c = p.indexOf(',');
                if (c < 0) {
                    group = p;
                    panel = null;
                } else {
                    group = p.substring(0, c);
                    panel = p.substring(c + 1);
                }
            } else {
                Gerrit.display(token, new NotFoundScreen());
                return;
            }
            GroupApi.getGroupDetail(group, new GerritCallback<GroupInfo>() {

                @Override
                public void onSuccess(GroupInfo group) {
                    if (panel == null || panel.isEmpty()) {
                        //
                        if (AccountGroup.isInternalGroup(group.getGroupUUID())) {
                            String newToken = toGroup(group.getGroupId(), AccountGroupScreen.MEMBERS);
                            Gerrit.display(newToken, new AccountGroupMembersScreen(group, newToken));
                        } else {
                            String newToken = toGroup(group.getGroupId(), AccountGroupScreen.INFO);
                            Gerrit.display(newToken, new AccountGroupInfoScreen(group, newToken));
                        }
                    } else if (AccountGroupScreen.INFO.equals(panel)) {
                        Gerrit.display(token, new AccountGroupInfoScreen(group, token));
                    } else if (AccountGroupScreen.MEMBERS.equals(panel)) {
                        Gerrit.display(token, new AccountGroupMembersScreen(group, token));
                    } else if (AccountGroupScreen.AUDIT_LOG.equals(panel)) {
                        Gerrit.display(token, new AccountGroupAuditLogScreen(group, token));
                    } else {
                        Gerrit.display(token, new NotFoundScreen());
                    }
                }
            });
        }

        private Screen selectProject() {
            if (matchPrefix(ADMIN_PROJECTS, token)) {
                String rest = skip(token);
                int c = rest.lastIndexOf(',');
                if (c < 0) {
                    return new ProjectInfoScreen(Project.NameKey.parse(rest));
                } else if (c == 0) {
                    return new NotFoundScreen();
                }
                int q = rest.lastIndexOf('?');
                if (q > 0 && rest.lastIndexOf(',', q) > 0) {
                    c = rest.substring(0, q - 1).lastIndexOf(',');
                }
                Project.NameKey k = Project.NameKey.parse(rest.substring(0, c));
                String panel = rest.substring(c + 1);
                if (ProjectScreen.INFO.equals(panel)) {
                    return new ProjectInfoScreen(k);
                }
                if (ProjectScreen.BRANCHES.equals(panel) || matchPrefix(ProjectScreen.BRANCHES, panel)) {
                    return new ProjectBranchesScreen(k);
                }
                if (ProjectScreen.TAGS.equals(panel) || matchPrefix(ProjectScreen.TAGS, panel)) {
                    return new ProjectTagsScreen(k);
                }
                if (ProjectScreen.ACCESS.equals(panel)) {
                    return new ProjectAccessScreen(k);
                }
                if (ProjectScreen.DASHBOARDS.equals(panel)) {
                    return new ProjectDashboardsScreen(k);
                }
            }
            return new NotFoundScreen();
        }
    });
}
Also used : ProjectTagsScreen(com.google.gerrit.client.admin.ProjectTagsScreen) ProjectAccessScreen(com.google.gerrit.client.admin.ProjectAccessScreen) AccountGroupMembersScreen(com.google.gerrit.client.admin.AccountGroupMembersScreen) AccountGroupInfoScreen(com.google.gerrit.client.admin.AccountGroupInfoScreen) ProjectInfoScreen(com.google.gerrit.client.admin.ProjectInfoScreen) GroupInfo(com.google.gerrit.client.info.GroupInfo) ProjectDashboardsScreen(com.google.gerrit.client.admin.ProjectDashboardsScreen) EditScreen(com.google.gerrit.client.editor.EditScreen) AccountGroupAuditLogScreen(com.google.gerrit.client.admin.AccountGroupAuditLogScreen) ProjectScreen(com.google.gerrit.client.admin.ProjectScreen) MyWatchedProjectsScreen(com.google.gerrit.client.account.MyWatchedProjectsScreen) MyEditPreferencesScreen(com.google.gerrit.client.account.MyEditPreferencesScreen) MyGroupsScreen(com.google.gerrit.client.account.MyGroupsScreen) MyProfileScreen(com.google.gerrit.client.account.MyProfileScreen) ProjectDashboardsScreen(com.google.gerrit.client.admin.ProjectDashboardsScreen) NewAgreementScreen(com.google.gerrit.client.account.NewAgreementScreen) CreateGroupScreen(com.google.gerrit.client.admin.CreateGroupScreen) MyContactInformationScreen(com.google.gerrit.client.account.MyContactInformationScreen) MyPasswordScreen(com.google.gerrit.client.account.MyPasswordScreen) ProjectInfoScreen(com.google.gerrit.client.admin.ProjectInfoScreen) MyOAuthTokenScreen(com.google.gerrit.client.account.MyOAuthTokenScreen) MyPreferencesScreen(com.google.gerrit.client.account.MyPreferencesScreen) MyAgreementsScreen(com.google.gerrit.client.account.MyAgreementsScreen) Screen(com.google.gerrit.client.ui.Screen) ProjectDashboardScreen(com.google.gerrit.client.changes.ProjectDashboardScreen) ExtensionSettingsScreen(com.google.gerrit.client.api.ExtensionSettingsScreen) ValidateEmailScreen(com.google.gerrit.client.account.ValidateEmailScreen) ProjectBranchesScreen(com.google.gerrit.client.admin.ProjectBranchesScreen) AccountGroupScreen(com.google.gerrit.client.admin.AccountGroupScreen) CustomDashboardScreen(com.google.gerrit.client.changes.CustomDashboardScreen) AccountDashboardScreen(com.google.gerrit.client.changes.AccountDashboardScreen) PluginListScreen(com.google.gerrit.client.admin.PluginListScreen) AccountGroupInfoScreen(com.google.gerrit.client.admin.AccountGroupInfoScreen) MyIdentitiesScreen(com.google.gerrit.client.account.MyIdentitiesScreen) QueryScreen(com.google.gerrit.client.changes.QueryScreen) ExtensionScreen(com.google.gerrit.client.api.ExtensionScreen) MyDiffPreferencesScreen(com.google.gerrit.client.account.MyDiffPreferencesScreen) RegisterScreen(com.google.gerrit.client.account.RegisterScreen) MySshKeysScreen(com.google.gerrit.client.account.MySshKeysScreen) ProjectListScreen(com.google.gerrit.client.admin.ProjectListScreen) DocScreen(com.google.gerrit.client.documentation.DocScreen) CreateProjectScreen(com.google.gerrit.client.admin.CreateProjectScreen) GroupListScreen(com.google.gerrit.client.admin.GroupListScreen) MyGpgKeysScreen(com.google.gerrit.client.account.MyGpgKeysScreen) ProjectTagsScreen(com.google.gerrit.client.admin.ProjectTagsScreen) AccountGroupMembersScreen(com.google.gerrit.client.admin.AccountGroupMembersScreen) ProjectAccessScreen(com.google.gerrit.client.admin.ProjectAccessScreen) ChangeScreen(com.google.gerrit.client.change.ChangeScreen) ProjectBranchesScreen(com.google.gerrit.client.admin.ProjectBranchesScreen) ProjectListScreen(com.google.gerrit.client.admin.ProjectListScreen) AccountGroupAuditLogScreen(com.google.gerrit.client.admin.AccountGroupAuditLogScreen) GerritCallback(com.google.gerrit.client.rpc.GerritCallback) GroupListScreen(com.google.gerrit.client.admin.GroupListScreen) CreateGroupScreen(com.google.gerrit.client.admin.CreateGroupScreen) PluginListScreen(com.google.gerrit.client.admin.PluginListScreen) CreateProjectScreen(com.google.gerrit.client.admin.CreateProjectScreen)

Example 2 with GroupInfo

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

the class AccountGroupInfoScreen method initOwner.

private void initOwner() {
    final VerticalPanel ownerPanel = new VerticalPanel();
    ownerPanel.setStyleName(Gerrit.RESOURCES.css().groupOwnerPanel());
    ownerPanel.add(new SmallHeading(AdminConstants.I.headingOwner()));
    final AccountGroupSuggestOracle accountGroupOracle = new AccountGroupSuggestOracle();
    ownerTxt = new RemoteSuggestBox(accountGroupOracle);
    ownerTxt.setStyleName(Gerrit.RESOURCES.css().groupOwnerTextBox());
    ownerTxt.setVisibleLength(60);
    ownerPanel.add(ownerTxt);
    saveOwner = new Button(AdminConstants.I.buttonChangeGroupOwner());
    saveOwner.setEnabled(false);
    saveOwner.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            final String newOwner = ownerTxt.getText().trim();
            if (newOwner.length() > 0) {
                AccountGroup.UUID ownerUuid = accountGroupOracle.getUUID(newOwner);
                String ownerId = ownerUuid != null ? ownerUuid.get() : newOwner;
                GroupApi.setGroupOwner(getGroupUUID(), ownerId, new GerritCallback<GroupInfo>() {

                    @Override
                    public void onSuccess(final GroupInfo result) {
                        updateOwnerGroup(result);
                        saveOwner.setEnabled(false);
                    }
                });
            }
        }
    });
    ownerPanel.add(saveOwner);
    add(ownerPanel);
}
Also used : AccountGroupSuggestOracle(com.google.gerrit.client.ui.AccountGroupSuggestOracle) SmallHeading(com.google.gerrit.client.ui.SmallHeading) GerritCallback(com.google.gerrit.client.rpc.GerritCallback) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(com.google.gwt.user.client.ui.Button) GroupInfo(com.google.gerrit.client.info.GroupInfo) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) RemoteSuggestBox(com.google.gerrit.client.ui.RemoteSuggestBox)

Example 3 with GroupInfo

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

the class GroupTable method displaySubset.

public void displaySubset(List<GroupInfo> list, String toHighlight, int fromIndex, int toIndex) {
    while (1 < table.getRowCount()) {
        table.removeRow(table.getRowCount() - 1);
    }
    Collections.sort(list, new Comparator<GroupInfo>() {

        @Override
        public int compare(GroupInfo a, GroupInfo b) {
            return a.name().compareTo(b.name());
        }
    });
    for (GroupInfo group : list.subList(fromIndex, toIndex)) {
        final int row = table.getRowCount();
        table.insertRow(row);
        applyDataRowStyle(row);
        populate(row, group, toHighlight);
    }
}
Also used : GroupInfo(com.google.gerrit.client.info.GroupInfo)

Example 4 with GroupInfo

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

the class GroupApi method addIncludedGroups.

/** Include groups into a group. */
public static void addIncludedGroups(AccountGroup.UUID group, Set<String> includedGroups, final AsyncCallback<JsArray<GroupInfo>> cb) {
    if (includedGroups.size() == 1) {
        addIncludedGroup(group, includedGroups.iterator().next(), new AsyncCallback<GroupInfo>() {

            @Override
            public void onSuccess(GroupInfo result) {
                cb.onSuccess(Natives.arrayOf(result));
            }

            @Override
            public void onFailure(Throwable caught) {
                cb.onFailure(caught);
            }
        });
    } else {
        IncludedGroupInput input = IncludedGroupInput.create();
        for (String includedGroup : includedGroups) {
            input.addGroup(includedGroup);
        }
        groups(group).post(input, cb);
    }
}
Also used : GroupInfo(com.google.gerrit.client.info.GroupInfo) NativeString(com.google.gerrit.client.rpc.NativeString)

Aggregations

GroupInfo (com.google.gerrit.client.info.GroupInfo)4 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)2 MyAgreementsScreen (com.google.gerrit.client.account.MyAgreementsScreen)1 MyContactInformationScreen (com.google.gerrit.client.account.MyContactInformationScreen)1 MyDiffPreferencesScreen (com.google.gerrit.client.account.MyDiffPreferencesScreen)1 MyEditPreferencesScreen (com.google.gerrit.client.account.MyEditPreferencesScreen)1 MyGpgKeysScreen (com.google.gerrit.client.account.MyGpgKeysScreen)1 MyGroupsScreen (com.google.gerrit.client.account.MyGroupsScreen)1 MyIdentitiesScreen (com.google.gerrit.client.account.MyIdentitiesScreen)1 MyOAuthTokenScreen (com.google.gerrit.client.account.MyOAuthTokenScreen)1 MyPasswordScreen (com.google.gerrit.client.account.MyPasswordScreen)1 MyPreferencesScreen (com.google.gerrit.client.account.MyPreferencesScreen)1 MyProfileScreen (com.google.gerrit.client.account.MyProfileScreen)1 MySshKeysScreen (com.google.gerrit.client.account.MySshKeysScreen)1 MyWatchedProjectsScreen (com.google.gerrit.client.account.MyWatchedProjectsScreen)1 NewAgreementScreen (com.google.gerrit.client.account.NewAgreementScreen)1 RegisterScreen (com.google.gerrit.client.account.RegisterScreen)1 ValidateEmailScreen (com.google.gerrit.client.account.ValidateEmailScreen)1 AccountGroupAuditLogScreen (com.google.gerrit.client.admin.AccountGroupAuditLogScreen)1 AccountGroupInfoScreen (com.google.gerrit.client.admin.AccountGroupInfoScreen)1