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

Hide "send invite" action conditionally

Mir Bhatia2c66af839a49
diff --git a/modules/meeting/app/components/meetings/header_component.rb b/modules/meeting/app/components/meetings/header_component.rb
index fb3aa044720..1368320d544 100644
--- a/modules/meeting/app/components/meetings/header_component.rb
+++ b/modules/meeting/app/components/meetings/header_component.rb
@@ -75,7 +75,7 @@ module Meetings
def send_emails?
- @meeting.notify &&
+ @meeting.notify? &&
User.current.allowed_in_project?(:send_meeting_invites_and_outcomes, @meeting.project)
end
diff --git a/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb b/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb
index 44f493935f3..958977cfccf 100644
--- a/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb
+++ b/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb
@@ -39,12 +39,14 @@
item.with_leading_visual_icon(icon: :calendar)
end
- menu.with_item(
- label: t("meeting.label_mail_all_participants"),
- href: notify_project_recurring_meeting_path(@project, @meeting),
- form_arguments: { method: :post }
- ) do |item|
- item.with_leading_visual_icon(icon: :mail)
+ if send_emails?
+ menu.with_item(
+ label: t("meeting.label_mail_all_participants"),
+ href: notify_project_recurring_meeting_path(@project, @meeting),
+ form_arguments: { method: :post }
+ ) do |item|
+ item.with_leading_visual_icon(icon: :mail)
+ end
end
if [email protected]_ended? && @meeting.start_time.to_date < Time.zone.today
diff --git a/modules/meeting/app/components/recurring_meetings/show_page_header_component.rb b/modules/meeting/app/components/recurring_meetings/show_page_header_component.rb
index 5813be8ffc1..69f10958854 100644
--- a/modules/meeting/app/components/recurring_meetings/show_page_header_component.rb
+++ b/modules/meeting/app/components/recurring_meetings/show_page_header_component.rb
@@ -49,6 +49,11 @@ module RecurringMeetings
end
end
+ def send_emails?
+ @meeting.notify? &&
+ User.current.allowed_in_project?(:send_meeting_invites_and_outcomes, @meeting.project)
+ end
+
def dynamic_path
polymorphic_path([:new, @project, :recurring_meeting])
end
diff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rb
index 150e5014297..03c73358a52 100644
--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb
@@ -222,8 +222,12 @@ class RecurringMeetingsController < ApplicationController
end
def notify
- deliver_invitation_mails
- flash[:notice] = I18n.t(:notice_successful_notification)
+ if deliver_invitation_mails == false
+ flash[:error] = I18n.t(:error_notification)
+ else
+ flash[:notice] = I18n.t(:notice_successful_notification)
+ end
+
redirect_to action: :show
end
@@ -246,7 +250,7 @@ class RecurringMeetingsController < ApplicationController
end
def deliver_invitation_mails
- return unless @recurring_meeting.template.notify?
+ return false unless @recurring_meeting.template.notify?
@recurring_meeting
.template
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index cf47223a922..1471edf0be6 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -115,6 +115,7 @@ en:
meeting_minutes: Meeting minutes edited
meeting_minutes_created: Meeting minutes created
+ error_notification: "Failed to send notification."
error_notification_with_errors: "Failed to send notification. The following recipients could not be notified: %{recipients}"
label_meeting: "Meeting"