aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2017-09-26 15:53:34 +0200
committerStas Vilchik <stas.vilchik@sonarsource.com>2017-09-27 11:04:22 +0200
commita999a0da52f9014e95dee330095cb1e90af5ef41 (patch)
tree485cde01532bc53573e2bcd70ce4cf4ac1e3b330 /server/sonar-web/src/main
parent8d4e3f45dfb9e31df001a8b25175beac7c1d99c6 (diff)
downloadsonarqube-a999a0da52f9014e95dee330095cb1e90af5ef41.tar.gz
sonarqube-a999a0da52f9014e95dee330095cb1e90af5ef41.zip
SONAR-9425 Drop locations indicator when browsing issue details
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/ListItem.js1
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js6
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js4
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/Line.js4
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js4
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js4
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineIssuesList-test.js.snap8
-rw-r--r--server/sonar-web/src/main/js/components/issue/Issue.js24
-rw-r--r--server/sonar-web/src/main/js/components/issue/IssueView.js6
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js15
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js22
-rw-r--r--server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap8
13 files changed, 77 insertions, 31 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js
index eed561cee25..ef5904ea704 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js
+++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js
@@ -89,6 +89,8 @@ export default class IssuesSourceViewer extends React.PureComponent {
branch={this.props.branch}
component={openIssue.component}
displayAllIssues={true}
+ displayIssueLocationsCount={false}
+ displayIssueLocationsLink={false}
highlightedLocations={locations}
highlightedLocationMessage={locationMessage}
loadIssues={this.props.loadIssues}
diff --git a/server/sonar-web/src/main/js/apps/issues/components/ListItem.js b/server/sonar-web/src/main/js/apps/issues/components/ListItem.js
index 6dc60a3776f..94da47a46ab 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/ListItem.js
+++ b/server/sonar-web/src/main/js/apps/issues/components/ListItem.js
@@ -107,6 +107,7 @@ export default class ListItem extends React.PureComponent {
)}
<Issue
checked={this.props.checked}
+ displayLocationsLink={false}
issue={issue}
onChange={this.props.onChange}
onCheck={this.props.onCheck}
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js
index 6d3a4378b2f..c4c0cfc0c80 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js
+++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js
@@ -57,6 +57,8 @@ type Props = {
branch?: string,
component: string,
displayAllIssues: boolean,
+ displayIssueLocationsCount?: boolean;
+ displayIssueLocationsLink?: boolean;
filterLine?: (line: SourceLine) => boolean,
highlightedLine?: number,
highlightedLocations?: Array<FlowLocation>,
@@ -134,6 +136,8 @@ export default class SourceViewerBase extends React.PureComponent {
static defaultProps = {
displayAllIssues: false,
+ displayIssueLocationsCount: true,
+ displayIssueLocationsLink: true,
loadComponent,
loadIssues,
loadSources
@@ -581,6 +585,8 @@ export default class SourceViewerBase extends React.PureComponent {
return (
<SourceViewerCode
displayAllIssues={this.props.displayAllIssues}
+ displayIssueLocationsCount={this.props.displayIssueLocationsCount}
+ displayIssueLocationsLink={this.props.displayIssueLocationsLink}
duplications={this.state.duplications}
duplicationsByLine={this.state.duplicationsByLine}
duplicatedFiles={this.state.duplicatedFiles}
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js
index 55fb081c59d..617e45710cb 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js
+++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js
@@ -38,6 +38,8 @@ const ZERO_LINE = {
export default class SourceViewerCode extends React.PureComponent {
/*:: props: {|
displayAllIssues: boolean,
+ displayIssueLocationsCount?: boolean;
+ displayIssueLocationsLink?: boolean;
duplications?: Array<Duplication>,
duplicationsByLine: { [number]: Array<number> },
duplicatedFiles?: Array<{ key: string }>,
@@ -152,6 +154,8 @@ export default class SourceViewerCode extends React.PureComponent {
displayDuplications={displayDuplications}
displayFiltered={displayFiltered}
displayIssues={displayIssues}
+ displayIssueLocationsCount={this.props.displayIssueLocationsCount}
+ displayIssueLocationsLink={this.props.displayIssueLocationsLink}
duplications={this.getDuplicationsForLine(line)}
duplicationsCount={duplicationsCount}
filtered={filtered}
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.js b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.js
index 1d81eb24712..73906c1ff2e 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.js
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.js
@@ -39,6 +39,8 @@ type Props = {|
displayDuplications: boolean,
displayFiltered: boolean,
displayIssues: boolean,
+ displayIssueLocationsCount?: boolean;
+ displayIssueLocationsLink?: boolean;
duplications: Array<number>,
duplicationsCount: number,
filtered: boolean | null,
@@ -147,6 +149,8 @@ export default class Line extends React.PureComponent {
)}
<LineCode
+ displayIssueLocationsCount={this.props.displayIssueLocationsCount}
+ displayIssueLocationsLink={this.props.displayIssueLocationsLink}
highlightedLocationMessage={this.props.highlightedLocationMessage}
highlightedSymbols={this.props.highlightedSymbols}
issues={this.props.issues}
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js
index 63782ced438..3635c3c315f 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js
@@ -31,6 +31,8 @@ import { splitByTokens, highlightSymbol, highlightIssueLocations } from '../help
/*::
type Props = {|
+ displayIssueLocationsCount?: boolean,
+ displayIssueLocationsLink?: boolean,
highlightedLocationMessage?: { index: number, text: string },
highlightedSymbols?: Array<string>,
issues: Array<Issue>,
@@ -215,6 +217,8 @@ export default class LineCode extends React.PureComponent {
{showIssues &&
issues.length > 0 && (
<LineIssuesList
+ displayIssueLocationsCount={this.props.displayIssueLocationsCount}
+ displayIssueLocationsLink={this.props.displayIssueLocationsLink}
issues={issues}
onIssueChange={this.props.onIssueChange}
onIssueClick={onIssueSelect}
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js
index e3f12d153be..d4c186a83e5 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js
@@ -24,6 +24,8 @@ import Issue from '../../issue/Issue';
/*::
type Props = {
+ displayIssueLocationsCount?: boolean;
+ displayIssueLocationsLink?: boolean;
issues: Array<IssueType>,
onIssueChange: IssueType => void,
onIssueClick: (issueKey: string) => void,
@@ -43,6 +45,8 @@ export default class LineIssuesList extends React.PureComponent {
<div className="issue-list">
{issues.map(issue => (
<Issue
+ displayLocationsCount={this.props.displayIssueLocationsCount}
+ displayLocationsLink={this.props.displayIssueLocationsLink}
issue={issue}
key={issue.key}
onChange={this.props.onIssueChange}
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineIssuesList-test.js.snap b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineIssuesList-test.js.snap
index f31277211ba..6bd44307b2f 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineIssuesList-test.js.snap
+++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineIssuesList-test.js.snap
@@ -4,7 +4,9 @@ exports[`render issues list 1`] = `
<div
className="issue-list"
>
- <BaseIssue
+ <Issue
+ displayLocationsCount={true}
+ displayLocationsLink={true}
issue={
Object {
"key": "foo",
@@ -15,7 +17,9 @@ exports[`render issues list 1`] = `
openPopup={null}
selected={true}
/>
- <BaseIssue
+ <Issue
+ displayLocationsCount={true}
+ displayLocationsLink={true}
issue={
Object {
"key": "bar",
diff --git a/server/sonar-web/src/main/js/components/issue/Issue.js b/server/sonar-web/src/main/js/components/issue/Issue.js
index 70a1fc90746..a67e04c3faf 100644
--- a/server/sonar-web/src/main/js/components/issue/Issue.js
+++ b/server/sonar-web/src/main/js/components/issue/Issue.js
@@ -25,23 +25,25 @@ import IssueView from './IssueView';
import { onFail } from '../../store/rootActions';
import { setIssueAssignee } from '../../api/issues';
import { updateIssue } from './actions';
-/*:: import type { Issue } from './types'; */
+/*:: import type { Issue as IssueType } from './types'; */
/*::
type Props = {|
checked?: boolean,
- issue: Issue,
- onChange: Issue => void,
+ displayLocationsCount?: boolean;
+ displayLocationsLink?: boolean;
+ issue: IssueType,
+ onChange: IssueType => void,
onCheck?: string => void,
onClick: string => void,
- onFilter?: (property: string, issue: Issue) => void,
- onPopupToggle: (issue: string, popupName: string, open: ?boolean ) => void,
+ onFilter?: (property: string, issue: IssueType) => void,
+ onPopupToggle: (issue: string, popupName: string, open: ?boolean) => void,
openPopup: ?string,
selected: boolean
|};
*/
-export default class BaseIssue extends React.PureComponent {
+export default class Issue extends React.PureComponent {
/*:: props: Props; */
static contextTypes = {
@@ -49,6 +51,8 @@ export default class BaseIssue extends React.PureComponent {
};
static defaultProps = {
+ displayLocationsCount: true,
+ displayLocationsLink: true,
selected: false
};
@@ -142,17 +146,19 @@ export default class BaseIssue extends React.PureComponent {
render() {
return (
<IssueView
- issue={this.props.issue}
checked={this.props.checked}
+ currentPopup={this.props.openPopup}
+ displayLocationsCount={this.props.displayLocationsCount}
+ displayLocationsLink={this.props.displayLocationsLink}
+ issue={this.props.issue}
onAssign={this.handleAssignement}
onCheck={this.props.onCheck}
onClick={this.props.onClick}
onFail={this.handleFail}
onFilter={this.props.onFilter}
onChange={this.props.onChange}
- togglePopup={this.togglePopup}
- currentPopup={this.props.openPopup}
selected={this.props.selected}
+ togglePopup={this.togglePopup}
/>
);
}
diff --git a/server/sonar-web/src/main/js/components/issue/IssueView.js b/server/sonar-web/src/main/js/components/issue/IssueView.js
index 49de5e25b6c..fd6b8f2aa6d 100644
--- a/server/sonar-web/src/main/js/components/issue/IssueView.js
+++ b/server/sonar-web/src/main/js/components/issue/IssueView.js
@@ -31,6 +31,8 @@ import { deleteIssueComment, editIssueComment } from '../../api/issues';
type Props = {|
checked?: boolean,
currentPopup: ?string,
+ displayLocationsCount?: boolean;
+ displayLocationsLink?: boolean;
issue: Issue,
onAssign: string => void,
onChange: Issue => void,
@@ -87,8 +89,10 @@ export default class IssueView extends React.PureComponent {
role="listitem"
tabIndex={0}>
<IssueTitleBar
- issue={issue}
currentPopup={this.props.currentPopup}
+ displayLocationsCount={this.props.displayLocationsCount}
+ displayLocationsLink={this.props.displayLocationsLink}
+ issue={issue}
onFail={this.props.onFail}
onFilter={this.props.onFilter}
togglePopup={this.props.togglePopup}
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 97bf195fdac..bd4acefaa84 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
@@ -33,8 +33,10 @@ import { translate, translateWithParameters } from '../../../helpers/l10n';
/*::
type Props = {|
- issue: Issue,
currentPopup: ?string,
+ displayLocationsCount?: boolean;
+ displayLocationsLink?: boolean;
+ issue: Issue,
onFail: Error => void,
onFilter?: (property: string, issue: Issue) => void,
togglePopup: (string, boolean | void) => void
@@ -62,8 +64,7 @@ export default function IssueTitleBar(props /*: Props */) {
</Tooltip>
);
- // dirty trick :(
- const onIssuesPage = document.getElementById('issues-page') != null;
+ const displayLocations = props.displayLocationsCount && locationsCount > 0;
const issueUrl = getComponentIssuesUrl(issue.project, { issues: issue.key, open: issue.key });
@@ -96,14 +97,14 @@ export default function IssueTitleBar(props /*: Props */) {
</span>
</li>
)}
- {locationsCount > 0 && (
+ {displayLocations && (
<li className="issue-meta">
- {onIssuesPage ? (
- locationsBadge
- ) : (
+ {props.displayLocationsLink ? (
<Link onClick={stopPropagation} target="_blank" to={issueUrl}>
{locationsBadge}
</Link>
+ ) : (
+ locationsBadge
)}
</li>
)}
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 02e2bce9e13..bf2980f0c2d 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
@@ -39,6 +39,12 @@ const issue = {
secondaryLocations: []
};
+const issueWithLocations = {
+ ...issue,
+ flows: [[{}, {}, {}], [{}, {}]],
+ secondaryLocations: [{}, {}]
+};
+
it('should render the titlebar correctly', () => {
const element = shallow(
<IssueTitleBar issue={issue} currentPopup={null} onFail={jest.fn()} togglePopup={jest.fn()} />
@@ -60,16 +66,8 @@ it('should render the titlebar with the filter', () => {
});
it('should count all code locations', () => {
- const issueWithLocations = {
- ...issue,
- flows: [[{}, {}, {}], [{}, {}]],
- secondaryLocations: [{}, {}]
- };
- const element = shallow(<IssueTitleBar issue={issueWithLocations} />);
- expect(
- element
- .find('LocationIndex')
- .children()
- .text()
- ).toBe('7');
+ const element = shallow(
+ <IssueTitleBar displayLocationsCount={true} issue={issueWithLocations} />
+ );
+ expect(element.find('LocationIndex')).toMatchSnapshot();
});
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 2d1ac03a834..1302c5f2ac0 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
@@ -1,5 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`should count all code locations 1`] = `
+<LocationIndex
+ selected={false}
+>
+ 7
+</LocationIndex>
+`;
+
exports[`should render the titlebar correctly 1`] = `
<table
className="issue-table"