From feb6f67ea0938dd93ca8e9832feb0e4c2f59e498 Mon Sep 17 00:00:00 2001 From: Carolyn Au <6052978+beets@users.noreply.github.com> Date: Wed, 11 Sep 2024 16:17:23 -0700 Subject: [PATCH] forward along page url to feedback link (#4615) --- server/config/base/header_v2.json | 2 +- server/templates/metadata/routes.html | 1 + static/js/apps/base/utilities/utilities.ts | 13 ++++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/server/config/base/header_v2.json b/server/config/base/header_v2.json index f51472dc1e..73bf59031e 100644 --- a/server/config/base/header_v2.json +++ b/server/config/base/header_v2.json @@ -133,7 +133,7 @@ "id": "feedback", "label": "Feedback", "ariaLabel": "Give feedback", - "url": "https://docs.google.com/forms/d/e/1FAIpQLSc_xIinZPbO5RHDjq2a4eMoElkFgfe79U5DQ8-_kVhCNf2FJQ/viewform", + "url": "{feedback-prefill}", "exposeInMobileBanner": true } ] \ No newline at end of file diff --git a/server/templates/metadata/routes.html b/server/templates/metadata/routes.html index bc500b1ed8..07e677ee7c 100644 --- a/server/templates/metadata/routes.html +++ b/server/templates/metadata/routes.html @@ -19,6 +19,7 @@ {% for route_name in routes %}
{% endfor %} +
{% endmacro %} diff --git a/static/js/apps/base/utilities/utilities.ts b/static/js/apps/base/utilities/utilities.ts index 579cd9ce18..4f366cb39e 100644 --- a/static/js/apps/base/utilities/utilities.ts +++ b/static/js/apps/base/utilities/utilities.ts @@ -33,7 +33,18 @@ export const resolveHref = (href: string, routes: Routes): string => { if (match) { const routeKey = match[1]; const resolvedRoute = routes[routeKey] || ""; - return href.replace(regex, resolvedRoute); + + let url = href.replace(regex, resolvedRoute); + + // TODO(beets): Find a more appropriate place to do this only for feedback links. + if (routeKey === "feedback-prefill") { + const windowHash = window.location.hash; + if (windowHash) { + url += encodeURIComponent(windowHash); + } + } + + return url; } else { return href; }