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
Deal with multiple flashes
Oliver Günther7d396c8c2230
diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erbindex 0d3485e6f41..5cbfbf9540f 100644--- a/app/views/layouts/base.html.erb+++ b/app/views/layouts/base.html.erb@@ -119,7 +119,9 @@ See COPYRIGHT and LICENSE files for more details.<main id="content-wrapper" class="<%= initial_classes %>"><%= render_primer_banner_message %><%= render_streameable_primer_banner_message %>- <turbo-frame id="flash-messages" class="op-primer-banner">+ <%# Banner messages are being rendered using primer %>+ <div id="banner-messages" class="op-primer-banner"></div>+ <turbo-frame id="flash-messages"><%= render_flash_messages %></turbo-frame><% if show_onboarding_modal? %>diff --git a/frontend/src/global_styles/primer/_banners.sass b/frontend/src/global_styles/primer/_banners.sassindex 5f26272ffc3..90dc71bb786 100644--- a/frontend/src/global_styles/primer/_banners.sass+++ b/frontend/src/global_styles/primer/_banners.sass@@ -29,12 +29,18 @@$op-primer-banner-toaster-width: 80%.op-primer-banner- &--wrapper- // Move below sidebar- z-index: 599- position: absolute- max-width: $op-primer-banner-toaster-width- margin: 0 auto- left: 10%- right: 10%- top: 1rem+ z-index: 599+ position: absolute+ max-width: $op-primer-banner-toaster-width+ margin: 0 auto+ left: 10%+ right: 10%+ top: 1rem++ // Align multiple toasts+ display: flex+ flex-direction: column+ gap: 1rem++ &--item+ word-wrap: break-worddiff --git a/frontend/src/turbo/flash-stream-action.ts b/frontend/src/turbo/flash-stream-action.tsindex 7e9dc69c90a..725959bd31b 100644--- a/frontend/src/turbo/flash-stream-action.ts+++ b/frontend/src/turbo/flash-stream-action.ts@@ -3,7 +3,8 @@ import { StreamActions, StreamElement } from '@hotwired/turbo';export function registerFlashStreamAction() {StreamActions.flash = function dialogStreamAction(this:StreamElement) {const content = this.templateElement.content;- const target = document.getElementById('flash-messages');- target?.append(content);+ const target = document.getElementById('banner-messages') as HTMLElement;+ target.innerHTML = '';+ target.append(content);};}diff --git a/modules/meeting/app/components/meetings/update_flash_component.html.erb b/modules/meeting/app/components/meetings/update_flash_component.html.erbindex 2f6d2837443..447927b419f 100644--- a/modules/meeting/app/components/meetings/update_flash_component.html.erb+++ b/modules/meeting/app/components/meetings/update_flash_component.html.erb@@ -1,4 +1,4 @@-<div class="op-primer-banner--wrapper">+<div class="op-primer-banner--item"><%=render(Primer::Alpha::Banner.new(full: false,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 3d58fe99b48..495b4e77861 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-toast--wrapper"+ flash_component = ".op-primer-banner--item"## Add agenda itemshow_page.visit!@@ -74,7 +74,7 @@ RSpec.describe "Structured meetings CRUD",show_page.trigger_change_pollexpect(page).to have_css(flash_component, wait: 5)expect(page).to have_text I18n.t(:notice_meeting_updated)- page.within(".flash") { click_on "Reload" }+ page.within(flash_component) { click_on "Reload" }end# Expect no notification in window2@@ -103,7 +103,7 @@ RSpec.describe "Structured meetings CRUD",expect(page).to have_css(flash_component, wait: 5)expect(page).to have_text I18n.t(:notice_meeting_updated)- page.within(".flash") { click_on "Reload" }+ page.within(flash_component) { click_on "Reload" }## Add sectionshow_page.add_section do@@ -119,7 +119,7 @@ RSpec.describe "Structured meetings CRUD",show_page.trigger_change_pollexpect(page).to have_css(flash_component, wait: 5)expect(page).to have_text I18n.t(:notice_meeting_updated)- page.within(".flash") { click_on "Reload" }+ page.within(flash_component) { click_on "Reload" }end# Expect no notification in window2@@ -147,7 +147,7 @@ RSpec.describe "Structured meetings CRUD",show_page.trigger_change_pollexpect(page).to have_text I18n.t(:notice_meeting_updated)- page.within(".flash") { click_on "Reload" }+ page.within(flash_component) { click_on "Reload" }## Close meetingfind_test_selector("close-meeting-button").click@@ -158,7 +158,7 @@ RSpec.describe "Structured meetings CRUD",show_page.trigger_change_pollexpect(page).to have_css(flash_component, wait: 5)expect(page).to have_text I18n.t(:notice_meeting_updated)- page.within(".flash") { click_on "Reload" }+ page.within(flash_component) { click_on "Reload" }end# Expect no notification in window2diff --git a/modules/meeting/spec/support/pages/structured_meeting/show.rb b/modules/meeting/spec/support/pages/structured_meeting/show.rbindex 5d225826277..10a9367420d 100644--- a/modules/meeting/spec/support/pages/structured_meeting/show.rb+++ b/modules/meeting/spec/support/pages/structured_meeting/show.rb@@ -43,8 +43,6 @@ module Pages::StructuredMeetingdef trigger_change_pollscript = <<~JS- // Remove flashes from the page to prevent race conditions- document.querySelectorAll('.op-toast--wrapper').forEach((el) => el.remove());var target = document.querySelector('[data-test-selector="meeting-page-header"]');var controller = window.Stimulus.getControllerForElementAndIdentifier(target, 'poll-for-changes')controller.triggerTurboStream();