summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/graphql_shared
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/graphql_shared')
-rw-r--r--app/assets/javascripts/graphql_shared/fragments/alert.fragment.graphql17
-rw-r--r--app/assets/javascripts/graphql_shared/fragments/alert_note.fragment.graphql17
-rw-r--r--app/assets/javascripts/graphql_shared/mutations/update_alert_status.mutation.graphql17
-rw-r--r--app/assets/javascripts/graphql_shared/queries/get_alerts.query.graphql36
-rw-r--r--app/assets/javascripts/graphql_shared/utils.js2
5 files changed, 88 insertions, 1 deletions
diff --git a/app/assets/javascripts/graphql_shared/fragments/alert.fragment.graphql b/app/assets/javascripts/graphql_shared/fragments/alert.fragment.graphql
new file mode 100644
index 00000000000..62119177887
--- /dev/null
+++ b/app/assets/javascripts/graphql_shared/fragments/alert.fragment.graphql
@@ -0,0 +1,17 @@
+fragment AlertListItem on AlertManagementAlert {
+ iid
+ title
+ severity
+ status
+ startedAt
+ eventCount
+ issueIid
+ assignees {
+ nodes {
+ name
+ username
+ avatarUrl
+ webUrl
+ }
+ }
+}
diff --git a/app/assets/javascripts/graphql_shared/fragments/alert_note.fragment.graphql b/app/assets/javascripts/graphql_shared/fragments/alert_note.fragment.graphql
new file mode 100644
index 00000000000..74b425717a0
--- /dev/null
+++ b/app/assets/javascripts/graphql_shared/fragments/alert_note.fragment.graphql
@@ -0,0 +1,17 @@
+#import "~/graphql_shared/fragments/author.fragment.graphql"
+
+fragment AlertNote on Note {
+ id
+ author {
+ id
+ state
+ ...Author
+ }
+ body
+ bodyHtml
+ createdAt
+ discussion {
+ id
+ }
+ systemNoteIconName
+}
diff --git a/app/assets/javascripts/graphql_shared/mutations/update_alert_status.mutation.graphql b/app/assets/javascripts/graphql_shared/mutations/update_alert_status.mutation.graphql
new file mode 100644
index 00000000000..42dc388c9d1
--- /dev/null
+++ b/app/assets/javascripts/graphql_shared/mutations/update_alert_status.mutation.graphql
@@ -0,0 +1,17 @@
+#import "~/graphql_shared/fragments/alert_note.fragment.graphql"
+
+mutation updateAlertStatus($projectPath: ID!, $status: AlertManagementStatus!, $iid: String!) {
+ updateAlertStatus(input: { iid: $iid, status: $status, projectPath: $projectPath }) {
+ errors
+ alert {
+ iid
+ status
+ endedAt
+ notes {
+ nodes {
+ ...AlertNote
+ }
+ }
+ }
+ }
+}
diff --git a/app/assets/javascripts/graphql_shared/queries/get_alerts.query.graphql b/app/assets/javascripts/graphql_shared/queries/get_alerts.query.graphql
new file mode 100644
index 00000000000..e94758ef60e
--- /dev/null
+++ b/app/assets/javascripts/graphql_shared/queries/get_alerts.query.graphql
@@ -0,0 +1,36 @@
+#import "~/graphql_shared/fragments/alert.fragment.graphql"
+
+query getAlerts(
+ $projectPath: ID!
+ $statuses: [AlertManagementStatus!]
+ $sort: AlertManagementAlertSort
+ $firstPageSize: Int
+ $lastPageSize: Int
+ $prevPageCursor: String = ""
+ $nextPageCursor: String = ""
+ $searchTerm: String = ""
+ $assigneeUsername: String = ""
+) {
+ project(fullPath: $projectPath) {
+ alertManagementAlerts(
+ search: $searchTerm
+ assigneeUsername: $assigneeUsername
+ statuses: $statuses
+ sort: $sort
+ first: $firstPageSize
+ last: $lastPageSize
+ after: $nextPageCursor
+ before: $prevPageCursor
+ ) {
+ nodes {
+ ...AlertListItem
+ }
+ pageInfo {
+ hasNextPage
+ endCursor
+ hasPreviousPage
+ startCursor
+ }
+ }
+ }
+}
diff --git a/app/assets/javascripts/graphql_shared/utils.js b/app/assets/javascripts/graphql_shared/utils.js
index 813e21b6ce9..4715bbc94f6 100644
--- a/app/assets/javascripts/graphql_shared/utils.js
+++ b/app/assets/javascripts/graphql_shared/utils.js
@@ -51,4 +51,4 @@ export const convertToGraphQLId = (type, id) => {
* @param {Array} ids An array of id values
* @returns {Array}
*/
-export const convertToGraphQLIds = (type, ids) => ids.map(id => convertToGraphQLId(type, id));
+export const convertToGraphQLIds = (type, ids) => ids.map((id) => convertToGraphQLId(type, id));