Skip to content

Commit

Permalink
Pass request to meetings menu
Browse files Browse the repository at this point in the history
This doesn't help, as the requested url is the turbo frame
  • Loading branch information
oliverguenther committed Oct 1, 2024
1 parent edef0e7 commit 4a85acc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
6 changes: 4 additions & 2 deletions app/menus/submenu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
# ++
class Submenu
include Rails.application.routes.url_helpers
attr_reader :view_type, :project, :params
include ActionView::Helpers::UrlHelper
attr_reader :view_type, :project, :request, :params

def initialize(view_type:, project: nil, params: nil)
def initialize(view_type:, params:, request: nil, project: nil)
@view_type = view_type
@project = project
@request = request
@params = params
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MenusController < ApplicationController
before_action :load_and_authorize_in_optional_project

def show
@submenu_menu_items = ::Meetings::Menu.new(project: @project, params:).menu_items
@submenu_menu_items = ::Meetings::Menu.new(project: @project, params:, request:).menu_items
@create_btn_options = if @project.present? && User.current.allowed_in_project?(:create_meetings, @project)
{ href: new_project_meeting_path(@project), module_key: "meeting" }
elsif @project.nil? && User.current.allowed_in_any_project?(:create_meetings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def create

private

def find_optional_project
@project = Project.find(params[:project_id]) if params[:project_id].present?
rescue ActiveRecord::RecordNotFound
render_404
end

def find_meeting
@recurring_meeting = RecurringMeeting.visible.find(params[:id])
rescue ActiveRecord::RecordNotFound
Expand Down
21 changes: 11 additions & 10 deletions modules/meeting/app/menus/meetings/menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@
# ++
module Meetings
class Menu < Submenu
attr_reader :view_type, :project

def initialize(project: nil, params: nil)
@project = project
@params = params

super(view_type:, project:, params:)
def initialize(request:, params:, project: nil)
super(view_type: nil, project:, params:, request:)
end

def menu_items
Expand All @@ -52,9 +47,15 @@ def top_level_menu_items
query_params: { filters: upcoming_filter, sort: "start_time" }),
menu_item(title: I18n.t(:label_past_meetings),
query_params: { filters: past_filter, sort: "start_time:desc" }),
menu_link(title: I18n.t(:label_recurring_meeting_plural),
href: polymorphic_path([project, :recurring_meetings]))
]
recurring_menu_item
].compact
end

def recurring_menu_item
return unless OpenProject::FeatureDecisions.recurring_meetings_active?

menu_link(title: I18n.t(:label_recurring_meeting_plural),
href: polymorphic_path([project, :recurring_meetings]))
end

def involvement_sidebar_menu_items
Expand Down

0 comments on commit 4a85acc

Please sign in to comment.