]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4136 Fixed lost context when redirecting after a resource-level dashboard creation
authorJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>
Fri, 21 Jun 2013 09:45:35 +0000 (11:45 +0200)
committerJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>
Fri, 21 Jun 2013 09:45:50 +0000 (11:45 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_create_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_edit_form.html.erb

index ed206bab77c9fe5307074e7385553f949fab522c..aa6beb0f624ca244f2c112940e601e67bdeccc7e 100644 (file)
@@ -65,7 +65,7 @@ class DashboardsController < ApplicationController
       add_default_dashboards_if_first_user_dashboard(@dashboard.global?)
       last_index=current_user.active_dashboards.max_by(&:order_index).order_index
       current_user.active_dashboards.create(:dashboard => @dashboard, :user => current_user, :order_index => (last_index+1))
-      render :text => @dashboard.id.to_s, :resource => params[:resource], :highlight => @dashboard.id, :status => 200
+      render :text => params[:resource], :highlight => @dashboard.id, :status => 200
     else
       render :partial => 'dashboards/create_form', :status => 400, :resource => params[:resource]
     end
@@ -86,7 +86,7 @@ class DashboardsController < ApplicationController
     if @dashboard.editable_by?(current_user)
       load_dashboard_from_params(@dashboard)
       if @dashboard.save
-        render :text => @dashboard.id.to_s, :resource => params[:resource], :status => 200
+        render :text => params[:resource], :status => 200
       else
         render :partial => 'dashboards/edit_form', :status => 400, :resource => params[:resource]
       end
index 5cee02f7eafe62b6d67154f430ca72127c774f62..5fbe198f9fd199e2aafcce9ab00a4ce9bd6464a2 100644 (file)
@@ -38,7 +38,8 @@
 
 <script>
   $j("#create-dashboard-form").modalForm({success: function (data) {
-    window.location = baseUrl + '/dashboards';
+    var contextParams = data.trim().length > 0 ? '?resource=' + data.trim() : '';
+    window.location = baseUrl + '/dashboards' + contextParams;
   }});
 </script>
 
index a3312878ae5fe77314eccc09284b166ea82e59de..abce4ae6c3c59f21f6e9ff02a23505b2f222033a 100644 (file)
@@ -45,6 +45,7 @@
 
 <script>
   $j("#edit-dashboard-form").modalForm({success: function (data) {
-    window.location = baseUrl + '/dashboards';
+    var contextParams = data.trim().length > 0 ? '?resource=' + data.trim() : '';
+    window.location = baseUrl + '/dashboards' + contextParams;
   }});
-</script>
\ No newline at end of file
+</script>