Skip to content

Commit

Permalink
Sentry errors (#652)
Browse files Browse the repository at this point in the history
* Fix null screenshot case

* Ensure permission settings exist before rendering project users component

* Protect against undefined input to hashCode

* Protect against `undefined.length`
  • Loading branch information
annehaley authored May 4, 2023
1 parent 90d76cc commit d194e2d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions web_client/src/components/ExperimentsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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)}...${
Expand Down Expand Up @@ -357,7 +358,7 @@ export default defineComponent({
>
{{ ellipsisText(scan.name) }}
<span
v-if="scan.decisions.length !== 0"
v-if="scan.decisions && scan.decisions.length !== 0"
:class="scan.color + ' pl-3'"
small
>({{ scan.decision }})</span>
Expand All @@ -374,7 +375,7 @@ export default defineComponent({
</ul>
</div>
<div
v-else-if="currentProject.experiments.length"
v-else-if="currentProject.experiments?.length"
class="pa-5"
style="width: 60%; text-align: center"
>
Expand Down
1 change: 1 addition & 0 deletions web_client/src/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export default defineComponent({
@click="emailDialog = true"
>
<v-badge
v-if="screenshots"
:value="screenshots.length"
right
>
Expand Down
1 change: 1 addition & 0 deletions web_client/src/components/ProjectUsers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion web_client/src/components/ScreenshotDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions web_client/src/components/UserAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions web_client/src/views/Projects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export default defineComponent({
class="flex-container"
>
<ExperimentsView />
<ProjectUsers />
<ProjectUsers v-if="currentProject?.settings?.permissions" />
</div>
</div>
<v-card
Expand Down Expand Up @@ -405,7 +405,7 @@ export default defineComponent({
</v-subheader>
</div>
<div
v-else-if="projects.length > 0"
v-else-if="projects && projects.length > 0"
class="text-h6"
>
Select a project
Expand Down

0 comments on commit d194e2d

Please sign in to comment.