diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx')
-rw-r--r-- | server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx index 6ad0277f98f..0fd57eb1956 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx @@ -18,9 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Alert } from 'sonar-ui-common/components/ui/Alert'; import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner'; +import { translate } from 'sonar-ui-common/helpers/l10n'; import { getDuplications } from '../../../api/components'; import { getIssueFlowSnippets } from '../../../api/issues'; +import throwGlobalError from '../../../app/utils/throwGlobalError'; import DuplicationPopup from '../../../components/SourceViewer/components/DuplicationPopup'; import { filterDuplicationBlocksByLine, @@ -59,6 +62,7 @@ interface State { issuePopup?: { issue: string; name: string }; linePopup?: T.LinePopup & { component: string }; loading: boolean; + notAccessible: boolean; } export default class CrossComponentSourceViewerWrapper extends React.PureComponent<Props, State> { @@ -66,7 +70,8 @@ export default class CrossComponentSourceViewerWrapper extends React.PureCompone state: State = { components: {}, duplicationsByLine: {}, - loading: true + loading: true, + notAccessible: false }; componentDidMount() { @@ -122,9 +127,12 @@ export default class CrossComponentSourceViewerWrapper extends React.PureCompone } } }, - () => { + (response: Response) => { + if (response.status !== 403) { + throwGlobalError(response); + } if (this.mounted) { - this.setState({ loading: false }); + this.setState({ loading: false, notAccessible: response.status === 403 }); } } ); @@ -197,7 +205,7 @@ export default class CrossComponentSourceViewerWrapper extends React.PureCompone }; render() { - const { loading } = this.state; + const { loading, notAccessible } = this.state; if (loading) { return ( @@ -207,6 +215,14 @@ export default class CrossComponentSourceViewerWrapper extends React.PureCompone ); } + if (notAccessible) { + return ( + <Alert className="spacer-top" variant="warning"> + {translate('code_viewer.no_source_code_displayed_due_to_security')} + </Alert> + ); + } + const { components, duplications, duplicationsByLine, linePopup } = this.state; const issuesByComponent = issuesByComponentAndLine(this.props.issues); const locationsByComponent = groupLocationsByComponent(this.props.locations, components); |