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

Correct permission check as the calendar menu is only shown in a project context && correctly highlight currently active menu item

Henriette Dargeeafacff352d7
diff --git a/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts b/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts
index 5795a423c40..7c682c59487 100644
--- a/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts
+++ b/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts
@@ -431,6 +431,7 @@ export class WorkPackagesListService {
}
private navigateToDefaultQuery(query:QueryResource):void {
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const sideMenuOptions = this.$state.$current.data?.sideMenuOptions as { hardReloadOnBaseRoute?:boolean, defaultQuery?:string };
const hardReloadOnBaseRoute = sideMenuOptions?.hardReloadOnBaseRoute;
@@ -461,6 +462,7 @@ export class WorkPackagesListService {
}
private reloadSidemenu(selectedQueryId:string|null):void {
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
const menuIdentifier:string|undefined = this.$state.current.data.sideMenuOptions?.sidemenuId;
if (menuIdentifier) {
diff --git a/modules/calendar/app/controllers/calendar/menus_controller.rb b/modules/calendar/app/controllers/calendar/menus_controller.rb
index a0219a1db6d..b32d394b53d 100644
--- a/modules/calendar/app/controllers/calendar/menus_controller.rb
+++ b/modules/calendar/app/controllers/calendar/menus_controller.rb
@@ -32,7 +32,7 @@ module ::Calendar
def show
@submenu_menu_items = ::Calendar::Menu.new(project: @project, params:).menu_items
- @create_btn_options = if User.current.allowed_in_any_project?(:manage_calendars)
+ @create_btn_options = if User.current.allowed_in_project?(:manage_calendars, @project)
{ href: new_project_calendars_path(@project), text: I18n.t("label_calendar") }
end
diff --git a/modules/calendar/app/menus/calendar/menu.rb b/modules/calendar/app/menus/calendar/menu.rb
index 148ce15fba0..b0c7d257d3e 100644
--- a/modules/calendar/app/menus/calendar/menu.rb
+++ b/modules/calendar/app/menus/calendar/menu.rb
@@ -41,6 +41,10 @@ module Calendar
[]
end
+ def selected?(query_params)
+ query_params[:id].to_s == params[:id]
+ end
+
def query_params(id)
{ id: }
end
diff --git a/modules/calendar/app/views/calendar/menus/_menu.html.erb b/modules/calendar/app/views/calendar/menus/_menu.html.erb
index 972fe4c353d..336ee33a79f 100644
--- a/modules/calendar/app/views/calendar/menus/_menu.html.erb
+++ b/modules/calendar/app/views/calendar/menus/_menu.html.erb
@@ -1,5 +1,5 @@
<%= turbo_frame_tag "calendar_sidemenu",
- src: @project ? menu_project_calendars_path(@project) : calendars_menu_path(),
+ src: menu_project_calendars_path(@project, **params.permit(:id)),
target: '_top',
data: { turbo: false },
loading: :lazy %>
diff --git a/modules/calendar/config/routes.rb b/modules/calendar/config/routes.rb
index 95469b1666a..ec673b259fc 100644
--- a/modules/calendar/config/routes.rb
+++ b/modules/calendar/config/routes.rb
@@ -14,8 +14,4 @@ Rails.application.routes.draw do
end
resources :calendars, only: %i[index new create], controller: "calendar/calendars"
-
- namespace :calendars do
- resource :menu, only: %[show]
- end
end