From 5b59619d680fc0a101df2292c780cbe14208ecb4 Mon Sep 17 00:00:00 2001 From: Grace Park Date: Wed, 11 Aug 2021 10:37:41 -0700 Subject: [PATCH] Adding Product feedback redirect (#20785) * adding product feedback redirect for community on sponsors, discussions, and actions community link * remove community redirect from actions and add to codespaces and add tests * update wording for these links * updating to add name of the button to frontmatter --- components/context/MainContext.tsx | 5 +++++ components/page-footer/Support.tsx | 10 ++++++++-- content/codespaces/index.md | 3 +++ content/discussions/index.md | 3 +++ content/sponsors/index.md | 3 +++ lib/frontmatter.js | 8 ++++++++ tests/rendering/footer.js | 30 ++++++++++++++++++++++++++++++ 7 files changed, 60 insertions(+), 2 deletions(-) diff --git a/components/context/MainContext.tsx b/components/context/MainContext.tsx index 18cce7fce1..438f95082b 100644 --- a/components/context/MainContext.tsx +++ b/components/context/MainContext.tsx @@ -62,6 +62,10 @@ export type MainContextT = { article?: BreadcrumbT } activeProducts: Array + community_redirect: { + name: string + href: string + } currentProduct?: ProductT currentLayoutName: string isHomepageVersion: boolean @@ -106,6 +110,7 @@ export const getMainContextFromRequest = (req: any): MainContextT => { return { breadcrumbs: req.context.breadcrumbs || {}, activeProducts: req.context.activeProducts, + community_redirect: req.context.page?.community_redirect || {}, currentProduct: req.context.productMap[req.context.currentProduct] || null, currentLayoutName: req.context.currentLayoutName, isHomepageVersion: req.context.page?.documentType === 'homepage', diff --git a/components/page-footer/Support.tsx b/components/page-footer/Support.tsx index e6259e4675..13f8234528 100644 --- a/components/page-footer/Support.tsx +++ b/components/page-footer/Support.tsx @@ -2,17 +2,23 @@ import { PeopleIcon, CommentDiscussionIcon } from '@primer/octicons-react' import { useTranslation } from 'components/hooks/useTranslation' import { useVersion } from 'components/hooks/useVersion' +import { useMainContext } from 'components/context/MainContext' export const Support = () => { const { isEnterprise } = useVersion() const { t } = useTranslation('support') + const { community_redirect } = useMainContext() return (

{t`still_need_help`}

- + - {t`ask_community`} + {Object.keys(community_redirect).length === 0 ? t`ask_community` : community_redirect.name} diff --git a/lib/frontmatter.js b/lib/frontmatter.js index 12f584f7c0..35b1526959 100644 --- a/lib/frontmatter.js +++ b/lib/frontmatter.js @@ -149,6 +149,14 @@ export const schema = { interactive: { type: 'boolean', }, + // Redirect Community Support link to Public Discussions + community_redirect: { + type: 'object', + properties: { + name: 'string', + href: 'string', + }, + }, // Platform-specific content preference defaultPlatform: { type: 'string', diff --git a/tests/rendering/footer.js b/tests/rendering/footer.js index efc6bb2ba5..1b969b52e2 100644 --- a/tests/rendering/footer.js +++ b/tests/rendering/footer.js @@ -29,4 +29,34 @@ describe('footer', () => { expect($('a#contact-us').attr('href')).toBe('https://support.github.com/contact') }) }) + + describe('test redirects for product landing community links pages', () => { + test('codespaces product landing page leads to codespaces discussions page', async () => { + const $ = await getDOM(`/en/codespaces`) + expect($('a#ask-community').attr('href')).toBe( + 'https://github.com/github/feedback/discussions/categories/codespaces-feedback' + ) + }) + + test('sponsors product landing page leads to sponsors discussions page', async () => { + const $ = await getDOM(`/en/sponsors`) + expect($('a#ask-community').attr('href')).toBe( + 'https://github.com/github/feedback/discussions/categories/sponsors-feedback' + ) + }) + + test('codespaces product landing page leads to discussions discussions page', async () => { + const $ = await getDOM(`/en/discussions`) + expect($('a#ask-community').attr('href')).toBe( + 'https://github.com/github/feedback/discussions/categories/discussions-feedback' + ) + }) + }) + + describe('test redirects for non-product landing community links pages', () => { + test('leads to https://github.community/ when clicking on the community link', async () => { + const $ = await getDOM(`/en/github/authenticating-to-github`) + expect($('a#ask-community').attr('href')).toBe('https://github.community/') + }) + }) })