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
Check permission for creating time entries
Klaus Zanderscc50c1fa57ba
diff --git a/modules/costs/app/components/my/time_tracking/sub_header_component.html.erb b/modules/costs/app/components/my/time_tracking/sub_header_component.html.erbindex af5815cdcb7..04e096e4fa8 100644--- a/modules/costs/app/components/my/time_tracking/sub_header_component.html.erb+++ b/modules/costs/app/components/my/time_tracking/sub_header_component.html.erb@@ -10,21 +10,25 @@group.with_button(icon: "arrow-right", tag: :a, **next_attrs)end- component.with_action_button(tag: :a,- href: today_href,- leading_icon: :"op-calendar-day",- label: I18n.t(:label_today)) do- I18n.t(:label_today_capitalized)- end-component.with_action_button(- scheme: :primary,- leading_icon: :plus,- label: I18n.t(:button_log_time),- data: { "turbo-stream" => true },tag: :a,- href: dialog_time_entries_path(onlyMe: true, date: date.iso8601)+ href: today_href,+ leading_icon: :"op-calendar-day",+ label: I18n.t(:label_today)) do- t(:button_add_time_entry)+ I18n.t(:label_today_capitalized)+ end++ if can_create_time_entry?+ component.with_action_button(+ scheme: :primary,+ leading_icon: :plus,+ label: I18n.t(:button_log_time),+ data: { "turbo-stream" => true },+ tag: :a,+ href: dialog_time_entries_path(onlyMe: true, date: date.iso8601)+ ) do+ t(:button_add_time_entry)+ endendend %>diff --git a/modules/costs/app/components/my/time_tracking/sub_header_component.rb b/modules/costs/app/components/my/time_tracking/sub_header_component.rbindex 914b94ee0de..5365d41dbff 100644--- a/modules/costs/app/components/my/time_tracking/sub_header_component.rb+++ b/modules/costs/app/components/my/time_tracking/sub_header_component.rb@@ -90,6 +90,10 @@ module Myaria: { label: I18n.t(:label_next_month) } }endend++ def can_create_time_entry?+ User.current.allowed_in_any_work_package?(:log_own_time) || User.current.allowed_in_project?(:log_time)+ endendendenddiff --git a/modules/costs/app/components/my/time_tracking/time_entries_list_component.rb b/modules/costs/app/components/my/time_tracking/time_entries_list_component.rbindex 08d4dce17bc..79b68527690 100644--- a/modules/costs/app/components/my/time_tracking/time_entries_list_component.rb+++ b/modules/costs/app/components/my/time_tracking/time_entries_list_component.rb@@ -43,10 +43,13 @@ module MyTimeEntry.model_name.human(count: 2)end- def has_actions? = true+ def has_actions?+ can_create_time_entry? || options[:mode] != :month+ enddef action_row_header_contentreturn if options[:mode] == :month+ return unless can_create_time_entry?render(Primer::Beta::IconButton.new(icon: "plus",@@ -85,6 +88,10 @@ module Myfalseendend++ def can_create_time_entry?+ User.current.allowed_in_any_work_package?(:log_own_time) || User.current.allowed_in_project?(:log_time)+ endendendend