Skip to content

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

Replace custom header of Meetings with Primer::PageHeader

Henriette Darge217c9de5d7c8
diff --git a/modules/meeting/app/components/meetings/header_component.html.erb b/modules/meeting/app/components/meetings/header_component.html.erb
index f45c3ec1789..19ac108a6d4 100644
--- a/modules/meeting/app/components/meetings/header_component.html.erb
+++ b/modules/meeting/app/components/meetings/header_component.html.erb
@@ -1,113 +1,76 @@
<%=
component_wrapper do
- case @state
- when :show
- flex_layout do |show_header|
- show_header.with_row do
- flex_layout(justify_content: :space_between, align_items: :center) do |title|
- title.with_column(flex: 1) do
- render(Primer::Beta::Heading.new(tag: :h2)) { @meeting.title }
- end
-
- title.with_column do
- render(Primer::Alpha::ActionMenu.new) do |menu|
- menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("label_meeting_actions"), test_selector: 'op-meetings-header-action-trigger')
-
- menu.with_item(label: t("label_meeting_edit_title"),
- href: edit_meeting_path(@meeting),
- content_arguments: {
- data: { 'turbo-stream': true }
- }) do |item|
- item.with_leading_visual_icon(icon: :pencil)
- end if @meeting.editable?
-
- menu.with_item(label: t(:button_copy),
- href: copy_meeting_path(@meeting),
- content_arguments: {
- data: { turbo: false }
- }) do |item|
- item.with_leading_visual_icon(icon: :copy)
- end
+ render(Primer::OpenProject::PageHeader.new) do |header|
+ if show_state?
+ header.with_title { @meeting.title }
+ header.with_breadcrumbs(breadcrumb_items)
+ header.with_description { render(Meetings::HeaderInfolineComponent.new(@meeting)) }
+ header.with_action_menu(menu_arguments: {},
+ button_arguments: { icon: "kebab-horizontal",
+ "aria-label": t("label_meeting_actions"),
+ test_selector: 'op-meetings-header-action-trigger'}) do |menu|
+ menu.with_item(label: t("label_meeting_edit_title"),
+ href: edit_meeting_path(@meeting),
+ content_arguments: {
+ data: { 'turbo-stream': true }
+ }) do |item|
+ item.with_leading_visual_icon(icon: :pencil)
+ end if @meeting.editable?
- menu.with_item(label: t(:label_icalendar_download),
- href: download_ics_meeting_path(@meeting)) do |item|
- item.with_leading_visual_icon(icon: :download)
- end
-
- if User.current.allowed_in_project?(:send_meeting_agendas_notification, @meeting.project
- )
- menu.with_item(label: t('meeting.label_mail_all_participants'),
- href: notify_meeting_path(@meeting),
- form_arguments: { method: :post, data: { turbo: 'false' } }) do |item|
- item.with_leading_visual_icon(icon: :mail)
- end
- end
+ menu.with_item(label: t(:button_copy),
+ href: copy_meeting_path(@meeting),
+ content_arguments: {
+ data: { turbo: false }
+ }) do |item|
+ item.with_leading_visual_icon(icon: :copy)
+ end
- menu.with_item(label: t(:label_history),
- tag: :a,
- href: history_meeting_path(@meeting),
- content_arguments: {
- "data-controller": "async-dialog",
- },
- value: ""
- ) do |item|
- item.with_leading_visual_icon(icon: :clock) # or :check TBD
- end
+ menu.with_item(label: t(:label_icalendar_download),
+ href: download_ics_meeting_path(@meeting)) do |item|
+ item.with_leading_visual_icon(icon: :download)
+ end
- menu.with_item(label: t("label_meeting_delete"),
- scheme: :danger,
- href: meeting_path(@meeting),
- form_arguments: {
- method: :delete, data: { confirm: t("text_are_you_sure"), turbo: 'false' }
- }) do |item|
- item.with_leading_visual_icon(icon: :trash)
- end if delete_enabled?
- end
+ if User.current.allowed_in_project?(:send_meeting_agendas_notification, @meeting.project
+ )
+ menu.with_item(label: t('meeting.label_mail_all_participants'),
+ href: notify_meeting_path(@meeting),
+ form_arguments: { method: :post, data: { turbo: 'false' } }) do |item|
+ item.with_leading_visual_icon(icon: :mail)
end
end
- end
- show_header.with_row do
- render(Meetings::HeaderInfolineComponent.new(@meeting))
- end
- end
-
- when :edit
- if @meeting.editable?
- flex_layout do |edit_header|
- edit_header.with_row(mb: 2) do
- primer_form_with(
- model: @meeting,
- method: :put,
- url: update_title_meeting_path(@meeting)
- ) do |f|
- flex_layout do |editable_title_form|
- editable_title_form.with_column(flex: 1, mr: 2) do
- render(Meeting::Title.new(f))
- end
-
- editable_title_form.with_column(mr: 2) do
- render(Meeting::Submit.new(f))
- end
-
- editable_title_form.with_column do
- render(Primer::Beta::Button.new(
- scheme: :secondary,
- tag: :a,
- href: cancel_edit_meeting_path(@meeting),
- data: { 'turbo-stream': true }
- )) do |_c|
- t("button_cancel")
- end
- end
- end
- end
+ menu.with_item(label: t(:label_history),
+ tag: :a,
+ href: history_meeting_path(@meeting),
+ content_arguments: {
+ "data-controller": "async-dialog",
+ },
+ value: ""
+ ) do |item|
+ item.with_leading_visual_icon(icon: :clock) # or :check TBD
end
- edit_header.with_row do
- render(Meetings::HeaderInfolineComponent.new(@meeting))
+ menu.with_item(label: t("label_meeting_delete"),
+ scheme: :danger,
+ href: meeting_path(@meeting),
+ form_arguments: {
+ method: :delete, data: { confirm: t("text_are_you_sure"), turbo: 'false' }
+ }) do |item|
+ item.with_leading_visual_icon(icon: :trash)
+ end if delete_enabled?
+ end
+ elsif @meeting.editable?
+ header.with_title do
+ primer_form_with(
+ model: @meeting,
+ method: :put,
+ url: update_title_meeting_path(@meeting)
+ ) do |f|
+ render(Meeting::Title.new(f, meeting: @meeting))
end
end
+ header.with_breadcrumbs(breadcrumb_items)
+ header.with_description { render(Meetings::HeaderInfolineComponent.new(@meeting)) }
end
end
end
diff --git a/modules/meeting/app/components/meetings/header_component.rb b/modules/meeting/app/components/meetings/header_component.rb
index d3e69e2592a..77a6de63cc9 100644
--- a/modules/meeting/app/components/meetings/header_component.rb
+++ b/modules/meeting/app/components/meetings/header_component.rb
@@ -31,18 +31,42 @@ module Meetings
include ApplicationHelper
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
+ include Primer::FetchOrFallbackHelper
- def initialize(meeting:, state: :show)
+ STATE_DEFAULT = :show
+ STATE_EDIT = :edit
+ STATE_OPTIONS = [STATE_DEFAULT, STATE_EDIT].freeze
+ def initialize(meeting:, project: nil, state: :show)
super
@meeting = meeting
- @state = state
+ @project = project
+ @state = fetch_or_fallback(STATE_OPTIONS, state)
end
private
+ def show_state?
+ @state == :show
+ end
+
def delete_enabled?
User.current.allowed_in_project?(:delete_meetings, @meeting.project)
end
+
+ def breadcrumb_items
+ [parent_element,
+ { href: @project.present? ? project_meetings_path(@project.id) : meetings_path,
+ text: I18n.t(:label_meeting_plural) },
+ @meeting.title]
+ end
+
+ def parent_element
+ if @project.present?
+ { href: project_overview_path(@project.id), text: @project.name }
+ else
+ { href: home_path, text: I18n.t(:label_home) }
+ end
+ end
end
end
diff --git a/modules/meeting/app/components/meetings/header_infoline_component.html.erb b/modules/meeting/app/components/meetings/header_infoline_component.html.erb
index d6e0169dc7d..d5ac7c726ff 100644
--- a/modules/meeting/app/components/meetings/header_infoline_component.html.erb
+++ b/modules/meeting/app/components/meetings/header_infoline_component.html.erb
@@ -1,7 +1,8 @@
-<%= render(Primer::BaseComponent.new(tag: :div, color: :subtle, font_size: :small)) do %>
+<%= render(Primer::BaseComponent.new(tag: :div)) do %>
<%= t("label_meeting_created_by") %>
- <%= render(Primer::Beta::Link.new(href: user_path(@meeting.author), underline: false,
+ <%= render(Primer::Beta::Link.new(href: user_path(@meeting.author),
+ underline: false,
target: "_blank")) { @meeting.author.name } %>.
<%= t("label_meeting_last_updated") %>
- <%= render(OpPrimer::RelativeTimeComponent.new(font_size: :small, datetime: last_updated_at, prefix: I18n.t(:label_on))) %>.
+ <%= render(OpPrimer::RelativeTimeComponent.new(datetime: last_updated_at, prefix: I18n.t(:label_on))) %>.
<% end %>
diff --git a/modules/meeting/app/components/meetings/index_page_header_component.rb b/modules/meeting/app/components/meetings/index_page_header_component.rb
index a6d3b01aad2..e17a3ca8f37 100644
--- a/modules/meeting/app/components/meetings/index_page_header_component.rb
+++ b/modules/meeting/app/components/meetings/index_page_header_component.rb
@@ -72,7 +72,7 @@ module Meetings
end
def parent_element
- if @project
+ if @project.present?
{ href: project_overview_path(@project.id), text: @project.name }
else
{ href: home_path, text: I18n.t(:label_home) }
diff --git a/modules/meeting/app/components/meetings/row_component.rb b/modules/meeting/app/components/meetings/row_component.rb
index 800a65cc551..c3e90647980 100644
--- a/modules/meeting/app/components/meetings/row_component.rb
+++ b/modules/meeting/app/components/meetings/row_component.rb
@@ -35,7 +35,7 @@ module Meetings
end
def title
- link_to model.title, meeting_path(model)
+ link_to model.title, project_meeting_path(model.project, model)
end
def type
diff --git a/modules/meeting/app/components/meetings/show_component.html.erb b/modules/meeting/app/components/meetings/show_component.html.erb
index 2cf6000430b..38e4240339e 100644
--- a/modules/meeting/app/components/meetings/show_component.html.erb
+++ b/modules/meeting/app/components/meetings/show_component.html.erb
@@ -7,8 +7,8 @@
render(FlashMessageComponent.new)
end
- show_page.with_row(mt: 2, mb: 3, pb: 2, border: :bottom) do
- render(Meetings::HeaderComponent.new(meeting: @meeting))
+ show_page.with_row do
+ render(Meetings::HeaderComponent.new(meeting: @meeting, project: @project))
end
show_page.with_row do
diff --git a/modules/meeting/app/components/meetings/show_component.rb b/modules/meeting/app/components/meetings/show_component.rb
index 88c8ce12bff..7a50d6f7c53 100644
--- a/modules/meeting/app/components/meetings/show_component.rb
+++ b/modules/meeting/app/components/meetings/show_component.rb
@@ -31,10 +31,11 @@ module Meetings
include ApplicationHelper
include OpPrimer::ComponentHelpers
- def initialize(meeting:)
+ def initialize(meeting:, project:)
super
@meeting = meeting
+ @project = project
end
end
end
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index d4b6c440d63..d71402442d9 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -28,7 +28,7 @@
class MeetingsController < ApplicationController
around_action :set_time_zone
- before_action :find_optional_project, only: %i[index new create history]
+ before_action :find_optional_project, only: %i[index new show create history]
before_action :verify_activities_module_activated, only: %i[history]
before_action :determine_date_range, only: %i[history]
before_action :determine_author, only: %i[history]
@@ -68,7 +68,7 @@ class MeetingsController < ApplicationController
def show
html_title "#{t(:label_meeting)}: #{@meeting.title}"
if @meeting.is_a?(StructuredMeeting)
- render(Meetings::ShowComponent.new(meeting: @meeting))
+ render(Meetings::ShowComponent.new(meeting: @meeting, project: @project))
elsif @meeting.agenda.present? && @meeting.agenda.locked?
params[:tab] ||= 'minutes'
end
diff --git a/modules/meeting/app/forms/meeting/submit.rb b/modules/meeting/app/forms/meeting/submit.rb
deleted file mode 100644
index 47a86063684..00000000000
--- a/modules/meeting/app/forms/meeting/submit.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2024 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.
-#++
-
-class Meeting::Submit < ApplicationForm
- form do |meeting_form|
- meeting_form.submit(name: :submit, label: I18n.t("button_save"), scheme: :primary)
- end
-end
diff --git a/modules/meeting/app/forms/meeting/title.rb b/modules/meeting/app/forms/meeting/title.rb
index 61f04a27afc..8df8e0deb5e 100644
--- a/modules/meeting/app/forms/meeting/title.rb
+++ b/modules/meeting/app/forms/meeting/title.rb
@@ -27,14 +27,34 @@
#++
class Meeting::Title < ApplicationForm
- form do |meeting_form|
- meeting_form.text_field(
- name: :title,
- placeholder: Meeting.human_attribute_name(:title),
- label: Meeting.human_attribute_name(:title),
- visually_hide_label: true,
- required: true,
- autofocus: true
- )
+ include OpenProject::StaticRouting::UrlHelpers
+
+ form do |query_form|
+ query_form.group(layout: :horizontal) do |group|
+ group.text_field(
+ name: :title,
+ placeholder: Meeting.human_attribute_name(:title),
+ label: Meeting.human_attribute_name(:title),
+ visually_hide_label: true,
+ required: true,
+ autofocus: true
+ )
+
+ group.submit(name: :submit, label: I18n.t("button_save"), scheme: :primary)
+
+ group.button(
+ name: :cancel,
+ scheme: :secondary,
+ label: I18n.t(:button_cancel),
+ tag: :a,
+ data: { 'turbo-stream': true },
+ href: OpenProject::StaticRouting::StaticUrlHelpers.new.cancel_edit_meeting_path(@meeting)
+ )
+ end
+ end
+
+ def initialize(meeting:)
+ super()
+ @meeting = meeting
end
end
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index f9e015eb11e..acdad57b0da 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -28,7 +28,7 @@
Rails.application.routes.draw do
resources :projects, only: %i[] do
- resources :meetings, only: %i[index new create]
+ resources :meetings, only: %i[index new create show]
end
resources :work_packages, only: %i[] do