Skip to content

Commit

Permalink
Use article's contributionsServiceUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
shtukas committed Jan 28, 2025
1 parent c24d570 commit 714b804
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions dotcom-rendering/src/components/ArticleBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export const ArticleBody = ({
isSensitive={isSensitive}
abTests={abTests}
editionId={editionId}
contributionsServiceUrl={contributionsServiceUrl}
/>
</div>
</>
Expand Down
1 change: 1 addition & 0 deletions dotcom-rendering/src/components/Island.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ describe('Island: server-side rendering', () => {
isPreview={false}
pageId={''}
switches={{}}
contributionsServiceUrl={''}
/>
</WithConfig>,
),
Expand Down
23 changes: 20 additions & 3 deletions dotcom-rendering/src/components/SignInGateSelector.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Props = {
pageId: string;
idUrl?: string;
switches: Switches;
contributionsServiceUrl: string;
};

// interface for the component which shows the sign in gate
Expand Down Expand Up @@ -199,7 +200,14 @@ const SignInGateSelectorDefault = ({
pageId,
idUrl = 'https://profile.theguardian.com',
switches,
contributionsServiceUrl,
}: Props) => {
// comment group: auxia-prototype-e55a86ef
// The following (useless) instruction only exists to avoid linting error
// so that SignInGateSelectorDefault, SignInGateSelectorAuxia and SignInGateSelector
// alll have the same signature, while we give shape to the Auxia prototype.
contributionsServiceUrl;

const authStatus = useAuthStatus();
const isSignedIn =
authStatus.kind === 'SignedInWithOkta' ||
Expand Down Expand Up @@ -349,6 +357,7 @@ export const SignInGateSelector = ({
pageId,
idUrl = 'https://profile.theguardian.com',
switches,
contributionsServiceUrl,
}: Props) => {
const abTestAPI = useAB()?.api;
const userIsInAuxiaExperiment = !!abTestAPI?.isUserInVariant(
Expand All @@ -367,12 +376,14 @@ export const SignInGateSelector = ({
pageId,
idUrl,
switches,
contributionsServiceUrl,
});
} else {
return SignInGateSelectorAuxia({
host,
pageId,
idUrl,
contributionsServiceUrl,
});
}
};
Expand Down Expand Up @@ -404,6 +415,7 @@ type PropsAuxia = {
host?: string;
pageId: string;
idUrl?: string;
contributionsServiceUrl: string;
};

/*
Expand Down Expand Up @@ -432,8 +444,10 @@ const dismissGateAuxia = (
setShowGate(false);
};

const fetchAuxiaDisplayDataFromProxy = async (): Promise<SDCProxyData> => {
const url = 'https://contributions.guardianapis.com/auxia';
const fetchAuxiaDisplayDataFromProxy = async (
contributionsServiceUrl: string,
): Promise<SDCProxyData> => {
const url = `${contributionsServiceUrl}/auxia`;
const headers = {
'Content-Type': 'application/json',
};
Expand All @@ -455,6 +469,7 @@ const SignInGateSelectorAuxia = ({
host = 'https://theguardian.com/',
pageId,
idUrl = 'https://profile.theguardian.com',
contributionsServiceUrl,
}: PropsAuxia) => {
/*
comment group: auxia-prototype-e55a86ef
Expand Down Expand Up @@ -494,7 +509,9 @@ const SignInGateSelectorAuxia = ({

useOnce(() => {
void (async () => {
const data = await fetchAuxiaDisplayDataFromProxy();
const data = await fetchAuxiaDisplayDataFromProxy(
contributionsServiceUrl,
);
setShouldShowSignInGateUsingAuxiaAnswer(data.shouldShowSignInGate);
})().catch((error) => {
console.error('Error fetching Auxia display data:', error);
Expand Down
3 changes: 3 additions & 0 deletions dotcom-rendering/src/lib/ArticleRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Props = {
isSensitive: boolean;
abTests: ServerSideTests;
editionId: EditionId;
contributionsServiceUrl: string;
};

export const ArticleRenderer = ({
Expand All @@ -55,6 +56,7 @@ export const ArticleRenderer = ({
isDev,
abTests,
editionId,
contributionsServiceUrl,
}: Props) => {
const isSectionedMiniProfilesArticle =
elements.filter(
Expand Down Expand Up @@ -129,6 +131,7 @@ export const ArticleRenderer = ({
switches,
isSensitive,
isDev,
contributionsServiceUrl,
})}
</div>
); // classname that space finder is going to target for in-body ads in DCR
Expand Down
5 changes: 5 additions & 0 deletions dotcom-rendering/src/lib/withSignInGateSlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Props = {
switches: Switches;
isSensitive?: boolean;
isDev?: boolean;
contributionsServiceUrl: string;
};

export const withSignInGateSlot = ({
Expand All @@ -33,6 +34,7 @@ export const withSignInGateSlot = ({
pageId,
idUrl,
switches,
contributionsServiceUrl,
}: Props): React.ReactNode => {
return renderedElements.map((element, i) => {
return (
Expand All @@ -52,6 +54,9 @@ export const withSignInGateSlot = ({
pageId={pageId}
idUrl={idUrl}
switches={switches}
contributionsServiceUrl={
contributionsServiceUrl
}
/>
</Island>
</div>
Expand Down

0 comments on commit 714b804

Please sign in to comment.