Skip to content

Commit

Permalink
fix: move and update global exclude list
Browse files Browse the repository at this point in the history
  • Loading branch information
mcstover committed Nov 29, 2021
1 parent 038ec3e commit 4d3a787
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 24 deletions.
5 changes: 4 additions & 1 deletion src/components/WwwFrame/DisclaimersContentful.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 ?? [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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'],
Expand All @@ -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
Expand Down Expand Up @@ -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;
},
},
Expand Down
14 changes: 7 additions & 7 deletions src/pages/Checkout/CheckoutPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
20 changes: 19 additions & 1 deletion src/util/urlUtils.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
/**
* 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
*
* @param {array} urlArray - Array of Url path fragments
* @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
Expand Down

0 comments on commit 4d3a787

Please sign in to comment.