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

fix[Op#52449]: only render health notifications in automatically managed context

Kabiru Mwenja31bf7c9c6268
diff --git a/modules/storages/app/components/storages/admin/sidebar/health_notifications_component.rb b/modules/storages/app/components/storages/admin/sidebar/health_notifications_component.rb
index fe19dab2382..a2960c5e693 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
@@ -41,6 +41,10 @@ module Storages
@storage = storage
end
+ def render?
+ storage.automatically_managed?
+ end
+
def notification_status
if storage.health_notifications_enabled?
{ icon: :"bell-slash",
diff --git a/modules/storages/spec/components/storages/admin/sidebar/health_notifications_component_spec.rb b/modules/storages/spec/components/storages/admin/sidebar/health_notifications_component_spec.rb
index 356c435effc..41034f3836b 100644
--- a/modules/storages/spec/components/storages/admin/sidebar/health_notifications_component_spec.rb
+++ b/modules/storages/spec/components/storages/admin/sidebar/health_notifications_component_spec.rb
@@ -31,12 +31,10 @@ require_module_spec_helper
RSpec.describe Storages::Admin::Sidebar::HealthNotificationsComponent, type: :component do
context "when subscribed to email notifications" do
- let(:health_notifications_component) { described_class.new(storage:) }
-
- let(:storage) { build_stubbed(:nextcloud_storage, :with_health_notifications_enabled) }
+ let(:storage) { build_stubbed(:nextcloud_storage, :with_health_notifications_enabled, :as_automatically_managed) }
before do
- render_inline(health_notifications_component)
+ render_inline(described_class.new(storage:))
end
it "renders an unsubscribe option with info" do
@@ -50,12 +48,10 @@ RSpec.describe Storages::Admin::Sidebar::HealthNotificationsComponent, type: :co
end
context "when unsubscribed to email notifications" do
- let(:health_notifications_component) { described_class.new(storage:) }
-
- let(:storage) { build_stubbed(:nextcloud_storage, :with_health_notifications_disabled) }
+ let(:storage) { build_stubbed(:nextcloud_storage, :with_health_notifications_disabled, :as_automatically_managed) }
before do
- render_inline(health_notifications_component)
+ render_inline(described_class.new(storage:))
end
it "renders an unsubscribe option with info" do
@@ -67,4 +63,13 @@ RSpec.describe Storages::Admin::Sidebar::HealthNotificationsComponent, type: :co
expect(page).to have_button("Subscribe")
end
end
+
+ context "with non-automatically managed storage" do
+ let(:storage) { build_stubbed(:nextcloud_storage, :as_not_automatically_managed) }
+
+ it "does not render" do
+ render_inline described_class.new(storage:)
+ expect(page.text).to be_empty
+ end
+ end
end