Skip to content

Commit 28416b4

Browse files
committed
refactoring
1 parent 638f97c commit 28416b4

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

dotcom-rendering/src/components/SignInGate/displayRule.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,35 @@ export const canShowSignInGateWithOffers = ({
153153
// hide the sign in gate for AU and US readers
154154
!['AU', ...US_REGION_CODES].includes(currentLocaleCode),
155155
);
156+
157+
/*
158+
Date: 29th April 2025
159+
160+
We have a request to prevent sign-in gate for a specific URL. This feels like an
161+
adhoc request and not a new general feature to implement.
162+
163+
We have a check in SDC: https://github.com/guardian/support-dotcom-components/pull/1345 ,
164+
to prevent the Auxia gate from showing, but we also need to prevent the legacy gate from
165+
showing. For a cleaner implementation. we are simply going to prevent any of the two
166+
gates components from rendering.
167+
168+
To keep things simple, we are going to add a check in SignInGateSelector, which seems
169+
like a good place.
170+
*/
171+
172+
export const pageIdIsAllowedForGating = (pageId: string): boolean => {
173+
// This function was introduced to handle the specific request of not showing a gate for
174+
// this url: https://www.theguardian.com/tips
175+
176+
// pageId is the path without the starting slash
177+
// example:
178+
// - full url: https://www.theguardian.com/world/2025/apr/29/canada-election-result-liberal-win-mark-carney-anti-trump
179+
// - pageId: world/2025/apr/29/canada-election-result-liberal-win-mark-carney-anti-trump
180+
181+
const denyPaths = [
182+
'tips',
183+
'help/ng-interactive/2017/mar/17/contact-the-guardian-securely',
184+
];
185+
186+
return !denyPaths.some((denyPath) => pageId.startsWith(denyPath));
187+
};

dotcom-rendering/src/components/SignInGateSelector.importable.tsx

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
retrieveDismissedCount,
3232
setUserDismissedGate,
3333
} from './SignInGate/dismissGate';
34+
import { pageIdIsAllowedForGating } from './SignInGate/displayRule';
3435
import { SignInGateAuxia } from './SignInGate/gateDesigns/SignInGateAuxia';
3536
import { signInGateTestIdToComponentId } from './SignInGate/signInGateMappings';
3637
import type {
@@ -370,38 +371,6 @@ const SignInGateSelectorDefault = ({
370371
// Auxia Integration Experiment //
371372
// -------------------------------
372373

373-
/*
374-
Date: 29th April 2025
375-
376-
We have a request to prevent sign-in gate for a specific URL. This feels like an
377-
adhoc request and not a new general feature to implement.
378-
379-
We have a check in SDC: https://github.com/guardian/support-dotcom-components/pull/1345 ,
380-
to prevent the Auxia gate from showing, but we also need to prevent the legacy gate from
381-
showing. For a cleaner implementation. we are simply going to prevent any of the two
382-
gates components from rendering.
383-
384-
To keep things simple, we are going to add a check in SignInGateSelector, which seems
385-
like a good place.
386-
*/
387-
388-
export const pageIdIsAllowedForGating = (pageId: string): boolean => {
389-
// This function was introduced to handle the specific request of not showing a gate for
390-
// this url: https://www.theguardian.com/tips
391-
392-
// pageId is the path without the starting slash
393-
// example:
394-
// - full url: https://www.theguardian.com/world/2025/apr/29/canada-election-result-liberal-win-mark-carney-anti-trump
395-
// - pageId: world/2025/apr/29/canada-election-result-liberal-win-mark-carney-anti-trump
396-
397-
const denyPaths = [
398-
'tips',
399-
'help/ng-interactive/2017/mar/17/contact-the-guardian-securely',
400-
];
401-
402-
return !denyPaths.some((denyPath) => pageId.startsWith(denyPath));
403-
};
404-
405374
export const SignInGateSelector = ({
406375
contentType,
407376
sectionId = '',

0 commit comments

Comments
 (0)