Commit 9ff397d0 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'tr-link-error-to-issue-frontend' into 'master'

Surface GitLab issue in error detail page

See merge request gitlab-org/gitlab!21019
parents 513557fe db2ccdfe
......@@ -127,9 +127,11 @@ export default {
<input name="issue[description]" :value="issueDescription" type="hidden" />
<gl-form-input :value="csrfToken" class="hidden" name="authenticity_token" />
<loading-button
v-if="!error.gitlab_issue"
class="btn-success"
:label="__('Create issue')"
:loading="issueCreationInProgress"
data-qa-selector="create_issue_button"
@click="createIssue"
/>
</form>
......@@ -140,6 +142,12 @@ export default {
</tooltip-on-truncate>
<h3>{{ __('Error details') }}</h3>
<ul>
<li v-if="error.gitlab_issue">
<span class="bold">{{ __('GitLab Issue') }}:</span>
<gl-link :href="error.gitlab_issue">
<span>{{ error.gitlab_issue }}</span>
</gl-link>
</li>
<li>
<span class="bold">{{ __('Sentry event') }}:</span>
<gl-link
......
......@@ -10,6 +10,7 @@ module ErrorTracking
:first_release_short_version,
:first_seen,
:frequency,
:gitlab_issue,
:id,
:last_release_last_commit,
:last_release_short_version,
......
---
title: Surface GitLab issue in error detail page
merge_request: 21019
author:
type: added
......@@ -15,6 +15,7 @@ module Gitlab
:first_seen,
:frequency,
:gitlab_project,
:gitlab_issue,
:id,
:last_release_last_commit,
:last_release_short_version,
......
......@@ -233,6 +233,15 @@ module Sentry
stack_trace_entry.dig('stacktrace', 'frames')
end
def parse_gitlab_issue(plugin_issues)
return unless plugin_issues
gitlab_plugin = plugin_issues.detect { |item| item['id'] == 'gitlab' }
return unless gitlab_plugin
gitlab_plugin.dig('issue', 'url')
end
def map_to_detailed_error(issue)
Gitlab::ErrorTracking::DetailedError.new(
id: issue.fetch('id'),
......@@ -252,6 +261,7 @@ module Sentry
project_id: issue.dig('project', 'id'),
project_name: issue.dig('project', 'name'),
project_slug: issue.dig('project', 'slug'),
gitlab_issue: parse_gitlab_issue(issue.fetch('pluginIssues', nil)),
first_release_last_commit: issue.dig('firstRelease', 'lastCommit'),
last_release_last_commit: issue.dig('lastRelease', 'lastCommit'),
first_release_short_version: issue.dig('firstRelease', 'shortVersion'),
......
......@@ -8360,6 +8360,9 @@ msgstr ""
msgid "GitLab Import"
msgstr ""
msgid "GitLab Issue"
msgstr ""
msgid "GitLab Shared Runners execute code of different projects on the same Runner unless you configure GitLab Runner Autoscale with MaxBuilds 1 (which it is on GitLab.com)."
msgstr ""
......
......@@ -23,6 +23,7 @@ FactoryBot.define do
[Time.now.to_i, 10]
]
end
gitlab_issue { 'http://gitlab.example.com/issues/1' }
first_release_last_commit { '68c914da9' }
last_release_last_commit { '9ad419c86' }
first_release_short_version { 'abc123' }
......
......@@ -13,6 +13,7 @@
"short_id",
"status",
"frequency",
"gitlab_issue",
"first_release_last_commit",
"last_release_last_commit",
"first_release_short_version",
......@@ -36,6 +37,7 @@
"short_id": { "type": "string"},
"status": { "type": "string"},
"frequency": { "type": "array"},
"gitlab_issue": { "type": ["string", "null"] },
"first_release_last_commit": { "type": ["string", "null"] },
"last_release_last_commit": { "type": ["string", "null"] },
"first_release_short_version": { "type": ["string", "null"] },
......
......@@ -138,5 +138,48 @@ describe('ErrorDetails', () => {
submitSpy.mockRestore();
});
});
describe('GitLab issue link', () => {
const gitlabIssue = 'https://gitlab.example.com/issues/1';
const findGitLabLink = () => wrapper.find(`[href="${gitlabIssue}"]`);
const findCreateIssueButton = () => wrapper.find('[data-qa-selector="create_issue_button"]');
describe('is present', () => {
beforeEach(() => {
store.state.details.loading = false;
store.state.details.error = {
id: 1,
gitlab_issue: gitlabIssue,
};
mountComponent();
});
it('should display the issue link', () => {
expect(findGitLabLink().exists()).toBe(true);
});
it('should not display a create issue button', () => {
expect(findCreateIssueButton().exists()).toBe(false);
});
});
describe('is not present', () => {
beforeEach(() => {
store.state.details.loading = false;
store.state.details.error = {
id: 1,
gitlab_issue: null,
};
mountComponent();
});
it('should not display an issue link', () => {
expect(findGitLabLink().exists()).toBe(false);
});
it('should display the create issue button', () => {
expect(findCreateIssueButton().exists()).toBe(true);
});
});
});
});
});
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