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

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 { ...@@ -127,9 +127,11 @@ export default {
<input name="issue[description]" :value="issueDescription" type="hidden" /> <input name="issue[description]" :value="issueDescription" type="hidden" />
<gl-form-input :value="csrfToken" class="hidden" name="authenticity_token" /> <gl-form-input :value="csrfToken" class="hidden" name="authenticity_token" />
<loading-button <loading-button
v-if="!error.gitlab_issue"
class="btn-success" class="btn-success"
:label="__('Create issue')" :label="__('Create issue')"
:loading="issueCreationInProgress" :loading="issueCreationInProgress"
data-qa-selector="create_issue_button"
@click="createIssue" @click="createIssue"
/> />
</form> </form>
...@@ -140,6 +142,12 @@ export default { ...@@ -140,6 +142,12 @@ export default {
</tooltip-on-truncate> </tooltip-on-truncate>
<h3>{{ __('Error details') }}</h3> <h3>{{ __('Error details') }}</h3>
<ul> <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> <li>
<span class="bold">{{ __('Sentry event') }}:</span> <span class="bold">{{ __('Sentry event') }}:</span>
<gl-link <gl-link
......
...@@ -10,6 +10,7 @@ module ErrorTracking ...@@ -10,6 +10,7 @@ module ErrorTracking
:first_release_short_version, :first_release_short_version,
:first_seen, :first_seen,
:frequency, :frequency,
:gitlab_issue,
:id, :id,
:last_release_last_commit, :last_release_last_commit,
:last_release_short_version, :last_release_short_version,
......
---
title: Surface GitLab issue in error detail page
merge_request: 21019
author:
type: added
...@@ -15,6 +15,7 @@ module Gitlab ...@@ -15,6 +15,7 @@ module Gitlab
:first_seen, :first_seen,
:frequency, :frequency,
:gitlab_project, :gitlab_project,
:gitlab_issue,
:id, :id,
:last_release_last_commit, :last_release_last_commit,
:last_release_short_version, :last_release_short_version,
......
...@@ -233,6 +233,15 @@ module Sentry ...@@ -233,6 +233,15 @@ module Sentry
stack_trace_entry.dig('stacktrace', 'frames') stack_trace_entry.dig('stacktrace', 'frames')
end 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) def map_to_detailed_error(issue)
Gitlab::ErrorTracking::DetailedError.new( Gitlab::ErrorTracking::DetailedError.new(
id: issue.fetch('id'), id: issue.fetch('id'),
...@@ -252,6 +261,7 @@ module Sentry ...@@ -252,6 +261,7 @@ module Sentry
project_id: issue.dig('project', 'id'), project_id: issue.dig('project', 'id'),
project_name: issue.dig('project', 'name'), project_name: issue.dig('project', 'name'),
project_slug: issue.dig('project', 'slug'), project_slug: issue.dig('project', 'slug'),
gitlab_issue: parse_gitlab_issue(issue.fetch('pluginIssues', nil)),
first_release_last_commit: issue.dig('firstRelease', 'lastCommit'), first_release_last_commit: issue.dig('firstRelease', 'lastCommit'),
last_release_last_commit: issue.dig('lastRelease', 'lastCommit'), last_release_last_commit: issue.dig('lastRelease', 'lastCommit'),
first_release_short_version: issue.dig('firstRelease', 'shortVersion'), first_release_short_version: issue.dig('firstRelease', 'shortVersion'),
......
...@@ -8360,6 +8360,9 @@ msgstr "" ...@@ -8360,6 +8360,9 @@ msgstr ""
msgid "GitLab Import" msgid "GitLab Import"
msgstr "" 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)." 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 "" msgstr ""
   
......
...@@ -23,6 +23,7 @@ FactoryBot.define do ...@@ -23,6 +23,7 @@ FactoryBot.define do
[Time.now.to_i, 10] [Time.now.to_i, 10]
] ]
end end
gitlab_issue { 'http://gitlab.example.com/issues/1' }
first_release_last_commit { '68c914da9' } first_release_last_commit { '68c914da9' }
last_release_last_commit { '9ad419c86' } last_release_last_commit { '9ad419c86' }
first_release_short_version { 'abc123' } first_release_short_version { 'abc123' }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
"short_id", "short_id",
"status", "status",
"frequency", "frequency",
"gitlab_issue",
"first_release_last_commit", "first_release_last_commit",
"last_release_last_commit", "last_release_last_commit",
"first_release_short_version", "first_release_short_version",
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
"short_id": { "type": "string"}, "short_id": { "type": "string"},
"status": { "type": "string"}, "status": { "type": "string"},
"frequency": { "type": "array"}, "frequency": { "type": "array"},
"gitlab_issue": { "type": ["string", "null"] },
"first_release_last_commit": { "type": ["string", "null"] }, "first_release_last_commit": { "type": ["string", "null"] },
"last_release_last_commit": { "type": ["string", "null"] }, "last_release_last_commit": { "type": ["string", "null"] },
"first_release_short_version": { "type": ["string", "null"] }, "first_release_short_version": { "type": ["string", "null"] },
......
...@@ -138,5 +138,48 @@ describe('ErrorDetails', () => { ...@@ -138,5 +138,48 @@ describe('ErrorDetails', () => {
submitSpy.mockRestore(); 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);
});
});
});
}); });
}); });
Supports Markdown
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