diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /lib/gitlab/quick_actions | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'lib/gitlab/quick_actions')
-rw-r--r-- | lib/gitlab/quick_actions/issue_and_merge_request_actions.rb | 18 | ||||
-rw-r--r-- | lib/gitlab/quick_actions/relate_actions.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/quick_actions/work_item_actions.rb | 16 |
3 files changed, 16 insertions, 20 deletions
diff --git a/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb b/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb index e01be4e0604..c94deea0dfb 100644 --- a/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb +++ b/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb @@ -145,10 +145,18 @@ module Gitlab desc { _('Set time estimate') } explanation do |time_estimate| - formatted_time_estimate = format_time_estimate(time_estimate) - _("Sets time estimate to %{time_estimate}.") % { time_estimate: formatted_time_estimate } if formatted_time_estimate + next unless time_estimate + + if time_estimate == 0 + _('Removes time estimate.') + elsif time_estimate > 0 + formatted_time_estimate = format_time_estimate(time_estimate) + _("Sets time estimate to %{time_estimate}.") % { time_estimate: formatted_time_estimate } if formatted_time_estimate + end end execution_message do |time_estimate| + next _('Removed time estimate.') if time_estimate == 0 + formatted_time_estimate = format_time_estimate(time_estimate) _("Set time estimate to %{time_estimate}.") % { time_estimate: formatted_time_estimate } if formatted_time_estimate end @@ -159,12 +167,10 @@ module Gitlab current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project) end parse_params do |raw_duration| - Gitlab::TimeTrackingFormatter.parse(raw_duration) + Gitlab::TimeTrackingFormatter.parse(raw_duration, keep_zero: true) end command :estimate, :estimate_time do |time_estimate| - if time_estimate - @updates[:time_estimate] = time_estimate - end + @updates[:time_estimate] = time_estimate end desc { _('Add or subtract spent time') } diff --git a/lib/gitlab/quick_actions/relate_actions.rb b/lib/gitlab/quick_actions/relate_actions.rb index 058c1e7e9bf..294ddd985de 100644 --- a/lib/gitlab/quick_actions/relate_actions.rb +++ b/lib/gitlab/quick_actions/relate_actions.rb @@ -36,7 +36,7 @@ module Gitlab extract_references(issue_param, :issue).first end command :unlink do |issue| - link = IssueLink.for_issues(quick_action_target, issue).first + link = IssueLink.for_items(quick_action_target, issue).first if link call_link_service(IssueLinks::DestroyService.new(link, current_user)) diff --git a/lib/gitlab/quick_actions/work_item_actions.rb b/lib/gitlab/quick_actions/work_item_actions.rb index a5c3c6a56be..0a96d502862 100644 --- a/lib/gitlab/quick_actions/work_item_actions.rb +++ b/lib/gitlab/quick_actions/work_item_actions.rb @@ -54,18 +54,9 @@ module Gitlab def validate_promote_to(type) return error_msg(:not_found, action: 'promote') unless type && supports_promote_to?(type.name) + return if current_user.can?(:"create_#{type.base_type}", quick_action_target) - unless current_user.can?(:"create_#{type.base_type}", quick_action_target) - return error_msg(:forbidden, action: 'promote') - end - - validate_hierarchy - end - - def validate_hierarchy - return unless current_type.task? && quick_action_target.parent_link - - error_msg(:hierarchy, action: 'promote') + error_msg(:forbidden, action: 'promote') end def current_type @@ -88,8 +79,7 @@ module Gitlab message = { not_found: 'Provided type is not supported', same_type: 'Types are the same', - forbidden: 'You have insufficient permissions', - hierarchy: 'A task cannot be promoted when a parent issue is present' + forbidden: 'You have insufficient permissions' }.freeze format(_("Failed to %{action} this work item: %{reason}."), { action: action, reason: message[reason] }) |