Skip to content

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

Show error if gantt module enabled as default without work packages

Oliver Günther736a1d7f0159
diff --git a/app/controllers/admin/settings/projects_settings_controller.rb b/app/controllers/admin/settings/projects_settings_controller.rb
index aa90d96147d..84a4d34c8e9 100644
--- a/app/controllers/admin/settings/projects_settings_controller.rb
+++ b/app/controllers/admin/settings/projects_settings_controller.rb
@@ -30,8 +30,32 @@ module Admin::Settings
class ProjectsSettingsController < ::Admin::SettingsController
menu_item :settings_projects
+ before_action :validate_enabled_modules, only: :update
+
def default_breadcrumb
t(:label_project_plural)
end
+
+ private
+
+ def validate_enabled_modules
+ return if settings_params[:default_projects_modules].blank?
+
+ enabled_modules = settings_params[:default_projects_modules].map(&:to_sym)
+
+ module_missing_deps = OpenProject::AccessControl
+ .modules
+ .detect { |m| m[:dependencies] && enabled_modules.include?(m[:name]) && (m[:dependencies] & enabled_modules) != m[:dependencies] }
+
+ if module_missing_deps
+ flash[:error] = I18n.t(
+ 'settings.projects.missing_dependencies',
+ module: I18n.t("project_module_#{module_missing_deps[:name]}"),
+ dependencies: module_missing_deps[:dependencies].map { |dep| I18n.t("project_module_#{dep}") }.join(', ')
+ )
+
+ redirect_to action: :show
+ end
+ end
end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 8e8f58bbc01..6da24c970d7 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -3011,6 +3011,7 @@ en:
other: "Other"
passwords: "Passwords"
projects:
+ missing_dependencies: "Project module %{module} was checked which depends on %{dependencies}. You need to check these dependencies as well."
section_new_projects: "Settings for new projects"
section_project_overview: "Settings for project overview list"
session: "Session"