From 059692599345f5a22b5c9b25c34189cf09a99cb8 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 27 Oct 2016 13:59:18 +0200 Subject: do not display global error when source viewer can't show code due to security reason --- .../sonar-web/src/main/js/components/source-viewer/main.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'server/sonar-web/src/main/js/components') diff --git a/server/sonar-web/src/main/js/components/source-viewer/main.js b/server/sonar-web/src/main/js/components/source-viewer/main.js index 497e3d847c0..ca259f91d35 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/main.js +++ b/server/sonar-web/src/main/js/components/source-viewer/main.js @@ -215,8 +215,15 @@ export default Marionette.LayoutView.extend({ requestSource (aroundLine) { const that = this; const url = window.baseUrl + '/api/sources/lines'; - const options = _.extend({ uuid: this.model.id }, this.linesLimit(aroundLine)); - return $.get(url, options).done(function (data) { + const data = _.extend({ uuid: this.model.id }, this.linesLimit(aroundLine)); + return $.ajax({ + url, + data, + statusCode: { + // don't display global error + 403: null + } + }).done(function (data) { let source = (data.sources || []).slice(0); if (source.length === 0 || (source.length > 0 && _.first(source).line === 1)) { source.unshift({ line: 0 }); @@ -228,7 +235,7 @@ export default Marionette.LayoutView.extend({ }); }); const firstLine = _.first(source).line; - const linesRequested = options.to - options.from + 1; + const linesRequested = data.to - data.from + 1; that.model.set({ source, hasUTCoverage: that.model.hasUTCoverage(source), -- cgit v1.2.3