From b01fd7ad81524b5f2773ccba4b5789a6074ffb9d Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Thu, 12 Apr 2018 17:29:54 +0100 Subject: Fixes unresolved discussions rendering the error state instead of the diff --- app/assets/javascripts/notes.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'app/assets/javascripts/notes.js') diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index ac70ddb3ff4..184f335809d 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -19,7 +19,7 @@ import AjaxCache from '~/lib/utils/ajax_cache'; import Vue from 'vue'; import syntaxHighlight from '~/syntax_highlight'; import SkeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue'; -import { __ } from '~/locale'; +import { __, sprintf } from '~/locale'; import axios from './lib/utils/axios_utils'; import { getLocationHash } from './lib/utils/url_utility'; import Flash from './flash'; @@ -1434,10 +1434,11 @@ export default class Notes { static renderDiffError($container) { $container.find('.line_content').html( $(` -
- ${__( - 'Unable to load the diff.', - )} Try again? +
+ ${sprintf(__('Unable to load the diff.%{buttonStartTag}Try again%{buttonEndTag}?'), { + buttonStartTag: '' + }, false)}
`), ); @@ -1455,7 +1456,12 @@ export default class Notes { const fileHolder = $container.find('.file-holder'); const url = fileHolder.data('linesPath'); - axios + /** + * We only fetch resolved discussions. + * Unresolved discussions don't have an endpoint being provided. + */ + if (url) { + axios .get(url) .then(({ data }) => { Notes.renderDiffContent($container, data); @@ -1463,6 +1469,7 @@ export default class Notes { .catch(() => { Notes.renderDiffError($container); }); + } } toggleCommitList(e) { -- cgit v1.2.3