Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
105498f7
Commit
105498f7
authored
Sep 07, 2020
by
Vitali Tatarintev
Committed by
Shinya Maeda
Sep 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow reading severity of Issuable
Issuable returns incident severity
parent
1a9d624a
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
194 additions
and
1 deletion
+194
-1
app/graphql/types/issuable_severity_enum.rb
app/graphql/types/issuable_severity_enum.rb
+12
-0
app/graphql/types/issue_type.rb
app/graphql/types/issue_type.rb
+3
-0
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+6
-0
app/models/issuable_severity.rb
app/models/issuable_severity.rb
+2
-0
app/models/issue.rb
app/models/issue.rb
+1
-0
changelogs/unreleased/238568-add-incident-severity-to-issue-graphql-query.yml
...d/238568-add-incident-severity-to-issue-graphql-query.yml
+5
-0
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+40
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+69
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+2
-0
spec/graphql/types/issuable_severity_enum_spec.rb
spec/graphql/types/issuable_severity_enum_spec.rb
+13
-0
spec/graphql/types/issue_type_spec.rb
spec/graphql/types/issue_type_spec.rb
+1
-1
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+3
-0
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+37
-0
No files found.
app/graphql/types/issuable_severity_enum.rb
0 → 100644
View file @
105498f7
# frozen_string_literal: true
module
Types
class
IssuableSeverityEnum
<
BaseEnum
graphql_name
'IssuableSeverity'
description
'Incident severity'
::
IssuableSeverity
.
severities
.
keys
.
each
do
|
severity
|
value
severity
.
upcase
,
value:
severity
,
description:
"
#{
severity
.
titleize
}
severity"
end
end
end
app/graphql/types/issue_type.rb
View file @
105498f7
...
...
@@ -106,6 +106,9 @@ module Types
Types
::
AlertManagement
::
AlertType
,
null:
true
,
description:
'Alert associated to this issue'
field
:severity
,
Types
::
IssuableSeverityEnum
,
null:
true
,
description:
'Severity level of the incident'
end
end
...
...
app/models/concerns/issuable.rb
View file @
105498f7
...
...
@@ -189,6 +189,12 @@ module Issuable
is_a?
(
Issue
)
&&
super
end
def
severity
return
IssuableSeverity
::
DEFAULT
unless
incident?
issuable_severity
&
.
severity
||
IssuableSeverity
::
DEFAULT
end
private
def
description_max_length_for_new_records_is_valid
...
...
app/models/issuable_severity.rb
View file @
105498f7
# frozen_string_literal: true
class
IssuableSeverity
<
ApplicationRecord
DEFAULT
=
'unknown'
belongs_to
:issue
validates
:issue
,
presence:
true
,
uniqueness:
true
...
...
app/models/issue.rb
View file @
105498f7
...
...
@@ -60,6 +60,7 @@ class Issue < ApplicationRecord
end
end
has_one
:issuable_severity
has_one
:sentry_issue
has_one
:alert_management_alert
,
class_name:
'AlertManagement::Alert'
has_and_belongs_to_many
:self_managed_prometheus_alert_events
,
join_table: :issues_self_managed_prometheus_alert_events
# rubocop: disable Rails/HasAndBelongsToMany
...
...
changelogs/unreleased/238568-add-incident-severity-to-issue-graphql-query.yml
0 → 100644
View file @
105498f7
---
title
:
Exposes Incident's severity via GraphQL
merge_request
:
40945
author
:
type
:
added
doc/api/graphql/reference/gitlab_schema.graphql
View file @
105498f7
...
...
@@ -5564,6 +5564,11 @@ type EpicIssue implements Noteable {
"""
relativePosition
:
Int
"""
Severity
level
of
the
incident
"""
severity
:
IssuableSeverity
"""
State
of
the
issue
"""
...
...
@@ -7032,6 +7037,36 @@ type InstanceSecurityDashboard {
):
VulnerabilityScannerConnection
}
"""
Incident severity
"""
enum
IssuableSeverity
{
"""
Critical
severity
"""
CRITICAL
"""
High
severity
"""
HIGH
"""
Low
severity
"""
LOW
"""
Medium
severity
"""
MEDIUM
"""
Unknown
severity
"""
UNKNOWN
}
"""
State of a GitLab issue or merge request
"""
...
...
@@ -7278,6 +7313,11 @@ type Issue implements Noteable {
"""
relativePosition
:
Int
"""
Severity
level
of
the
incident
"""
severity
:
IssuableSeverity
"""
State
of
the
issue
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
105498f7
...
...
@@ -15512,6 +15512,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "severity",
"description": "Severity level of the incident",
"args": [
],
"type": {
"kind": "ENUM",
"name": "IssuableSeverity",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "state",
"description": "State of the issue",
...
...
@@ -19423,6 +19437,47 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "IssuableSeverity",
"description": "Incident severity",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "UNKNOWN",
"description": "Unknown severity",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "LOW",
"description": "Low severity",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "MEDIUM",
"description": "Medium severity",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "HIGH",
"description": "High severity",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "CRITICAL",
"description": "Critical severity",
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "IssuableState",
...
...
@@ -20075,6 +20130,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "severity",
"description": "Severity level of the incident",
"args": [
],
"type": {
"kind": "ENUM",
"name": "IssuableSeverity",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "state",
"description": "State of the issue",
doc/api/graphql/reference/index.md
View file @
105498f7
...
...
@@ -932,6 +932,7 @@ Relationship between an epic and an issue
|
`reference`
| String! | Internal reference of the issue. Returned in shortened format by default |
|
`relationPath`
| String | URI path of the epic-issue relation |
|
`relativePosition`
| Int | Relative position of the issue (used for positioning in epic tree and issue boards) |
|
`severity`
| IssuableSeverity | Severity level of the incident |
|
`state`
| IssueState! | State of the issue |
|
`statusPagePublishedIncident`
| Boolean | Indicates whether an issue is published to the status page |
|
`subscribed`
| Boolean! | Indicates the currently logged in user is subscribed to the issue |
...
...
@@ -1103,6 +1104,7 @@ Represents a Group Membership
|
`milestone`
| Milestone | Milestone of the issue |
|
`reference`
| String! | Internal reference of the issue. Returned in shortened format by default |
|
`relativePosition`
| Int | Relative position of the issue (used for positioning in epic tree and issue boards) |
|
`severity`
| IssuableSeverity | Severity level of the incident |
|
`state`
| IssueState! | State of the issue |
|
`statusPagePublishedIncident`
| Boolean | Indicates whether an issue is published to the status page |
|
`subscribed`
| Boolean! | Indicates the currently logged in user is subscribed to the issue |
...
...
spec/graphql/types/issuable_severity_enum_spec.rb
0 → 100644
View file @
105498f7
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Types
::
IssuableSeverityEnum
do
specify
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'IssuableSeverity'
)
}
it
'exposes all the existing issuable severity values'
do
expect
(
described_class
.
values
.
keys
).
to
contain_exactly
(
*
%w[UNKNOWN LOW MEDIUM HIGH CRITICAL]
)
end
end
spec/graphql/types/issue_type_spec.rb
View file @
105498f7
...
...
@@ -15,7 +15,7 @@ RSpec.describe GitlabSchema.types['Issue'] do
fields
=
%i[id iid title description state reference author assignees participants labels milestone due_date
confidential discussion_locked upvotes downvotes user_notes_count web_path web_url relative_position
subscribed time_estimate total_time_spent closed_at created_at updated_at task_completion_status
designs design_collection alert_management_alert]
designs design_collection alert_management_alert
severity
]
fields
.
each
do
|
field_name
|
expect
(
described_class
).
to
have_graphql_field
(
field_name
)
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
105498f7
...
...
@@ -15,6 +15,7 @@ issues:
-
resource_iteration_events
-
sent_notifications
-
sentry_issue
-
issuable_severity
-
label_links
-
labels
-
last_edited_by
...
...
@@ -649,6 +650,8 @@ zoom_meetings:
-
issue
sentry_issue
:
-
issue
issuable_severity
:
-
issue
design_versions
:
*version
epic
:
-
subscriptions
...
...
spec/models/concerns/issuable_spec.rb
View file @
105498f7
...
...
@@ -860,4 +860,41 @@ RSpec.describe Issuable do
it
{
is_expected
.
to
eq
(
incident
)
}
end
end
describe
'#severity'
do
subject
{
issuable
.
severity
}
context
'when issuable is not an incident'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:issuable_type
,
:severity
)
do
:issue
|
'unknown'
:merge_request
|
'unknown'
end
with_them
do
let
(
:issuable
)
{
build_stubbed
(
issuable_type
)
}
it
{
is_expected
.
to
eq
(
severity
)
}
end
end
context
'when issuable type is an incident'
do
let!
(
:issuable
)
{
build_stubbed
(
:incident
)
}
context
'when incident does not have issuable_severity'
do
it
'returns default serverity'
do
is_expected
.
to
eq
(
IssuableSeverity
::
DEFAULT
)
end
end
context
'when incident has issuable_severity'
do
let!
(
:issuable_severity
)
{
build_stubbed
(
:issuable_severity
,
issue:
issuable
,
severity:
'critical'
)
}
it
'returns issuable serverity'
do
is_expected
.
to
eq
(
'critical'
)
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment