Skip to content

Commit

Permalink
Merge pull request #16495 from opf/implementation/57028-removal-of-a-…
Browse files Browse the repository at this point in the history
…project-leaves-some-angular-components-as-not-clickable

Implementation/57028 removal of a project leaves some angular components as not clickable
  • Loading branch information
akabiru authored Aug 21, 2024
2 parents f3a0db2 + b01293a commit eb5def9
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
module Settings
module ProjectCustomFields
module ProjectCustomFieldMapping
class RowComponent < Projects::RowComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
class RowComponent < Projects::RowComponent
include OpTurbo::Streamable

def wrapper_uniq_by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,54 +28,68 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<%=
primer_form_with(
model: @project_storage,
url: admin_settings_storage_project_storage_path(id: @project_storage),
data: {
controller: 'disable-when-checked',
'disable-when-checked-reversed-value': true
},
method: :delete
) do |form|
render(Primer::Alpha::Dialog.new(
id: id,
title: nil,
test_selector: id,
size: :large
)) do |dialog|
dialog.with_body do
flex_layout do |layout|
layout.with_row(mb: 3) do
render(Primer::Beta::Heading.new(tag: :h1, text_align: :center)) do
render(Primer::Beta::Octicon.new(icon: :alert, color: :danger, size: :medium))
component_wrapper do
primer_form_with(
model: @project_storage,
url: admin_settings_storage_project_storage_path(id: @project_storage),
data: {
turbo: true,
controller: 'disable-when-checked',
'disable-when-checked-reversed-value': true
},
method: :delete
) do |form|
render(Primer::Alpha::Dialog.new(
id: id,
title: nil,
test_selector: id,
size: :large
)) do |dialog|
dialog.with_body do
flex_layout do |layout|
layout.with_row(mb: 3) do
render(Primer::Beta::Heading.new(tag: :h1, text_align: :center)) do
render(Primer::Beta::Octicon.new(icon: :alert, color: :danger, size: :medium))
end
end
end
layout.with_row(mb: 1) do
render(Primer::Beta::Heading.new(tag: :h2, color: :default, text_align: :center)) do
heading

layout.with_row(mb: 1) do
render(Primer::Beta::Heading.new(tag: :h2, color: :default, text_align: :center)) do
heading
end
end
end
layout.with_row(mb: 2) do
render(Primer::Beta::Text.new(tag: :p, color: :subtle, text_align: :center)) do
text

layout.with_row(mb: 2) do
render(Primer::Beta::Text.new(tag: :p, color: :subtle, text_align: :center)) do
text
end
end

layout.with_row do
render(Primer::Alpha::CheckBox.new(
name: "confirm_delete",
label: confirmation_text,
data: { 'disable-when-checked-target': 'cause' }
))
end
end
layout.with_row do
render(Primer::Alpha::CheckBox.new(
name: "confirm_delete",
label: confirmation_text,
data: { 'disable-when-checked-target': 'cause' }
))
end
end
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' })) do
I18n.t("button_remove")

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,27 @@ def destroy_confirmation_dialog
end

def destroy
result = Storages::ProjectStorages::DeleteService
delete_service = Storages::ProjectStorages::DeleteService
.new(user: current_user, model: @project_storage)
.call

# rubocop:disable Rails/ActionControllerFlashBeforeRender
result.on_success do
flash[:primer_banner] = { message: I18n.t(:notice_successful_delete) }
delete_service.on_success do
update_flash_message_via_turbo_stream(
message: I18n.t(:notice_successful_delete),
full: true, dismiss_scheme: :hide, scheme: :default
)
update_project_list_via_turbo_stream(url_for_action: :index)
end

result.on_failure do |failure|
delete_service.on_failure do |failure|
error = failure.errors.map(&:message).to_sentence
flash[:primer_banner] = { message: t("project_storages.remove_project.deletion_failure_flash", error:), scheme: :danger }
render_error_flash_message_via_turbo_stream(
message: I18n.t("project_storages.remove_project.deletion_failure_flash", error:),
full: true, dismiss_scheme: :hide
)
end
# rubocop:enable Rails/ActionControllerFlashBeforeRender

redirect_to admin_settings_storage_project_storages_path(@storage)
respond_to_with_turbo_streams(status: delete_service.success? ? :ok : :unprocessable_entity)
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ def call
end
end

expect(page).to have_no_selector("dialog")
expect(page).to have_text("Successful deletion.")
expect(page).to have_no_text(project.name)
end
Expand Down

0 comments on commit eb5def9

Please sign in to comment.