Skip to content

Commit

Permalink
Merge pull request #3102 from csordasmarton/handle_missing_report
Browse files Browse the repository at this point in the history
[gui] Handle missing report
  • Loading branch information
bruntib authored Jan 7, 2021
2 parents 75ef0ec + bb507d3 commit 1149cbe
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 10 deletions.
75 changes: 66 additions & 9 deletions web/server/vue-cli/src/views/ReportDetail.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
<template>
<splitpanes class="default-theme">
<v-container
v-if="reportNotFound"
class="text-center"
fill-height
>
<v-row align="center" justify="center">
<v-col class="error--text" cols="6">
<h1 class="display-2">
404 - Report not found!
</h1>

<v-alert
class="mt-4"
type="error"
dense
outlined
text
>
The report (report ID: {{ $router.currentRoute.query["report-id"] }},
report hash: {{ $router.currentRoute.query["report-hash"] }},
file path: {{ $router.currentRoute.query["report-filepath"] }})
was removed from the database.

<span v-if="!$router.currentRoute.query['report-hash']">
Unfortunatelly your URL parameter was saved from and older version
of CodeChecker and it does not contain a <i>report-hash</i>
parameter to fallback the search for.
</span>
</v-alert>
</v-col>
</v-row>
</v-container>

<splitpanes
v-else
class="default-theme"
>
<pane size="20">
<v-container
fluid
Expand All @@ -18,6 +54,7 @@
:to="{ name: 'reports', query: {
...$router.currentRoute.query,
'report-id': undefined,
'report-filepath': undefined,
...(
reportFilter.reportHash ? {} : { 'report-hash' : undefined }
)
Expand Down Expand Up @@ -85,7 +122,8 @@ export default {
return {
report: null,
treeItem: null,
showComments: true
showComments: true,
reportNotFound: false
};
},
computed: {
Expand All @@ -105,17 +143,30 @@ export default {
methods: {
loadReport(reportId, reportHash) {
if (reportId) {
this.loadReportById(reportId);
this.loadReportById(reportId).catch(() => {
if (reportHash) {
this.loadReportByHash(reportHash);
} else {
this.reportNotFound = true;
}
});
} else if (reportHash) {
this.loadReportByHash(reportHash);
}
},
loadReportById(reportId) {
ccService.getClient().getReport(reportId,
handleThriftError(reportData => {
this.report = reportData;
}));
return new Promise((res, rej) => {
ccService.getClient().getReport(reportId,
handleThriftError(reportData => {
this.report = reportData;
res(true);
}, err => {
console.warn("Failed to get report for ID:", reportId);
console.warn(err);
rej(err);
}));
});
},
loadReportByHash(reportHash) {
Expand All @@ -128,16 +179,22 @@ export default {
ord: Order.ASC
});
const filePath = this.$router.currentRoute.query["report-filepath"];
const reportFilter = new ReportFilter({
...this.reportFilter,
isUnique: false,
reportHash: [ reportHash ]
reportHash: [ reportHash ],
filePath: [ filePath ]
});
ccService.getClient().getRunResults(this.runIds, limit, offset,
[ sortType ], reportFilter, this.cmpData, getDetails,
handleThriftError(reports => {
this.report = reports[0];
if (reports.length) {
this.report = reports[0];
} else {
this.reportNotFound = true;
}
}));
},
Expand Down
4 changes: 3 additions & 1 deletion web/server/vue-cli/src/views/Reports.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@
:to="{ name: 'report-detail', query: {
...$router.currentRoute.query,
'report-id': item.reportId ? item.reportId : undefined,
'report-hash': item.reportId ? undefined : item.bugHash
'report-hash': item.bugHash,
'report-filepath': reportFilter.isUnique
? `*${item.checkedFile}` : item.checkedFile
}}"
class="file-name"
>
Expand Down

0 comments on commit 1149cbe

Please sign in to comment.