From 4d3a787a2efd8ddc0a168ec180358f5f226a1f36 Mon Sep 17 00:00:00 2001 From: Matt Stover Date: Mon, 29 Nov 2021 11:26:02 -0800 Subject: [PATCH] fix: move and update global exclude list --- .../WwwFrame/DisclaimersContentful.vue | 5 ++++- .../GlobalPromotionalBannerContentful.vue | 18 +++-------------- src/pages/Checkout/CheckoutPage.vue | 14 ++++++------- src/util/urlUtils.js | 20 ++++++++++++++++++- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/components/WwwFrame/DisclaimersContentful.vue b/src/components/WwwFrame/DisclaimersContentful.vue index 04a185ade8..73a6a9328b 100644 --- a/src/components/WwwFrame/DisclaimersContentful.vue +++ b/src/components/WwwFrame/DisclaimersContentful.vue @@ -16,7 +16,7 @@ import _get from 'lodash/get'; import numeral from 'numeral'; import gql from 'graphql-tag'; import { settingEnabled, settingWithinDateRange } from '@/util/settingsUtils'; -import isExcludedUrl from '@/util/urlUtils'; +import { globalBannerDenyList, isExcludedUrl } from '@/util/urlUtils'; import { documentToHtmlString } from '~/@contentful/rich-text-html-renderer'; const disclaimerQuery = gql`query disclaimerQuery($basketId: String) { @@ -56,6 +56,9 @@ export default { query: disclaimerQuery, preFetch: true, result({ data }) { + // Hide ALL banners on these pages + if (isExcludedUrl(globalBannerDenyList, this.$route.path)) return false; + this.disclaimerContent = []; // gather contentful content and the uiSetting key ui-global-promo const contentfulContent = data?.contentful?.entries?.items ?? []; diff --git a/src/components/WwwFrame/PromotionalBanner/GlobalPromotionalBannerContentful.vue b/src/components/WwwFrame/PromotionalBanner/GlobalPromotionalBannerContentful.vue index ace9d601de..eba83a30c3 100644 --- a/src/components/WwwFrame/PromotionalBanner/GlobalPromotionalBannerContentful.vue +++ b/src/components/WwwFrame/PromotionalBanner/GlobalPromotionalBannerContentful.vue @@ -17,7 +17,7 @@ import _get from 'lodash/get'; import gql from 'graphql-tag'; import { settingEnabled } from '@/util/settingsUtils'; -import isExcludedUrl from '@/util/urlUtils'; +import { globalBannerDenyList, isExcludedUrl } from '@/util/urlUtils'; import AppealBannerCircularContainer from '@/components/WwwFrame/PromotionalBanner/Banners/AppealBanner/AppealBannerCircularContainer'; @@ -49,18 +49,6 @@ export default { appealBannerContent: {}, appealEnabled: false, customAppealEnabled: false, - globalBannerDenyList: [ - '/checkout', - '/confirm-instant-donation/*', - '/donate/support-kiva', - '/error', - '/instant-donation-thanks', - '/join-team', - '/register/social', - '/possibility/giving-tuesday', - '/possibility/12-days-of-lending', - '/possibility/year-end' - ] }; }, inject: ['apollo', 'cookieStore'], @@ -69,7 +57,7 @@ export default { preFetch: true, result({ data }) { // Hide ALL banners on these pages - if (isExcludedUrl(this.globalBannerDenyList, this.$route.path)) return false; + if (isExcludedUrl(globalBannerDenyList, this.$route.path)) return false; // returns the contentful content of the uiSetting key ui-global-promo or empty object // it should always be the first and only item in the array, since we pass the variable to the query above @@ -137,7 +125,7 @@ export default { computed: { showAppeal() { // Check if Appeal Banner is active and the user is not on a denied page URL - if (this.appealEnabled && !isExcludedUrl(this.globalBannerDenyList, this.$route.path)) return true; + if (this.appealEnabled && !isExcludedUrl(globalBannerDenyList, this.$route.path)) return true; return false; }, }, diff --git a/src/pages/Checkout/CheckoutPage.vue b/src/pages/Checkout/CheckoutPage.vue index a107c8c04a..cc9e8f0f43 100644 --- a/src/pages/Checkout/CheckoutPage.vue +++ b/src/pages/Checkout/CheckoutPage.vue @@ -319,13 +319,13 @@ export default { // TODO: remove once bonus credit functionality is added if (hasFreeCredits || lendingRewardOffered) { // cancel the promise, returning a route for redirect - // return Promise.reject({ - // path: '/basket', - // query: { - // kexpn: 'checkout_beta.minimal_checkout', - // kexpv: 'a' - // } - // }); + return Promise.reject({ + path: '/basket', + query: { + kexpn: 'checkout_beta.minimal_checkout', + kexpv: 'a' + } + }); } return data; }).then(() => { diff --git a/src/util/urlUtils.js b/src/util/urlUtils.js index 24a0e79ec7..e65f44bdbe 100644 --- a/src/util/urlUtils.js +++ b/src/util/urlUtils.js @@ -1,3 +1,21 @@ +/** + * Global exclude list for promoation banners + disclaimers + */ +export const globalBannerDenyList = [ + '/checkout', + '/confirm-instant-donation/*', + '/donate/support-kiva', + '/error', + '/instant-donation-thanks', + '/instant-lending-error', + '/join-team', + '/register/social', + '/possibility/giving-tuesday', + '/possibility/12-days-of-lending', + '/possibility/year-end', + '/process-instant-lending/*', +]; + /** * Check the current route against a list of restricted url fragments * @@ -5,7 +23,7 @@ * @param {string} route - target url to check against * @returns {boolean} */ -export default function isExcludedUrl(urlArray, route) { +export function isExcludedUrl(urlArray, route) { let excludeUrl = false; urlArray.forEach(url => { // match specific urls