aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2017-05-08 17:52:40 +0200
committerStas Vilchik <stas-vilchik@users.noreply.github.com>2017-05-09 10:02:57 +0200
commit522f110b5516279b723f50ffcb60b59403a40536 (patch)
tree75f28d7e4d51dc1568828e46f00478f4e7b81577 /server/sonar-web/src/main
parent0df7d25fad23f50f5ef969360d7040ce90f3e630 (diff)
downloadsonarqube-522f110b5516279b723f50ffcb60b59403a40536.tar.gz
sonarqube-522f110b5516279b723f50ffcb60b59403a40536.zip
SONAR-8908 Check permissions when displaying an issue permalink
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js11
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js1
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap9
-rw-r--r--server/sonar-web/src/main/js/helpers/urls.js7
4 files changed, 13 insertions, 15 deletions
diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js
index c6ca72d5747..8621fce9439 100644
--- a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js
+++ b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js
@@ -25,7 +25,7 @@ import IssueMessage from './IssueMessage';
import SimilarIssuesFilter from './SimilarIssuesFilter';
import LocationIndex from '../../common/LocationIndex';
import Tooltip from '../../controls/Tooltip';
-import { getSingleIssueUrl } from '../../../helpers/urls';
+import { getComponentIssuesUrl } from '../../../helpers/urls';
import { formatMeasure } from '../../../helpers/measures';
import { translate, translateWithParameters } from '../../../helpers/l10n';
import type { Issue } from '../types';
@@ -62,6 +62,8 @@ export default function IssueTitleBar(props: Props) {
// dirty trick :(
const onIssuesPage = document.getElementById('issues-page') != null;
+ const issueUrl = getComponentIssuesUrl(issue.project, { issues: issue.key, open: issue.key });
+
return (
<table className="issue-table">
<tbody>
@@ -94,10 +96,7 @@ export default function IssueTitleBar(props: Props) {
<li className="issue-meta">
{onIssuesPage
? locationsBadge
- : <Link
- onClick={stopPropagation}
- target="_blank"
- to={getSingleIssueUrl(issue.key)}>
+ : <Link onClick={stopPropagation} target="_blank" to={issueUrl}>
{locationsBadge}
</Link>}
</li>}
@@ -106,7 +105,7 @@ export default function IssueTitleBar(props: Props) {
className="js-issue-permalink icon-link"
onClick={stopPropagation}
target="_blank"
- to={getSingleIssueUrl(issue.key)}
+ to={issueUrl}
/>
</li>
{hasSimilarIssuesFilter &&
diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js
index 8545979087b..f09d709908f 100644
--- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js
+++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js
@@ -25,6 +25,7 @@ const issue = {
line: 26,
creationDate: '2017-03-01T09:36:01+0100',
organization: 'myorg',
+ project: 'myproject',
key: 'AVsae-CQS-9G3txfbFN2',
rule: 'javascript:S1067',
message: 'Reduce the number of conditional operators (4) used in the expression',
diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap
index 2e3be9e376e..2a7d3bdbcea 100644
--- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap
+++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap
@@ -33,6 +33,7 @@ exports[`should render the titlebar correctly 1`] = `
"line": 26,
"message": "Reduce the number of conditional operators (4) used in the expression",
"organization": "myorg",
+ "project": "myproject",
"rule": "javascript:S1067",
"secondaryLocations": Array [],
}
@@ -63,8 +64,9 @@ exports[`should render the titlebar correctly 1`] = `
target="_blank"
to={
Object {
- "pathname": "/issues",
+ "pathname": "/project/issues",
"query": Object {
+ "id": "myproject",
"issues": "AVsae-CQS-9G3txfbFN2",
"open": "AVsae-CQS-9G3txfbFN2",
},
@@ -112,6 +114,7 @@ exports[`should render the titlebar with the filter 1`] = `
"line": 26,
"message": "Reduce the number of conditional operators (4) used in the expression",
"organization": "myorg",
+ "project": "myproject",
"rule": "javascript:S1067",
"secondaryLocations": Array [],
}
@@ -142,8 +145,9 @@ exports[`should render the titlebar with the filter 1`] = `
target="_blank"
to={
Object {
- "pathname": "/issues",
+ "pathname": "/project/issues",
"query": Object {
+ "id": "myproject",
"issues": "AVsae-CQS-9G3txfbFN2",
"open": "AVsae-CQS-9G3txfbFN2",
},
@@ -164,6 +168,7 @@ exports[`should render the titlebar with the filter 1`] = `
"line": 26,
"message": "Reduce the number of conditional operators (4) used in the expression",
"organization": "myorg",
+ "project": "myproject",
"rule": "javascript:S1067",
"secondaryLocations": Array [],
}
diff --git a/server/sonar-web/src/main/js/helpers/urls.js b/server/sonar-web/src/main/js/helpers/urls.js
index ffa866797e7..7f512e298c8 100644
--- a/server/sonar-web/src/main/js/helpers/urls.js
+++ b/server/sonar-web/src/main/js/helpers/urls.js
@@ -56,13 +56,6 @@ export function getComponentIssuesUrlAsString(componentKey, query) {
}
/**
- * Generate URL for a single issue
- */
-export function getSingleIssueUrl(issues) {
- return { pathname: '/issues', query: { issues, open: issues } };
-}
-
-/**
* Generate URL for a component's drilldown page
* @param {string} componentKey
* @param {string} metric