diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-12-09 15:13:04 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-12-09 16:19:11 +0100 |
commit | 7dea0e7e33f3a6072b3ac9ae9984399089160b4e (patch) | |
tree | f05599c3d9e4bfd3d799b4aa8609505899511be1 /server/sonar-web/src/main | |
parent | aed4140165da7195ebf82f6149603be31a3ac198 (diff) | |
download | sonarqube-7dea0e7e33f3a6072b3ac9ae9984399089160b4e.tar.gz sonarqube-7dea0e7e33f3a6072b3ac9ae9984399089160b4e.zip |
fix line permalink in source viewer
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r-- | server/sonar-web/src/main/js/apps/component/components/App.js | 8 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/components/source-viewer/SourceViewer.js | 9 |
2 files changed, 14 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/apps/component/components/App.js b/server/sonar-web/src/main/js/apps/component/components/App.js index 139838f7342..05058cdc793 100644 --- a/server/sonar-web/src/main/js/apps/component/components/App.js +++ b/server/sonar-web/src/main/js/apps/component/components/App.js @@ -23,6 +23,10 @@ import SourceViewer from '../../../components/source-viewer/SourceViewer'; import { getComponentNavigation } from '../../../api/nav'; export default class App extends React.Component { + static propTypes = { + location: React.PropTypes.object.isRequired + }; + state = {}; componentDidMount () { @@ -36,9 +40,11 @@ export default class App extends React.Component { return null; } + const { line } = this.props.location.query; + return ( <div className="page"> - <SourceViewer component={{ id: this.state.component.id }}/> + <SourceViewer component={{ id: this.state.component.id }} line={line}/> </div> ); } diff --git a/server/sonar-web/src/main/js/components/source-viewer/SourceViewer.js b/server/sonar-web/src/main/js/components/source-viewer/SourceViewer.js index 024d7501b5b..69f1c969591 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/SourceViewer.js +++ b/server/sonar-web/src/main/js/components/source-viewer/SourceViewer.js @@ -27,7 +27,8 @@ export default class SourceViewer extends React.Component { component: React.PropTypes.shape({ id: React.PropTypes.string.isRequired }).isRequired, - period: React.PropTypes.object + period: React.PropTypes.object, + line: React.PropTypes.oneOfType([React.PropTypes.number, React.PropTypes.string]) }; componentDidMount () { @@ -62,13 +63,17 @@ export default class SourceViewer extends React.Component { } handleLoad () { - const { period } = this.props; + const { period, line } = this.props; if (period) { const periodDate = getPeriodDate(period); const periodLabel = getPeriodLabel(period); this.sourceViewer.filterLinesByDate(periodDate, periodLabel); } + + if (line) { + this.sourceViewer.highlightLine(line); + } } render () { |