aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/component
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2018-03-12 12:06:11 +0100
committerTeryk Bellahsene <teryk@users.noreply.github.com>2018-03-13 14:05:36 +0100
commit913c82c8772fd4747626a1fbe665ccda2e5ca9f1 (patch)
treed48784851df80905ce125cc60ac8aec8570751a9 /server/sonar-web/src/main/js/apps/component
parent751e4000e40a4af66b80767d632b1bef64dc5647 (diff)
downloadsonarqube-913c82c8772fd4747626a1fbe665ccda2e5ca9f1.tar.gz
sonarqube-913c82c8772fd4747626a1fbe665ccda2e5ca9f1.zip
SONAR-10374 Support pull request in the web app
Diffstat (limited to 'server/sonar-web/src/main/js/apps/component')
-rw-r--r--server/sonar-web/src/main/js/apps/component/components/App.tsx21
-rw-r--r--server/sonar-web/src/main/js/apps/component/components/__tests__/__snapshots__/App-test.tsx.snap9
2 files changed, 27 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/apps/component/components/App.tsx b/server/sonar-web/src/main/js/apps/component/components/App.tsx
index 96ff380b906..71fc859ea2f 100644
--- a/server/sonar-web/src/main/js/apps/component/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/component/components/App.tsx
@@ -18,6 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { PullRequest, BranchType, ShortLivingBranch } from '../../../app/types';
import SourceViewer from '../../../components/SourceViewer/SourceViewer';
interface Props {
@@ -26,6 +27,7 @@ interface Props {
branch?: string;
id: string;
line?: string;
+ pullRequest?: string;
};
};
}
@@ -45,15 +47,30 @@ export default class App extends React.PureComponent<Props> {
};
render() {
- const { branch, id, line } = this.props.location.query;
+ const { branch, id, line, pullRequest } = this.props.location.query;
const finalLine = line ? Number(line) : undefined;
+ // TODO find a way to avoid creating this fakeBranchLike
+ // probably the best way would be to drop this page completely
+ // and redirect to the Code page
+ let fakeBranchLike: ShortLivingBranch | PullRequest | undefined = undefined;
+ if (branch) {
+ fakeBranchLike = {
+ isMain: false,
+ mergeBranch: '',
+ name: branch,
+ type: BranchType.SHORT
+ } as ShortLivingBranch;
+ } else if (pullRequest) {
+ fakeBranchLike = { base: '', branch: '', key: pullRequest, title: '' } as PullRequest;
+ }
+
return (
<div className="page page-limited">
<SourceViewer
aroundLine={finalLine}
- branch={branch}
+ branchLike={fakeBranchLike}
component={id}
highlightedLine={finalLine}
onLoaded={this.scrollToLine}
diff --git a/server/sonar-web/src/main/js/apps/component/components/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/component/components/__tests__/__snapshots__/App-test.tsx.snap
index 1cb5c653533..f5dd7e1a6ce 100644
--- a/server/sonar-web/src/main/js/apps/component/components/__tests__/__snapshots__/App-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/component/components/__tests__/__snapshots__/App-test.tsx.snap
@@ -6,7 +6,14 @@ exports[`renders 1`] = `
>
<Connect(SourceViewerBase)
aroundLine={7}
- branch="b"
+ branchLike={
+ Object {
+ "isMain": false,
+ "mergeBranch": "",
+ "name": "b",
+ "type": "SHORT",
+ }
+ }
component="foo"
highlightedLine={7}
onLoaded={[Function]}