Skip to content

Commit

Permalink
forward along page url to feedback link (#4615)
Browse files Browse the repository at this point in the history
  • Loading branch information
beets authored Sep 11, 2024
1 parent 946cf68 commit feb6f67
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/config/base/header_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
1 change: 1 addition & 0 deletions server/templates/metadata/routes.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
{% for route_name in routes %}
<div data-route="{{ route_name }}" data-value="{{ url_for(route_name) }}"></div>
{% endfor %}
<div data-route="feedback-prefill" data-value="https://docs.google.com/forms/d/e/1FAIpQLSdo_IpV4rlQzDcSZOBOnXLlJDSFv_lFU7j8m2_i1ctRCP3HGw/viewform?usp=pp_url&entry.871991796={{ url_for(request.endpoint, **request.view_args) }}"></div>
</div>
{% endmacro %}

Expand Down
13 changes: 12 additions & 1 deletion static/js/apps/base/utilities/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit feb6f67

Please sign in to comment.