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
move allowed_to_customize_life_cycle? to a module
Ivan Kuchinb7be7f825e1f
diff --git a/app/components/settings/project_life_cycle_step_definitions/index_component.html.erb b/app/components/settings/project_life_cycle_step_definitions/index_component.html.erbindex 54dae4694b7..c09c6bd2505 100644--- a/app/components/settings/project_life_cycle_step_definitions/index_component.html.erb+++ b/app/components/settings/project_life_cycle_step_definitions/index_component.html.erb@@ -109,7 +109,6 @@ See COPYRIGHT and LICENSE files for more details.) dorender(Settings::ProjectLifeCycleStepDefinitions::RowComponent.new(definition,- allowed_to_customize_life_cycle?: allowed_to_customize_life_cycle?,first?: definition == definitions.first,last?: definition == definitions.last,))diff --git a/app/components/settings/project_life_cycle_step_definitions/index_component.rb b/app/components/settings/project_life_cycle_step_definitions/index_component.rbindex 0178a7fb471..14a3963fc03 100644--- a/app/components/settings/project_life_cycle_step_definitions/index_component.rb+++ b/app/components/settings/project_life_cycle_step_definitions/index_component.rb@@ -31,9 +31,9 @@ module Settingsclass IndexComponent < ApplicationComponentinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable+ include Projects::LifeCycleDefinitionHelper- options :definitions,- :allowed_to_customize_life_cycle?+ options :definitionsprivatediff --git a/app/components/settings/project_life_cycle_step_definitions/index_header_component.rb b/app/components/settings/project_life_cycle_step_definitions/index_header_component.rbindex 3c5e28a27d2..c0235f93d0e 100644--- a/app/components/settings/project_life_cycle_step_definitions/index_header_component.rb+++ b/app/components/settings/project_life_cycle_step_definitions/index_header_component.rb@@ -29,8 +29,6 @@module Settingsmodule ProjectLifeCycleStepDefinitionsclass IndexHeaderComponent < ApplicationComponent- options :allowed_to_customize_life_cycle?-def breadcrumbs_items[{ href: admin_index_path, text: t("label_administration") },diff --git a/app/components/settings/project_life_cycle_step_definitions/row_component.rb b/app/components/settings/project_life_cycle_step_definitions/row_component.rbindex 2ce3a97664c..a1525094f8f 100644--- a/app/components/settings/project_life_cycle_step_definitions/row_component.rb+++ b/app/components/settings/project_life_cycle_step_definitions/row_component.rb@@ -30,11 +30,11 @@ module Settingsmodule ProjectLifeCycleStepDefinitionsclass RowComponent < ApplicationComponentinclude OpPrimer::ComponentHelpers+ include Projects::LifeCycleDefinitionHelperalias_method :definition, :model- options :allowed_to_customize_life_cycle?,- :first?,+ options :first?,:last?privatediff --git a/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb b/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rbindex 72c05dda012..47311d48048 100644--- a/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb+++ b/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb@@ -30,11 +30,10 @@ module Admin::Settingsclass ProjectLifeCycleStepDefinitionsController < ::Admin::SettingsControllerinclude FlashMessagesOutputSafetyHelperinclude OpTurbo::ComponentStream+ include Projects::LifeCycleDefinitionHelpermenu_item :project_life_cycle_step_definitions_settings- helper_method :allowed_to_customize_life_cycle?-before_action :check_feature_flagbefore_action :require_enterprise_token, except: %i[index]@@ -113,10 +112,6 @@ module Admin::Settingsprivate- def allowed_to_customize_life_cycle?- EnterpriseToken.allows_to?(:customize_life_cycle)- end-def check_feature_flagrender_404 unless OpenProject::FeatureDecisions.stages_and_gates_active?end@@ -140,8 +135,7 @@ module Admin::Settingsdef update_definitions_via_turbo_streamupdate_via_turbo_stream(component: Settings::ProjectLifeCycleStepDefinitions::IndexComponent.new(- definitions: find_definitions,- allowed_to_customize_life_cycle?: allowed_to_customize_life_cycle?+ definitions: find_definitions))enddiff --git a/app/controllers/concerns/projects/life_cycle_definition_helper.rb b/app/controllers/concerns/projects/life_cycle_definition_helper.rbnew file mode 100644index 00000000000..b645b369d7d--- /dev/null+++ b/app/controllers/concerns/projects/life_cycle_definition_helper.rb@@ -0,0 +1,35 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program 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 General Public License for more details.+#+# You should have received a copy of the GNU 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.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module Projects::LifeCycleDefinitionHelper+ private++ def allowed_to_customize_life_cycle?+ EnterpriseToken.allows_to?(:customize_life_cycle)+ end+enddiff --git a/app/views/admin/settings/project_life_cycle_step_definitions/index.html.erb b/app/views/admin/settings/project_life_cycle_step_definitions/index.html.erbindex ac37177f5b5..cf8877a719e 100644--- a/app/views/admin/settings/project_life_cycle_step_definitions/index.html.erb+++ b/app/views/admin/settings/project_life_cycle_step_definitions/index.html.erb@@ -29,10 +29,5 @@ See COPYRIGHT and LICENSE files for more details.<% html_title t(:label_administration), t("settings.project_life_cycle_step_definitions.heading") %>-<%= render Settings::ProjectLifeCycleStepDefinitions::IndexHeaderComponent.new(- allowed_to_customize_life_cycle?: allowed_to_customize_life_cycle?-) %>-<%= render Settings::ProjectLifeCycleStepDefinitions::IndexComponent.new(- definitions: @definitions,- allowed_to_customize_life_cycle?: allowed_to_customize_life_cycle?-) %>+<%= render Settings::ProjectLifeCycleStepDefinitions::IndexHeaderComponent.new %>+<%= render Settings::ProjectLifeCycleStepDefinitions::IndexComponent.new(definitions: @definitions) %>