Search in sources :

Example 1 with DashboardInfo

use of com.google.gerrit.client.dashboards.DashboardInfo in project gerrit by GerritCodeReview.

the class Dispatcher method projects.

private static void projects(final String token) {
    String rest = skip(token);
    int c = rest.indexOf(DASHBOARDS);
    if (0 <= c) {
        final String project = URL.decodePathSegment(rest.substring(0, c));
        rest = rest.substring(c);
        if (matchPrefix(DASHBOARDS, rest)) {
            final String dashboardId = skip(rest);
            GerritCallback<DashboardInfo> cb = new GerritCallback<DashboardInfo>() {

                @Override
                public void onSuccess(DashboardInfo result) {
                    if (matchPrefix("/dashboard/", result.url())) {
                        String params = skip(result.url()).substring(1);
                        ProjectDashboardScreen dash = new ProjectDashboardScreen(new Project.NameKey(project), params);
                        Gerrit.display(token, dash);
                    }
                }

                @Override
                public void onFailure(Throwable caught) {
                    if ("default".equals(dashboardId) && RestApi.isNotFound(caught)) {
                        Gerrit.display(toChangeQuery(PageLinks.projectQuery(new Project.NameKey(project))));
                    } else {
                        super.onFailure(caught);
                    }
                }
            };
            if ("default".equals(dashboardId)) {
                DashboardList.getDefault(new Project.NameKey(project), cb);
                return;
            }
            c = dashboardId.indexOf(":");
            if (0 <= c) {
                final String ref = URL.decodeQueryString(dashboardId.substring(0, c));
                final String path = URL.decodeQueryString(dashboardId.substring(c + 1));
                DashboardList.get(new Project.NameKey(project), ref + ":" + path, cb);
                return;
            }
        }
    }
    Gerrit.display(token, new NotFoundScreen());
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) Project(com.google.gerrit.reviewdb.client.Project) ProjectDashboardScreen(com.google.gerrit.client.changes.ProjectDashboardScreen) DashboardInfo(com.google.gerrit.client.dashboards.DashboardInfo)

Aggregations

ProjectDashboardScreen (com.google.gerrit.client.changes.ProjectDashboardScreen)1 DashboardInfo (com.google.gerrit.client.dashboards.DashboardInfo)1 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)1 Project (com.google.gerrit.reviewdb.client.Project)1