debian-mirror-gitlab/app/graphql/mutations/issues/set_escalation_status.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.2 KiB
Ruby
Raw Normal View History

2022-03-02 08:16:31 +05:30
# frozen_string_literal: true
module Mutations
module Issues
class SetEscalationStatus < Base
graphql_name 'IssueSetEscalationStatus'
argument :status, Types::IncidentManagement::EscalationStatusEnum,
required: true,
description: 'Set the escalation status.'
def resolve(project_path:, iid:, status:)
issue = authorized_find!(project_path: project_path, iid: iid)
project = issue.project
authorize_escalation_status!(project)
2022-04-04 11:22:00 +05:30
check_feature_availability!(issue)
2022-03-02 08:16:31 +05:30
::Issues::UpdateService.new(
2023-04-23 21:23:45 +05:30
container: project,
2022-03-02 08:16:31 +05:30
current_user: current_user,
params: { escalation_status: { status: status } }
).execute(issue)
{
issue: issue,
errors: errors_on_object(issue)
}
end
private
def authorize_escalation_status!(project)
return if Ability.allowed?(current_user, :update_escalation_status, project)
raise_resource_not_available_error!
end
2022-04-04 11:22:00 +05:30
def check_feature_availability!(issue)
return if issue.supports_escalation?
2022-03-02 08:16:31 +05:30
raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature unavailable for provided issue'
end
end
end
end