support remove and install actions
authorEugene Petrenko <eugene.petrenko@gmail.com>
Mon, 15 Aug 2011 21:31:28 +0000 (01:31 +0400)
committerEugene Petrenko <eugene.petrenko@gmail.com>
Mon, 15 Aug 2011 21:31:28 +0000 (01:31 +0400)
nuget-server/resources/tool/installTool-show.jsp
nuget-server/resources/tool/tools.js
nuget-server/resources/tool/tools.jsp
nuget-server/src/jetbrains/buildServer/nuget/server/toolRegistry/impl/NuGetToolManagerImpl.java
nuget-server/src/jetbrains/buildServer/nuget/server/toolRegistry/tab/InstallToolController.java

index b780fd3092bf5bb6e705bbddd3424ba9814e8c87..9aab76ba2f2f46348966d36d96fc788b21c30df7 100644 (file)
@@ -14,7 +14,6 @@
   ~ limitations under the License.\r
   --%>\r
 <%@ include file="/include-internal.jsp" %>\r
-<%@ taglib prefix="props" tagdir="/WEB-INF/tags/props" %>\r
 <jsp:useBean id="available"\r
              type="java.util.Collection<jetbrains.buildServer.nuget.server.toolRegistry.NuGetTool>"\r
              scope="request"/>\r
         <tr>\r
           <th><label for="toolId">Version:<l:star/></label></th>\r
           <td>\r
-            <props:selectProperty name="toolId" style="width:15em;">\r
-              <props:option value="">-- Please choose version --</props:option>\r
+            <input type="hidden" name="whatToDo" value="install" />\r
+            <forms:select name="toolId" style="width:15em;">\r
+              <forms:option value="">-- Please choose version --</forms:option>\r
               <c:forEach var="t" items="${available}">\r
                 <forms:option value="${t.id}"><c:out value="${t.version}"/></forms:option>\r
               </c:forEach>\r
-            </props:selectProperty>\r
+            </forms:select>\r
             <span class="smallNote">\r
               Choose version of NuGet Commandline Tools to install.\r
             </span>\r
index 1e074dbcaeb27c29b0f00855e699cab1115d4bf2..c991159ec232a06c77265de028bcbee2716ec643 100644 (file)
@@ -19,10 +19,25 @@ if (!BS) BS = {};
 if (!BS.NuGet) BS.NuGet = {};\r
 \r
 BS.NuGet.Tools = {\r
+  installUrl : '',\r
+\r
   refreshPackagesList : function() {\r
     $('nugetPackagesList').refresh();\r
   },\r
 \r
+  removeTool : function(toolId) {\r
+    BS.ajaxRequest(this.installUrl, {\r
+      parameters : {\r
+        whatToDo : "remove",\r
+        toolId : toolId\r
+      },\r
+\r
+      onComplete: function() {\r
+        BS.NuGet.Tools.refreshPackagesList();\r
+      }\r
+    })\r
+  },\r
+\r
   InstallPopup : OO.extend(BS.PluginPropertiesForm, OO.extend(BS.AbstractModalDialog, {\r
     getContainer : function() {\r
       return $('nugetInstallFormDialog');\r
index f1da916e63671a29487f13c80a970f1fa014c2cc..588a69f8c05cd9ba03b9edc954e033adc1a7a447 100644 (file)
@@ -48,7 +48,7 @@
               <td>\r
                 <c:choose>\r
                   <c:when test="${tool.state.installed}">\r
-                    <a href="#">Remove</a>\r
+                    <a href="#" onclick="BS.NuGet.Tools.removeTool('<bs:forJs>${tool.id}</bs:forJs>');">Remove</a>\r
                   </c:when>\r
                   <c:when test="${tool.state.installing}">\r
                     <bs:commentIcon text="Messages"/>\r
@@ -99,5 +99,6 @@
 </bs:modalDialog>\r
 \r
 <script type="text/javascript">\r
+  BS.NuGet.Tools.installUrl = "<bs:forJs>${actualInstallerUrl}</bs:forJs>";\r
   BS.NuGet.Tools.InstallPopup.disableSubmit();\r
 </script>\r
index 8e13e8fece38b8af1aeb2ddd3a54d79e969ddf4d..df1b2246229d54547dcf8bab4bb5189234d03cb3 100644 (file)
@@ -25,6 +25,7 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;\r
 import java.util.Arrays;\r
 import java.util.Collection;\r
+import java.util.Collections;\r
 import java.util.List;\r
 \r
 /**\r
@@ -53,7 +54,7 @@ public class NuGetToolManagerImpl implements NuGetToolManager {
 \r
   @NotNull\r
   public Collection<NuGetInstallingTool> getInstallingTool() {\r
-    return mockInstallingTools();\r
+    return Collections.emptyList();\r
   }\r
 \r
   @NotNull\r
index 9c48accca9a98421359e44dddc9739853083f256..a033e1adeb2d8367e7c28eef00ac85e57f047ee3 100644 (file)
@@ -96,7 +96,7 @@ public class InstallToolController extends BaseFormXmlController {
 \r
   @Override\r
   protected void doPost(HttpServletRequest request, HttpServletResponse response, Element xmlResponse) {\r
-    final String toolId = request.getParameter("prop:toolId");\r
+    String toolId = request.getParameter("toolId");\r
     if (StringUtil.isEmptyOrSpaces(toolId)) {\r
       ActionErrors ae = new ActionErrors();\r
       ae.addError("toolId", "Select NuGet.Commandline package version to install");\r
@@ -104,6 +104,14 @@ public class InstallToolController extends BaseFormXmlController {
       return;\r
     }\r
 \r
-    myToolsManager.installTool(toolId);\r
+    final String whatToDo = request.getParameter("whatToDo");\r
+    if ("install".equals(whatToDo)) {\r
+      myToolsManager.installTool(toolId);\r
+      return;\r
+    }\r
+\r
+    if ("remove".equals(whatToDo)) {\r
+      myToolsManager.removeTool(toolId);\r
+    }\r
   }\r
 }\r