Commit 199ae04f authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch...

Merge branch '323304-jira-issues-list-improve-user-facing-error-messages-when-fetch-fails' into 'master'

Prioritize server-provided error messages to present to users when Jira Issues list fails

See merge request gitlab-org/gitlab!60455
parents 9b466bb0 18534ff0
...@@ -62,9 +62,10 @@ export default { ...@@ -62,9 +62,10 @@ export default {
<gl-sprintf :message="emptyStateDescription" /> <gl-sprintf :message="emptyStateDescription" />
</template> </template>
<template v-if="!hasIssues" #actions> <template v-if="!hasIssues" #actions>
<gl-button :href="issueCreateUrl" target="_blank" category="primary" variant="success" <gl-button :href="issueCreateUrl" target="_blank" category="primary" variant="success">
>{{ s__('Integrations|Create new issue in Jira') }}<gl-icon name="external-link" {{ s__('Integrations|Create new issue in Jira') }}
/></gl-button> <gl-icon name="external-link" />
</gl-button>
</template> </template>
</gl-empty-state> </gl-empty-state>
</template> </template>
...@@ -128,8 +128,11 @@ export default { ...@@ -128,8 +128,11 @@ export default {
}) })
.catch((error) => { .catch((error) => {
this.issuesListLoadFailed = true; this.issuesListLoadFailed = true;
const errors = error?.response?.data?.errors || [];
const errorMessage = errors[0] || __('An error occurred while loading issues');
createFlash({ createFlash({
message: __('An error occurred while loading issues'), message: errorMessage,
captureError: true, captureError: true,
error, error,
}); });
...@@ -200,9 +203,10 @@ export default { ...@@ -200,9 +203,10 @@ export default {
@filter="handleFilterIssues" @filter="handleFilterIssues"
> >
<template #nav-actions> <template #nav-actions>
<gl-button :href="issueCreateUrl" target="_blank" class="gl-my-5" <gl-button :href="issueCreateUrl" target="_blank" class="gl-my-5">
>{{ s__('Integrations|Create new issue in Jira') }}<gl-icon name="external-link" {{ s__('Integrations|Create new issue in Jira') }}
/></gl-button> <gl-icon name="external-link" />
</gl-button>
</template> </template>
<template #reference="{ issuable }"> <template #reference="{ issuable }">
<span v-safe-html="jiraLogo" class="svg-container jira-logo-container"></span> <span v-safe-html="jiraLogo" class="svg-container jira-logo-container"></span>
......
...@@ -106,7 +106,7 @@ module Projects ...@@ -106,7 +106,7 @@ module Projects
def render_request_error(exception) def render_request_error(exception)
log_exception(exception) log_exception(exception)
render json: { errors: [_('An error occurred while requesting data from the Jira service')] }, status: :bad_request render json: { errors: [_('An error occurred while requesting data from the Jira service.')] }, status: :bad_request
end end
end end
end end
......
...@@ -30,7 +30,7 @@ module Projects ...@@ -30,7 +30,7 @@ module Projects
raise IntegrationError, _('Jira service not configured.') unless jira_service&.active? raise IntegrationError, _('Jira service not configured.') unless jira_service&.active?
project_key = jira_service.project_key project_key = jira_service.project_key
raise IntegrationError, _('Jira project key is not configured') if project_key.blank? raise IntegrationError, _('Jira project key is not configured.') if project_key.blank?
fetch_issues(project_key) fetch_issues(project_key)
end end
......
---
title: Display wider variety of error messages when Jira Issues List fails
merge_request: 60455
author:
type: changed
...@@ -97,7 +97,7 @@ RSpec.describe Projects::Integrations::Jira::IssuesController do ...@@ -97,7 +97,7 @@ RSpec.describe Projects::Integrations::Jira::IssuesController do
get :index, params: { namespace_id: project.namespace, project_id: project }, format: :json get :index, params: { namespace_id: project.namespace, project_id: project }, format: :json
expect(response).to have_gitlab_http_status(:bad_request) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['errors']).to eq ['An error occurred while requesting data from the Jira service'] expect(json_response['errors']).to eq ['An error occurred while requesting data from the Jira service.']
end end
it 'sets pagination headers' do it 'sets pagination headers' do
......
...@@ -18,7 +18,7 @@ RSpec.describe Projects::Integrations::Jira::IssuesFinder do ...@@ -18,7 +18,7 @@ RSpec.describe Projects::Integrations::Jira::IssuesFinder do
context 'when jira service integration does not have project_key' do context 'when jira service integration does not have project_key' do
it 'raises error' do it 'raises error' do
expect { subject }.to raise_error(Projects::Integrations::Jira::IssuesFinder::IntegrationError, 'Jira project key is not configured') expect { subject }.to raise_error(Projects::Integrations::Jira::IssuesFinder::IntegrationError, 'Jira project key is not configured.')
end end
end end
......
...@@ -124,7 +124,7 @@ describe('JiraIssuesListRoot', () => { ...@@ -124,7 +124,7 @@ describe('JiraIssuesListRoot', () => {
describe('when request fails', () => { describe('when request fails', () => {
it.each` it.each`
APIErrorMessage | expectedRenderedErrorMessage APIErrorMessage | expectedRenderedErrorMessage
${'API error'} | ${'An error occurred while loading issues'} ${'API error'} | ${'API error'}
${undefined} | ${'An error occurred while loading issues'} ${undefined} | ${'An error occurred while loading issues'}
`( `(
'calls `createFlash` with "$expectedRenderedErrorMessage" when API responds with "$APIErrorMessage"', 'calls `createFlash` with "$expectedRenderedErrorMessage" when API responds with "$APIErrorMessage"',
......
...@@ -3661,7 +3661,7 @@ msgstr "" ...@@ -3661,7 +3661,7 @@ msgstr ""
msgid "An error occurred while reordering issues." msgid "An error occurred while reordering issues."
msgstr "" msgstr ""
msgid "An error occurred while requesting data from the Jira service" msgid "An error occurred while requesting data from the Jira service."
msgstr "" msgstr ""
msgid "An error occurred while retrieving calendar activity" msgid "An error occurred while retrieving calendar activity"
...@@ -18399,7 +18399,7 @@ msgstr "" ...@@ -18399,7 +18399,7 @@ msgstr ""
msgid "Jira integration not configured." msgid "Jira integration not configured."
msgstr "" msgstr ""
msgid "Jira project key is not configured" msgid "Jira project key is not configured."
msgstr "" msgstr ""
msgid "Jira project: %{importProject}" msgid "Jira project: %{importProject}"
......
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