From d194e2ddd1efc13e42c1d99813bb2ba4435fcecf Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Thu, 4 May 2023 11:04:36 -0400 Subject: [PATCH] Sentry errors (#652) * Fix null screenshot case * Ensure permission settings exist before rendering project users component * Protect against undefined input to hashCode * Protect against `undefined.length` --- web_client/src/components/ExperimentsView.vue | 7 ++++--- web_client/src/components/Navbar.vue | 1 + web_client/src/components/ProjectUsers.vue | 1 + web_client/src/components/ScreenshotDialog.vue | 2 +- web_client/src/components/UserAvatar.vue | 1 + web_client/src/views/Projects.vue | 4 ++-- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/web_client/src/components/ExperimentsView.vue b/web_client/src/components/ExperimentsView.vue index 594d7f29..d95e383a 100644 --- a/web_client/src/components/ExperimentsView.vue +++ b/web_client/src/components/ExperimentsView.vue @@ -58,7 +58,7 @@ export default defineComponent({ /** Assigns a color and character if a decision has been rendered on a given scan */ function decisionToRating(decisions) { // decisions are an array of objects - if (decisions.length === 0) return {}; + if (!decisions || decisions.length === 0) return {}; const rating = _.last(_.sortBy(decisions, (decision) => decision.created)).decision; let color = 'grey--text'; if (rating === 'U') { @@ -88,6 +88,7 @@ export default defineComponent({ /** Receives a string like "NCANDA_E08710" (name of an image file), * this is used as the experiment name */ function ellipsisText(str) { + if (!str) return ''; if (!props.minimal) return str; if (str.length > 25) { return `${str.substr(0, 10)}...${ @@ -357,7 +358,7 @@ export default defineComponent({ > {{ ellipsisText(scan.name) }} ({{ scan.decision }}) @@ -374,7 +375,7 @@ export default defineComponent({
diff --git a/web_client/src/components/Navbar.vue b/web_client/src/components/Navbar.vue index 8347127e..ffd2abe9 100644 --- a/web_client/src/components/Navbar.vue +++ b/web_client/src/components/Navbar.vue @@ -119,6 +119,7 @@ export default defineComponent({ @click="emailDialog = true" > diff --git a/web_client/src/components/ProjectUsers.vue b/web_client/src/components/ProjectUsers.vue index 1a65e45c..2b07f0c1 100644 --- a/web_client/src/components/ProjectUsers.vue +++ b/web_client/src/components/ProjectUsers.vue @@ -60,6 +60,7 @@ export default defineComponent({ return `${user.first_name} ${user.last_name}`; } function allEmails(inputs) { + if (!inputs) return true; for (let i = 0; i < inputs.length; i += 1) { const match = String(inputs[i]) .toLowerCase() diff --git a/web_client/src/components/ScreenshotDialog.vue b/web_client/src/components/ScreenshotDialog.vue index d11bd94d..11a6291d 100644 --- a/web_client/src/components/ScreenshotDialog.vue +++ b/web_client/src/components/ScreenshotDialog.vue @@ -70,7 +70,7 @@ export default defineComponent({ onMounted(async () => { output.value = await getOutput(); - fileName.value = currentScreenshot.value.name; + fileName.value = currentScreenshot.value ? currentScreenshot.value.name : 'Screenshot'; }); return { diff --git a/web_client/src/components/UserAvatar.vue b/web_client/src/components/UserAvatar.vue index 0be762a5..cb759144 100644 --- a/web_client/src/components/UserAvatar.vue +++ b/web_client/src/components/UserAvatar.vue @@ -32,6 +32,7 @@ export default defineComponent({ return name; }); function hashCode(s) { + if (!s) return 0; return s.split('') .reduce((a, b) => { const c = a < 5 ? 1 : 0; diff --git a/web_client/src/views/Projects.vue b/web_client/src/views/Projects.vue index 6b45b88b..5c6770ae 100644 --- a/web_client/src/views/Projects.vue +++ b/web_client/src/views/Projects.vue @@ -359,7 +359,7 @@ export default defineComponent({ class="flex-container" > - +
Select a project