From b4b91a8cba33b1767c4374bb32d7ce40f5c31953 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 27 Mar 2018 13:08:38 +0200 Subject: [PATCH] SONAR-10444 clean source viewer state when fetching component --- .../SourceViewer/SourceViewerBase.tsx | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx index 35e97cf8847..1c615cc6bd4 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx @@ -96,15 +96,16 @@ interface Props { interface State { component?: SourceViewerFile; displayDuplications: boolean; + duplicatedFiles?: { [ref: string]: DuplicatedFile }; duplications?: Duplication[]; duplicationsByLine: { [line: number]: number[] }; - duplicatedFiles?: { [ref: string]: DuplicatedFile }; hasSourcesAfter: boolean; highlightedLine?: number; highlightedSymbols: string[]; + issueLocationsByLine: { [line: number]: LinearIssueLocation[] }; + issuePopup?: { issue: string; name: string }; issues?: Issue[]; issuesByLine: { [line: number]: Issue[] }; - issueLocationsByLine: { [line: number]: LinearIssueLocation[] }; linePopup?: { index?: number; line: number; name: string }; loading: boolean; loadingSourcesAfter: boolean; @@ -112,10 +113,9 @@ interface State { notAccessible: boolean; notExist: boolean; openIssuesByLine: { [line: number]: boolean }; - issuePopup?: { issue: string; name: string }; selectedIssue?: string; - sources?: SourceLine[]; sourceRemoved: boolean; + sources?: SourceLine[]; symbolsByLine: { [line: number]: string[] }; } @@ -245,15 +245,24 @@ export default class SourceViewerBase extends React.PureComponent this.setState( { component, + displayDuplications: false, + duplicatedFiles: undefined, + duplications: undefined, + duplicationsByLine: {}, + hasSourcesAfter: sources.length > LINES, + highlightedLine: undefined, + highlightedSymbols: [], + issueLocationsByLine: locationsByLine(issues), issues, issuesByLine: issuesByLine(issues), - issueLocationsByLine: locationsByLine(issues), + linePopup: undefined, loading: false, notAccessible: false, notExist: false, - hasSourcesAfter: sources.length > LINES, - sources: this.computeCoverageStatus(finalSources), + openIssuesByLine: {}, + issuePopup: undefined, sourceRemoved: false, + sources: this.computeCoverageStatus(finalSources), symbolsByLine: symbolsByLine(sources.slice(0, LINES)) }, () => { -- 2.39.5