Commit 305a8e54 authored by Simon Knox's avatar Simon Knox

Merge branch 'alert-incident-url-follow' into 'master'

Feat(incidents): allow alert to link to incidents

See merge request gitlab-org/gitlab!55426
parents 01fd0e58 312fa4c4
...@@ -225,7 +225,7 @@ export default { ...@@ -225,7 +225,7 @@ export default {
getIssueMeta({ issue: { iid, state } }) { getIssueMeta({ issue: { iid, state } }) {
return { return {
state: state === 'closed' ? `(${this.$options.i18n.closed})` : '', state: state === 'closed' ? `(${this.$options.i18n.closed})` : '',
link: joinPaths('/', this.projectPath, '-', 'issues', iid), link: joinPaths('/', this.projectPath, '-', 'issues/incident', iid),
}; };
}, },
tbodyTrClass(item) { tbodyTrClass(item) {
......
...@@ -222,7 +222,9 @@ export default { ...@@ -222,7 +222,9 @@ export default {
}); });
}, },
incidentPath(issueId) { incidentPath(issueId) {
return joinPaths(this.projectIssuesPath, issueId); return this.isThreatMonitoringPage
? joinPaths(this.projectIssuesPath, issueId)
: joinPaths(this.projectIssuesPath, 'incident', issueId);
}, },
trackPageViews() { trackPageViews() {
const { category, action } = this.trackAlertsDetailsViewsOptions; const { category, action } = this.trackAlertsDetailsViewsOptions;
......
---
title: Allow alert to link to incidents
merge_request: 55426
author:
type: changed
...@@ -251,7 +251,7 @@ describe('AlertManagementTable', () => { ...@@ -251,7 +251,7 @@ describe('AlertManagementTable', () => {
const tooltip = getBinding(issueField.element, 'gl-tooltip'); const tooltip = getBinding(issueField.element, 'gl-tooltip');
expect(issueField.text()).toBe(`#1 (closed)`); expect(issueField.text()).toBe(`#1 (closed)`);
expect(issueField.attributes('href')).toBe('/gitlab-org/gitlab/-/issues/1'); expect(issueField.attributes('href')).toBe('/gitlab-org/gitlab/-/issues/incident/1');
expect(issueField.attributes('title')).toBe('My test issue'); expect(issueField.attributes('title')).toBe('My test issue');
expect(tooltip).not.toBe(undefined); expect(tooltip).not.toBe(undefined);
}); });
......
...@@ -188,6 +188,18 @@ describe('AlertDetails', () => { ...@@ -188,6 +188,18 @@ describe('AlertDetails', () => {
}); });
expect(findMetricsTab().exists()).toBe(false); expect(findMetricsTab().exists()).toBe(false);
}); });
it('should display "View incident" button that links the issues page when incident exists', () => {
const iid = '3';
mountComponent({
data: { alert: { ...mockAlert, issue: { iid } }, sidebarStatus: false },
provide: { isThreatMonitoringPage: true },
});
expect(findViewIncidentBtn().exists()).toBe(true);
expect(findViewIncidentBtn().attributes('href')).toBe(joinPaths(projectIssuesPath, iid));
expect(findCreateIncidentBtn().exists()).toBe(false);
});
}); });
describe('Create incident from alert', () => { describe('Create incident from alert', () => {
...@@ -198,7 +210,9 @@ describe('AlertDetails', () => { ...@@ -198,7 +210,9 @@ describe('AlertDetails', () => {
}); });
expect(findViewIncidentBtn().exists()).toBe(true); expect(findViewIncidentBtn().exists()).toBe(true);
expect(findViewIncidentBtn().attributes('href')).toBe(joinPaths(projectIssuesPath, iid)); expect(findViewIncidentBtn().attributes('href')).toBe(
joinPaths(projectIssuesPath, 'incident', iid),
);
expect(findCreateIncidentBtn().exists()).toBe(false); expect(findCreateIncidentBtn().exists()).toBe(false);
}); });
......
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