openIssuesByLine: { [number]: boolean },
selectedIssue?: string,
sources?: Array<SourceLine>,
+ sourceRemoved: boolean,
symbolsByLine: { [number]: Array<string> }
};
openIssuesByLine: {},
selectedIssue: props.selectedIssue,
selectedIssueLocation: null,
+ sourceRemoved: false,
symbolsByLine: {}
};
}
loading: false,
hasSourcesAfter: sources.length > LINES,
sources: this.computeCoverageStatus(finalSources),
+ sourceRemoved: false,
symbolsByLine: symbolsByLine(sources.slice(0, LINES))
},
() => {
if (this.mounted) {
if (response.status === 403) {
this.setState({ component, loading: false, notAccessible: true });
+ } else if (response.status === 404) {
+ this.setState({ component, loading: false, sourceRemoved: true });
}
}
};
const onFailLoadSources = ({ response }) => {
// TODO handle other statuses
if (this.mounted) {
- if (response.status === 403) {
+ if ([403, 404].includes(response.status)) {
reject(response);
- } else if (response.status === 404) {
+ } else {
resolve([]);
}
}
}
render() {
- const { component, loading } = this.state;
+ const { component, loading, sources, notAccessible, sourceRemoved } = this.state;
if (loading) {
return null;
'source-duplications-expanded': this.state.displayDuplications
});
+ const displaySources = !notAccessible && !sourceRemoved;
+
return (
<div className={className} ref={node => (this.node = node)}>
<SourceViewerHeader component={this.state.component} showMeasures={this.showMeasures} />
- {this.state.notAccessible &&
+ {notAccessible &&
<div className="alert alert-warning spacer-top">
{translate('code_viewer.no_source_code_displayed_due_to_security')}
</div>}
- {this.state.sources != null && this.renderCode(this.state.sources)}
+ {sourceRemoved &&
+ <div className="alert alert-warning spacer-top">
+ {translate('code_viewer.no_source_code_displayed_due_to_source_removed')}
+ </div>}
+ {displaySources && sources != null && this.renderCode(sources)}
</div>
);
}