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

Replace browser confirmation with danger dialog

Mir Bhatia0b610ddfcfcc
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
index 81536db65fe..233a98b944f 100644
--- a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
@@ -150,17 +150,11 @@ module MeetingAgendaItems
menu.with_item(
label: t(:label_agenda_item_move_to_next),
- href: move_to_next_meeting_agenda_item_path(@meeting_agenda_item.meeting,
+ href: move_to_next_dialog_meeting_agenda_item_path(@meeting_agenda_item.meeting,
@meeting_agenda_item,
datetime: next_date.iso8601),
- form_arguments: {
- method: :post,
- data: {
- confirm: t(:text_agenda_item_move_next_meeting,
- date: format_date(next_date),
- time: format_time(next_date, include_date: false)),
- "turbo-stream": true
- }
+ content_arguments: {
+ data: { controller: "async-dialog" }
}
) do |item|
item.with_leading_visual_icon(icon: "arrow-right")
diff --git a/modules/meeting/app/components/meeting_agenda_items/move_to_next_meeting_dialog_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/move_to_next_meeting_dialog_component.html.erb
new file mode 100644
index 00000000000..c29cc8ef0e7
--- /dev/null
+++ b/modules/meeting/app/components/meeting_agenda_items/move_to_next_meeting_dialog_component.html.erb
@@ -0,0 +1,51 @@
+<%#-- 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.
+
+++#%>
+
+<%=
+ render(
+ Primer::OpenProject::DangerDialog.new(
+ id: "agenda-item-move-to-next-meeting-dialog",
+ confirm_button_text: I18n.t(:label_agenda_item_move),
+ title:,
+ form_arguments: {
+ action: move_to_next_meeting_agenda_item_path(
+ @agenda_item.meeting,
+ @agenda_item,
+ datetime: @datetime
+ ),
+ method: :post
+ }
+ )
+ ) do |dialog|
+ dialog.with_confirmation_message do |message|
+ message.with_heading(tag: :h2) { title }
+ message.with_description_content(confirmation_message)
+ end
+ end
+%>
diff --git a/modules/meeting/app/components/meeting_agenda_items/move_to_next_meeting_dialog_component.rb b/modules/meeting/app/components/meeting_agenda_items/move_to_next_meeting_dialog_component.rb
new file mode 100644
index 00000000000..7fbba6b7cba
--- /dev/null
+++ b/modules/meeting/app/components/meeting_agenda_items/move_to_next_meeting_dialog_component.rb
@@ -0,0 +1,55 @@
+# 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 MeetingAgendaItems
+ class MoveToNextMeetingDialogComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+
+ def initialize(agenda_item:, datetime:)
+ super
+
+ @agenda_item = agenda_item
+ @datetime = datetime
+ end
+
+ private
+
+ def title = I18n.t(:label_agenda_item_move_to_next_title)
+
+ def confirmation_message
+ I18n.t(
+ :text_agenda_item_move_next_meeting,
+ date: format_date(@datetime),
+ time: format_time(@datetime, include_date: false)
+ )
+ end
+ end
+end
diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
index 86303d2f33f..2f8ceb7edb5 100644
--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
@@ -222,6 +222,13 @@ class MeetingAgendaItemsController < ApplicationController
respond_with_turbo_streams
end
+ def move_to_next_meeting_dialog
+ respond_with_dialog MeetingAgendaItems::MoveToNextMeetingDialogComponent.new(
+ agenda_item: @meeting_agenda_item,
+ datetime: params[:datetime]
+ )
+ end
+
def move_to_next_meeting # rubocop:disable Metrics/AbcSize
next_occurrence = init_next_meeting_occurrence
return if next_occurrence.nil?
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index a55a820222d..3c677fb889e 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -487,6 +487,8 @@ en:
label_agenda_item_undisclosed_wp: "Work package #%{id} not visible"
label_agenda_item_deleted_wp: "Deleted work package reference"
label_agenda_item_actions: "Agenda items actions"
+ label_agenda_item_move_to_next_title: "Move to next meeting?"
+ label_agenda_item_move: "Move"
label_agenda_item_move_to_next: "Move to next meeting"
label_agenda_item_move_to_backlog: "Move to backlog"
label_agenda_item_move_to_current_meeting: "Move to current meeting"
@@ -572,7 +574,7 @@ en:
text_add_work_package_to_meeting_description: "A work package can be added to one or multiple meetings for discussion. Any notes concerning it are also visible here."
text_agenda_item_no_notes: "No notes provided"
text_agenda_item_not_editable_anymore: "This agenda item is not editable anymore."
- text_agenda_item_move_next_meeting: "Are you sure you want to move this to the next meeting on %{date} at %{time}?"
+ text_agenda_item_move_next_meeting: "This item will be moved to the next meeting on %{date} at %{time}."
text_agenda_item_moved_to_next_meeting: "Agenda item moved to the next meeting, on %{date}"
text_work_package_has_no_upcoming_meeting_agenda_items: "This work package is not scheduled in an upcoming meeting agenda yet."
text_agenda_item_move_next_meeting_cancelled: "Unable to move to the next meeting since it has been cancelled."
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index a0068f222cf..0078e52fdbd 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -110,6 +110,7 @@ Rails.application.routes.draw do
get :cancel_edit
put :drop
put :move
+ get :move_to_next_dialog, action: :move_to_next_meeting_dialog
post :move_to_next, action: :move_to_next_meeting
end
end
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index 837f146af79..81f9bdd448d 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -85,7 +85,7 @@ module OpenProject::Meeting
{
meetings: %i[change_state],
meeting_agenda_items: %i[new cancel_new create edit cancel_edit update destroy drop move
- move_to_next_meeting],
+ move_to_next_meeting move_to_next_meeting_dialog],
meeting_sections: %i[new cancel_new create edit cancel_edit update destroy drop move
clear_backlog clear_backlog_dialog]
},
diff --git a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_move_to_next_spec.rb b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_move_to_next_spec.rb
index 1ffe5dae530..055cd88a77f 100644
--- a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_move_to_next_spec.rb
+++ b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_move_to_next_spec.rb
@@ -92,9 +92,7 @@ RSpec.describe "Recurring meetings move to next meeting", :js do
it "shows the move to next meeting option" do
meeting_page.expect_agenda_item(title: "Test notes")
- accept_confirm do
- meeting_page.select_action(agenda_item, "Move to next meeting")
- end
+ meeting_page.move_item_to_next_meeting(agenda_item)
expect_and_dismiss_flash(message: "Agenda item moved to the next meeting")
@@ -114,9 +112,7 @@ RSpec.describe "Recurring meetings move to next meeting", :js do
it "shows the move to next meeting option" do
meeting_page.expect_agenda_item(title: "Test notes")
- accept_confirm do
- meeting_page.select_action(agenda_item, "Move to next meeting")
- end
+ meeting_page.move_item_to_next_meeting(agenda_item)
expect(page).to have_text "Unable to move to the next meeting since it has been cancelled."
meeting_page.expect_agenda_item(title: "Test notes")
diff --git a/modules/meeting/spec/support/pages/meetings/show.rb b/modules/meeting/spec/support/pages/meetings/show.rb
index 68535693448..fae3af6fdf7 100644
--- a/modules/meeting/spec/support/pages/meetings/show.rb
+++ b/modules/meeting/spec/support/pages/meetings/show.rb
@@ -224,6 +224,17 @@ module Pages::Meetings
end
end
+ def move_item_to_next_meeting(item)
+ select_action(item, "Move to next meeting")
+ expect_modal("Move to next meeting?")
+
+ retry_block do
+ page.within_modal "Move to next meeting?" do
+ click_on "Move"
+ end
+ end
+ end
+
def open_menu(item, &)
retry_block do
page.within("#meeting-agenda-items-item-component-#{item.id}") do