Commit f652ba57 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '215095-alerts-by-status-BE-integration' into 'master'

Organize alerts by status in list view  (BE integration)

See merge request gitlab-org/gitlab!31749
parents 4af08d23 ae1c2a0f
...@@ -10,7 +10,6 @@ import { ...@@ -10,7 +10,6 @@ import {
GlDropdownItem, GlDropdownItem,
GlTabs, GlTabs,
GlTab, GlTab,
GlBadge,
} from '@gitlab/ui'; } from '@gitlab/ui';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
...@@ -87,7 +86,6 @@ export default { ...@@ -87,7 +86,6 @@ export default {
GlIcon, GlIcon,
GlTabs, GlTabs,
GlTab, GlTab,
GlBadge,
}, },
mixins: [glFeatureFlagsMixin()], mixins: [glFeatureFlagsMixin()],
props: { props: {
...@@ -118,7 +116,7 @@ export default { ...@@ -118,7 +116,7 @@ export default {
variables() { variables() {
return { return {
projectPath: this.projectPath, projectPath: this.projectPath,
status: this.statusFilter, statuses: this.statusFilter,
}; };
}, },
update(data) { update(data) {
...@@ -135,7 +133,7 @@ export default { ...@@ -135,7 +133,7 @@ export default {
errored: false, errored: false,
isAlertDismissed: false, isAlertDismissed: false,
isErrorAlertDismissed: false, isErrorAlertDismissed: false,
statusFilter: this.$options.statusTabs[0].status, statusFilter: this.$options.statusTabs[4].filters,
}; };
}, },
computed: { computed: {
...@@ -151,7 +149,7 @@ export default { ...@@ -151,7 +149,7 @@ export default {
}, },
methods: { methods: {
filterALertsByStatus(tabIndex) { filterALertsByStatus(tabIndex) {
this.statusFilter = this.$options.statusTabs[tabIndex].status; this.statusFilter = this.$options.statusTabs[tabIndex].filters;
}, },
capitalizeFirstCharacter, capitalizeFirstCharacter,
updateAlertStatus(status, iid) { updateAlertStatus(status, iid) {
...@@ -190,9 +188,6 @@ export default { ...@@ -190,9 +188,6 @@ export default {
<gl-tab v-for="tab in $options.statusTabs" :key="tab.status"> <gl-tab v-for="tab in $options.statusTabs" :key="tab.status">
<template slot="title"> <template slot="title">
<span>{{ tab.title }}</span> <span>{{ tab.title }}</span>
<gl-badge v-if="alerts" size="sm" class="gl-tab-counter-badge">
{{ alerts.length }}
</gl-badge>
</template> </template>
</gl-tab> </gl-tab>
</gl-tabs> </gl-tabs>
......
...@@ -10,32 +10,37 @@ export const ALERTS_SEVERITY_LABELS = { ...@@ -10,32 +10,37 @@ export const ALERTS_SEVERITY_LABELS = {
}; };
export const ALERTS_STATUS = { export const ALERTS_STATUS = {
OPEN: 'open', OPEN: 'OPEN',
TRIGGERED: 'triggered', TRIGGERED: 'TRIGGERED',
ACKNOWLEDGED: 'acknowledged', ACKNOWLEDGED: 'ACKNOWLEDGED',
RESOLVED: 'resolved', RESOLVED: 'RESOLVED',
ALL: 'all', ALL: 'ALL',
}; };
export const ALERTS_STATUS_TABS = [ export const ALERTS_STATUS_TABS = [
{ {
title: s__('AlertManagement|Open'), title: s__('AlertManagement|Open'),
status: ALERTS_STATUS.OPEN, status: ALERTS_STATUS.OPEN,
filters: [ALERTS_STATUS.TRIGGERED, ALERTS_STATUS.ACKNOWLEDGED],
}, },
{ {
title: s__('AlertManagement|Triggered'), title: s__('AlertManagement|Triggered'),
status: ALERTS_STATUS.TRIGGERED, status: ALERTS_STATUS.TRIGGERED,
filters: [ALERTS_STATUS.TRIGGERED],
}, },
{ {
title: s__('AlertManagement|Acknowledged'), title: s__('AlertManagement|Acknowledged'),
status: ALERTS_STATUS.ACKNOWLEDGED, status: ALERTS_STATUS.ACKNOWLEDGED,
filters: [ALERTS_STATUS.ACKNOWLEDGED],
}, },
{ {
title: s__('AlertManagement|Resolved'), title: s__('AlertManagement|Resolved'),
status: ALERTS_STATUS.RESOLVED, status: ALERTS_STATUS.RESOLVED,
filters: [ALERTS_STATUS.RESOLVED],
}, },
{ {
title: s__('AlertManagement|All alerts'), title: s__('AlertManagement|All alerts'),
status: ALERTS_STATUS.ALL, status: ALERTS_STATUS.ALL,
filters: [ALERTS_STATUS.TRIGGERED, ALERTS_STATUS.ACKNOWLEDGED, ALERTS_STATUS.RESOLVED],
}, },
]; ];
#import "../fragments/listItem.fragment.graphql" #import "../fragments/listItem.fragment.graphql"
query getAlerts($projectPath: ID!) { query getAlerts($projectPath: ID!, $statuses: [AlertManagementStatus!]) {
project(fullPath: $projectPath) { project(fullPath: $projectPath) {
alertManagementAlerts { alertManagementAlerts(statuses: $statuses) {
nodes { nodes {
...AlertListItem ...AlertListItem
} }
......
...@@ -5,7 +5,6 @@ import { ...@@ -5,7 +5,6 @@ import {
GlAlert, GlAlert,
GlLoadingIcon, GlLoadingIcon,
GlDropdown, GlDropdown,
GlBadge,
GlIcon, GlIcon,
GlTab, GlTab,
GlDropdownItem, GlDropdownItem,
...@@ -28,7 +27,6 @@ describe('AlertManagementList', () => { ...@@ -28,7 +27,6 @@ describe('AlertManagementList', () => {
const findLoader = () => wrapper.find(GlLoadingIcon); const findLoader = () => wrapper.find(GlLoadingIcon);
const findStatusDropdown = () => wrapper.find(GlDropdown); const findStatusDropdown = () => wrapper.find(GlDropdown);
const findStatusFilterTabs = () => wrapper.findAll(GlTab); const findStatusFilterTabs = () => wrapper.findAll(GlTab);
const findNumberOfAlertsBadge = () => wrapper.findAll(GlBadge);
const findDateFields = () => wrapper.findAll(TimeAgo); const findDateFields = () => wrapper.findAll(TimeAgo);
const findFirstStatusOption = () => findStatusDropdown().find(GlDropdownItem); const findFirstStatusOption = () => findStatusDropdown().find(GlDropdownItem);
const findSeverityFields = () => wrapper.findAll('[data-testid="severityField"]'); const findSeverityFields = () => wrapper.findAll('[data-testid="severityField"]');
...@@ -106,15 +104,6 @@ describe('AlertManagementList', () => { ...@@ -106,15 +104,6 @@ describe('AlertManagementList', () => {
expect(tab.text()).toContain(ALERTS_STATUS_TABS[i].title); expect(tab.text()).toContain(ALERTS_STATUS_TABS[i].title);
}); });
}); });
it('should have number of items badge along with status tab', () => {
expect(findNumberOfAlertsBadge().length).toEqual(ALERTS_STATUS_TABS.length);
expect(
findNumberOfAlertsBadge()
.at(0)
.text(),
).toEqual(`${mockAlerts.length}`);
});
}); });
describe('alertListStatusFilteringEnabled feature flag disabled', () => { describe('alertListStatusFilteringEnabled feature flag disabled', () => {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"eventCount": 7, "eventCount": 7,
"startedAt": "2020-04-17T23:18:14.996Z", "startedAt": "2020-04-17T23:18:14.996Z",
"endedAt": "2020-04-17T23:18:14.996Z", "endedAt": "2020-04-17T23:18:14.996Z",
"status": "triggered" "status": "TRIGGERED"
}, },
{ {
"iid": "1527543", "iid": "1527543",
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"eventCount": 1, "eventCount": 1,
"startedAt": "2020-04-17T23:18:14.996Z", "startedAt": "2020-04-17T23:18:14.996Z",
"endedAt": "2020-04-17T23:18:14.996Z", "endedAt": "2020-04-17T23:18:14.996Z",
"status": "acknowledged" "status": "ACKNOWLEDGED"
}, },
{ {
"iid": "1527544", "iid": "1527544",
...@@ -24,6 +24,6 @@ ...@@ -24,6 +24,6 @@
"eventCount": 4, "eventCount": 4,
"startedAt": "2020-04-17T23:18:14.996Z", "startedAt": "2020-04-17T23:18:14.996Z",
"endedAt": "2020-04-17T23:18:14.996Z", "endedAt": "2020-04-17T23:18:14.996Z",
"status": "resolved" "status": "RESOLVED"
} }
] ]
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