]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9425 Drop locations indicator when browsing issue details
authorStas Vilchik <stas.vilchik@sonarsource.com>
Tue, 26 Sep 2017 13:53:34 +0000 (15:53 +0200)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Wed, 27 Sep 2017 09:04:22 +0000 (11:04 +0200)
13 files changed:
server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js
server/sonar-web/src/main/js/apps/issues/components/ListItem.js
server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.js
server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js
server/sonar-web/src/main/js/components/SourceViewer/components/Line.js
server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.js
server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.js
server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/__snapshots__/LineIssuesList-test.js.snap
server/sonar-web/src/main/js/components/issue/Issue.js
server/sonar-web/src/main/js/components/issue/IssueView.js
server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js
server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js
server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap

index eed561cee2503cb3fb0df6c835357ab963f313f9..ef5904ea7045ef7864646fa1d4e2121441b657d3 100644 (file)
@@ -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}
index 6dc60a3776f9d0229d2d862ab2e09475d16f8781..94da47a46ab928d8141d4c0080d4a843d083085f 100644 (file)
@@ -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}
index 6d3a4378b2faa0f563c321574af80cc7fca471cb..c4c0cfc0c80c27c672e3c8da2a6270d5333d1576 100644 (file)
@@ -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}
index 55fb081c59d51fe84eb8351f14c1281aa7d987de..617e45710cb5601b1967e9f7dfa7c5d1e58267ec 100644 (file)
@@ -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}
index 1d81eb247124a0f777ad8ab709aa237666cb59b7..73906c1ff2e680b5727504b2772dc2c71fe50bf0 100644 (file)
@@ -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}
index 63782ced4384fc301c069bf78011ac8729ad2e84..3635c3c315f5df6371270e651e7d136f9ac91020 100644 (file)
@@ -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}
index e3f12d153be16e943d28541176557e31a40441dd..d4c186a83e531693bfef81c62c2ab7e25ed6af20 100644 (file)
@@ -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}
index f31277211ba72aad9583ca248167796af4c7140d..6bd44307b2f855bc3ecaa30035e77d52d483418a 100644 (file)
@@ -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",
index 70a1fc907462b14cd9515a1a0a0c3c0f90e8604b..a67e04c3fafaec184f41d141d1ebc511037794c7 100644 (file)
@@ -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}
       />
     );
   }
index 49de5e25b6c0ac68dfd5f9696811446f0b05498b..fd6b8f2aa6dcebf7d473ae3197a1f746ce7a1496 100644 (file)
@@ -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}
index 97bf195fdac4b1e43c91a7c146fbc43a06ce49f7..bd4acefaa8448f4e3b96022a87888f35bf71f272 100644 (file)
@@ -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>
               )}
index 02e2bce9e13e650dd910b25b350192e1d504f1c9..bf2980f0c2dc7f00ddf984897c3bf13b8545f30a 100644 (file)
@@ -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();
 });
index 2d1ac03a834bc6e3549a2887d3e05a7de2d80e9d..1302c5f2ac041d6d919a115758a9080cc5a356e1 100644 (file)
@@ -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"