Add Plugin web UI

Put a link under Admin to show the list of installed plugins

Signed-off-by: Brad Larson <bklarson@gmail.com>
Change-Id: I35d41fd49ed88dc17bdf5bed55e18299cb98f07f
This commit is contained in:
Brad Larson
2012-05-16 10:49:15 -05:00
committed by gerrit code review
parent 573bf7f5cf
commit cbd00cd34f
13 changed files with 209 additions and 0 deletions

View File

@@ -40,6 +40,7 @@ public class PageLinks {
public static final String ADMIN_GROUPS = "/admin/groups/";
public static final String ADMIN_PROJECTS = "/admin/projects/";
public static final String ADMIN_CREATE_PROJECT = "/admin/create-project/";
public static final String ADMIN_PLUGINS = "/admin/plugins/";
public static String toChange(final ChangeInfo c) {
return toChange(c.getId());

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.client;
import static com.google.gerrit.common.PageLinks.ADMIN_CREATE_PROJECT;
import static com.google.gerrit.common.PageLinks.ADMIN_GROUPS;
import static com.google.gerrit.common.PageLinks.ADMIN_PROJECTS;
import static com.google.gerrit.common.PageLinks.ADMIN_PLUGINS;
import static com.google.gerrit.common.PageLinks.MINE;
import static com.google.gerrit.common.PageLinks.REGISTER;
import static com.google.gerrit.common.PageLinks.SETTINGS;
@@ -48,6 +49,7 @@ import com.google.gerrit.client.admin.AccountGroupMembersScreen;
import com.google.gerrit.client.admin.AccountGroupScreen;
import com.google.gerrit.client.admin.CreateProjectScreen;
import com.google.gerrit.client.admin.GroupListScreen;
import com.google.gerrit.client.admin.PluginListScreen;
import com.google.gerrit.client.admin.ProjectAccessScreen;
import com.google.gerrit.client.admin.ProjectBranchesScreen;
import com.google.gerrit.client.admin.ProjectInfoScreen;
@@ -621,6 +623,10 @@ public class Dispatcher {
} else if (matchPrefix("/admin/projects/", token)) {
Gerrit.display(token, selectProject());
} 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());

View File

@@ -577,6 +577,7 @@ public class Gerrit implements EntryPoint {
m = new LinkMenuBar();
addLink(m, C.menuGroups(), PageLinks.ADMIN_GROUPS);
addLink(m, C.menuProjects(), PageLinks.ADMIN_PROJECTS);
addLink(m, C.menuPlugins(), PageLinks.ADMIN_PLUGINS);
menuLeft.add(m, C.menuAdmin());
}

View File

@@ -72,6 +72,7 @@ public interface GerritConstants extends Constants {
String menuPeople();
String menuGroups();
String menuProjects();
String menuPlugins();
String menuDocumentation();
String menuDocumentationIndex();

View File

@@ -55,6 +55,7 @@ menuAdmin = Admin
menuPeople = People
menuGroups = Groups
menuProjects = Projects
menuPlugins = Plugins
menuDocumentation = Documentation
menuDocumentationIndex = Index

View File

@@ -169,6 +169,7 @@ public interface GerritCss extends CssResource {
String patchSetUserIdentity();
String patchSizeCell();
String permalink();
String pluginsTable();
String posscore();
String projectAdminApprovalCategoryRangeLine();
String projectAdminApprovalCategoryValue();

View File

@@ -104,6 +104,12 @@ public interface AdminConstants extends Constants {
String projectAdminTabBranches();
String projectAdminTabAccess();
String plugins();
String pluginTabInstalled();
String columnPluginName();
String columnPluginVersion();
String noGroupSelected();
String errorNoMatchingGroups();
String errorNoGitRepository();

View File

@@ -84,6 +84,11 @@ projectAdminTabGeneral = General
projectAdminTabBranches = Branches
projectAdminTabAccess = Access
plugins = Plugins
pluginTabInstalled = Installed
columnPluginName = Plugin Name
columnPluginVersion = Version
noGroupSelected = (No group selected)
errorNoMatchingGroups = No Matching Groups
errorNoGitRepository = No Git Repository

View File

@@ -0,0 +1,92 @@
// Copyright (C) 2012 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.admin;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.plugins.PluginInfo;
import com.google.gerrit.client.plugins.PluginMap;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.FancyFlexTable;
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Panel;
public class PluginListScreen extends PluginScreen {
private Panel pluginPanel;
private PluginTable pluginTable;
@Override
protected void onInitUI() {
super.onInitUI();
initPluginList();
}
@Override
protected void onLoad() {
super.onLoad();
PluginMap.all(new ScreenLoadCallback<PluginMap>(this) {
@Override
protected void preDisplay(final PluginMap result) {
pluginTable.display(result);
}
});
}
private void initPluginList() {
pluginTable = new PluginTable();
pluginTable.addStyleName(Gerrit.RESOURCES.css().pluginsTable());
pluginPanel = new FlowPanel();
pluginPanel.setWidth("500px");
pluginPanel.add(pluginTable);
add(pluginPanel);
}
private class PluginTable extends FancyFlexTable<PluginInfo> {
PluginTable() {
table.setText(0, 1, Util.C.columnPluginName());
table.setText(0, 2, Util.C.columnPluginVersion());
final FlexCellFormatter fmt = table.getFlexCellFormatter();
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().dataHeader());
fmt.addStyleName(0, 2, Gerrit.RESOURCES.css().dataHeader());
}
void display(final PluginMap plugins) {
while (1 < table.getRowCount()) {
table.removeRow(table.getRowCount() - 1);
}
for (final PluginInfo p : plugins.values().asList()) {
final int row = table.getRowCount();
table.insertRow(row);
applyDataRowStyle(row);
populate(row, p);
}
}
void populate(final int row, final PluginInfo plugin) {
table.setText(row, 1, plugin.name());
table.setText(row, 2, plugin.version());
final FlexCellFormatter fmt = table.getFlexCellFormatter();
fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().dataCell());
fmt.addStyleName(row, 2, Gerrit.RESOURCES.css().dataCell());
setRowItem(row, plugin);
}
}
}

View File

@@ -0,0 +1,35 @@
// Copyright (C) 2012 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.admin;
import static com.google.gerrit.common.PageLinks.ADMIN_PLUGINS;
import com.google.gerrit.client.ui.MenuScreen;
public abstract class PluginScreen extends MenuScreen {
public PluginScreen() {
setRequiresSignIn(true);
link(Util.C.pluginTabInstalled(), ADMIN_PLUGINS);
}
@Override
protected void onLoad() {
super.onLoad();
setPageTitle(Util.C.plugins());
display();
}
}

View File

@@ -1386,3 +1386,7 @@ a:hover.downloadLink {
font-style: italic;
padding: 2px 6px 1px;
}
/** PluginListScreen **/
.pluginsTable {
}

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2012 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.plugins;
import com.google.gwt.core.client.JavaScriptObject;
public class PluginInfo extends JavaScriptObject {
public final native String name() /*-{ return this.name; }-*/;
public final native String version() /*-{ return this.version; }-*/;
protected PluginInfo() {
}
}

View File

@@ -0,0 +1,30 @@
// Copyright (C) 2012 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.plugins;
import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gwtjsonrpc.common.AsyncCallback;
/** Plugins available from {@code /plugins/}. */
public class PluginMap extends NativeMap<PluginInfo> {
public static void all(AsyncCallback<PluginMap> callback) {
new RestApi("/plugins/")
.send(NativeMap.copyKeysIntoChildren(callback));
}
protected PluginMap() {
}
}