added diff endpoint which returns a parsed diff as json

This commit is contained in:
Sebastian Sdorra
2020-01-22 15:49:50 +01:00
parent fd15c68ca0
commit fe8e4db10b
10 changed files with 424 additions and 16 deletions

View File

@@ -50,10 +50,15 @@ class LoadingDiff extends React.Component<Props, State> {
this.setState({ loading: true });
apiClient
.get(url)
.then(response => response.text())
.then(parser.parse)
// $FlowFixMe
.then((diff: any) => {
.then(response => {
const contentType = response.headers.get("Content-Type");
if (contentType && contentType.toLowerCase() === "application/vnd.scmm-diffparsed+json;v=2") {
return response.json().then(data => data.files);
} else {
return response.text().then(parser.parse);
}
})
.then((diff: File[]) => {
this.setState({
loading: false,
diff: diff