Commit ae8ea6eb authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch '229971-remove-weight-incidents' into 'master'

Remove weight from incidents sidebar

See merge request gitlab-org/gitlab!40794
parents e25d35f7 63a9156d
......@@ -177,10 +177,6 @@ module Issuable
assignees.count > 1
end
def supports_weight?
false
end
def supports_time_tracking?
is_a?(TimeTrackable) && !incident?
end
......
......@@ -30,7 +30,7 @@
= render_if_exists "shared/issuable/form/merge_request_blocks", issuable: issuable, form: form
- if has_due_date || issuable.supports_weight?
- if has_due_date
.col-lg-6
- if @issue[:issue_type] != 'incident'
= render_if_exists "shared/issuable/form/weight", issuable: issuable, form: form
......
......@@ -15,7 +15,7 @@ module EE
field :weight, GraphQL::INT_TYPE, null: true,
description: 'Weight of the issue',
resolve: -> (obj, _args, _ctx) { obj.supports_weight? ? obj.weight : nil }
resolve: -> (obj, _args, _ctx) { obj.weight_available? ? obj.weight : nil }
field :blocked, GraphQL::BOOLEAN_TYPE, null: false,
description: 'Indicates the issue is blocked',
......
......@@ -12,5 +12,13 @@ module EE
def supports_health_status?
false
end
def supports_weight?
false
end
def weight_available?
supports_weight? && project&.feature_available?(:issue_weights)
end
end
end
......@@ -111,7 +111,7 @@ module EE
# override
def weight
super if supports_weight?
super if weight_available?
end
# override
......@@ -132,8 +132,9 @@ module EE
changed_fields && (changed_fields & ELASTICSEARCH_PERMISSION_TRACKED_FIELDS).any?
end
override :supports_weight?
def supports_weight?
project&.feature_available?(:issue_weights)
!incident?
end
def can_assign_epic?(user)
......
......@@ -10,12 +10,12 @@ module EE
has_many :boards
end
def supports_weight?
def weight_available?
resource_parent&.feature_available?(:issue_weights)
end
def supports_milestone_charts?
resource_parent&.feature_available?(:milestone_charts) && supports_weight?
resource_parent&.feature_available?(:milestone_charts) && weight_available?
end
def burnup_charts_available?
......
......@@ -8,6 +8,8 @@ module EE
expose :scoped_labels_available do |issuable|
issuable.project&.feature_available?(:scoped_labels)
end
expose :supports_weight?, as: :supports_weight
end
end
end
......@@ -5,7 +5,7 @@ module EE
include RequestAwareEntity
prepended do
expose :weight, if: ->(issue, _) { issue.supports_weight? }
expose :weight, if: ->(issue, _) { issue.weight_available? }
expose :blocked do |issue, options|
options[:blocked_issue_ids].present? && options[:blocked_issue_ids].include?(issue.id)
end
......
......@@ -4,7 +4,7 @@ module EE
extend ActiveSupport::Concern
prepended do
expose :weight, if: ->(issue, _) { issue.supports_weight? }
expose :weight, if: ->(issue, _) { issue.weight_available? }
with_options if: -> (_, options) { options[:with_blocking_issues] } do
expose :blocked?, as: :blocked
......
......@@ -11,7 +11,7 @@ module EE
expose :supports_health_status?, as: :health_status
expose :issue_weights do |issuable|
issuable.project.feature_available?(:issue_weights)
issuable.weight_available?
end
expose :epics do |issuable|
......
......@@ -13,7 +13,7 @@ module EE
def filter_params(issuable)
can_admin_issuable = can_admin_issuable?(issuable)
unless can_admin_issuable && issuable.supports_weight?
unless can_admin_issuable && issuable.weight_available?
params.delete(:weight)
end
......
- if issuable_sidebar[:type] == "issue"
- if issuable_sidebar[:supports_weight]
- if issuable_sidebar[:features_available][:issue_weights]
.js-sidebar-weight-entry-point
- else
......
- return unless issuable.weight_available?
- issuable = local_assigns.fetch(:issuable)
- has_due_date = issuable.has_attribute?(:due_date)
......
- milestone = local_assigns.fetch(:milestone)
- return unless milestone.supports_weight?
- return unless milestone.weight_available?
- total_weight = milestone.issues_visible_to_user(current_user).sum(:weight) # rubocop: disable CodeReuse/ActiveRecord
.block.weight
......
---
title: Remove weight from incidents sidebar
merge_request: 40794
author:
type: changed
......@@ -7,7 +7,7 @@ module EE
extend ActiveSupport::Concern
prepended do
expose :weight, if: ->(issue, _) { issue.supports_weight? }
expose :weight, if: ->(issue, _) { issue.weight_available? }
expose(:blocking_issues_count) do |issue, options|
issuable_metadata.blocking_issues_count
......
......@@ -30,7 +30,7 @@ module EE
params "0, 1, 2, …"
types Issue, MergeRequest
condition do
quick_action_target.supports_weight? &&
quick_action_target.weight_available? &&
current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target)
end
parse_params do |weight|
......@@ -49,7 +49,7 @@ module EE
types Issue, MergeRequest
condition do
quick_action_target.persisted? &&
quick_action_target.supports_weight? &&
quick_action_target.weight_available? &&
quick_action_target.weight? &&
current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target)
end
......
......@@ -54,4 +54,29 @@ RSpec.describe EE::Issuable do
it { is_expected.to eq(supports_epic) }
end
end
describe '#weight_available?' do
let(:group) { build_stubbed(:group) }
let(:project_with_group) { build_stubbed(:project, group: group) }
let(:project_without_group) { build_stubbed(:project) }
where(:issuable_type, :project, :weight_available) do
[
[:issue, :project_with_group, true],
[:issue, :project_without_group, true],
[:incident, :project_with_group, false],
[:incident, :project_without_group, false],
[:merge_request, :project_with_group, false],
[:merge_request, :project_without_group, false]
]
end
with_them do
let(:issuable) { build_stubbed(issuable_type, project: send(project)) }
subject { issuable.weight_available? }
it { is_expected.to eq(weight_available) }
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment