From 35073d49dcd6fccb468c9f7914ac7d99d265bbc6 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 19 May 2022 16:25:28 +0200 Subject: [PATCH] Add error message on subscription dashboard if v1 is down (instead of returning a 500 error page) (#7947) * Add error message on subscription dashboard if v1 is down GitOrigin-RevId: 8c8b5ac4d44cfd2c42101efe1d55a5993ca21eea --- .../SubscriptionViewModelBuilder.js | 16 ++++++++++-- .../dashboard/_institution_memberships.pug | 26 +++++++++++-------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/services/web/app/src/Features/Subscription/SubscriptionViewModelBuilder.js b/services/web/app/src/Features/Subscription/SubscriptionViewModelBuilder.js index cd865c65bd..f85c7e1e68 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionViewModelBuilder.js +++ b/services/web/app/src/Features/Subscription/SubscriptionViewModelBuilder.js @@ -11,7 +11,11 @@ const _ = require('underscore') const async = require('async') const SubscriptionHelper = require('./SubscriptionHelper') const { promisify } = require('../../util/promises') -const { InvalidError, NotFoundError } = require('../Errors/Errors') +const { + InvalidError, + NotFoundError, + V1ConnectionError, +} = require('../Errors/Errors') function buildHostedLink(type) { return `/user/subscription/recurly/${type}` @@ -109,7 +113,15 @@ function buildUsersSubscriptionViewModel(user, callback) { SubscriptionLocator.getManagedGroupSubscriptions(user, cb) }, currentInstitutionsWithLicence(cb) { - InstitutionsGetter.getCurrentInstitutionsWithLicence(user._id, cb) + InstitutionsGetter.getCurrentInstitutionsWithLicence( + user._id, + (error, institutions) => { + if (error instanceof V1ConnectionError) { + return cb(null, false) + } + cb(null, institutions) + } + ) }, managedInstitutions(cb) { InstitutionsGetter.getManagedInstitutions(user._id, cb) diff --git a/services/web/app/views/subscriptions/dashboard/_institution_memberships.pug b/services/web/app/views/subscriptions/dashboard/_institution_memberships.pug index 9556100c51..ea627edc0f 100644 --- a/services/web/app/views/subscriptions/dashboard/_institution_memberships.pug +++ b/services/web/app/views/subscriptions/dashboard/_institution_memberships.pug @@ -1,11 +1,15 @@ -each institution in currentInstitutionsWithLicence - -hasDisplayedSubscription = true - p - | You have a - | - strong(ng-non-bindable) Professional - | - | #{settings.appName} account as a confirmed member of - | - strong(ng-non-bindable)= institution.name - hr +if currentInstitutionsWithLicence === false + .alert.alert-warning + p Sorry, something went wrong. Subscription information related to institutional affiliations may not be displayed. Please try again later. +else + each institution in currentInstitutionsWithLicence + -hasDisplayedSubscription = true + p + | You have a + | + strong(ng-non-bindable) Professional + | + | #{settings.appName} account as a confirmed member of + | + strong(ng-non-bindable)= institution.name + hr