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
Implement requested by CR changes.
Pavel Balashou71eccfa053ab
diff --git a/modules/storages/app/components/storages/admin/sidebar/health_notifications_component.html.erb b/modules/storages/app/components/storages/admin/sidebar/health_notifications_component.html.erbindex 14e630e7dd6..3fe5419e808 100644--- a/modules/storages/app/components/storages/admin/sidebar/health_notifications_component.html.erb+++ b/modules/storages/app/components/storages/admin/sidebar/health_notifications_component.html.erb@@ -1,3 +1,32 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 2012-2024 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.++++#%>+<%=component_wrapper(data: { turbo: true }) doflex_layout do |notifications_container|@@ -7,11 +36,11 @@notifications_container.with_row(mt: 2) doform_for(@storage, method: :patch,- url: change_health_email_notifications_admin_settings_storage_path(@storage),+ url: change_health_notifications_enabled_admin_settings_storage_path(@storage),data: { turbo_stream: true }) do |f|flex_layout do |notification_status_actions|notification_status_actions.with_row do- f.hidden_field :health_notifications_enabled, value: (storage.health_notifications_enabled? ? "0" : "1")+ f.hidden_field :health_notifications_enabled, value: (@storage.health_notifications_enabled? ? "0" : "1")endnotification_status_actions.with_row(test_selector: "storage-health-notifications-button") dodiff --git a/modules/storages/app/components/storages/admin/sidebar/health_notifications_component.rb b/modules/storages/app/components/storages/admin/sidebar/health_notifications_component.rbindex a2960c5e693..31134e5d356 100644--- a/modules/storages/app/components/storages/admin/sidebar/health_notifications_component.rb+++ b/modules/storages/app/components/storages/admin/sidebar/health_notifications_component.rb@@ -33,20 +33,17 @@ module Storagesinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers- attr_reader :storage-def initialize(storage:)super-@storage = storageenddef render?- storage.automatically_managed?+ @storage.automatically_managed?enddef notification_status- if storage.health_notifications_enabled?+ if @storage.health_notifications_enabled?{ icon: :"bell-slash",label: I18n.t("storages.health_email_notifications.unsubscribe"),description: I18n.t("storages.health_email_notifications.description_subscribed") }diff --git a/modules/storages/app/components/storages/admin/sidebar/health_status_component.html.erb b/modules/storages/app/components/storages/admin/sidebar/health_status_component.html.erbindex 39672b8d570..013a1272589 100644--- a/modules/storages/app/components/storages/admin/sidebar/health_status_component.html.erb+++ b/modules/storages/app/components/storages/admin/sidebar/health_status_component.html.erb@@ -1,3 +1,32 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 2012-2024 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.++++#%>+<%=component_wrapper doflex_layout do |health_status_container|diff --git a/modules/storages/app/components/storages/admin/sidebar/health_status_component.rb b/modules/storages/app/components/storages/admin/sidebar/health_status_component.rbindex 8aba2915861..42e05f958ca 100644--- a/modules/storages/app/components/storages/admin/sidebar/health_status_component.rb+++ b/modules/storages/app/components/storages/admin/sidebar/health_status_component.rb@@ -34,8 +34,6 @@ module Storages::Admininclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers- attr_reader :storage-def initialize(storage:)super(storage)@storage = storage@@ -44,7 +42,7 @@ module Storages::Adminprivatedef health_status_indicator- case storage.health_status+ case @storage.health_statuswhen "healthy"{ scheme: :success, label: I18n.t("storages.health.label_healthy") }when "unhealthy"@@ -57,8 +55,8 @@ module Storages::Admin# This method returns the health identifier, description and the time since when the error occurs in a# formatted manner. e.g. "Not found: Outbound request destination not found since 12/07/2023 03:45 PM"def formatted_health_reason- "#{storage.health_reason_identifier.tr('_', ' ').strip.capitalize}: #{storage.health_reason_description} " +- I18n.t("storages.health.since", datetime: helpers.format_time(storage.health_changed_at))+ "#{@storage.health_reason_identifier.tr('_', ' ').strip.capitalize}: #{@storage.health_reason_description} " ++ I18n.t("storages.health.since", datetime: helpers.format_time(@storage.health_changed_at))endendenddiff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rbindex a33257169bb..edecb0d2799 100644--- a/modules/storages/app/controllers/storages/admin/storages_controller.rb+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb@@ -46,7 +46,7 @@ class Storages::Admin::StoragesController < ApplicationControllerbefore_action :require_adminbefore_action :find_model_object,only: %i[show_oauth_application destroy edit edit_host confirm_destroy update- change_health_email_notifications replace_oauth_application]+ change_health_notifications_enabled replace_oauth_application]before_action :ensure_valid_provider_type_selected, only: %i[select_provider]before_action :require_ee_token_for_one_drive, only: %i[select_provider]@@ -165,11 +165,11 @@ class Storages::Admin::StoragesController < ApplicationControllerendend- def change_health_email_notifications- return head :forbidden unless %w[1 0].include?(permitted_storage_params[:health_notifications_enabled])+ def change_health_notifications_enabled+ return head :bad_request unless %w[1 0].include?(permitted_storage_params[:health_notifications_enabled])if @storage.update(health_notifications_enabled: permitted_storage_params[:health_notifications_enabled])- update_via_turbo_stream(component: Storages::Admin::Sidebar::HealthNotificationsComponent.new(storage: @storage.reload))+ update_via_turbo_stream(component: Storages::Admin::Sidebar::HealthNotificationsComponent.new(storage: @storage))respond_with_turbo_streamselseflash.now[:primer_banner] = {diff --git a/modules/storages/app/workers/storages/health_status_mailer_job.rb b/modules/storages/app/workers/storages/health_status_mailer_job.rbindex 4c0d75b8477..434fc38fe37 100644--- a/modules/storages/app/workers/storages/health_status_mailer_job.rb+++ b/modules/storages/app/workers/storages/health_status_mailer_job.rb@@ -39,11 +39,9 @@ module Storageskey: -> { "#{self.class.name}-#{arguments.last[:storage]}" })- def perform(storage:)- return unless ::Storages::Storage.exists?(storage.id)-- storage.reload+ discard_on ActiveJob::DeserializationError+ def perform(storage:)return unless storage.health_notifications_enabled?return if storage.health_healthy?diff --git a/modules/storages/config/routes.rb b/modules/storages/config/routes.rbindex b1f19012d00..1d4786c30fe 100644--- a/modules/storages/config/routes.rb+++ b/modules/storages/config/routes.rb@@ -48,7 +48,7 @@ Rails.application.routes.draw domember doget :show_oauth_applicationget :edit_host- patch :change_health_email_notifications+ patch :change_health_notifications_enabledget :confirm_destroydelete :replace_oauth_applicationenddiff --git a/modules/storages/spec/jobs/storages/health_status_mailer_job_spec.rb b/modules/storages/spec/jobs/storages/health_status_mailer_job_spec.rbindex b950f890d9d..f2bcbabf8d5 100644--- a/modules/storages/spec/jobs/storages/health_status_mailer_job_spec.rb+++ b/modules/storages/spec/jobs/storages/health_status_mailer_job_spec.rb@@ -72,11 +72,5 @@ RSpec.describe Storages::HealthStatusMailerJob doit_behaves_like "skips sending an email"end-- context "when the storage does not exist" do- let(:storage) { build(:nextcloud_storage) }-- it_behaves_like "skips sending an email"- endendend