Skip to content

Commit

Permalink
Merge pull request #16843 from opf/bug/58142-update-storage-banners-t…
Browse files Browse the repository at this point in the history
…o-render-with-rounded-borders

[#58142] Update banners to render overlayed flash with rounded borders
  • Loading branch information
akabiru authored Sep 30, 2024
2 parents b588816 + 46312dd commit 16fef22
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ def create
create_service.on_success { render_project_list(url_for_action: :index) }

create_service.on_failure do
update_flash_message_via_turbo_stream(
message: join_flash_messages(create_service.errors),
full: true, dismiss_scheme: :hide, scheme: :danger
render_error_flash_message_via_turbo_stream(
message: join_flash_messages(create_service.errors)
)
end

Expand All @@ -82,9 +81,8 @@ def destroy
delete_service.on_success { render_project_list(url_for_action: :index) }

delete_service.on_failure do
update_flash_message_via_turbo_stream(
message: join_flash_messages(delete_service.errors.full_messages),
full: true, dismiss_scheme: :hide, scheme: :danger
render_error_flash_message_via_turbo_stream(
message: join_flash_messages(delete_service.errors.full_messages)
)
end

Expand Down Expand Up @@ -139,15 +137,6 @@ def find_custom_field_project_to_destroy
respond_with_project_not_found_turbo_streams
end

def update_project_list_via_turbo_stream(url_for_action: action_name)
update_via_turbo_stream(
component: Admin::CustomFields::CustomFieldProjects::TableComponent.new(
query: available_custom_fields_projects_query,
params: { custom_field: @custom_field, url_for_action: }
)
)
end

def available_custom_fields_projects_query
@available_custom_fields_projects_query = ProjectQuery.new(
name: "custom-fields-projects-#{@custom_field.id}"
Expand All @@ -166,9 +155,8 @@ def initialize_custom_field_project
end

def respond_with_project_not_found_turbo_streams
update_flash_message_via_turbo_stream message: t(:notice_project_not_found), full: true, dismiss_scheme: :hide,
scheme: :danger
update_project_list_via_turbo_stream
render_error_flash_message_via_turbo_stream message: t(:notice_project_not_found)
render_project_list(url_for_action: :index)

respond_with_turbo_streams
end
Expand Down
27 changes: 8 additions & 19 deletions app/controllers/admin/settings/project_custom_fields_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ def link
create_service.on_success { render_project_list(url_for_action: :project_mappings) }

create_service.on_failure do
update_flash_message_via_turbo_stream(
message: join_flash_messages(create_service.errors),
full: true, dismiss_scheme: :hide, scheme: :danger
render_error_flash_message_via_turbo_stream(
message: join_flash_messages(create_service.errors)
)
end

Expand All @@ -106,9 +105,8 @@ def unlink
delete_service.on_success { render_project_list(url_for_action: :project_mappings) }

delete_service.on_failure do
update_flash_message_via_turbo_stream(
message: join_flash_messages(delete_service.errors.full_messages),
full: true, dismiss_scheme: :hide, scheme: :danger
render_error_flash_message_via_turbo_stream(
message: join_flash_messages(delete_service.errors.full_messages)
)
end

Expand Down Expand Up @@ -184,15 +182,8 @@ def find_unlink_project_custom_field_mapping
project_id: permitted_params.project_custom_field_project_mapping[:project_id]
)
rescue ActiveRecord::RecordNotFound
update_flash_message_via_turbo_stream(
message: t(:notice_file_not_found), full: true, dismiss_scheme: :hide, scheme: :danger
)
replace_via_turbo_stream(
component: Settings::ProjectCustomFields::ProjectCustomFieldMapping::TableComponent.new(
query: project_custom_field_mappings_query,
params: { custom_field: @custom_field }
)
)
render_error_flash_message_via_turbo_stream(message: t(:notice_file_not_found))
render_project_list(url_for_action: :project_mappings)

respond_with_turbo_streams
end
Expand All @@ -213,10 +204,8 @@ def find_custom_field_projects_to_link
false
end
rescue ActiveRecord::RecordNotFound
update_flash_message_via_turbo_stream(
message: t(:notice_project_not_found), full: true, dismiss_scheme: :hide, scheme: :danger
)
render_project_list
render_error_flash_message_via_turbo_stream(message: t(:notice_project_not_found))
render_project_list(url_for_action: :project_mappings)

respond_with_turbo_streams
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,15 @@ def destroy

delete_service.on_success do
update_flash_message_via_turbo_stream(
message: I18n.t(:notice_successful_delete),
full: true, dismiss_scheme: :hide, scheme: :success
message: I18n.t(:notice_successful_delete), scheme: :success
)
update_project_list_via_turbo_stream(url_for_action: :index)
end

delete_service.on_failure do |failure|
error = failure.errors.map(&:message).to_sentence
render_error_flash_message_via_turbo_stream(
message: I18n.t("project_storages.remove_project.deletion_failure_flash", error:),
full: true, dismiss_scheme: :hide
message: I18n.t("project_storages.remove_project.deletion_failure_flash", error:)
)
end

Expand All @@ -151,9 +149,7 @@ def destroy
def load_project_storage
@project_storage = Storages::ProjectStorage.find(params[:id])
rescue ActiveRecord::RecordNotFound
update_flash_message_via_turbo_stream(
message: t(:notice_file_not_found), full: true, dismiss_scheme: :hide, scheme: :danger
)
render_error_flash_message_via_turbo_stream(message: t(:notice_file_not_found))
update_project_list_via_turbo_stream

respond_with_turbo_streams
Expand All @@ -175,8 +171,7 @@ def find_projects_to_activate_for_storage
respond_with_turbo_streams
end
rescue ActiveRecord::RecordNotFound
update_flash_message_via_turbo_stream message: t(:notice_project_not_found), full: true, dismiss_scheme: :hide,
scheme: :danger
render_error_flash_message_via_turbo_stream(message: t(:notice_project_not_found))
update_project_list_via_turbo_stream

respond_with_turbo_streams
Expand Down Expand Up @@ -214,11 +209,8 @@ def include_sub_projects?
def ensure_storage_configured!
return if @storage.configured?

update_flash_message_via_turbo_stream(
message: I18n.t("storages.enabled_in_projects.setup_incomplete_description"),
full: true,
dismiss_scheme: :hide,
scheme: :danger
render_error_flash_message_via_turbo_stream(
message: I18n.t("storages.enabled_in_projects.setup_incomplete_description")
)
respond_with_turbo_streams
false
Expand Down

0 comments on commit 16fef22

Please sign in to comment.