Skip to content

Commit

Permalink
Merge pull request #16758 from opf/fix/meeting-flash-banner-width
Browse files Browse the repository at this point in the history
Change meeting flash banner width to 80%
  • Loading branch information
oliverguenther authored Sep 20, 2024
2 parents a377143 + 7d396c8 commit 43d3a96
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 31 deletions.
2 changes: 2 additions & 0 deletions app/views/layouts/base.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ See COPYRIGHT and LICENSE files for more details.
<main id="content-wrapper" class="<%= initial_classes %>">
<%= render_primer_banner_message %>
<%= render_streameable_primer_banner_message %>
<%# 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>
Expand Down
46 changes: 46 additions & 0 deletions frontend/src/global_styles/primer/_banners.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//-- copyright
// OpenProject is an open source project management software.
// Copyright (C) the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++
$op-primer-banner-toaster-width: 80%

.op-primer-banner
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-word
1 change: 1 addition & 0 deletions frontend/src/global_styles/primer/_index.sass
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@import icons
@import overrides
@import banners
4 changes: 3 additions & 1 deletion frontend/src/turbo/flash-stream-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { StreamActions, StreamElement } from '@hotwired/turbo';
export function registerFlashStreamAction() {
StreamActions.flash = function dialogStreamAction(this:StreamElement) {
const content = this.templateElement.content;
document.body.append(content);
const target = document.getElementById('banner-messages') as HTMLElement;
target.innerHTML = '';
target.append(content);
};
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
<%=
component_wrapper do
flex_layout do |flex|
flex.with_row(classes: "op-toast--wrapper") do
render(Primer::Alpha::Banner.new(
full: false,
icon: 'info',
scheme: :default,
data: {
singleton: true
}
)) do |component|
component.with_action_button(
tag: :a,
href: meeting_path(@meeting),
data: { turbo: false },
size: :medium) { I18n.t("label_meeting_reload") }
I18n.t("notice_meeting_updated")
end
end
<div class="op-primer-banner--item">
<%=
render(Primer::Alpha::Banner.new(
full: false,
icon: :info,
scheme: :default,
data: {
singleton: true
}
)) do |component|
component.with_action_button(
tag: :a,
href: meeting_path(@meeting),
data: { turbo: false },
size: :medium) { I18n.t("label_meeting_reload") }
I18n.t("notice_meeting_updated")
end
end
%>
%>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
end

it do
flash_component = ".op-toast--wrapper"
flash_component = ".op-primer-banner--item"

## Add agenda item
show_page.visit!
Expand All @@ -74,7 +74,7 @@
show_page.trigger_change_poll
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" }
end

# Expect no notification in window2
Expand Down Expand Up @@ -103,7 +103,7 @@
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 section
show_page.add_section do
Expand All @@ -119,7 +119,7 @@
show_page.trigger_change_poll
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" }
end

# Expect no notification in window2
Expand Down Expand Up @@ -147,7 +147,7 @@
show_page.trigger_change_poll
expect(page).to have_text I18n.t(:notice_meeting_updated)

page.within(".flash") { click_on "Reload" }
page.within(flash_component) { click_on "Reload" }

## Close meeting
find_test_selector("close-meeting-button").click
Expand All @@ -158,7 +158,7 @@
show_page.trigger_change_poll
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" }
end

# Expect no notification in window2
Expand Down
2 changes: 0 additions & 2 deletions modules/meeting/spec/support/pages/structured_meeting/show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def trigger_dropdown_menu_item(name)

def trigger_change_poll
script = <<~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();
Expand Down

0 comments on commit 43d3a96

Please sign in to comment.