From: Stas Vilchik Date: Tue, 26 Sep 2017 13:53:34 +0000 (+0200) Subject: SONAR-9425 Drop locations indicator when browsing issue details X-Git-Tag: 6.6-RC1~194 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a999a0da52f9014e95dee330095cb1e90af5ef41;p=sonarqube.git SONAR-9425 Drop locations indicator when browsing issue details --- 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 { )} boolean, highlightedLine?: number, highlightedLocations?: Array, @@ -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 ( , duplicationsByLine: { [number]: Array }, 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, duplicationsCount: number, filtered: boolean | null, @@ -147,6 +149,8 @@ export default class Line extends React.PureComponent { )} , issues: Array, @@ -215,6 +217,8 @@ export default class LineCode extends React.PureComponent { {showIssues && issues.length > 0 && ( , onIssueChange: IssueType => void, onIssueClick: (issueKey: string) => void, @@ -43,6 +45,8 @@ export default class LineIssuesList extends React.PureComponent {
{issues.map(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 ( ); } 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}> void, onFilter?: (property: string, issue: Issue) => void, togglePopup: (string, boolean | void) => void @@ -62,8 +64,7 @@ export default function IssueTitleBar(props /*: Props */) { ); - // 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 */) { )} - {locationsCount > 0 && ( + {displayLocations && (
  • - {onIssuesPage ? ( - locationsBadge - ) : ( + {props.displayLocationsLink ? ( {locationsBadge} + ) : ( + locationsBadge )}
  • )} 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( @@ -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(); - expect( - element - .find('LocationIndex') - .children() - .text() - ).toBe('7'); + const element = shallow( + + ); + 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`] = ` + + 7 + +`; + exports[`should render the titlebar correctly 1`] = `