diff options
author | Godin <mandrikov@gmail.com> | 2010-10-27 16:45:56 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-10-27 16:45:56 +0000 |
commit | 6b50f77089e03519fcb395b9e40e56f1f8738a51 (patch) | |
tree | 109c7795b6a2581f882cbbeaa080a90e8b1c6990 | |
parent | 4321c5607b08c56e6b20543f00744aa53b1dc116 (diff) | |
download | sonarqube-6b50f77089e03519fcb395b9e40e56f1f8738a51.tar.gz sonarqube-6b50f77089e03519fcb395b9e40e56f1f8738a51.zip |
SONAR-1886: Uninstall a plugin
6 files changed, 73 insertions, 16 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index 6fde91d0f0a..7c83558c18a 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -31,8 +31,13 @@ import org.sonar.api.profiles.ProfileImporter; import org.sonar.api.resources.Language; import org.sonar.api.rules.DefaultRulesManager; import org.sonar.api.rules.RuleRepository; +import org.sonar.api.utils.SonarException; import org.sonar.api.utils.ValidationMessages; -import org.sonar.api.web.*; +import org.sonar.api.web.Footer; +import org.sonar.api.web.NavigationSection; +import org.sonar.api.web.Page; +import org.sonar.api.web.RubyRailsWebservice; +import org.sonar.api.web.Widget; import org.sonar.jpa.dao.AsyncMeasuresService; import org.sonar.jpa.dialect.Dialect; import org.sonar.jpa.session.DatabaseConnector; @@ -52,6 +57,7 @@ import org.sonar.server.rules.RulesConsole; import org.sonar.updatecenter.common.Version; import java.util.Collection; +import java.util.Collections; import java.util.List; public final class JRubyFacade implements ServerComponent { @@ -73,6 +79,18 @@ public final class JRubyFacade implements ServerComponent { return getContainer().getComponent(PluginDownloader.class).getDownloads(); } + public void uninstallPlugin(String pluginKey) { + throw new SonarException("Implement me!"); + } + + public void cancelPluginUninstalls() { + throw new SonarException("Implement me!"); + } + + public List<String> getPluginUninstalls() { + return Collections.emptyList(); + } + public UpdateFinder getUpdateFinder(boolean forceReload) { return getContainer().getComponent(UpdateFinderFactory.class).getFinder(forceReload); } @@ -87,7 +105,6 @@ public final class JRubyFacade implements ServerComponent { } } - public List<ViewProxy<Widget>> getWidgets(String resourceScope, String resourceQualifier, String resourceLanguage) { return getContainer().getComponent(Views.class).getWidgets(resourceScope, resourceQualifier, resourceLanguage); } @@ -124,7 +141,6 @@ public final class JRubyFacade implements ServerComponent { return getContainer().getComponent(Plugins.class).getPlugins(); } - /* PROFILES CONSOLE : RULES AND METRIC THRESHOLDS */ public List<RuleRepository> getRuleRepositories() { @@ -234,7 +250,7 @@ public final class JRubyFacade implements ServerComponent { Object component = null; PicoContainer container = getContainer(); Class componentClass = container.getComponent(PluginClassLoaders.class).getClass(pluginKey, className); - if (componentClass!=null) { + if (componentClass != null) { component = container.getComponent(componentClass); } return component; diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb index 28c89ac0d68..9cbc245abe5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb @@ -25,6 +25,7 @@ class UpdatecenterController < ApplicationController verify :method => :post, :only => [:cancel, :install], :redirect_to => {:action => :index} def index + @uninstalls=java_facade.getPluginUninstalls() @user_plugins=Plugin.user_plugins @core_plugins=Plugin.core_plugins end @@ -78,9 +79,27 @@ class UpdatecenterController < ApplicationController end redirect_to :action => (params[:from] || 'index') end + + def uninstall + key=params[:key] + if key + begin + java_facade.uninstallPlugin(key) + rescue Exception => e + flash[:error]=e.message + end + end + redirect_to :action => 'index' + end + + def cancel_uninstalls + java_facade.cancelPluginUninstalls() + flash[:notice]="Plugin uninstalls are canceled." + redirect_to :action => 'index' + end private def load_update_finder @finder=java_facade.getUpdateFinder(params[:reload]=='true') end -end
\ No newline at end of file +end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_uninstalls.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_uninstalls.html.erb new file mode 100644 index 00000000000..4158e78b201 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_uninstalls.html.erb @@ -0,0 +1,11 @@ +<% if @uninstalls.size > 0 %> +<form action="<%= ApplicationController.root_context -%>/updatecenter/cancel_uninstalls" method="post" class="warning"> +<p>Sonar needs to be restarted in order to uninstall the following plugins: <ul> + <% @uninstalls.each do |uninstall| %> + <li><%= uninstall -%></li> + <% end %> + </ul> + <input type="submit" value="Cancel uninstalls"></input> +</p> +</form> +<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb index fcdfa93b3d6..c508cf887ae 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb @@ -11,7 +11,7 @@ </ul> <div class="tabs-panel"> -<%= render :partial => 'updatecenter/downloads' %> +<%= render :partial => 'updatecenter/downloads' -%> <table class="data width100"> <thead> @@ -66,7 +66,7 @@ <% end %> <form method="post" action="<%= ApplicationController.root_context -%>/updatecenter/install?from=available&key=<%= plugin.getKey() -%>&version=<%= update.getRelease().getVersion() -%>" style="display: inline-block"> <input type="submit" value="Install" onClick="return checkTermsConditions('<%= plugin.getKey() -%>')"></input> - </form> + </form> </div> <% elsif update.requiresSonarUpgrade %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb index 79c813a2e52..555b604b415 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb @@ -12,7 +12,8 @@ <div class="tabs-panel"> -<%= render :partial => 'updatecenter/common' %> +<%= render :partial => 'updatecenter/uninstalls' -%> +<%= render :partial => 'updatecenter/common' -%> <h2>User-installed plugins</h2> <table class="data"> @@ -42,9 +43,12 @@ By: <%= link_to_if plugin.organization_url, plugin.organization, plugin.organization_url, :class=>'external' -%><br/> <% end %> <% if plugin.homepage %> - <%= link_to 'Details', plugin.homepage, :class => 'external' -%><br/> - <% end %> - </p> + <%= link_to 'Details', plugin.homepage, :class => 'external' -%><br/> + <% end %> + </p> + <form method="post" action="<%= ApplicationController.root_context -%>/updatecenter/uninstall?key=<%= plugin.plugin_key -%>" style="display: inline-block"> + <input type="submit" value="Uninstall"></input> + </form> </div> </td> </tr> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb index 8b60ccf1b0d..fa8d744adbe 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb @@ -10,7 +10,7 @@ </li> </ul> <div class="tabs-panel"> -<%= render :partial => 'updatecenter/downloads' %> +<%= render :partial => 'updatecenter/downloads' -%> <% if @center %> <table class="data width100" id="plugin-updates"> @@ -22,15 +22,20 @@ <tbody> <% if @plugin_updates.empty? %> <tr class="even"> - <td colspan="3" >No updates</td> + <td colspan="3">No updates</td> </tr> <% end %> <% @plugin_updates.each do |update| %> <tr class="<%= cycle('even','odd', :name => 'user-plugins') -%>"> - <td><%= h(update.getPlugin().getName()) -%></td> + <td><b><%= h(update.getPlugin().getName()) -%></b></td> <td> - + <%= update.getRelease().getVersion() -%> + <% if update.isIncompatible() %> + not compatible + <% elsif update.requiresSonarUpgrade %> + not compatible, needs Sonar upgrade + <% end %> </td> <td> <div> @@ -43,7 +48,9 @@ <% end %> </tbody> </table> + <br/> + <table class="data width100" id="system-updates"> <thead> <tr> @@ -61,7 +68,7 @@ sonar_release=update.getRelease() %> <tr class="<%= cycle('even','odd', :name => 'system') -%>"> - <td>Sonar <%= sonar_release.getVersion() -%></td> + <td><b>Sonar <%= sonar_release.getVersion() -%></b></td> <td><%= sonar_release.getDescription() -%></td> <td> <%= link_to 'Release Notes', sonar_release.getChangelogUrl(), :class => 'external' if sonar_release.getChangelogUrl() %> |