Commit 54368096 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '227678-create-incident-button-alert' into 'master'

Rename issue button to incident

Closes #227678

See merge request gitlab-org/gitlab!39684
parents eab19c32 71ad697a
...@@ -113,8 +113,8 @@ export default { ...@@ -113,8 +113,8 @@ export default {
errored: false, errored: false,
sidebarStatus: false, sidebarStatus: false,
isErrorDismissed: false, isErrorDismissed: false,
createIssueError: '', createIncidentError: '',
issueCreationInProgress: false, incidentCreationInProgress: false,
sidebarErrorMessage: '', sidebarErrorMessage: '',
}; };
}, },
...@@ -172,8 +172,8 @@ export default { ...@@ -172,8 +172,8 @@ export default {
this.errored = true; this.errored = true;
this.sidebarErrorMessage = errorMessage; this.sidebarErrorMessage = errorMessage;
}, },
createIssue() { createIncident() {
this.issueCreationInProgress = true; this.incidentCreationInProgress = true;
this.$apollo this.$apollo
.mutate({ .mutate({
...@@ -185,18 +185,18 @@ export default { ...@@ -185,18 +185,18 @@ export default {
}) })
.then(({ data: { createAlertIssue: { errors, issue } } }) => { .then(({ data: { createAlertIssue: { errors, issue } } }) => {
if (errors?.length) { if (errors?.length) {
[this.createIssueError] = errors; [this.createIncidentError] = errors;
this.issueCreationInProgress = false; this.incidentCreationInProgress = false;
} else if (issue) { } else if (issue) {
visitUrl(this.issuePath(issue.iid)); visitUrl(this.incidentPath(issue.iid));
} }
}) })
.catch(error => { .catch(error => {
this.createIssueError = error; this.createIncidentError = error;
this.issueCreationInProgress = false; this.incidentCreationInProgress = false;
}); });
}, },
issuePath(issueId) { incidentPath(issueId) {
return joinPaths(this.projectIssuesPath, issueId); return joinPaths(this.projectIssuesPath, issueId);
}, },
trackPageViews() { trackPageViews() {
...@@ -213,12 +213,12 @@ export default { ...@@ -213,12 +213,12 @@ export default {
<p v-html="sidebarErrorMessage || $options.i18n.errorMsg"></p> <p v-html="sidebarErrorMessage || $options.i18n.errorMsg"></p>
</gl-alert> </gl-alert>
<gl-alert <gl-alert
v-if="createIssueError" v-if="createIncidentError"
variant="danger" variant="danger"
data-testid="issueCreationError" data-testid="incidentCreationError"
@dismiss="createIssueError = null" @dismiss="createIncidentError = null"
> >
{{ createIssueError }} {{ createIncidentError }}
</gl-alert> </gl-alert>
<div v-if="loading"><gl-loading-icon size="lg" class="gl-mt-5" /></div> <div v-if="loading"><gl-loading-icon size="lg" class="gl-mt-5" /></div>
<div <div
...@@ -244,24 +244,24 @@ export default { ...@@ -244,24 +244,24 @@ export default {
</div> </div>
<gl-button <gl-button
v-if="alert.issueIid" v-if="alert.issueIid"
class="gl-mt-3 mt-sm-0 align-self-center align-self-sm-baseline alert-details-issue-button" class="gl-mt-3 mt-sm-0 align-self-center align-self-sm-baseline alert-details-incident-button"
data-testid="viewIssueBtn" data-testid="viewIncidentBtn"
:href="issuePath(alert.issueIid)" :href="incidentPath(alert.issueIid)"
category="primary" category="primary"
variant="success" variant="success"
> >
{{ s__('AlertManagement|View issue') }} {{ s__('AlertManagement|View incident') }}
</gl-button> </gl-button>
<gl-button <gl-button
v-else v-else
class="gl-mt-3 mt-sm-0 align-self-center align-self-sm-baseline alert-details-issue-button" class="gl-mt-3 mt-sm-0 align-self-center align-self-sm-baseline alert-details-incident-button"
data-testid="createIssueBtn" data-testid="createIncidentBtn"
:loading="issueCreationInProgress" :loading="incidentCreationInProgress"
category="primary" category="primary"
variant="success" variant="success"
@click="createIssue()" @click="createIncident()"
> >
{{ s__('AlertManagement|Create issue') }} {{ s__('AlertManagement|Create incident') }}
</gl-button> </gl-button>
<gl-button <gl-button
:aria-label="__('Toggle sidebar')" :aria-label="__('Toggle sidebar')"
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
} }
@include media-breakpoint-down(xs) { @include media-breakpoint-down(xs) {
.alert-details-issue-button { .alert-details-incident-button {
width: 100%; width: 100%;
} }
} }
......
---
title: Rename create issue button to create incidents in ALert details
merge_request: 39684
author:
type: changed
...@@ -2108,7 +2108,7 @@ msgstr "" ...@@ -2108,7 +2108,7 @@ msgstr ""
msgid "AlertManagement|Authorize external service" msgid "AlertManagement|Authorize external service"
msgstr "" msgstr ""
msgid "AlertManagement|Create issue" msgid "AlertManagement|Create incident"
msgstr "" msgstr ""
msgid "AlertManagement|Critical" msgid "AlertManagement|Critical"
...@@ -2234,7 +2234,7 @@ msgstr "" ...@@ -2234,7 +2234,7 @@ msgstr ""
msgid "AlertManagement|View alerts in Opsgenie" msgid "AlertManagement|View alerts in Opsgenie"
msgstr "" msgstr ""
msgid "AlertManagement|View issue" msgid "AlertManagement|View incident"
msgstr "" msgstr ""
msgid "AlertManagement|You have enabled the Opsgenie integration. Your alerts will be visible directly in Opsgenie." msgid "AlertManagement|You have enabled the Opsgenie integration. Your alerts will be visible directly in Opsgenie."
......
...@@ -63,9 +63,9 @@ describe('AlertDetails', () => { ...@@ -63,9 +63,9 @@ describe('AlertDetails', () => {
mock.restore(); mock.restore();
}); });
const findCreateIssueBtn = () => wrapper.find('[data-testid="createIssueBtn"]'); const findCreateIncidentBtn = () => wrapper.find('[data-testid="createIncidentBtn"]');
const findViewIssueBtn = () => wrapper.find('[data-testid="viewIssueBtn"]'); const findViewIncidentBtn = () => wrapper.find('[data-testid="viewIncidentBtn"]');
const findIssueCreationAlert = () => wrapper.find('[data-testid="issueCreationError"]'); const findIncidentCreationAlert = () => wrapper.find('[data-testid="incidentCreationError"]');
describe('Alert details', () => { describe('Alert details', () => {
describe('when alert is null', () => { describe('when alert is null', () => {
...@@ -135,18 +135,20 @@ describe('AlertDetails', () => { ...@@ -135,18 +135,20 @@ describe('AlertDetails', () => {
}); });
}); });
describe('Create issue from alert', () => { describe('Create incident from alert', () => {
it('should display "View issue" button that links the issue page when issue exists', () => { it('should display "View incident" button that links the incident page when incident exists', () => {
const issueIid = '3'; const issueIid = '3';
mountComponent({ mountComponent({
data: { alert: { ...mockAlert, issueIid }, sidebarStatus: false }, data: { alert: { ...mockAlert, issueIid }, sidebarStatus: false },
}); });
expect(findViewIssueBtn().exists()).toBe(true); expect(findViewIncidentBtn().exists()).toBe(true);
expect(findViewIssueBtn().attributes('href')).toBe(joinPaths(projectIssuesPath, issueIid)); expect(findViewIncidentBtn().attributes('href')).toBe(
expect(findCreateIssueBtn().exists()).toBe(false); joinPaths(projectIssuesPath, issueIid),
);
expect(findCreateIncidentBtn().exists()).toBe(false);
}); });
it('should display "Create issue" button when issue doesn\'t exist yet', () => { it('should display "Create incident" button when incident doesn\'t exist yet', () => {
const issueIid = null; const issueIid = null;
mountComponent({ mountComponent({
mountMethod: mount, mountMethod: mount,
...@@ -154,8 +156,8 @@ describe('AlertDetails', () => { ...@@ -154,8 +156,8 @@ describe('AlertDetails', () => {
}); });
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(findViewIssueBtn().exists()).toBe(false); expect(findViewIncidentBtn().exists()).toBe(false);
expect(findCreateIssueBtn().exists()).toBe(true); expect(findCreateIncidentBtn().exists()).toBe(true);
}); });
}); });
...@@ -165,7 +167,7 @@ describe('AlertDetails', () => { ...@@ -165,7 +167,7 @@ describe('AlertDetails', () => {
.spyOn(wrapper.vm.$apollo, 'mutate') .spyOn(wrapper.vm.$apollo, 'mutate')
.mockResolvedValue({ data: { createAlertIssue: { issue: { iid: issueIid } } } }); .mockResolvedValue({ data: { createAlertIssue: { issue: { iid: issueIid } } } });
findCreateIssueBtn().trigger('click'); findCreateIncidentBtn().trigger('click');
expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({ expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({
mutation: createIssueMutation, mutation: createIssueMutation,
variables: { variables: {
...@@ -175,7 +177,7 @@ describe('AlertDetails', () => { ...@@ -175,7 +177,7 @@ describe('AlertDetails', () => {
}); });
}); });
it('shows error alert when issue creation fails ', () => { it('shows error alert when incident creation fails ', () => {
const errorMsg = 'Something went wrong'; const errorMsg = 'Something went wrong';
mountComponent({ mountComponent({
mountMethod: mount, mountMethod: mount,
...@@ -183,10 +185,10 @@ describe('AlertDetails', () => { ...@@ -183,10 +185,10 @@ describe('AlertDetails', () => {
}); });
jest.spyOn(wrapper.vm.$apollo, 'mutate').mockRejectedValue(errorMsg); jest.spyOn(wrapper.vm.$apollo, 'mutate').mockRejectedValue(errorMsg);
findCreateIssueBtn().trigger('click'); findCreateIncidentBtn().trigger('click');
setImmediate(() => { setImmediate(() => {
expect(findIssueCreationAlert().text()).toBe(errorMsg); expect(findIncidentCreationAlert().text()).toBe(errorMsg);
}); });
}); });
}); });
......
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