Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DAH-3200 update broken sf.gov link redirects #2528

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions app/assets/json/additional-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@
"title": "assistance.additionalResources.sfHousingResources.fcfs.title",
"agency": "assistance.additionalResources.sfHousingResources.fcfs.agency",
"description": "assistance.additionalResources.sfHousingResources.fcfs.description",
"externalUrl": "https://sf.gov/reports/january-2023/first-come-first-served-bmr-listings",
"sfGovNode": 6396
"externalUrl": "https://sf.gov/reports/january-2023/first-come-first-served-bmr-listings"
},
{
"title": "assistance.additionalResources.sfHousingResources.downpayment.title",
"agency": "assistance.additionalResources.sfHousingResources.downpayment.agency",
"description": "assistance.additionalResources.sfHousingResources.downpayment.description",
"externalUrl": "https://sf.gov/reports/december-2022/city-second-program-current-listings",
"sfGovNode": 7189
"externalUrl": "https://sf.gov/reports/december-2022/city-second-program-current-listings"
},
{
"title": "assistance.additionalResources.sfHousingResources.rental.title",
"agency": "assistance.additionalResources.sfHousingResources.rental.agency",
"description": "assistance.additionalResources.sfHousingResources.rental.description",
"externalUrl": "https://sf.gov/information/san-francisco-rental-opportunities",
"sfGovNode": 7153
"externalUrl": "https://sf.gov/information/san-francisco-rental-opportunities"
},
{
"title": "assistance.additionalResources.sfHousingResources.support.title",
Expand Down
23 changes: 14 additions & 9 deletions app/javascript/__tests__/util/languageUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,25 @@ describe("languageUtil", () => {
})

describe("getSfGovUrl", () => {
const node = 55
it("returns the correct url for a sf.gov link", () => {
const enLink = "https://sf.gov/departments/mayors-office-housing-and-community-development"
expect(getSfGovUrl(enLink, node, "https://housing.sfgov.org")).toBe(enLink)
expect(getSfGovUrl(enLink, node, "es")).toBe("https://sf.gov/es/node/55")
expect(getSfGovUrl(enLink, node, "zh")).toBe("https://sf.gov/zh-hant/node/55")
expect(getSfGovUrl(enLink, node, "tl")).toBe("https://sf.gov/fil/node/55")
expect(getSfGovUrl(enLink, "https://housing.sfgov.org")).toBe(enLink)
expect(getSfGovUrl(enLink, "es")).toBe(
"https://sf.gov/es/departments/mayors-office-housing-and-community-development"
)
expect(getSfGovUrl(enLink, "zh")).toBe(
"https://sf.gov/zh-hant/departments/mayors-office-housing-and-community-development"
)
expect(getSfGovUrl(enLink, "tl")).toBe(
"https://sf.gov/fil/departments/mayors-office-housing-and-community-development"
)
})
it("returns the same url if not an sf.gov link", () => {
const enLink = "https://housing.acgov.org"
expect(getSfGovUrl(enLink, node, "https://housing.sfgov.org")).toBe(enLink)
expect(getSfGovUrl(enLink, node, "es")).toBe(enLink)
expect(getSfGovUrl(enLink, node, "zh")).toBe(enLink)
expect(getSfGovUrl(enLink, node, "tl")).toBe(enLink)
expect(getSfGovUrl(enLink, "https://housing.sfgov.org")).toBe(enLink)
expect(getSfGovUrl(enLink, "es")).toBe(enLink)
expect(getSfGovUrl(enLink, "zh")).toBe(enLink)
expect(getSfGovUrl(enLink, "tl")).toBe(enLink)
})
})
})
15 changes: 4 additions & 11 deletions app/javascript/components/BeforeApplyingForSale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,37 +57,30 @@ export const BeforeApplyingForSale = ({ beforeApplyingType }: BeforeApplyingForS
) {
requirements = renderInlineMarkup(
`${t("saleDirectory.beforeApplying.readFullList", {
url: getSfGovUrl(
"https://sf.gov/determine-if-you-can-buy-affordable-housing-program",
7164
),
url: getSfGovUrl("https://sf.gov/determine-if-you-can-buy-affordable-housing-program"),
})}`
)
listItems = [
{ content: t("saleDirectory.beforeApplying.step1") },
{
content: renderInlineMarkup(
`${t("saleDirectory.beforeApplying.step2", {
url: getSfGovUrl(
"https://sf.gov/determine-if-you-can-buy-affordable-housing-program",
7164
),
url: getSfGovUrl("https://sf.gov/determine-if-you-can-buy-affordable-housing-program"),
})}`
),
},
{
content: renderInlineMarkup(
`${t("saleDirectory.beforeApplying.step3", {
url: getSfGovUrl("https://sf.gov/sign-complete-homebuyer-education", 212),
url: getSfGovUrl("https://sf.gov/sign-complete-homebuyer-education"),
})}`
),
},
{
content: renderInlineMarkup(
`${t("saleDirectory.beforeApplying.step4", {
url: getSfGovUrl(
"https://sf.gov/reports/october-2023/find-lender-below-market-rate-program",
6953
"https://sf.gov/reports/october-2023/find-lender-below-market-rate-program"
),
})}`
),
Expand Down
11 changes: 3 additions & 8 deletions app/javascript/layouts/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ const Layout = (props: LayoutProps) => {
<Markdown>
{t("footer.dahliaDescription", {
mohcdUrl: getSfGovUrl(
"https://sf.gov/departments/mayors-office-housing-and-community-development",
55
"https://sf.gov/departments/mayors-office-housing-and-community-development"
),
})}
</Markdown>
Expand All @@ -207,13 +206,9 @@ const Layout = (props: LayoutProps) => {
<Markdown>
{t("footer.inPartnershipWith", {
sfdsUrl: getSfGovUrl(
"https://sf.gov/departments/city-administrator/digital-services",
1788
),
mayorUrl: getSfGovUrl(
"https://sf.gov/departments/mayors-office-innovation",
3095
"https://sf.gov/departments/city-administrator/digital-services"
),
mayorUrl: getSfGovUrl("https://sf.gov/departments/mayors-office-innovation"),
})}
</Markdown>
</p>
Expand Down
5 changes: 2 additions & 3 deletions app/javascript/layouts/Sidebar/ContactSidebarBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const SidebarContactInfo = () => (
{renderInlineMarkup(
t("assistance.contact.questionsAboutPrograms.contactWebsite", {
url: getSfGovUrl(
"https://sf.gov/departments/mayors-office-housing-and-community-development",
55
"https://sf.gov/departments/mayors-office-housing-and-community-development"
),
})
)}
Expand Down Expand Up @@ -45,7 +44,7 @@ const SidebarSFHelp = () => (
<br />
{renderInlineMarkup(
t("assistance.contact.helpLine.subtitle", {
url: getSfGovUrl("https://sf.gov/departments/311-customer-service-center", 217),
url: getSfGovUrl("https://sf.gov/departments/311-customer-service-center"),
})
)}
</p>
Expand Down
5 changes: 1 addition & 4 deletions app/javascript/layouts/Sidebar/GetHelpSidebarBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ const GetHelpSidebarBlock = () => (
<LinkButton
transition={true}
newTab={true}
href={getSfGovUrl(
"https://www.sf.gov/resource/2022/homebuyer-program-counseling-agencies",
7209
)}
href={getSfGovUrl("https://www.sf.gov/resource/2022/homebuyer-program-counseling-agencies")}
className={"w-full"}
>
{t("housingCounselor.findAHousingCounselor")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export const ListingDetailsChisholmPreferences = ({
{renderInlineMarkup(
t("listings.customListingType.educator.preferences.part4a", {
chisholmLotteryLink: getSfGovUrl(
"https://sf.gov/information/learn-how-lottery-works-shirley-chisholm-village",
10493
"https://sf.gov/information/learn-how-lottery-works-shirley-chisholm-village"
),
})
)}
Expand All @@ -34,8 +33,7 @@ export const ListingDetailsChisholmPreferences = ({
{renderInlineMarkup(
t("listings.customListingType.educator.preferences.part4b", {
preferencesLink: getSfGovUrl(
"https://sf.gov/information/learn-about-housing-lottery-preference-programs",
3274
"https://sf.gov/information/learn-about-housing-lottery-preference-programs"
),
})
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ export const ListingDetailsEligibility = ({
{renderInlineMarkup(
t("listings.customListingType.educator.eligibility.part2", {
chisholmLink: getSfGovUrl(
"https://sf.gov/apply-shirley-chisholm-village-housing",
10543
"https://sf.gov/apply-shirley-chisholm-village-housing"
),
})
)}
Expand Down Expand Up @@ -204,8 +203,7 @@ export const ListingDetailsEligibility = ({
{renderInlineMarkup(
t("listings.customListingType.educator.eligibility.part2", {
chisholmLink: getSfGovUrl(
"https://sf.gov/apply-shirley-chisholm-village-housing",
10543
"https://sf.gov/apply-shirley-chisholm-village-housing"
),
})
)}
Expand Down Expand Up @@ -259,8 +257,7 @@ export const ListingDetailsEligibility = ({
{renderMarkup(
t("listings.incomeExceptions.intro", {
url: getSfGovUrl(
"https://sf.gov/information/special-calculations-household-income",
7080
"https://sf.gov/information/special-calculations-household-income"
),
})
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ export const ListingDetailsHabitat = ({ listing }: ListingDetailsHabitatProps) =
<div className="mt-4">
{renderMarkup(
t("listings.incomeExceptions.intro", {
url: getSfGovUrl(
"https://sf.gov/information/special-calculations-household-income",
7080
),
url: getSfGovUrl("https://sf.gov/information/special-calculations-household-income"),
})
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,6 @@ export interface ListingDetailsPreferencesProps {
translations?: RailsTranslations
}

export const mapPreferenceLink = (link: string): string => {
switch (link) {
case "http://sfmohcd.org/certificate-preference":
return getSfGovUrl(link, 3275)
case "http://sfmohcd.org/displaced-tenant-housing-preference":
return getSfGovUrl(link, 7488)
case "http://sfmohcd.org/housing-preference-programs":
return getSfGovUrl(link, 3274)
case "http://sfmohcd.org/neighborhood-resident-housing-preference":
return getSfGovUrl(link, 3274)
case "https://www.sf.gov/certain-buildings-have-special-lottery-preferences":
return getSfGovUrl(link, 11931)
default:
return link
}
}

export const ListingDetailsPreferences = ({
listingID,
translations,
Expand Down Expand Up @@ -85,7 +68,7 @@ export const ListingDetailsPreferences = ({
if (preference.readMoreUrl) {
links.push({
title: t("label.readMore"),
url: mapPreferenceLink(preference.readMoreUrl),
url: getSfGovUrl(preference.readMoreUrl),
ariaLabel: t(`listings.lotteryPreference.${preference.preferenceName}.readMore`),
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ const StandardHowToApply = ({
url: isHabitatListing
? "https://habitatgsf.org/amber-drive-info/"
: getSfGovUrl(
"https://sf.gov/determine-if-you-can-buy-affordable-housing-program",
7164
"https://sf.gov/determine-if-you-can-buy-affordable-housing-program"
),
})
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export const NeedHelpBlock = ({ listing }: { listing: RailsSaleListing | RailsRe
const isListingRental = isRental(listing)

const salesNeedHelpLink = getSfGovUrl(
"https://www.sf.gov/resource/2022/homebuyer-program-counseling-agencies",
7209
"https://www.sf.gov/resource/2022/homebuyer-program-counseling-agencies"
)

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const ListingDetailsLotteryRanking = ({
<Link
className="text-blue-700"
external={true}
href={getSfGovUrl("https://sf.gov/after-rental-housing-lottery", 12704)}
href={getSfGovUrl("https://sf.gov/after-rental-housing-lottery")}
target="_blank"
>
{t("lottery.nextStepsLearnMore")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ export const fcfsNoLotteryRequired = () => {
<CardFooter className="mx-6 mb-6 underline fcfs-no-lottery-section">
<Link
newWindowTarget
href={getSfGovUrl(
"https://www.sf.gov/step-by-step/buy-home-without-entering-lottery",
14246
)}
href={getSfGovUrl("https://www.sf.gov/step-by-step/buy-home-without-entering-lottery")}
hideExternalLinkIcon={true}
ariaLabel={t("listings.fcfs.bmrSales.noLotteryRequired.footer.aria")}
className="fcfs-no-lottery-link"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const AdditionalResources = () => {
<InfoCard
title={t(resource.title)}
subtitle={t(resource.agency)}
externalHref={getSfGovUrl(resource.externalUrl, resource.sfGovNode)}
externalHref={getSfGovUrl(resource.externalUrl)}
className="info-card-additional-resources is-normal-primary-lighter"
key={resource.title}
>
Expand Down
13 changes: 4 additions & 9 deletions app/javascript/pages/getAssistance/document-checklist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const DocumentChecklist = () => {
<p>
{renderInlineMarkup(
t("documentChecklist.copDoc2", {
url: getSfGovUrl("https://sf.gov/learn-about-certificate-preference-cop", 3275),
url: getSfGovUrl("https://sf.gov/learn-about-certificate-preference-cop"),
})
)}
</p>
Expand All @@ -90,10 +90,7 @@ const DocumentChecklist = () => {
<p>
{renderInlineMarkup(
t("documentChecklist.dthpDoc3", {
url: getSfGovUrl(
"https://sf.gov/displaced-tenant-housing-preference-program-dthp",
7488
),
url: getSfGovUrl("https://sf.gov/displaced-tenant-housing-preference-program-dthp"),
})
)}
</p>
Expand Down Expand Up @@ -187,8 +184,7 @@ const DocumentChecklist = () => {
{renderInlineMarkup(
t("documentChecklist.p3", {
url: getSfGovUrl(
"https://sf.gov/information/learn-about-housing-lottery-preference-programs",
3274
"https://sf.gov/information/learn-about-housing-lottery-preference-programs"
),
})
)}
Expand All @@ -208,8 +204,7 @@ const DocumentChecklist = () => {
{renderInlineMarkup(
t("documentChecklist.homebuyerLoanDesc", {
url: getSfGovUrl(
"https://sf.gov/reports/february-2023/find-lender-below-market-rate-program",
6953
"https://sf.gov/reports/february-2023/find-lender-below-market-rate-program"
),
})
)}
Expand Down
12 changes: 4 additions & 8 deletions app/javascript/pages/howToApply/how-to-apply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ const HowLongItTakesSection = ({ listing }: { listing: RailsSaleListing }) => {
)
}

const renderInlineSfGovUrl = (key: string, url: string, node: number) => {
const renderInlineSfGovUrl = (key: string, url: string) => {
return renderInlineMarkup(
`${t(key, {
url: getSfGovUrl(url, node),
url: getSfGovUrl(url),
})}`
)
}
Expand All @@ -127,17 +127,14 @@ const eligibilityListItems = [
{
index: 2,
link: "https://sf.gov/determine-if-you-can-buy-affordable-housing-program",
node: 7164,
},
{
index: 3,
link: "https://sf.gov/sign-complete-homebuyer-education",
node: 212,
},
{
index: 4,
link: "https://sf.gov/reports/october-2023/find-lender-below-market-rate-program",
node: 6953,
},
{ index: 5 },
]
Expand Down Expand Up @@ -202,8 +199,7 @@ const BeforeYouStartSection = ({ listing }: { listing: RailsSaleListing }) => {

renderInlineSfGovUrl(
`howToApplyPage.beforeYouStartSection.eligibilityList.listItem${item.index}`,
item.link,
item.node
item.link
)
}
</li>
Expand Down Expand Up @@ -409,7 +405,7 @@ const WhatHappensNextSection = () => {
<a
className="underline"
target="_blank"
href={getSfGovUrl("https://www.sf.gov/node/14246", 14246)}
href={getSfGovUrl("https://www.sf.gov/node/14246")}
cliu02 marked this conversation as resolved.
Show resolved Hide resolved
aria-label={t("listings.fcfs.bmrSales.noLotteryRequired.footer.aria")}
>
{t("listings.fcfs.bmrSales.noLotteryRequired.footer")}
Expand Down
Loading
Loading