diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-04-13 11:16:06 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-04-13 11:50:35 +0300 |
commit | a236b5e6a22cf762354a9bb3460e6bad80ab5b3f (patch) | |
tree | 5892871692ff57eed2ef6ceb4a60af7167ea8cab /app/assets/javascripts/notes.js | |
parent | b01fd7ad81524b5f2773ccba4b5789a6074ffb9d (diff) |
Render only one error message per diff
Move html to haml file instead of JS
Diffstat (limited to 'app/assets/javascripts/notes.js')
-rw-r--r-- | app/assets/javascripts/notes.js | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 184f335809d..9f1db70b06e 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -1431,31 +1431,21 @@ export default class Notes { syntaxHighlight(fileHolder); } - static renderDiffError($container) { - $container.find('.line_content').html( - $(` - <div class="js-error-load-lazy-diff nothing-here-block"> - ${sprintf(__('Unable to load the diff.%{buttonStartTag}Try again%{buttonEndTag}?'), { - buttonStartTag: '<button type="button" class="btn-link btn-no-padding js-toggle-lazy-diff">', - buttonEndTag: '</button>' - }, false)} - </div> - `), - ); - } - loadLazyDiff(e) { const $container = $(e.currentTarget).closest('.js-toggle-container'); Notes.renderPlaceholderComponent($container); $container.find('.js-toggle-lazy-diff').removeClass('js-toggle-lazy-diff'); - const tableEl = $container.find('tbody'); - if (tableEl.length === 0) return; + const $tableEl = $container.find('tbody'); + if ($tableEl.length === 0) return; const fileHolder = $container.find('.file-holder'); const url = fileHolder.data('linesPath'); + const $errorContainer = $container.find('.js-error-lazy-load-diff'); + const $successContainer = $container.find('.js-success-lazy-load'); + /** * We only fetch resolved discussions. * Unresolved discussions don't have an endpoint being provided. @@ -1464,10 +1454,15 @@ export default class Notes { axios .get(url) .then(({ data }) => { + // Reset state in case last request returned error + $successContainer.removeClass('hidden'); + $errorContainer.addClass('hidden'); + Notes.renderDiffContent($container, data); }) .catch(() => { - Notes.renderDiffError($container); + $successContainer.addClass('hidden'); + $errorContainer.removeClass('hidden'); }); } } |