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 ...@@ -177,10 +177,6 @@ module Issuable
assignees.count > 1 assignees.count > 1
end end
def supports_weight?
false
end
def supports_time_tracking? def supports_time_tracking?
is_a?(TimeTrackable) && !incident? is_a?(TimeTrackable) && !incident?
end end
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
= render_if_exists "shared/issuable/form/merge_request_blocks", issuable: issuable, form: form = 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 .col-lg-6
- if @issue[:issue_type] != 'incident' - if @issue[:issue_type] != 'incident'
= render_if_exists "shared/issuable/form/weight", issuable: issuable, form: form = render_if_exists "shared/issuable/form/weight", issuable: issuable, form: form
......
...@@ -15,7 +15,7 @@ module EE ...@@ -15,7 +15,7 @@ module EE
field :weight, GraphQL::INT_TYPE, null: true, field :weight, GraphQL::INT_TYPE, null: true,
description: 'Weight of the issue', 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, field :blocked, GraphQL::BOOLEAN_TYPE, null: false,
description: 'Indicates the issue is blocked', description: 'Indicates the issue is blocked',
......
...@@ -12,5 +12,13 @@ module EE ...@@ -12,5 +12,13 @@ module EE
def supports_health_status? def supports_health_status?
false false
end end
def supports_weight?
false
end
def weight_available?
supports_weight? && project&.feature_available?(:issue_weights)
end
end end
end end
...@@ -111,7 +111,7 @@ module EE ...@@ -111,7 +111,7 @@ module EE
# override # override
def weight def weight
super if supports_weight? super if weight_available?
end end
# override # override
...@@ -132,8 +132,9 @@ module EE ...@@ -132,8 +132,9 @@ module EE
changed_fields && (changed_fields & ELASTICSEARCH_PERMISSION_TRACKED_FIELDS).any? changed_fields && (changed_fields & ELASTICSEARCH_PERMISSION_TRACKED_FIELDS).any?
end end
override :supports_weight?
def supports_weight? def supports_weight?
project&.feature_available?(:issue_weights) !incident?
end end
def can_assign_epic?(user) def can_assign_epic?(user)
......
...@@ -10,12 +10,12 @@ module EE ...@@ -10,12 +10,12 @@ module EE
has_many :boards has_many :boards
end end
def supports_weight? def weight_available?
resource_parent&.feature_available?(:issue_weights) resource_parent&.feature_available?(:issue_weights)
end end
def supports_milestone_charts? def supports_milestone_charts?
resource_parent&.feature_available?(:milestone_charts) && supports_weight? resource_parent&.feature_available?(:milestone_charts) && weight_available?
end end
def burnup_charts_available? def burnup_charts_available?
......
...@@ -8,6 +8,8 @@ module EE ...@@ -8,6 +8,8 @@ module EE
expose :scoped_labels_available do |issuable| expose :scoped_labels_available do |issuable|
issuable.project&.feature_available?(:scoped_labels) issuable.project&.feature_available?(:scoped_labels)
end end
expose :supports_weight?, as: :supports_weight
end end
end end
end end
...@@ -5,7 +5,7 @@ module EE ...@@ -5,7 +5,7 @@ module EE
include RequestAwareEntity include RequestAwareEntity
prepended do prepended do
expose :weight, if: ->(issue, _) { issue.supports_weight? } expose :weight, if: ->(issue, _) { issue.weight_available? }
expose :blocked do |issue, options| expose :blocked do |issue, options|
options[:blocked_issue_ids].present? && options[:blocked_issue_ids].include?(issue.id) options[:blocked_issue_ids].present? && options[:blocked_issue_ids].include?(issue.id)
end end
......
...@@ -4,7 +4,7 @@ module EE ...@@ -4,7 +4,7 @@ module EE
extend ActiveSupport::Concern extend ActiveSupport::Concern
prepended do 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 with_options if: -> (_, options) { options[:with_blocking_issues] } do
expose :blocked?, as: :blocked expose :blocked?, as: :blocked
......
...@@ -11,7 +11,7 @@ module EE ...@@ -11,7 +11,7 @@ module EE
expose :supports_health_status?, as: :health_status expose :supports_health_status?, as: :health_status
expose :issue_weights do |issuable| expose :issue_weights do |issuable|
issuable.project.feature_available?(:issue_weights) issuable.weight_available?
end end
expose :epics do |issuable| expose :epics do |issuable|
......
...@@ -13,7 +13,7 @@ module EE ...@@ -13,7 +13,7 @@ module EE
def filter_params(issuable) def filter_params(issuable)
can_admin_issuable = can_admin_issuable?(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) params.delete(:weight)
end end
......
- if issuable_sidebar[:type] == "issue" - if issuable_sidebar[:supports_weight]
- if issuable_sidebar[:features_available][:issue_weights] - if issuable_sidebar[:features_available][:issue_weights]
.js-sidebar-weight-entry-point .js-sidebar-weight-entry-point
- else - else
......
- return unless issuable.weight_available?
- issuable = local_assigns.fetch(:issuable) - issuable = local_assigns.fetch(:issuable)
- has_due_date = issuable.has_attribute?(:due_date) - has_due_date = issuable.has_attribute?(:due_date)
......
- milestone = local_assigns.fetch(:milestone) - 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 - total_weight = milestone.issues_visible_to_user(current_user).sum(:weight) # rubocop: disable CodeReuse/ActiveRecord
.block.weight .block.weight
......
---
title: Remove weight from incidents sidebar
merge_request: 40794
author:
type: changed
...@@ -7,7 +7,7 @@ module EE ...@@ -7,7 +7,7 @@ module EE
extend ActiveSupport::Concern extend ActiveSupport::Concern
prepended do prepended do
expose :weight, if: ->(issue, _) { issue.supports_weight? } expose :weight, if: ->(issue, _) { issue.weight_available? }
expose(:blocking_issues_count) do |issue, options| expose(:blocking_issues_count) do |issue, options|
issuable_metadata.blocking_issues_count issuable_metadata.blocking_issues_count
......
...@@ -30,7 +30,7 @@ module EE ...@@ -30,7 +30,7 @@ module EE
params "0, 1, 2, …" params "0, 1, 2, …"
types Issue, MergeRequest types Issue, MergeRequest
condition do 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) current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target)
end end
parse_params do |weight| parse_params do |weight|
...@@ -49,7 +49,7 @@ module EE ...@@ -49,7 +49,7 @@ module EE
types Issue, MergeRequest types Issue, MergeRequest
condition do condition do
quick_action_target.persisted? && quick_action_target.persisted? &&
quick_action_target.supports_weight? && quick_action_target.weight_available? &&
quick_action_target.weight? && quick_action_target.weight? &&
current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target) current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target)
end end
......
...@@ -54,4 +54,29 @@ RSpec.describe EE::Issuable do ...@@ -54,4 +54,29 @@ RSpec.describe EE::Issuable do
it { is_expected.to eq(supports_epic) } it { is_expected.to eq(supports_epic) }
end end
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 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