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 danger dialog for storage removal confirmation
ulfertsc46cb4ddabe4
diff --git a/modules/meeting/spec/components/meetings/delete_dialog_component_spec.rb b/modules/meeting/spec/components/meetings/destroy_confirmation_dialog_component_spec.rbsimilarity index 100%rename from modules/meeting/spec/components/meetings/delete_dialog_component_spec.rbrename to modules/meeting/spec/components/meetings/destroy_confirmation_dialog_component_spec.rbdiff --git a/modules/meeting/spec/components/recurring_meetings/delete_dialog_component_spec.rb b/modules/meeting/spec/components/recurring_meetings/destroy_confirmation_dialog_component_spec.rbsimilarity index 100%rename from modules/meeting/spec/components/recurring_meetings/delete_dialog_component_spec.rbrename to modules/meeting/spec/components/recurring_meetings/destroy_confirmation_dialog_component_spec.rbdiff --git a/modules/storages/app/components/storages/admin/edit_form_header_component.html.erb b/modules/storages/app/components/storages/admin/edit_form_header_component.html.erbindex 840def3ec9b..4ed397f948e 100644--- a/modules/storages/app/components/storages/admin/edit_form_header_component.html.erb+++ b/modules/storages/app/components/storages/admin/edit_form_header_component.html.erb@@ -44,7 +44,7 @@ See COPYRIGHT and LICENSE files for more details.aria: { label: I18n.t("storages.label_delete_storage") },tag: :a,href: confirm_destroy_admin_settings_storage_path(@storage),- data: { "turbo-frame": "_top" },+ data: { "turbo-frame": "_top", controller: "async-dialog" },test_selector: "storage-delete-button") do |button|button.with_leading_visual_icon(icon: :trash)diff --git a/modules/storages/app/components/storages/admin/storages/destroy_confirmation_dialog_component.html.erb b/modules/storages/app/components/storages/admin/storages/destroy_confirmation_dialog_component.html.erbnew file mode 100644index 00000000000..e7306b24fd2--- /dev/null+++ b/modules/storages/app/components/storages/admin/storages/destroy_confirmation_dialog_component.html.erb@@ -0,0 +1,58 @@+<%#-- 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(+ title: I18n.t("storages.page_titles.file_storages.delete"),+ form_arguments:,+ size: :large,+ test_selector: TEST_SELECTOR+ )+ ) do |dialog|+%>+ <% dialog.with_confirmation_message do |message|+ message.with_heading(tag: :h2) { I18n.t("storages.page_titles.file_storages.delete") }+ end %>+ <% dialog.with_additional_details do %>+ <% render(Primer::OpenProject::FlexLayout.new) do |flex| %>+ <% flex.with_row do %>+ <%= t("storages.delete_warning.storage", file_storage: "<strong>#{h(@storage.name)}</strong>").html_safe %>+ <% end %>+ <% flex.with_row do %>+ <ul>+ <li> <%= t("storages.delete_warning.storage_delete_result_1") %>+ <li> <%= t("storages.delete_warning.storage_delete_result_2") %>+ <li> <%= t("storages.delete_warning.storage_delete_result_3") %>+ </ul>+ <% end %>+ <% end %>+ <% end %>+ <% dialog.with_confirmation_check_box_content(I18n.t(:text_permanent_delete_confirmation_checkbox_label)) %>+<% end %>diff --git a/modules/storages/app/components/storages/admin/storages/destroy_confirmation_dialog_component.rb b/modules/storages/app/components/storages/admin/storages/destroy_confirmation_dialog_component.rbnew file mode 100644index 00000000000..7c9d7842342--- /dev/null+++ b/modules/storages/app/components/storages/admin/storages/destroy_confirmation_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.+# ++++# Destroy confirmation dialog used when removing a storage from the system+# by going Administration -> Files.+module Storages+ module Admin+ module Storages+ class DestroyConfirmationDialogComponent < ApplicationComponent+ include OpTurbo::Streamable++ TEST_SELECTOR = "op-storages--destroy-confirm-dialog"++ def initialize(storage:)+ super+ @storage = storage+ end++ def form_arguments+ {+ action: admin_settings_storage_path(@storage),+ method: :delete+ }+ end+ end+ end+ end+enddiff --git a/modules/storages/app/components/storages/project_storages/projects/destroy_confirmation_dialog_component.html.erb b/modules/storages/app/components/storages/project_storages/projects/destroy_confirmation_dialog_component.html.erbnew file mode 100644index 00000000000..629fde84c45--- /dev/null+++ b/modules/storages/app/components/storages/project_storages/projects/destroy_confirmation_dialog_component.html.erb@@ -0,0 +1,57 @@+<%#-- 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(+ title: I18n.t("storages.page_titles.file_storages.delete"),+ form_arguments:,+ size: :large,+ test_selector: TEST_SELECTOR+ )+ ) do |dialog|+%>+ <% dialog.with_confirmation_message do |message|+ message.with_heading(tag: :h2) { I18n.t("storages.page_titles.file_storages.delete") }+ end %>+ <% dialog.with_additional_details do %>+ <% render(Primer::OpenProject::FlexLayout.new) do |flex| %>+ <% flex.with_row do %>+ <%= t("storages.delete_warning.storage", file_storage: "<strong>#{h(@project_storage.storage.name)}</strong>").html_safe %>+ <% end %>+ <% flex.with_row do %>+ <ul>+ <li> <%= t("storages.delete_warning.project_storage_delete_result_1") %>+ <li> <%= t("storages.delete_warning.project_storage_delete_result_2") %>+ </ul>+ <% end %>+ <% end %>+ <% end %>+ <% dialog.with_confirmation_check_box_content(I18n.t(:text_permanent_delete_confirmation_checkbox_label)) %>+<% end %>diff --git a/modules/storages/app/components/storages/project_storages/projects/destroy_confirmation_dialog_component.rb b/modules/storages/app/components/storages/project_storages/projects/destroy_confirmation_dialog_component.rbnew file mode 100644index 00000000000..a14f881810d--- /dev/null+++ b/modules/storages/app/components/storages/project_storages/projects/destroy_confirmation_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.+# ++++# Destroy confirmation dialog used when removing a storage from a project from within the project+# by going to "Some project" -> Project settings -> Files.+module Storages+ module ProjectStorages+ module Projects+ class DestroyConfirmationDialogComponent < ApplicationComponent+ include OpTurbo::Streamable++ TEST_SELECTOR = "op-project-storages--delete-dialog"++ def initialize(storage:)+ super+ @project_storage = storage+ end++ def form_arguments+ {+ action: project_settings_project_storage_path(project_id: @project_storage.project, id: @project_storage),+ method: :delete+ }+ end+ end+ end+ end+enddiff --git a/modules/storages/app/components/storages/project_storages/row_component.rb b/modules/storages/app/components/storages/project_storages/row_component.rbindex a79283c62b5..9abe4413e7b 100644--- a/modules/storages/app/components/storages/project_storages/row_component.rb+++ b/modules/storages/app/components/storages/project_storages/row_component.rb@@ -77,6 +77,7 @@ module Storages::ProjectStoragesconfirm_destroy_project_settings_project_storage_path(project_id: project_storage.project, id: project_storage),class: "icon icon-delete",title: I18n.t(:button_delete),+ data: { controller: "async-dialog" },method: :getendenddiff --git a/modules/storages/app/controllers/storages/admin/project_storages_controller.rb b/modules/storages/app/controllers/storages/admin/project_storages_controller.rbindex 3cc08c667c2..96a4cc13d6c 100644--- a/modules/storages/app/controllers/storages/admin/project_storages_controller.rb+++ b/modules/storages/app/controllers/storages/admin/project_storages_controller.rb@@ -30,6 +30,7 @@class Storages::Admin::ProjectStoragesController < Projects::SettingsControllerinclude Storages::OAuthAccessGrantable+ include OpTurbo::ComponentStreammodel_object Storages::ProjectStorage@@ -59,6 +60,18 @@ class Storages::Admin::ProjectStoragesController < Projects::SettingsControllerrender template: "/storages/project_settings/new"end+ def edit+ @project_storage = @object+ @project_storage.project_folder_mode = project_folder_mode_from_params if project_folder_mode_from_params.present?++ @last_project_folders = Storages::LastProjectFolder+ .where(project_storage: @project_storage)+ .pluck(:mode, :origin_folder_id)+ .to_h++ render "/storages/project_settings/edit"+ end+def createservice_result = ::Storages::ProjectStorages::CreateService.new(user: current_user)@@ -90,18 +103,6 @@ class Storages::Admin::ProjectStoragesController < Projects::SettingsControllerendend- def edit- @project_storage = @object- @project_storage.project_folder_mode = project_folder_mode_from_params if project_folder_mode_from_params.present?-- @last_project_folders = Storages::LastProjectFolder- .where(project_storage: @project_storage)- .pluck(:mode, :origin_folder_id)- .to_h-- render "/storages/project_settings/edit"- end-def updateservice_result = ::Storages::ProjectStorages::UpdateService.new(user: current_user, model: @object)@@ -127,9 +128,7 @@ class Storages::Admin::ProjectStoragesController < Projects::SettingsControllerenddef destroy_info- @project_storage_to_destroy = @object-- render "/storages/project_settings/destroy_info"+ respond_with_dialog Storages::ProjectStorages::Projects::DestroyConfirmationDialogComponent.new(storage: @object)endprivatediff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rbindex f9b49cc2cd4..68435f6bf47 100644--- a/modules/storages/app/controllers/storages/admin/storages_controller.rb+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb@@ -176,7 +176,7 @@ module Storagesenddef confirm_destroy- @storage_to_destroy = @storage+ respond_with_dialog Storages::DestroyConfirmationDialogComponent.new(storage: @storage)enddef destroydiff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex ebee1159ee5..64108671a5e 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -207,7 +207,7 @@ en:project_storage: 'Are you sure you want to delete %{file_storage} from this project? To confirm this action please introduce the storage name in the field below, this will:'project_storage_delete_result_1: Remove all links from work packages of this project to files and folders of that storage.project_storage_delete_result_2: In case this storage has an automatically managed project folder, this and its files will be deleted forever.- storage: 'Are you sure you want to delete %{file_storage}? To confirm this action please introduce the storage name in the field below, this will:'+ storage: 'Are you sure you want to delete %{file_storage}? This will:'storage_delete_result_1: Remove all storage setups for all projects using this storage.storage_delete_result_2: Remove all links from work packages of all projects to files and folders of that storage.storage_delete_result_3: In case this storage has automatically managed project folders, those and their contained files will be deleted forever.diff --git a/modules/storages/spec/features/delete_project_storage_and_file_links_spec.rb b/modules/storages/spec/features/delete_project_storage_and_file_links_spec.rbindex 4ccf43b21b7..4fa17a019ce 100644--- a/modules/storages/spec/features/delete_project_storage_and_file_links_spec.rb+++ b/modules/storages/spec/features/delete_project_storage_and_file_links_spec.rb@@ -70,30 +70,32 @@ RSpec.describe "Delete ProjectStorage with FileLinks", :js, :webmock do# The list of enabled file storages should now contain Storage 1expect(page).to have_heading "Files"- expect(page).to have_text("Storage 1")+ expect(page).to have_text(storage.name)# Press Delete icon to remove the storage from the projectpage.find(".icon.icon-delete").click# Danger zone confirmation flow- expect(page).to have_css(".form--section-title", text: "DELETE FILE STORAGE")- expect(page).to have_css(".danger-zone--warning", text: "Deleting a file storage is an irreversible action.")- expect(page).to have_button("Delete", disabled: true)+ within_test_selector("op-project-storages--delete-dialog") do+ expect(page).to have_text("Delete file storage")+ expect(page).to have_unchecked_field("I understand that this deletion cannot be reversed")+ expect(page).to have_button("Delete permanently", disabled: true)++ # Cancel Confirmation+ page.click_button("Cancel")+ end- # Cancel Confirmation- page.click_link("Cancel")expect(page).to have_current_path external_file_storages_project_settings_project_storages_path(project)+ expect(page).to have_text(storage.name)+ # Press Delete icon to remove the storage from the projectpage.find(".icon.icon-delete").click- # wait for danger zone form to be somewhat "ready" (not sure why, but- # without it the input field filled on next line may be cleared out due to a- # race condition I do not understand)- sleep(0.2)-- # Approve Confirmation- page.fill_in "delete_confirmation", with: storage.name- page.click_button("Delete")+ within_test_selector("op-project-storages--delete-dialog") do+ # Approve Confirmation+ page.check "I understand that this deletion cannot be reversed"+ page.click_button("Delete permanently")+ end# List of ProjectStorages empty againexpect(page).to have_current_path external_file_storages_project_settings_project_storages_path(project)@@ -102,5 +104,6 @@ RSpec.describe "Delete ProjectStorage with FileLinks", :js, :webmock do# Also check in the database that ProjectStorage and dependent FileLinks are goneexpect(Storages::ProjectStorage.count).to be 0expect(Storages::FileLink.count).to be 0+ expect(Storages::Storage.where(id: storage.id).count).to be 1endenddiff --git a/modules/storages/spec/features/manage_project_storage_spec.rb b/modules/storages/spec/features/manage_project_storage_spec.rbindex 7d9b73899fa..b93f37ba54a 100644--- a/modules/storages/spec/features/manage_project_storage_spec.rb+++ b/modules/storages/spec/features/manage_project_storage_spec.rb@@ -177,27 +177,29 @@ RSpec.describe("Activation of storages in projects",# Press Delete icon to remove the storage from the projectpage.find(".icon.icon-delete").click- # Danger zone confirmation flow- expect(page).to have_css(".form--section-title", text: "DELETE FILE STORAGE")- expect(page).to have_css(".danger-zone--warning", text: "Deleting a file storage is an irreversible action.")- expect(page).to have_button("Delete", disabled: true)+ within_test_selector("op-project-storages--delete-dialog") do+ expect(page).to have_text("Delete file storage")+ expect(page).to have_unchecked_field("I understand that this deletion cannot be reversed")+ expect(page).to have_button("Delete permanently", disabled: true)++ # Cancel Confirmation+ page.click_button("Cancel")+ end- # Cancel Confirmation- page.click_on("Cancel")expect(page).to have_current_path external_file_storages_project_settings_project_storages_path(project)+ expect(page).to have_text(storage.name)page.find(".icon.icon-delete").click- expect(page).to have_css(".form--section-title", text: "DELETE FILE STORAGE")-- # Approve Confirmation- page.fill_in "delete_confirmation", with: storage.name- expect(page).to have_button("Delete", disabled: false)- page.click_on("Delete")+ within_test_selector("op-project-storages--delete-dialog") do+ # Approve Confirmation+ page.check "I understand that this deletion cannot be reversed"+ page.click_button("Delete permanently")+ end# List of ProjectStorages empty again+ expect(page).to have_text(I18n.t("storages.no_results"))expect(page).to have_current_path external_file_storages_project_settings_project_storages_path(project)- expect(page).to have_content(I18n.t("storages.no_results"))enddescribe "automatic project folder mode" dodiff --git a/modules/storages/spec/features/storages/admin/edit_storage_spec.rb b/modules/storages/spec/features/storages/admin/edit_storage_spec.rbindex 679944e07c4..4baed1aeb77 100644--- a/modules/storages/spec/features/storages/admin/edit_storage_spec.rb+++ b/modules/storages/spec/features/storages/admin/edit_storage_spec.rb@@ -45,14 +45,14 @@ RSpec.describe "Admin Edit File storage",page.find_test_selector("storage-delete-button").click- expect(page).to have_text("DELETE FILE STORAGE")- expect(page).to have_current_path(confirm_destroy_admin_settings_storage_path(storage))- storage_delete_button = page.find_button("Delete", disabled: true)+ within_test_selector("op-storages--destroy-confirm-dialog") do+ expect(page).to have_text("Delete file storage")+ expect(page).to have_unchecked_field("I understand that this deletion cannot be reversed")+ expect(page).to have_button("Delete permanently", disabled: true)- fill_in("delete_confirmation", with: "Foo Nextcloud")- expect(storage_delete_button).not_to be_disabled-- storage_delete_button.click+ page.check("I understand that this deletion cannot be reversed")+ page.click_button("Delete permanently")+ endexpect(page).to have_no_text("Foo Nextcloud")expect(page).to have_text("Successful deletion.")diff --git a/modules/storages/spec/features/storages/admin/project_storages_spec.rb b/modules/storages/spec/features/storages/admin/project_storages_spec.rbindex 9aaadb7da30..ea2ae066e98 100644--- a/modules/storages/spec/features/storages/admin/project_storages_spec.rb+++ b/modules/storages/spec/features/storages/admin/project_storages_spec.rb@@ -181,8 +181,11 @@ RSpec.describe "Admin lists project mappings for a storage",it "links to the delete page of a storage" dopage.find_test_selector("storage-delete-button").click- expect(page).to have_text("DELETE FILE STORAGE")- expect(page).to have_current_path(confirm_destroy_admin_settings_storage_path(storage))+ within_test_selector("op-storages--destroy-confirm-dialog") do+ expect(page).to have_text("Delete file storage")+ expect(page).to have_unchecked_field("I understand that this deletion cannot be reversed")+ expect(page).to have_button("Delete permanently", disabled: true)+ endenddescribe "Linking a project to a storage with a manually managed folder" dodiff --git a/spec/components/projects/delete_dialog_component_spec.rb b/spec/components/projects/destroy_confirmation_dialog_component_spec.rbsimilarity index 100%rename from spec/components/projects/delete_dialog_component_spec.rbrename to spec/components/projects/destroy_confirmation_dialog_component_spec.rb