diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-07-27 11:21:01 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-07-28 09:14:54 +0200 |
commit | 562ce026e39be193bb341cd1460641f0c395258b (patch) | |
tree | 663ef438caf4f903924444adc58e18d69639f65f /server/sonar-web/src/main | |
parent | 9e90ec77057147e8ee53837b6b282a66795cce79 (diff) | |
download | sonarqube-562ce026e39be193bb341cd1460641f0c395258b.tar.gz sonarqube-562ce026e39be193bb341cd1460641f0c395258b.zip |
SONAR-7917 Drop is_global from DB table dashboards
Diffstat (limited to 'server/sonar-web/src/main')
8 files changed, 43 insertions, 22 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb index 08f98b294f1..6b2d9515a79 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb @@ -120,7 +120,7 @@ class DashboardController < ApplicationController :name => definition.getTitle(), :column_index => 1, :row_index => 1, - :configured => !(definition.hasRequiredProperties() || (dashboard.global && !definition.isGlobal))) + :configured => !(definition.hasRequiredProperties() || (!definition.isGlobal))) widget_id=new_widget.id first_column_widgets.each_with_index do |w, index| w.row_index=index+2 @@ -172,7 +172,7 @@ class DashboardController < ApplicationController elsif params[:name] @dashboard=Dashboard.first(:conditions => ['name=? AND user_id=?', params[:name], current_user.id]) else - active=ActiveDashboard.user_dashboards(current_user, true).first + active=ActiveDashboard.user_dashboards(current_user).first end end @@ -183,7 +183,7 @@ class DashboardController < ApplicationController elsif params[:name] @dashboard=Dashboard.first(:conditions => ['name=? AND shared=?', params[:name], true]) else - active=ActiveDashboard.user_dashboards(nil, true).first + active=ActiveDashboard.user_dashboards(nil).first end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb index 3ca18a8aa5c..a7029e3bc09 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb @@ -24,10 +24,8 @@ class DashboardsController < ApplicationController before_filter :login_required def index - @global = true - - @actives=ActiveDashboard.user_dashboards(current_user, @global) - @shared_dashboards=Dashboard.all(:conditions => ['(shared=? or user_id=?) and is_global=?', true, current_user.id, @global]) + @actives=ActiveDashboard.user_dashboards(current_user) + @shared_dashboards=Dashboard.all(:conditions => ['(shared=? or user_id=?)', true, current_user.id]) active_ids=@actives.map(&:dashboard_id) @shared_dashboards.reject! { |d| active_ids.include?(d.id) } @shared_dashboards=Api::Utils.insensitive_sort(@shared_dashboards, &:name) @@ -182,7 +180,6 @@ class DashboardsController < ApplicationController def load_dashboard_from_params(dashboard) dashboard.name = params[:name] dashboard.description = params[:description] - dashboard.is_global = params[:global].present? dashboard.shared = params[:shared].present? && has_role?(:shareDashboard) dashboard.column_layout = Dashboard::DEFAULT_LAYOUT if !dashboard.column_layout dashboard.user = User.find_active_by_login(params[:owner]) unless params[:owner].nil? diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb index dd425eb6d4b..3fbceeff018 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb @@ -155,7 +155,7 @@ module DashboardHelper end def widget_title(widget) - resource_name=link_to(h(@resource.name), {:controller => 'dashboard', :action => 'index', :id => @resource.id}) if @resource && @dashboard.global && !widget.java_definition.global + resource_name=link_to(h(@resource.name), {:controller => 'dashboard', :action => 'index', :id => @resource.id}) if @resource && !widget.java_definition.global [resource_name, @widget_title].compact.join(' - ') end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_dashboard.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_dashboard.rb index 08f38c35ae4..f3aed6c97c0 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_dashboard.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/active_dashboard.rb @@ -36,7 +36,7 @@ class ActiveDashboard < ActiveRecord::Base end def global? - dashboard.global + true end def owner?(user) @@ -55,13 +55,13 @@ class ActiveDashboard < ActiveRecord::Base user_id.nil? end - def self.user_dashboards(user, global) + def self.user_dashboards(user) result=nil if user && user.id - result=find_for_user(user.id).select { |a| a.global? == global} + result=find_for_user(user.id) end if result.nil? || result.empty? - result=default_dashboards.select { |a| a.global? == global} + result=default_dashboards end result end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/dashboard.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/dashboard.rb index 70694368ff4..d735bf86d0e 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/dashboard.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/dashboard.rb @@ -30,7 +30,6 @@ class Dashboard < ActiveRecord::Base validates_length_of :description, :maximum => 1000, :allow_blank => true, :allow_nil => true validates_length_of :column_layout, :maximum => 20, :allow_blank => false, :allow_nil => false validates_uniqueness_of :name, :scope => :user_id - validates_inclusion_of :is_global, :in => [true, false] validate :user_rights_consistency @@ -55,16 +54,12 @@ class Dashboard < ActiveRecord::Base read_attribute(:shared) || false end - def global=(global) - write_attribute(:is_global, global) - end - def global - read_attribute(:is_global) + true end def global? - global + true end def layout diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb index e2ceea91e73..b3f6a8dcbaa 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb @@ -6,7 +6,7 @@ <div class="widget-header"> <div class="widget-actions"> - <% if widget.java_definition.isEditable() || (!widget.java_definition.global && @dashboard.global) %> + <% if widget.java_definition.isEditable() || (!widget.java_definition.global) %> <a class="link-action" onclick="portal.editWidget(<%= widget.id -%>);return false;"><%= message('edit') -%></a> <% end %> <a class="link-action" onclick="portal.deleteWidget(this);return false;"><%= message('delete') -%></a> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb index 48343d6ab40..c333abd9e9e 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb @@ -3,7 +3,7 @@ <table class="table width100"> <tbody> - <% if !widget.java_definition.global && @dashboard.global %> + <% if !widget.java_definition.global %> <tr> <td class="form-key-cell"><%= message('widget.resource_id') %> <em class="mandatory">*</em></td> <td class="form-val-cell" id="row_resource"> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1301_drop_is_global_from_dashboards.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1301_drop_is_global_from_dashboards.rb new file mode 100644 index 00000000000..9f1cf8ac205 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1301_drop_is_global_from_dashboards.rb @@ -0,0 +1,29 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# SonarQube is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# +# SonarQube 6.1 +# +class DropIsGlobalFromDashboards < ActiveRecord::Migration + + def self.up + execute_java_migration('org.sonar.db.version.v61.DropIsGlobalFromDashboards') + end +end |