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
Rename to OpPrimer::FlashComponent / primerized_flash
Oliver Günther0923b625a8e4
diff --git a/app/components/op_primer/banner_message_component.html.erb b/app/components/op_primer/flash_component.erbsimilarity index 96%rename from app/components/op_primer/banner_message_component.html.erbrename to app/components/op_primer/flash_component.erbindex 0f7373dba3c..63c0bcfec36 100644--- a/app/components/op_primer/banner_message_component.html.erb+++ b/app/components/op_primer/flash_component.erb@@ -27,6 +27,6 @@ See COPYRIGHT and LICENSE files for more details.++#%>-<div class="op-primer-banner--item">+<div class="op-primer-flash--item"><%= render_parent %></div>diff --git a/app/components/op_primer/banner_message_component.rb b/app/components/op_primer/flash_component.rbsimilarity index 96%rename from app/components/op_primer/banner_message_component.rbrename to app/components/op_primer/flash_component.rbindex 82685bb4231..24fa22fcbb2 100644--- a/app/components/op_primer/banner_message_component.rb+++ b/app/components/op_primer/flash_component.rb@@ -27,7 +27,7 @@#++module OpPrimer- class BannerMessageComponent < Primer::Alpha::Banner+ class FlashComponent < Primer::Alpha::Bannerinclude ApplicationHelperinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpersdiff --git a/app/controllers/concerns/op_turbo/component_stream.rb b/app/controllers/concerns/op_turbo/component_stream.rbindex 7e77a32c0c2..125a26975e8 100644--- a/app/controllers/concerns/op_turbo/component_stream.rb+++ b/app/controllers/concerns/op_turbo/component_stream.rb@@ -77,7 +77,7 @@ module OpTurboupdate_flash_message_via_turbo_stream(**kwargs.merge(scheme: :danger, icon: :stop))end- def update_flash_message_via_turbo_stream(message:, component: OpPrimer::BannerMessageComponent, **)+ def update_flash_message_via_turbo_stream(message:, component: OpPrimer::FlashComponent, **)instance = component.new(**).with_content(message)turbo_streams << instance.render_as_turbo_stream(view_context:, action: :flash)enddiff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rbindex f3faf5b83ae..e26217385d0 100644--- a/app/controllers/my_controller.rb+++ b/app/controllers/my_controller.rb@@ -174,13 +174,13 @@ class MyController < ApplicationController# rubocop:disable Rails/ActionControllerFlashBeforeRenderresult.on_success do- flash[:primer_banner] = { message: t("my.access_token.notice_api_token_revoked") }+ flash[:op_primer_flash] = { message: t("my.access_token.notice_api_token_revoked") }endresult.on_failure do |r|error = r.errors.map(&:message).join("; ")Rails.logger.error("Failed to revoke api token ##{current_user.id}: #{error}")- flash[:primer_banner] = { message: t("my.access_token.failed_to_revoke_token", error:), scheme: :danger }+ flash[:op_primer_flash] = { message: t("my.access_token.failed_to_revoke_token", error:), scheme: :danger }end# rubocop:enable Rails/ActionControllerFlashBeforeRenderdiff --git a/app/helpers/flash_messages_helper.rb b/app/helpers/flash_messages_helper.rbindex 71c86c969b6..0e8b668c935 100644--- a/app/helpers/flash_messages_helper.rb+++ b/app/helpers/flash_messages_helper.rb@@ -37,7 +37,7 @@ module FlashMessagesHelper# Renders flash messagesdef render_flash_messagesmessages = flash- .reject { |k, _| k.to_s == "primer_banner" }+ .reject { |k, _| k.to_s == "op_primer_flash" }.reject { |k, _| k.start_with? "_" }.map do |k, v|if k.to_sym == :modaldiff --git a/app/helpers/banner_messages_helper.rb b/app/helpers/primerized_flash_helper.rbsimilarity index 85%rename from app/helpers/banner_messages_helper.rbrename to app/helpers/primerized_flash_helper.rbindex 4e6aa0e3545..ffe46356ab3 100644--- a/app/helpers/banner_messages_helper.rb+++ b/app/helpers/primerized_flash_helper.rb@@ -27,16 +27,16 @@#++#-module BannerMessagesHelper+module PrimerizedFlashHelperextend ActiveSupport::Concern- def render_primer_banner_message- return if flash[:primer_banner].blank?+ def render_primerized_flash+ return if flash[:op_primer_flash].blank?- system_arguments = flash[:primer_banner]+ system_arguments = flash[:op_primer_flash]message = system_arguments.delete(:message)- render(OpPrimer::BannerMessageComponent.new(**system_arguments)) do+ render(OpPrimer::FlashComponent.new(**system_arguments)) domessageendenddiff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erbindex 19c1006cd18..2e26596043a 100644--- a/app/views/layouts/base.html.erb+++ b/app/views/layouts/base.html.erb@@ -117,12 +117,12 @@ See COPYRIGHT and LICENSE files for more details.<% end %><div class="content-overlay"></div><main id="content-wrapper" class="<%= initial_classes %>">- <%# Banner messages are being rendered using primer %>- <div id="banner-messages" class="op-primer-banner">- <%= render_primer_banner_message %>+ <%# Primerized flash messages are being rendered separately %>+ <div id="primerized-flash-messages" class="op-primer-flash">+ <%= render_primerized_flash %></div><%# Banner messages are being rendered using primer %>- <div id="banner-messages" class="op-primer-banner"></div>+ <div id="primerized-flash-messages" class="op-primer-flash"></div><%# Flash messages are being rendered using the old op-flash style %><turbo-frame id="flash-messages"><%= render_flash_messages %>diff --git a/frontend/src/global_styles/primer/_banners.sass b/frontend/src/global_styles/primer/_flash.sasssimilarity index 93%rename from frontend/src/global_styles/primer/_banners.sassrename to frontend/src/global_styles/primer/_flash.sassindex 90dc71bb786..73ea1438690 100644--- a/frontend/src/global_styles/primer/_banners.sass+++ b/frontend/src/global_styles/primer/_flash.sass@@ -26,12 +26,12 @@// See COPYRIGHT and LICENSE files for more details.//++-$op-primer-banner-toaster-width: 80%+$op-primer-flash-toaster-width: 80%-.op-primer-banner+.op-primer-flashz-index: 599position: absolute- max-width: $op-primer-banner-toaster-width+ max-width: $op-primer-flash-toaster-widthmargin: 0 autoleft: 10%right: 10%diff --git a/frontend/src/global_styles/primer/_index.sass b/frontend/src/global_styles/primer/_index.sassindex 05cc6f6ffcb..587dc8f8a00 100644--- a/frontend/src/global_styles/primer/_index.sass+++ b/frontend/src/global_styles/primer/_index.sass@@ -1,3 +1,3 @@@import icons@import overrides-@import banners+@import flashdiff --git a/frontend/src/turbo/flash-stream-action.ts b/frontend/src/turbo/flash-stream-action.tsindex 725959bd31b..4a0ebe430b3 100644--- a/frontend/src/turbo/flash-stream-action.ts+++ b/frontend/src/turbo/flash-stream-action.ts@@ -3,7 +3,7 @@ import { StreamActions, StreamElement } from '@hotwired/turbo';export function registerFlashStreamAction() {StreamActions.flash = function dialogStreamAction(this:StreamElement) {const content = this.templateElement.content;- const target = document.getElementById('banner-messages') as HTMLElement;+ const target = document.getElementById('primerized-flash-messages') as HTMLElement;target.innerHTML = '';target.append(content);};diff --git a/lookbook/docs/patterns/08-flash-banner.md.erb b/lookbook/docs/patterns/08-flash-banner.md.erbindex 346e70ec5f2..a79cdd58fcf 100644--- a/lookbook/docs/patterns/08-flash-banner.md.erb+++ b/lookbook/docs/patterns/08-flash-banner.md.erb@@ -2,12 +2,12 @@ This component defines a specific use case of the Primer `Banner` component, con## Overview-To use a Primerised flash, the `OpPrimer::BannerMessageComponent` was introduced.+To use a Primerised flash, the `OpPrimer::FlashComponent` was introduced.-<%= embed OpPrimer::BannerMessageComponentPreview, :default, panels: %i[source] %>+<%= embed OpPrimer::FlashComponentPreview, :default, panels: %i[source] %>Internally, this component uses the `Primer::BannerComponent` to render the flash message.-The `OpPrimer::BannerMessageComponent` is a wrapper around the `Primer::BannerComponent` that adds a wrapper class to prepend the flash message to the `#banner-messages` div in the base layout.+The `OpPrimer::FlashComponent` is a wrapper around the `Primer::BannerComponent` that adds a wrapper class to prepend the flash message to the `#primerized-flash-messages` div in the base layout.Otherwise, you use the component as you would use `Primer::Alpha::Banner`.See below for available arguments.@@ -22,16 +22,16 @@ These are rendered using the previous `op-flash` styles, and are not yet primeriSo if you find yourself in need to render a primerized flash. You can use this pattern instead:```ruby-flash[:primer_banner] = { message: "Successful update", scheme: :success, icon: :check }+flash[:op_primer_flash] = { message: "Successful update", scheme: :success, icon: :check }```Or for an error:```ruby-flash[:primer_banner] = { message: "Oh no! Something went wrong", scheme: :danger, icon: :alert }+flash[:op_primer_flash] = { message: "Oh no! Something went wrong", scheme: :danger, icon: :alert }```-These are rendered in the layout through the `render_banner_messages` helper using the `OpPrimer::BannerMessageComponent`.+These are rendered in the layout through the `render_banner_messages` helper using the `OpPrimer::FlashComponent`.## Usage in turbo streams@@ -53,7 +53,7 @@ update_flash_message_via_turbo_stream()```-The width of this banner is always configured through the `op-primer-banner` namespace.+The width of this banner is always configured through the `op-primer-flash` namespace.It is set to 80% of the available widthNote that using a turbo stream will always remove all previous flashes.@@ -65,10 +65,10 @@ Please create a code maintenance ticket if you need to append/prepend messages iAs this is a common use case, the method `render_error_flash_message_via_turbo_stream()` is provided, generating a flash with `scheme: :danger` and `icon: :stop` by default.-<%= embed OpPrimer::BannerMessageComponentPreview, :danger, panels: %i[source] %>+<%= embed OpPrimer::FlashComponentPreview, :danger, panels: %i[source] %><% if false %>### With optional button:-<%= embed OpPrimer::BannerMessageComponentPreview , :button, panels: %i[source] %>+<%= embed OpPrimer::FlashComponentPreview, :button, panels: %i[source] %><% end %>diff --git a/lookbook/previews/op_primer/banner_message_component_preview.rb b/lookbook/previews/op_primer/flash_component_preview.rbsimilarity index 57%rename from lookbook/previews/op_primer/banner_message_component_preview.rbrename to lookbook/previews/op_primer/flash_component_preview.rbindex 00e95c160a6..33be6e1143e 100644--- a/lookbook/previews/op_primer/banner_message_component_preview.rb+++ b/lookbook/previews/op_primer/flash_component_preview.rb@@ -1,20 +1,20 @@module OpPrimer# @logical_path OpenProject/Primer- class BannerMessageComponentPreview < Lookbook::Preview+ class FlashComponentPreview < Lookbook::Previewdef default- render(OpPrimer::BannerMessageComponent.new) do+ render(OpPrimer::FlashComponent.new) doI18n.t("notice_meeting_updated")endenddef danger- render(OpPrimer::BannerMessageComponent.new(scheme: :danger, icon: :stop)) do |_component|+ render(OpPrimer::FlashComponent.new(scheme: :danger, icon: :stop)) do |_component|"Stop right there."endenddef button- render(OpPrimer::BannerMessageComponent.new) do |component|+ render(OpPrimer::FlashComponent.new) do |component|component.with_action_button(tag: :a,href: "/"diff --git a/modules/meeting/app/components/meetings/update_flash_component.rb b/modules/meeting/app/components/meetings/update_flash_component.rbindex 0bcc39bba27..3d5391352d4 100644--- a/modules/meeting/app/components/meetings/update_flash_component.rb+++ b/modules/meeting/app/components/meetings/update_flash_component.rb@@ -33,7 +33,7 @@ module Meetingsalias_method :meeting, :modeldef call- render(::OpPrimer::BannerMessageComponent.new(icon: :info)) do |banner|+ render(::OpPrimer::FlashComponent.new(icon: :info)) do |banner|banner.with_action_button(tag: :a,href: helpers.meeting_path(meeting),diff --git a/modules/meeting/spec/features/structured_meetings/structured_meeting_update_flash_spec.rb b/modules/meeting/spec/features/structured_meetings/structured_meeting_update_flash_spec.rbindex a0c0e91314c..6d7e479a5ac 100644--- a/modules/meeting/spec/features/structured_meetings/structured_meeting_update_flash_spec.rb+++ b/modules/meeting/spec/features/structured_meetings/structured_meeting_update_flash_spec.rb@@ -53,7 +53,7 @@ RSpec.describe "Structured meetings CRUD",endit do- flash_component = ".op-primer-banner--item"+ flash_component = ".op-primer-flash--item"## Add agenda itemshow_page.visit!diff --git a/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb b/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rbindex a68b972fc19..b11474c1eb1 100644--- a/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb+++ b/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb@@ -73,7 +73,7 @@ class Storages::Admin::AutomaticallyManagedProjectFoldersController < Applicatioservice_result = call_update_serviceif service_result.success?- flash[:primer_banner] = {+ flash[:op_primer_flash] = {message: I18n.t(:"storages.notice_successful_storage_connection"),scheme: :success}diff --git a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rbindex c82a707e746..fbc7c485a41 100644--- a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb+++ b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb@@ -125,7 +125,7 @@ class Storages::Admin::OAuthClientsController < ApplicationControllerenddef finish_setup- flash[:primer_banner] = { message: I18n.t(:"storages.notice_successful_storage_connection"), scheme: :success }+ flash[:op_primer_flash] = { message: I18n.t(:"storages.notice_successful_storage_connection"), scheme: :success }redirect_to edit_admin_settings_storage_path(@storage)enddiff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rbindex fc79f08844a..c3368842839 100644--- a/modules/storages/app/controllers/storages/admin/storages_controller.rb+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb@@ -191,7 +191,7 @@ class Storages::Admin::StoragesController < ApplicationControllerupdate_via_turbo_stream(component: Storages::Admin::SidePanel::HealthNotificationsComponent.new(storage: @storage))respond_with_turbo_streamselse- flash.now[:primer_banner] = {+ flash.now[:op_primer_flash] = {message: I18n.t("storages.health_email_notifications.error_could_not_be_saved"), scheme: :danger}render :edit@@ -209,11 +209,11 @@ class Storages::Admin::StoragesController < ApplicationController# rubocop:disable Rails/ActionControllerFlashBeforeRenderservice_result.on_failure do- flash[:primer_banner] = { message: join_flash_messages(service_result.errors.full_messages), scheme: :danger }+ flash[:op_primer_flash] = { message: join_flash_messages(service_result.errors.full_messages), scheme: :danger }endservice_result.on_success do- flash[:primer_banner] = { message: I18n.t(:notice_successful_delete), scheme: :success }+ flash[:op_primer_flash] = { message: I18n.t(:notice_successful_delete), scheme: :success }end# rubocop:enable Rails/ActionControllerFlashBeforeRender@@ -265,7 +265,7 @@ class Storages::Admin::StoragesController < ApplicationControllerdef ensure_valid_provider_type_selectedshort_provider_type = params[:provider]if short_provider_type.blank? || (@provider_type = ::Storages::Storage::PROVIDER_TYPE_SHORT_NAMES[short_provider_type]).blank?- flash[:primer_banner] = { message: I18n.t("storages.error_invalid_provider_type"), scheme: :danger }+ flash[:op_primer_flash] = { message: I18n.t("storages.error_invalid_provider_type"), scheme: :danger }redirect_to admin_settings_storages_pathendend