Browse Source

SONAR-11131 Use isNew field from api/sources/lines to display new lines of code

tags/7.5
Grégoire Aubert 5 years ago
parent
commit
1499510eb4

+ 2
- 1
server/sonar-web/src/main/js/api/components.ts View 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);
}


+ 1
- 0
server/sonar-web/src/main/js/app/types.ts View File

@@ -628,6 +628,7 @@ export interface SourceLine {
coverageStatus?: string;
coveredConditions?: number;
duplicated?: boolean;
isNew?: boolean;
line: number;
lineHits?: number;
scmAuthor?: string;

+ 0
- 9
server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx View 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}

+ 2
- 4
server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx View 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}

+ 2
- 10
server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx View 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'),

Loading…
Cancel
Save