]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11131 Use isNew field from api/sources/lines to display new lines of code
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 15 Aug 2018 14:40:40 +0000 (16:40 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 19 Sep 2018 08:51:40 +0000 (10:51 +0200)
server/sonar-web/src/main/js/api/components.ts
server/sonar-web/src/main/js/app/types.ts
server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx
server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx
server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx

index 671fb298cbf11a6fda9654cf1cd9fa0438edb1bb..39805e256497deb37aac7c91f92f0ffd262278f0 100644 (file)
@@ -20,6 +20,7 @@
 import throwGlobalError from '../app/utils/throwGlobalError';
 import { getJSON, postJSON, post, RequestData } from '../helpers/request';
 import {
+  SourceLine,
   Paging,
   Visibility,
   BranchParameters,
@@ -294,7 +295,7 @@ export function getComponentForSourceViewer(
 
 export function getSources(
   data: { key: string; from?: number; to?: number } & BranchParameters
-): Promise<any> {
+): Promise<SourceLine[]> {
   return getJSON('/api/sources/lines', data).then(r => r.sources);
 }
 
index 3918a750ed3e1e17d57acba9d1120913ab53d93e..237d4d6e981e9b8b1b6aa9d1c02de09dc673b6c5 100644 (file)
@@ -628,6 +628,7 @@ export interface SourceLine {
   coverageStatus?: string;
   coveredConditions?: number;
   duplicated?: boolean;
+  isNew?: boolean;
   line: number;
   lineHits?: number;
   scmAuthor?: string;
index d9008a88fbcf034652d9b3a1be53cd59229c94dc..85b04e98266d64a3f1313cd30741531686183bd6 100644 (file)
@@ -593,14 +593,6 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
     }
   };
 
-  handleFilterLine = (line: SourceLine) => {
-    const { component } = this.state;
-    const leakPeriodDate = component && component.leakPeriodDate;
-    return leakPeriodDate
-      ? line.scmDate !== undefined && parseDate(line.scmDate) > parseDate(leakPeriodDate)
-      : false;
-  };
-
   renderDuplicationPopup = (index: number, line: number) => {
     const { component, duplicatedFiles, duplications } = this.state;
 
@@ -648,7 +640,6 @@ export default class SourceViewerBase extends React.PureComponent<Props, State>
         displayLocationMarkers={this.props.displayLocationMarkers}
         duplications={this.state.duplications}
         duplicationsByLine={this.state.duplicationsByLine}
-        filterLine={this.handleFilterLine}
         hasSourcesAfter={this.state.hasSourcesAfter}
         hasSourcesBefore={hasSourcesBefore}
         highlightedLine={this.props.highlightedLine}
index 21dad198aa1e1bf1b99ade35d068aab6a4c0861d..a3d1fc4211d15e0dbf1c0c8d3946996b9572dd59 100644 (file)
@@ -37,6 +37,7 @@ const EMPTY_ARRAY: any[] = [];
 const ZERO_LINE = {
   code: '',
   duplicated: false,
+  isNew: false,
   line: 0
 };
 
@@ -49,7 +50,6 @@ interface Props {
   displayLocationMarkers?: boolean;
   duplications: Duplication[] | undefined;
   duplicationsByLine: { [line: number]: number[] };
-  filterLine?: (line: SourceLine) => boolean;
   hasSourcesAfter: boolean;
   hasSourcesBefore: boolean;
   highlightedLine: number | undefined;
@@ -126,8 +126,7 @@ export default class SourceViewerCode extends React.PureComponent<Props> {
     displayDuplications: boolean;
     displayIssues: boolean;
   }) => {
-    const { filterLine, highlightedLocationMessage, selectedIssue, sources } = this.props;
-    const filtered = filterLine && filterLine(line);
+    const { highlightedLocationMessage, selectedIssue, sources } = this.props;
 
     const secondaryIssueLocations = this.getSecondaryIssueLocationsForLine(line);
 
@@ -175,7 +174,6 @@ export default class SourceViewerCode extends React.PureComponent<Props> {
         displayLocationMarkers={this.props.displayLocationMarkers}
         duplications={this.getDuplicationsForLine(line)}
         duplicationsCount={duplicationsCount}
-        filtered={filtered}
         highlighted={line.line === this.props.highlightedLine}
         highlightedLocationMessage={optimizedLocationMessage}
         highlightedSymbols={optimizedHighlightedSymbols}
index fc8b7686a800cb65f1194c06962c1ab857571b7d..c2f2e4972e0121143fb64476747b0b3466ad4424 100644 (file)
@@ -41,7 +41,6 @@ interface Props {
   displayLocationMarkers?: boolean;
   duplications: number[];
   duplicationsCount: number;
-  filtered: boolean | undefined;
   highlighted: boolean;
   highlightedLocationMessage: { index: number; text: string | undefined } | undefined;
   highlightedSymbols: string[] | undefined;
@@ -101,17 +100,10 @@ export default class Line extends React.PureComponent<Props> {
   };
 
   render() {
-    const {
-      displayCoverage,
-      duplications,
-      duplicationsCount,
-      filtered,
-      issuePopup,
-      line
-    } = this.props;
+    const { displayCoverage, duplications, duplicationsCount, issuePopup, line } = this.props;
     const className = classNames('source-line', {
       'source-line-highlighted': this.props.highlighted,
-      'source-line-filtered': filtered === true,
+      'source-line-filtered': line.isNew,
       'source-line-filtered-dark':
         displayCoverage &&
         (line.coverageStatus === 'uncovered' || line.coverageStatus === 'partially-covered'),