Skip to content

Commit

Permalink
Merge pull request #17836 from opf/housekeeping/61185-replace-storage…
Browse files Browse the repository at this point in the history
…-deletion-dialog-with-new-dangerdialog

[61185] Replace storage deletion dialog with new DangerDialog
  • Loading branch information
HDinger authored Feb 5, 2025
2 parents ed3d677 + 1c9ee50 commit 2e92b26
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,54 +28,25 @@ See COPYRIGHT and LICENSE files for more details.
++#%>

<%=
component_wrapper do
primer_form_with(
model: @project_storage,
url: admin_settings_storage_project_storage_path(id: @project_storage, page: current_page),
data: {
turbo: true,
controller: 'disable-when-checked',
'disable-when-checked-reversed-value': true
},
method: :delete
) do |form|
render(Primer::OpenProject::FeedbackDialog.new(
id:,
title:,
test_selector: id,
size: :large
)) do |dialog|
dialog.with_feedback_message(icon_arguments: { icon: :alert, color: :danger }) do |message|
message.with_heading(tag: :h2) { heading }
message.with_description { text }
end

dialog.with_additional_details do
render(Primer::Alpha::CheckBox.new(
name: "confirm_delete",
label: confirmation_text,
data: { 'disable-when-checked-target': 'cause' }
))
end

dialog.with_footer do
component_collection do |footer|
footer.with_component(Primer::ButtonComponent.new(data: { "close-dialog-id": id })) do
I18n.t("button_close")
end

footer.with_component(
Primer::ButtonComponent.new(scheme: :danger, type: :submit,
test_selector: "remove-project-storage-button",
disabled: true,
data: {
"disable-when-checked-target": "effect",
"close-dialog-id": id
})
) { I18n.t("button_remove") }
end
end
end
render(Primer::OpenProject::DangerDialog.new(
id:,
title:,
test_selector: id,
size: :large,
form_arguments: {
model: @project_storage,
action: admin_settings_storage_project_storage_path(id: @project_storage, page: current_page),
data: {
turbo: true
},
method: :delete
},
confirm_button_text: I18n.t("button_remove")
)) do |dialog|
dialog.with_confirmation_message do |message|
message.with_heading(tag: :h2) { heading }
message.with_description_content(text)
end
dialog.with_confirmation_check_box_content(confirmation_text)
end
%>
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def call
page.within("dialog") do
expect(page).to have_text("Remove project from #{storage.name}")
expect(page).to have_text("this storage has an automatically managed project folder")
click_on "Close"
click_on "Cancel"
end

expect(page).to have_text(project.name)
Expand Down Expand Up @@ -393,7 +393,7 @@ def call
page.within("dialog") do
expect(page).to have_button("Remove", disabled: true)
Retryable.repeat_until_success do
check "Please, confirm you understand and want to remove this file storage from this project"
check "Please, confirm you understand and want to remove this file storage from this project", allow_label_click: true
expect(page).to have_button("Remove", disabled: false) # ensure button is clickable
click_on "Remove"
end
Expand Down

0 comments on commit 2e92b26

Please sign in to comment.