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
Use component in meetings
Mir Bhatia56286d4caeda
diff --git a/modules/meeting/app/components/meetings/side_panel/notifications_button_component.rb b/modules/meeting/app/components/meetings/side_panel/notifications_button_component.rbdeleted file mode 100644index 1c6cd17b1d9..00000000000--- a/modules/meeting/app/components/meetings/side_panel/notifications_button_component.rb+++ /dev/null@@ -1,75 +0,0 @@-# frozen_string_literal: true--#-- 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 Meetings- class SidePanel::NotificationsButtonComponent < ApplicationComponent- include ApplicationHelper- include OpTurbo::Streamable- include OpPrimer::ComponentHelpers-- def initialize(meeting:)- super-- @meeting = meeting- @project = meeting.project- end-- private-- def key- @key ||= @meeting.notify? ? "enabled" : "disabled"- end-- def state- I18n.t("meeting.notifications.sidepanel.state.#{key}")- end-- def description- I18n.t("meeting.notifications.sidepanel.description.#{key}")- end-- def additional_text- I18n.t("meeting.notifications.sidepanel.description.change_via_template")- end-- def button_label- label_key = @meeting.notify? ? "disable" : "enable"- I18n.t("meeting.notifications.sidepanel.button.#{label_key}")- end-- def button_icon- @meeting.notify? ? :"bell-slash" : :bell- end-- def show_button?- [email protected]? || @meeting.templated?- end- end-enddiff --git a/modules/meeting/app/components/meetings/side_panel_component.html.erb b/modules/meeting/app/components/meetings/side_panel_component.html.erbindex dcb1352159d..1efea7baf4b 100644--- a/modules/meeting/app/components/meetings/side_panel_component.html.erb+++ b/modules/meeting/app/components/meetings/side_panel_component.html.erb@@ -4,7 +4,7 @@panel.with_section(Meetings::SidePanel::DetailsComponent.new(meeting: @meeting))if @meeting.editable?- panel.with_section(Meetings::SidePanel::NotificationsButtonComponent.new(meeting: @meeting))+ panel.with_section(email_updates_switch)endunless @meeting.template?diff --git a/modules/meeting/app/components/meetings/side_panel_component.rb b/modules/meeting/app/components/meetings/side_panel_component.rbindex 087e88d8d73..0148b031c93 100644--- a/modules/meeting/app/components/meetings/side_panel_component.rb+++ b/modules/meeting/app/components/meetings/side_panel_component.rb@@ -38,5 +38,19 @@ module Meetings@meeting = meetingend++ private++ def email_updates_switch+ OpPrimer::EmailUpdatesSwitchComponent.new(+ toggle: @meeting.notify?,+ path: toggle_notifications_dialog_project_meeting_path(@meeting.project, @meeting),+ title: I18n.t("meeting.notifications.sidepanel.title"),+ enabled_description: I18n.t("meeting.notifications.sidepanel.description.enabled"),+ disabled_description: I18n.t("meeting.notifications.sidepanel.description.disabled"),+ alt_text: I18n.t("meeting.notifications.sidepanel.description.change_via_template"),+ show_button: [email protected]? || @meeting.templated?+ )+ endendenddiff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rbindex baa4c07308e..15ef352a22f 100644--- a/modules/meeting/app/controllers/meetings_controller.rb+++ b/modules/meeting/app/controllers/meetings_controller.rb@@ -345,7 +345,7 @@ class MeetingsController < ApplicationControllerenddef toggle_notifications- @meeting.update!(notify: [email protected])+ @meeting.toggle!(:notify)if @meeting.notify?handle_notification(type: :toggle_notifications)diff --git a/modules/meeting/spec/features/meeting_notifications_spec.rb b/modules/meeting/spec/features/meeting_notifications_spec.rbindex fc955a2565c..bf1485b44b8 100644--- a/modules/meeting/spec/features/meeting_notifications_spec.rb+++ b/modules/meeting/spec/features/meeting_notifications_spec.rb@@ -99,7 +99,7 @@ RSpec.describe "Meeting notifications", :js doshow_page.visit!# check calendar updates sidepanel component- page.within("[data-test-selector='notifications-button']") do+ page.within("[data-test-selector='email-updates-switch']") doexpect(page).to have_text("Email calendar updates")expect(page).to have_text("Enabled.")expect(page).to have_text("All participants will receive updated calendar invites via email informing them of changes.")@@ -125,7 +125,7 @@ RSpec.describe "Meeting notifications", :js doActionMailer::Base.deliveries.clear# disable updates from the sidepanel- page.within("[data-test-selector='notifications-button']") do+ page.within("[data-test-selector='email-updates-switch']") doclick_on "Disable"end@@ -139,7 +139,7 @@ RSpec.describe "Meeting notifications", :js do# check that updates are now disabledexpect(meeting.reload.notify).to be false- page.within("[data-test-selector='notifications-button']") do+ page.within("[data-test-selector='email-updates-switch']") doexpect(page).to have_text("Email calendar updates")expect(page).to have_text("Disabled.")expect(page).to have_text("Participants will not receive an email informing them of changes.")@@ -259,7 +259,7 @@ RSpec.describe "Meeting notifications", :js dotemplate_page.visit!# check sidepanel component- page.within("[data-test-selector='notifications-button']") do+ page.within("[data-test-selector='email-updates-switch']") doexpect(page).to have_text("Email calendar updates")expect(page).to have_text("Enabled.")expect(page).to have_text("All participants will receive updated calendar invites via email informing them of changes.")@@ -289,7 +289,7 @@ RSpec.describe "Meeting notifications", :js do# switch to occurrence and check sidepanel componentoccurrence_page.visit!- page.within("[data-test-selector='notifications-button']") do+ page.within("[data-test-selector='email-updates-switch']") doexpect(page).to have_text("Email calendar updates")expect(page).to have_text("Enabled.")expect(page).to have_text("All participants will receive updated calendar invites via email informing them of changes.")@@ -320,7 +320,7 @@ RSpec.describe "Meeting notifications", :js do# turn off updates from the templatetemplate_page.visit!- page.within("[data-test-selector='notifications-button']") do+ page.within("[data-test-selector='email-updates-switch']") doclick_on "Disable"end@@ -336,7 +336,7 @@ RSpec.describe "Meeting notifications", :js do# check that this is reflected for occurrences toooccurrence_page.visit!- page.within("[data-test-selector='notifications-button']") do+ page.within("[data-test-selector='email-updates-switch']") doexpect(page).to have_text("Email calendar updates")expect(page).to have_text("Disabled.")expect(page).to have_text("Participants will not receive an email informing them of changes.")@@ -371,7 +371,7 @@ RSpec.describe "Meeting notifications", :js doit "does not show the sidebar component" doshow_page.visit!- expect(page).to have_no_css("[data-test-selector='notifications-button']")+ expect(page).to have_no_css("[data-test-selector='email-updates-switch']")endend@@ -392,7 +392,7 @@ RSpec.describe "Meeting notifications", :js doit "does not show the sidebar component" doshow_page.visit!- expect(page).to have_no_css("[data-test-selector='notifications-button']")+ expect(page).to have_no_css("[data-test-selector='email-updates-switch']")endendend