Render JS plugins without href on plugin list view

Plugins are linkified on admin plugin list view. If activated, the
Documentation for the plugin is shown. Because JS plugins can not have
Documentation or other resources that can be activated, render them
without href.  To have this information on the client side, extend
REST API with index_url attribute.

Change-Id: I49cab14cc2b01bc4e8cd0c906f4b3bdde1da905c
This commit is contained in:
David Ostrovsky 2013-12-05 21:40:36 +01:00 committed by Shawn Pearce
parent d020143837
commit 83c7986122
4 changed files with 26 additions and 16 deletions

View File

@ -46,14 +46,16 @@ by plugin ID.
"delete-project": {
"kind": "gerritcodereview#plugin",
"id": "delete-project",
"version": "2.9-SNAPSHOT"
"index_url": "plugins/delete-project/",
"version": "2.9-SNAPSHOT",
},
"reviewers-by-blame": {
"kind": "gerritcodereview#plugin",
"id": "reviewers-by-blame",
"index_url": "plugins/reviewers-by-blame/",
"version": "2.9-SNAPSHOT",
"disabled": true
}
},
}
----
@ -262,11 +264,12 @@ The `PluginInfo` entity describes a plugin.
[options="header",width="50%",cols="1,^2,4"]
|=======================
|Field Name||Description
|`kind` ||`gerritcodereview#plugin`
|`id` ||The ID of the plugin.
|`version` ||The version of the plugin.
|`disabled`|not set if `false`|Whether the plugin is disabled.
|Field Name ||Description
|`kind` ||`gerritcodereview#plugin`
|`id` ||The ID of the plugin.
|`version` ||The version of the plugin.
|`index_url`|optional|URL of the plugin's default page.
|`disabled` |not set if `false`|Whether the plugin is disabled.
|=======================
[[plugin-input]]

View File

@ -83,17 +83,20 @@ public class PluginListScreen extends PluginScreen {
}
void populate(final int row, final PluginInfo plugin) {
if (plugin.isDisabled()) {
if (plugin.disabled() || plugin.indexUrl() == null) {
table.setText(row, 1, plugin.name());
} else {
table.setWidget(
row,
1,
new Anchor(plugin.name(), Gerrit.selfRedirect("/plugins/"
+ plugin.name() + "/"), "_blank"));
new Anchor(
plugin.name(),
Gerrit.selfRedirect(plugin.indexUrl()),
"_blank"));
}
table.setText(row, 2, plugin.version());
table.setText(row, 3, plugin.isDisabled() ? Util.C.pluginDisabled()
table.setText(row, 3, plugin.disabled()
? Util.C.pluginDisabled()
: Util.C.pluginEnabled());
final FlexCellFormatter fmt = table.getFlexCellFormatter();

View File

@ -17,11 +17,10 @@ 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; }-*/;
public final native boolean isDisabled()
/*-{ return this.disabled ? true : false; }-*/;
public final native String name() /*-{ return this.name }-*/;
public final native String version() /*-{ return this.version }-*/;
public final native String indexUrl() /*-{ return this.index_url }-*/;
public final native boolean disabled() /*-{ return this.disabled || false }-*/;
protected PluginInfo() {
}

View File

@ -127,12 +127,17 @@ public class ListPlugins implements RestReadView<TopLevelResource> {
final String kind = "gerritcodereview#plugin";
String id;
String version;
String indexUrl;
Boolean disabled;
PluginInfo(Plugin p) {
id = Url.encode(p.getName());
version = p.getVersion();
disabled = p.isDisabled() ? true : null;
if (p.getJarFile() != null) {
indexUrl = String.format("plugins/%s/", p.getName());
}
}
}
}