OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
restrict wp_graph widget to be ee only
ulfertsfdbcdc45bfcb
diff --git a/app/models/enterprise_token.rb b/app/models/enterprise_token.rbindex c8f2c265c25..363541d4574 100644--- a/app/models/enterprise_token.rb+++ b/app/models/enterprise_token.rb@@ -48,7 +48,7 @@ class EnterpriseToken < ActiveRecord::Basedef set_current_tokentoken = EnterpriseToken.order(Arel.sql('created_at DESC')).first- if token && token.token_object+ if token&.token_objecttokenendenddiff --git a/app/services/authorization/enterprise_service.rb b/app/services/authorization/enterprise_service.rbindex 14f7b9bee14..7baed738e07 100644--- a/app/services/authorization/enterprise_service.rb+++ b/app/services/authorization/enterprise_service.rb@@ -43,7 +43,8 @@ class Authorization::EnterpriseServiceconditional_highlightingreadonly_work_packagesattachment_filters- board_view).freeze+ board_view+ grid_widget_wp_graph).freezedef initialize(token)self.token = tokendiff --git a/modules/dashboards/spec/features/work_package_graph_spec.rb b/modules/dashboards/spec/features/work_package_graph_spec.rbindex 8a9b0226097..0e8500a3948 100644--- a/modules/dashboards/spec/features/work_package_graph_spec.rb+++ b/modules/dashboards/spec/features/work_package_graph_spec.rb@@ -85,12 +85,15 @@ describe 'Arbitrary WorkPackage query graph widget dashboard', type: :feature, jlet(:dashboard_page) doPages::Dashboard.new(project)end+ let(:enterprise_edition) { true }let(:modal) { ::Components::WorkPackages::TableConfigurationModal.new }let(:filters) { ::Components::WorkPackages::TableConfiguration::Filters.new }let(:general) { ::Components::WorkPackages::TableConfiguration::GraphGeneral.new }before do+ with_enterprise_token(enterprise_edition ? :grid_widget_wp_graph : nil)+login_as userdashboard_page.visit!@@ -106,7 +109,7 @@ describe 'Arbitrary WorkPackage query graph widget dashboard', type: :feature, jfilter_area.expect_to_span(1, 1, 2, 2)- sleep(0.1)+ sleep(0.5)# User has the ability to modify the query@@ -149,4 +152,12 @@ describe 'Arbitrary WorkPackage query graph widget dashboard', type: :feature, jdashboard_page.expect_unable_to_add_widget(1, 1, :within, "Work packages graph")endend++ context 'without an enterprise edition' do+ let(:enterprise_edition) { false }++ it 'cannot add the widget' do+ dashboard_page.expect_unable_to_add_widget(1, 2, :within, "Work packages graph")+ end+ endenddiff --git a/modules/grids/lib/grids/configuration/in_project_base_registration.rb b/modules/grids/lib/grids/configuration/in_project_base_registration.rbindex bf65b8f50d6..6a1ed85ee0c 100644--- a/modules/grids/lib/grids/configuration/in_project_base_registration.rb+++ b/modules/grids/lib/grids/configuration/in_project_base_registration.rb@@ -22,6 +22,11 @@ module Grids::Configurationuser.allowed_to?(:manage_public_queries, project)}+ queries_permission_and_ee_lambda = ->(user, project) {+ save_or_manage_queries_lambda.call(user, project) &&+ EnterpriseToken.allows_to?(:grid_widget_wp_graph)+ }+view_work_packages_lambda = ->(user, project) {user.allowed_to?(:view_work_packages, project)}@@ -37,7 +42,7 @@ module Grids::Configurationwidget_strategy 'work_packages_graph' doafter_destroy remove_query_lambda- allowed save_or_manage_queries_lambda+ allowed queries_permission_and_ee_lambdaoptions_representer '::API::V3::Grids::Widgets::ChartOptionsRepresenter'enddiff --git a/spec/services/authorization/enterprise_service_spec.rb b/spec/services/authorization/enterprise_service_spec.rbindex eef65558200..9a2848c79b5 100644--- a/spec/services/authorization/enterprise_service_spec.rb+++ b/spec/services/authorization/enterprise_service_spec.rb@@ -77,7 +77,8 @@ describe Authorization::EnterpriseService domultiselect_custom_fieldsedit_attribute_groupswork_package_query_relation_columns- attribute_help_texts).each do |guarded_action|+ attribute_help_texts+ grid_widget_wp_graph).each do |guarded_action|context "guarded action #{guarded_action}" dolet(:action) { guarded_action }