Commit 86ef6baa authored by Tristan Read's avatar Tristan Read Committed by Jacques Erasmus

Add issue column to alert list

parent ef2ce0f3
...@@ -84,6 +84,13 @@ export default { ...@@ -84,6 +84,13 @@ export default {
tdClass: `${tdClass} text-md-right`, tdClass: `${tdClass} text-md-right`,
sortable: true, sortable: true,
}, },
{
key: 'issue',
label: s__('AlertManagement|Issue'),
thClass: 'gl-w-12 gl-pointer-events-none',
tdClass,
sortable: false,
},
{ {
key: 'assignees', key: 'assignees',
label: s__('AlertManagement|Assignees'), label: s__('AlertManagement|Assignees'),
...@@ -278,6 +285,9 @@ export default { ...@@ -278,6 +285,9 @@ export default {
? assignees.nodes[0]?.username ? assignees.nodes[0]?.username
: s__('AlertManagement|Unassigned'); : s__('AlertManagement|Unassigned');
}, },
getIssueLink(item) {
return joinPaths('/', this.projectPath, '-', 'issues', item.issueIid);
},
handlePageChange(page) { handlePageChange(page) {
const { startCursor, endCursor } = this.alerts.pageInfo; const { startCursor, endCursor } = this.alerts.pageInfo;
...@@ -402,6 +412,13 @@ export default { ...@@ -402,6 +412,13 @@ export default {
<div class="gl-max-w-full text-truncate" :title="item.title">{{ item.title }}</div> <div class="gl-max-w-full text-truncate" :title="item.title">{{ item.title }}</div>
</template> </template>
<template #cell(issue)="{ item }">
<gl-link v-if="item.issueIid" data-testid="issueField" :href="getIssueLink(item)">
#{{ item.issueIid }}
</gl-link>
<div v-else data-testid="issueField">{{ s__('AlertManagement|None') }}</div>
</template>
<template #cell(assignees)="{ item }"> <template #cell(assignees)="{ item }">
<div class="gl-max-w-full text-truncate" data-testid="assigneesField"> <div class="gl-max-w-full text-truncate" data-testid="assigneesField">
{{ getAssignees(item.assignees) }} {{ getAssignees(item.assignees) }}
......
---
title: Add issue column to alert list
merge_request: 35291
author:
type: added
...@@ -1966,6 +1966,9 @@ msgstr "" ...@@ -1966,6 +1966,9 @@ msgstr ""
msgid "AlertManagement|Info" msgid "AlertManagement|Info"
msgstr "" msgstr ""
msgid "AlertManagement|Issue"
msgstr ""
msgid "AlertManagement|Low" msgid "AlertManagement|Low"
msgstr "" msgstr ""
......
...@@ -48,6 +48,7 @@ describe('AlertManagementList', () => { ...@@ -48,6 +48,7 @@ describe('AlertManagementList', () => {
const findSeverityColumnHeader = () => wrapper.findAll('th').at(0); const findSeverityColumnHeader = () => wrapper.findAll('th').at(0);
const findPagination = () => wrapper.find(GlPagination); const findPagination = () => wrapper.find(GlPagination);
const findSearch = () => wrapper.find(GlSearchBoxByType); const findSearch = () => wrapper.find(GlSearchBoxByType);
const findIssueFields = () => wrapper.findAll('[data-testid="issueField"]');
const alertsCount = { const alertsCount = {
open: 14, open: 14,
triggered: 10, triggered: 10,
...@@ -278,6 +279,37 @@ describe('AlertManagementList', () => { ...@@ -278,6 +279,37 @@ describe('AlertManagementList', () => {
expect(visitUrl).toHaveBeenCalledWith('/1527542/details'); expect(visitUrl).toHaveBeenCalledWith('/1527542/details');
}); });
describe('alert issue links', () => {
beforeEach(() => {
mountComponent({
props: { alertManagementEnabled: true, userCanEnableAlertManagement: true },
data: { alerts: { list: mockAlerts }, alertsCount, errored: false },
loading: false,
});
});
it('shows "None" when no link exists', () => {
expect(
findIssueFields()
.at(0)
.text(),
).toBe('None');
});
it('renders a link when one exists', () => {
expect(
findIssueFields()
.at(1)
.text(),
).toBe('#1');
expect(
findIssueFields()
.at(1)
.attributes('href'),
).toBe('/gitlab-org/gitlab/-/issues/1');
});
});
describe('handle date fields', () => { describe('handle date fields', () => {
it('should display time ago dates when values provided', () => { it('should display time ago dates when values provided', () => {
mountComponent({ mountComponent({
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
"endedAt": "2020-04-17T23:18:14.996Z", "endedAt": "2020-04-17T23:18:14.996Z",
"status": "ACKNOWLEDGED", "status": "ACKNOWLEDGED",
"assignees": { "nodes": [{ "username": "root" }] }, "assignees": { "nodes": [{ "username": "root" }] },
"issueIid": "1",
"notes": { "notes": {
"nodes": [ "nodes": [
{ {
......
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